HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with patrolling Hostiles please

10-06-2002, 12:31 PM#1
Guest
Anyone know a good code or the right way to make Neutral hosties, spawn, and patrol? when they die I try to make them respawn and continue to patrol their regions.
Everything I have tried they either jam up in the regions, I have them set to patrol, or they don't spawn at the same designated time I set for them. Or they don't spawn at all? Sometimes they spawn and don't partrol?
I have made a new category
Category=Monsterspawning:with these triggers
Triggers=Initialize Monster Spawning
Initialize Monster Group
Setup Monster Group
Monster Spawn Task
Monsters Death
Spawn Monster
My first trigger
Initialize Monster Spawning
Events
Conditions
Actions
Set Numspawners = 11
?For each (IntegerA) from o to NumSpawners, do (Set EnableSpawners[(IntegerA)]=True)

X=Set MonsterSpawners[0]=Furbolg Hut 0001 <gen>
X=Set SpawnTypes[0]=spittingspider
X=Set MaxMonster[0]=5
X=setFrequencies[0]=4
X=Set MonsterPatrolRegion[0]=Patrol Station 1<gen>
X=Set MonsterSpawners[1]=Furbolg Hut 0001 <gen>
X=Set SpawnTypes[1]=spittingspider
X=Set MaxMonster[1]=5
X=Set MonsterPatrolRegion[1]=Patrol Station 1<gen>
X=setFrequencies[1]=4
That is how it continues until I get down number 11

?For each (IntegerA) from 0 to NumSpawners, do (Set InitialFrequencies[(IntegerA)]= Frequencies[(IntegerA)])

Trigger - Run Initilaize MonsterGroup <gen> ( ignoring conditions)
Trigger- Turn on Monster Spawn Task <gen>
Trigger - Turn on Monster Death <gen>



Next trigger

Initialize Monster Group
Events
Conditions
Actions
Unit-order MonsterSpawners[(IntegerA)]to Patrol To (CenterofMonsterpatrolRegion)[(IntegerA)]

For each (IntegerA)from 0 to NumSpawners,do (Trigger-Run set up One Monster Group <gen> (ignoring conditions))


Next Trigger
Setup Monster Group
Events
Conditions
Actions
Unit- Create 1 Spawn Types[(IntegerA)] for Neutral Hostile at (Position of MonsterSpawners[(IntegerA)]) facing Default building facing degrees

Set MonsterGroups[(IntegerA)]=(Last created unit group)
Unit- Order(Last created unit) to Patrol (Center of MonsterPatrolRegion[(IntegerA)])


Next Trigger

Monster Spawn Task
Events
Time -Every 0.50 seconds of game time

Conditions
Actions
For each (IntegerA) from 0 to NumSpawners, do (If(((MonsterSpawners[(IntegerA)]is alive) Equal to True) and ((Number of units in MonsterGroups[(IntegerA)]) Less than MaxMonsters[(IntegerA)])) then do (Trigger- Run Spawn Monster <gen> (ignoring conditions)) else (do nothing)


*(takes deep breath)*
Next Trigger

Monsters Death
Events
Unit- A unit owned by Neutral Hostile Dies

Conditions
Actions
For each (IntegerA) from 0 to NumSpawners, do (If(((Dyingunit)is in MonsterGroups[(IntegerA)])Equal to True then do (Unit Group- Remove (Dying unit)from MonsterGroups[(IntegerA)]) else do (Do Nothing))


and for the last one

Spawn Monster
Events
Conditions
Actions
?If (EnableSpawners[(IntegerA)] Equal to False) then do (Skip remaining actions) else do (Do nothing)

X=Set Fequencies[(IntegerA)]=(Frequencies[(IntegerA)]-1)

?If (Fequencies[(IntegerA)] Not equal to 0) then do (Skip remaining actions) else do (Do nothing)

X=Set Fequencies[(IntegerA)]=InitialFrequencies[(IntegerA)]

Unit Group - Add all units of (Last created unit group) to MonsterGroups[(IntegerA)]

Unit- Create 1 SpawnTypes[(IntegerA)] for Neutral Hostile at (Position of MonsterSpawners[(IntegerA)]) facing (Random real number between 0.00- 360.00) degrees

Special effect for spawners goes in here to make them show a spawning animation

Unit-Order (Last created unit) to Patrol To (Center of MonsterPatrolRegion[(IntegerA)])

Then I have the Variables set up like this
MonsterSpawners= UnitArray
EnableSpawners= BooleanArray
SpawnTypes= Unit-TypeArray
MonsterGroups=UnitGroupArray
InitialFrequencies= IntegerArray
MaxMonsters=IntegerArray
MonsterPatrolRegion=RegionArray
NumSpawners=IntegerArray
Frequencies=IntegerArray

This system works until you add other things into your map.
Then they start acting up.
If you know how to make something like this work please let me know.
Can someone maybe help me get it to run right? Can I send the map to you or set up a server and show you what it is doing wrong?
Thanks in advance
10-06-2002, 03:30 PM#2
ph33rb0
The biggest problem is probably that you have no events...
10-06-2002, 07:39 PM#3
Guest
(LOL @ Fear.Factor)


Do you see what happens here?


Actions
Unit-order MonsterSpawners[(IntegerA)]to Patrol To (CenterofMonsterpatrolRegion)[(IntegerA)]
For each (IntegerA)from 0 to NumSpawners,do (Trigger-Run set up One Monster Group <gen> (ignoring conditions))



U give an order action to a unit, and you do a for-next loop, that will run THIS SAME trigger X times. And every time it is runned, it runs itself again X times. So if numspawners = 10, that would mean that the trigger starts, it runs itself 10 times, in which each time it gets runned, it runs itself AGAIN 10 times.. so that makes 100 times. 10000 times. 100000000 times... LOOP.

You can start a trigger within your 'for' action, but that trigger that gets started should NOT contain a 'for' action itself. You should just move your first action, the order, to a different trigger, and have that new one run in your for loop. That way it wont become an endless loop that gets bigger and bigger all the time....
10-06-2002, 10:41 PM#4
Guest
I had to set it up like that for it to know what group to spawn?
Does it not check the variables and do action until another trigger is set into action?
Quote:
So if numspawners = 10, that would mean that the trigger starts, it runs itself 10 times, in which each time it gets runned, it runs itself AGAIN 10 times.. so that makes 100 times. 10000 times. 100000000 times... LOOP.
If I change the number on the numspawner = 1 say then the only 1 hut or building will spawn hostiles. the trigger will not execute until a hostile dies right?
I don't know how to program hardly and am having a hard time seeing what I need to fix this with.
Thanks in Advance