Spawn Conditions Tutorial
heres a quick explanation of spawn conditions:
schema: Code:
CREATE TABLE spawn_conditions ( Code:
CREATE TABLE spawn_events ( condition mediumint(8) unsigned NOT NULL default '0', cond_value mediumint(9) NOT NULL default '1', Every spawn2 entry is associated with a spawn condition. If the value of the spawn condition variable is greater than or equal to the value in the cond_value field of this spawn2, then it is allowed to spawn. The condition 0 is always enabled, reguardless of the cond_value value. See the onchange value in spawn_condition for description of what happens when a spawn2's spawn condition is changed and crosses the threshold. Spawn conditions: - spawn conditions IDs are seperate per zone. (zone,id is the key, not id) - the name is only for human-readability, never used in the code. - the value is the current integer value of this spawn condition variable. - When a spawn condition changes, every spawn2 assigned to this spawn condition is checked against each ones cond_value. If the spawn2 changed from off to on, or on to off, then the action specified in onchange is executed on that spawn2. If the onchange action is 10 or greater, then a signal of type (onchange-10) is sent to the mob for a quest to handle. Other actions: DoNothing = 0 DoDepop = 1 DoRepop = 2 Spawn Events: - spawn events have global identifiers (id). - a spawn event effects a single spawn condition identifier by (zone, cond_id) - again, name is just for readability, never used. - period sets the number of EQ minutes between each execution of this spawn event. an eq minute is 3 seconds. - next_* - represents the next EQ time that this event will execute. once an event executes, 'period' is added to next_* and thus it is scheduled to execute again in 'period' EQ minutes. - enabled is a boolean field to determine if an event is enabled. - argument is a numeric value which is used by the action. - Action is one of: ActionSet = 0: set the condition's value to argument ActionAdd = 1: add argument to the condition's value ActionSubtract = 2: subtract argument from the condition's value ActionMultiply = 3: multiply the condition's value by the argument ActionDivide = 4: divide the condition's value by the argument all actions take place in the integer domain. Events are only triggered when a zone is up or is booting. But, an event will catch up as best it can if it missed some 'ticks' by executing the action defined by each event on zone boot until the event's next time is in the future. This will leave the condition variables in a consistent state (assuming no quest interactions while it was down), but the 'onchange' action for the spawns will not and cannot be faithfully executed to achieve the same consistent state. This just means dont rely on onchange for exact brhaviour if your zone is not static. You just have to consider the effects of the zone being down at any point. The mobs will spawn in accorsance to their cond_value and the final value of the conditions variable. Quest functions: void spawn_condition(const char *zone_short, uint16 condition_id, short new_value); - sets the value of a spawn condition. short get_spawn_condition(const char *zone_short, uint16 condition_id); - returns the value of the spawn condition for the supplied zone and condition id void toggle_spawn_event(int event_id, bool enable, bool reset_base); - changes the enabled state of a spawn event to the supplied state. - the reset_base parameter (if true) will change the next_* times to point to now plus one period of the even, resetting the event to happen in one full period from the time of the quest call. A quest function may affect spawn conditions in other zones. This is properly handled, by signaling the other zone that the change has occurred. This allows one zone's quests to affect the spawn in other zones (previously not possible) Quick EQ time tutorial: Code:
Code:
version(1000) a quick example: makes all mobs with even numbered spawn2 ids spawn during the day, and all mobs with odd numbered spawn2 ids only spawn at night in butcher. When the shifts change, the zone is completely repoped. Code:
|
Wow!! This is terrific!!
Finally, Kithicor will be inhabited by all the undead -- but only at night :P |
I am just wondering if this was already included in DR3 or we need to compile latest CVS?
|
dont ask me, check the changelog.
|
sorry about that, I will check it.
|
Try to use it :)
|
Does anyone use this or know if it works?
|
All times are GMT -4. The time now is 03:03 PM. |
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.