Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Support > Archive::Tutorials/Howto's > Tutorials--Outdated Use the Wiki > Tutorials::Discussion

Tutorials::Discussion Discuss Tutorials here. Do NOT POST tutorials here, they belong on the wiki.

Reply
 
Thread Tools Display Modes
  #1  
Old 03-21-2005, 06:10 AM
fathernitwit
Developer
 
Join Date: Jul 2004
Posts: 773
Default Spawn Conditions Tutorial

heres a quick explanation of spawn conditions:

schema:
Code:
CREATE TABLE spawn_conditions (
  zone varchar(16) NOT NULL default '',
  id mediumint(8) unsigned NOT NULL default '1',
  value mediumint(9) NOT NULL default '0',
  onchange tinyint(3) unsigned NOT NULL default '0',
  name varchar(255) NOT NULL default '',
  PRIMARY KEY  (zone,id)
) TYPE=MyISAM;
Code:
CREATE TABLE spawn_events (
  id int(10) unsigned NOT NULL auto_increment,
  zone varchar(16) NOT NULL default '',
  cond_id mediumint(8) unsigned NOT NULL default '0',
  name varchar(255) NOT NULL default '',
  period int(10) unsigned NOT NULL default '0',
  next_minute tinyint(3) unsigned NOT NULL default '0',
  next_hour tinyint(3) unsigned NOT NULL default '0',
  next_day tinyint(3) unsigned NOT NULL default '0',
  next_month tinyint(3) unsigned NOT NULL default '0',
  next_year int(10) unsigned NOT NULL default '0',
  enabled tinyint(4) NOT NULL default '1',
  action tinyint(3) unsigned NOT NULL default '0',
  argument mediumint(9) NOT NULL default '0',
  PRIMARY KEY  (id)
) TYPE=MyISAM;
New spawn2 fields:
condition mediumint( 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:
   /* The minutes range from 0 - 59 */

   // The hours range from 1-24
   // 1 = 1am
   // 2 = 2am
   // ...
   // 23 = 11 pm
   // 24 = 12 am
 
   // The days range from 1-28

   // The months range from 1-12

   //year is just a number
format of eqtime.cfg:
Code:
version(1000)
day
hour
minute
month
year
unix_time

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:
#create our conditions
insert into spawn_conditions (zone,id,value,onchange,name) VALUES('butcher', 1, 0, 2, 'Butcher Day Shifts');
insert into spawn_conditions (zone,id,value,onchange,name) VALUES('butcher', 2, 1, 2, 'Butcher Night Shifts');

#set up the spawn2 entries
UPDATE spawn2 set condition=1 where zone='butcher' AND id%2 = 0;
UPDATE spawn2 set condition=2 where zone='butcher' AND id%2 = 1;

#make the events to change shifts
INSERT INTO spawn_events (id,zone,cond_id,name,period,next_minute,next_hour,next_day,next_month,next_year,enabled,action,argument)
 VALUES(1,'butcher',1,'Enable Day Shift',720, 0, 6, 9, 1, 3100, 1, 0, 1);
INSERT INTO spawn_events (id,zone,cond_id,name,period,next_minute,next_hour,next_day,next_month,next_year,enabled,action,argument)
 VALUES(2,'butcher',1,'Disable Day Shift',720, 0, 18, 9, 1, 3100, 1, 0, 0);
INSERT INTO spawn_events (id,zone,cond_id,name,period,next_minute,next_hour,next_day,next_month,next_year,enabled,action,argument)
 VALUES(3,'butcher',2,'Enable Night Shift',720, 0, 18, 9, 1, 3100, 1, 0, 1);
INSERT INTO spawn_events (id,zone,cond_id,name,period,next_minute,next_hour,next_day,next_month,next_year,enabled,action,argument)
 VALUES(4,'butcher',2,'Disable Night Shift',720, 0, 6, 9, 1, 3100, 1, 0, 0);

Last edited by fathernitwit; 03-21-2005 at 02:14 PM..
Reply With Quote
  #2  
Old 03-21-2005, 06:18 AM
RangerDown
Demi-God
 
Join Date: Mar 2004
Posts: 1,066
Default

Wow!! This is terrific!!

Finally, Kithicor will be inhabited by all the undead -- but only at night :P
__________________
<idleRPG> Rogean ate a plate of discounted, day-old sushi. This terrible calamity has slowed them 0 days, 15:13:51 from level 48.
Reply With Quote
  #3  
Old 03-21-2005, 06:19 AM
sysadmin
Hill Giant
 
Join Date: Feb 2005
Posts: 163
Default

I am just wondering if this was already included in DR3 or we need to compile latest CVS?
__________________
Sysadmin.
Reply With Quote
  #4  
Old 03-21-2005, 06:21 AM
fathernitwit
Developer
 
Join Date: Jul 2004
Posts: 773
Default

dont ask me, check the changelog.
Reply With Quote
  #5  
Old 03-21-2005, 06:27 AM
sysadmin
Hill Giant
 
Join Date: Feb 2005
Posts: 163
Default

sorry about that, I will check it.
__________________
Sysadmin.
Reply With Quote
  #6  
Old 03-21-2005, 08:58 AM
Belfedia
Demi-God
 
Join Date: Jan 2005
Posts: 1,109
Default

Try to use it
__________________
__________________________________________________ _____________________________________
I speak english like a spanish cow..., I speak spanish like a english pudding...
But I try to speak good french !!! (Non au langage SMS sur forum)
http://eqfroggy.new.fr : Froggy French Server Website.

Last edited by Belfedia; 03-21-2005 at 05:02 PM..
Reply With Quote
  #7  
Old 03-30-2007, 03:08 AM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

Does anyone use this or know if it works?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 02:28 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3