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.
Make sure to include your VSCond's script after the main script is executed.
To prevent errors, put your VSCond into the root table:
This is the format for every VSCond:
Usable Functions
All the following commands require a handle to apply the entity to. (i.e. tankboss.AddVSCond() )
Other Handy Functions
Comes with readme, tutorial, my comments (still WIP), and a few example conditions to help get you started.
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)
- 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.
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.