Full Version : Trigger spawns based on the state of other objects
xmlspawner >>XMLSpawner - How do I? >>Trigger spawns based on the state of other objects
<< Prev | Next >>
ArteGordon- 12-27-2005
Example: Trigger a spawn when another spawn is damaged
Let's say you have one spawner, and you want it to trigger when two conditions are met,
1) a player is around and
2) the spawn on a second spawner is injured
To configure such a spawner you would
1) Set up proximity triggering by setting the ProximityRange to something > 0
2) set the TriggerObject property on the spawner to point to the second spawner.
3) Set the TriggerObjectProp property to "GETONSPAWN,SecondSpawner,1,hits<50". This will test to see if the mob spawned on subgroup 1 on the second spawner has its Hits property less than 50.
Another way to do it is to use the IF keyword and test for a particular spawn being present on a spawner using the GETONSPAWN keyword
Lets say you set up that second spawner with the name "SecondSpawner" and added some spawns on subgroup 1. Then on the first spawner you could test spawns from subgroup 1 with something like
1 IF/GETONSPAWN,SecondSpawner,1,hits<50/33
2 GOTO/1
33 ogrelord
where the leading numbers 1, 2, and 33 refer to the subgroup assignments for those entries. This would also be set to sequential spawn so that it would go through the entries in subgroup order.
It would execute entry 1, which would check the Hits property on the spawned mob for subgroup 1 on the spawner named SecondSpawner, and if that was less than 50, it would execute subgroup 33 which would spawn an ogrelord. It would then advance to the second entry, which would perform a goto to entry 1 and the process would be repeated.
Now, you could also achieve the same thing by using the TriggerObject and TriggerObjectProp approach I described earlier.
Set the TriggerObject to point to SecondSpawner, set the TriggerObjectProp to "GETONSPAWN,SecondSpawner,1,hits<50" and then the spawner would trigger when the spawn on subgroup 1 of SecondSpawner had its hits drop below 50.
Note, the same condition strings that you can test in an IF keyword can be used as tests in TriggerObjectProp.
Example: Trigger a spawn on opening a door
You can use this approach to make spawner triggering dependent on any object property. For example, you could set the TriggerObject to a door, and set the TriggerObjectProp to "open=true". This would test to see if the Open property on the door was set to true and only trigger when that condition was met.
Make a spawner and add the mobs that you want to be spawned upon triggering.
Example: Trigger a spawn on unlocking a chest
The two things you need to set in order to make the spawner trigger on the state of an item like a chest are the TriggerObject property (target the chest), and the TriggerObjectProp property.
You assign TriggerObjectProp a string that contains the trigger condition. Unfortunately, there is no property to detect when a chest is opened (there is for things like doors), but you can test to see when a chest is unlocked.
So to trigger on unlocking you would set TriggerObjectProp to
locked=false
What it does is to test the "locked" property on the target object. If the condition is met then the spawner triggers. You can test for any property. For example you could trigger it on the weight or totalitems props going below some level (e.g. "totalitems<1") which would trigger when someone took an item out of the chest.
You can also make this sensitive to the presence of a player (thus spawning when manually unlocked as opposed to magically unlocked at a distance) by setting the ProximityRange property on the spawner to the number of tiles away that a player has to be to trigger the event.
Rocko- 08-16-2006
I am trying to follow this example, with two spawners, one (name is Spawner2) spawn a troll, the second has exactly
1 IF/GETONSPAWN, Spawner2,1,hits<30/33
2 GOTO/1
33 ogrelord
and subgroups assigned as well (which I noticed change the sequencialspawn in props to 1).
However, after I manually drop the troll's hits to 1, the ogrelord didnt spawn. On this spawner, there is a red line showing "GETONSPAWN,Spawner2,1,hits :", as if it didnt recognize this line? I got a screen shot of my settings see below.
any idea what I did wrong?
Thanks!
ArteGordon- 08-16-2006
I would check the other spawner and make sure that it has the name "Spawner2" (capitalization matters), and that the name is unique (so that it isnt accidentally finding another spawner by that name) and that the troll is spawned into subgroup 1.
Although it is not related to your problem, I noticed that you have the Clr (ClearOnAdvance) flags checked for your spawn entries. You probably want to uncheck those since that will cause the spawns to automatically be cleared when the sequence advances past that subgroup so your ogrelord will spawn and then be immediately despawned.
Also, another little tip is that with recent updates of xmlspawner that support the #CONDITION spawn control keyword (v3.10 or later), you can do this with just one line and no sequential spawning.
Just use a spawn entry like
#CONDITION,GETONSPAWN, Spawner2,1,hits<30 ; ogrelord
Rocko- 08-16-2006
Ah that must be it, I thought the IF line was pointing to the 1st entry of Spawner2 (I did checked the name), and I didnt assign it to subgroup 1.
Thank you Arte for pointing me to the updated CONDITION keyword, will give it a try tonight after work.