HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Setting random variables = lag?

02-01-2003, 11:19 AM#1
Hakujin
I have a simple but effective monster spawner. It sets 4 variables for different monster types (melee, sec melee, caster, large unit) PER AREA. I have 9 areas. I refresh the variables every 5 seconds. Therefore every 5 seconds (4 x 9) variables are generated PLUS a variable when a player activates an encounter trigger determining attack pattern. Here is my question: would this second setup be easier on the players' CPUs / net connection?

***Alternate method***
Instead of generating variables for each monster type in different regions, create 4 master variables for the 4 monster types. Then when a player activates an encounter trigger, use the master variable to set monster types (using If -> then set variable monster type) and run the attack pattern trigger?

Example:
--------------
Master Variable Gerneator
[Event]
Every 5 seconds

[Action]
Set MonMeleeVar = random var 1-4
Set MonSecVar = random var 1-4
Set MonCasterVar = random var 1-4
Set MonHeroVar = random var 1-4
-------------------

Enounter Trigger (in a forest area)
[Event]
Unit enters region X

[Condition]
Unit type = Hero

[Action]
Run Trigger - ForestMonsterTranslator
----------------------

ForestMonsterTranslator
If MonMeleeVar = 1 set MonMelee to Spider
If MonMeleeVar = 2 set MonMelee to Wolf
If MonMeleeVar = 3 set MonMelee to Bear
If MonMeleeVar = 4 set MonMelee to Snake

If MonSecVar = 1 set MonSec to Kobold
''
''

If MonCasterVar = 1 set MonCaster to Shaman
''
''

If MonHeroVar = 1 set MonHero to Owlbear
''
''

Run Trigger - Attack Pattern
----------------------

This version would reduce my periodic variable generation to 4 var / 5 seconds, but then every encounter would have to run through the translator trigger. Is this more or less efficient then just setting direct regional monster variables? (ie, ForestMonMelee, ForestMonSec, ForestMonCaster, ForestMonHero)? I have omitted the functions relating to the Attack Patten Trigger for brevity, but it involves setting 3 region variables (not random) and one random attack pattern variable. This would be done in the Encounter Trigger.
02-01-2003, 02:16 PM#2
rwxr-xr-x
I'd be more concerned about performing actions every 5 seconds than performing a bunch of if statements whenever someone enters a region. Why not completely reduce the number of triggers and actions you are performing instead? Consider the following...

Create 4 String Arrays, and initialize the arrays to the names of the monsters you wish to randomly spawn. The names here must match exactly the Name of the monster (i.e. footman)

[Initialize Variables]
EVENTS
Map Initialization
ACTIONS
Set MonMeleeVar[0] = Spider
Set MonMeleeVar[1] = Wolf
Set MonMeleeVar[2] = Bear
Set MonMeleeVar[3] = Snake
Set MonSecVar[0] = Kobold
''
''
Set MonCasterVar[0] = Shaman
''
''
Set MonHeroVar[0] = Owlbear

[Encounter Trigger]
EVENTS
Unit enters Region X
ACTIONS
Unit - Create <number> (Unit-type(MonMeleeVar[(Random integer number between 0 and 3)])) for Player 12 at Center of (Triggering Region) facing Default building degrees
Unit - Create <number> (Unit-type(MonCasterVar[(Random number between 0 and 3)])) for Player 12 at Center of (Triggering Region) facing Default building degrees
"
"

When defining the above actions, for the unit type you would select...
Conversion - Convert String To Unit-Type

...then for the string, select one of your string arrays (i.e. MonCasterVar). For your index, select....
Math - Random Number

...and set the range to be between 0 and 3.

This would reduce your 4 triggers down to 1, with only 4 actions total, significantly reducing the number of CPU cycles.