Resource icon

AddVSCond 1.5.3 bug squashing update

  • Hey you! Yes, you! Add images to your downloads, it's free! Use the orange "Manage Download Image" button in the top right.

AddVSCond 1.5.3 bug squashing update

Create your own conditional states and apply to any entity

AddVSCond vscript is a system for controlling conditional states that can be applied to any entity.

It works like the addcond and removecond system, where one condition can be only "on" or "off", and there can be several conditions applied at once. Not just for players--For any entity.
  • Code your own conditional states, and apply them to entities under CBaseEntity class. (basically, all entities!)
  • Provides easy-to-use functions to add, remove, or check if a vscond is on an entity for application in any part of your code base.
  • Only one think script, which tracks when to clear conditional state from entities.
  • No game events or hooks are used here!
  • VSConds' names and their associated ID numbers are all organized by the system. No headaches trying to figure which cond name goes to what number!
  • And potty-trained! Includes a mass-cleanup function, which fires RemoveVSCond() specifically for ents with conditions applied to them, and removes any ents spawned by conditions.
  • And cleans your house. (no it doesn't)
How do I use this?
  • Run "addvscond/init.nut" through an entity in your map using a logic_script entity, or place function IncludeScript("addvscond/init.nut") into your map's main script.
  • After running the script, it will create a self-preserved entity that can't be removed on map reset.
  • To test your VSConds, simply rerun your vscond's script to reimplement it.
  • VSConds use a class structure to store all data for that condition.
Condition Class Structure
Setting up is easy! Here is the framework of all VSConds.

Make sure to include your VSCond's script after the main script is executed.
To prevent errors, put your VSCond into the root table:
JavaScript:
IncludeScript("addvscond/conditions/EXAMPLE_readme.nut", ROOT);

This is the format for every VSCond:
JavaScript:
// First, start with your vscond's name, then extend it from VSConds_Base, like so:
class MySuperCoolVSCondExample extends VSConds_Base
{
   //Various settings you can use for your condition
   //These are the defaults
    removedByDeath = true;    // Does death remove the condition?
    removedByResupply = true;    // Does resupply remove the condition? (player only)
    removedByTeamChange = true;   // Does changing team remove the condition? (player only)
    removedByClassChange = true;   // Does changing tfclass remove the condition? (player only)
    removedByCommand = true;    // Can RemoveVSCond() be used to remove the condition?
    addcondIgnoreDeathState = false;    // Can AddVSCond() still apply condition when target is considered dead?

    function AddCond() {
    // When cond is first applied, run this function
    }
    function RemoveCond() {
    // When cond is removed, run this function
    }
    function Think() {
    // OPTIONAL think script for your condition
    // Creates a separate entity with think script applied
    // If `function Think()` is not included within your condition, it does not create the separate entity
    // Separate entity auto-deletes itself on condition removal
    }
}
// Add your condition directly to the vsconds list by using this function:
VSCONDS_ADD_CONDITION("MySuperCoolVSCondExample")
// *Param must be in quotes!!
After that, the class itself is converted into a constant. Use it like
  • handle.AddVSCond( MySuperCoolVSCondExample )
  • handle.RemoveVSCond( MySuperCoolVSCondExample )

Usable Functions

All the following commands require a handle to apply the entity to. (i.e. tankboss.AddVSCond() )
  • AddVSCond( condition, duration, provider )
    • Adds a VSCond to entity.
    • Returns true if condition was added, or falseif nothing was added,
      • duration default is -1 (infinite),
      • provider default is worldspawn,
    • Also works for setting condition duration, similar to SetCondDuration()
  • RemoveVSCond( condition , alwaysRemove)
    • Removes condition from ent if it was already applied.
    • Returns true if condition was removed, or false if nothing was removed,
    • Additionally, alwaysRemove will bypass the setting removedByCommand if that is set to falseon any vsconds you make,
      • false by default.
  • InVSCond( condition )
    • Checks if entity is in a VSCond.
    • Returns true if ent in condition, or false if not.
  • GetVSCondDuration( condition )
    • Checks if entity is in a VSCond too.
    • Returns remaining duration before expiring (float),
      • If applied duration was -1, returns 1e30.


Other Handy Functions
  • VSCONDS_COMPILE()
    • This function is for debugging. It only runs if you run it.
    • First runs VSCONDS_CLEANUP(), then deletes Big Think entity, then recompiles AddVSConds from ground-up.
    • Used for restarting AddVSCond script.
  • VSCONDS_CLEANUP()
    • This function runs after second bootup forward, and by VSCONDS_COMPILE().
    • Removes all created entities made by vsconds and fires RemoveVSCond() on entities that need that condition removed.
      • "all created entities" only applies to ents that were processed by function VSCONDS_AddAttachmentEnt().
  • Includes many functions that can apply team-based particle attachments and parents them to the entity with condition.
    • "Team-based" means a smaller function chooses one-of-three names you put in. The name is chosen based off which team the entity you input in is.
    • "particles" include functions that create static (based on origin), drip (like Jarate, afterburn), and power-up style (vacc shield/mannpower style),
    • These are listed in vsconds_util.nut,
    • All functions mentioned are smaller functions for wrapper functions. Please take them apart if you intend to create other entities.

Comes with readme, tutorial, my comments (still WIP), and a few example conditions to help get you started.
License
Credit is required. Permission to modify required.
  • 1.png
    1.png
    1.5 MB · Views: 48
  • 2.png
    2.png
    1.9 MB · Views: 50
  • 4.png
    4.png
    1.8 MB · Views: 42
  • 4.png
    4.png
    2.1 MB · Views: 41
Author
Yaki
Downloads
211
Views
479
First release
Last update
Category
VScript

More downloads from Yaki

Latest updates

  1. 1.5.3 The "I will squash you bugs like bugs!" Update

    To prevent errors, please make sure to add your vsconds to the root table when using IncludeScript(). Example: IncludeScript("addvscond/conditions/EXAMPLE_readme.nut", ROOT); Compiler functions updated VSCONDS_CLEANUP() Removed a few checks...
  2. 1.5.2 The "OK" Update Vol 3

    Fixed bug where VSconds weren't cleared when running VSCONDS_COMPILE() Now runs VSCONDS_CLEANUP() first before reimplementing all vsconds Updated VSCONDS_CLEANUP() Added additional checks for VSCONDS_CLEANUP() to stop retrying to run itself...
  3. 1.5 The "OK" Update

    Fixed bug with GetVSCondDuration() returning 0 if duration was infinite (or -1) Now prints funny number 1e30 Updated "Big Think" Script Now runs VSCONDS_CLEANUP() on I/O firing RoundSpawn, and same function when spawned in Starts as classname...