nicked on 29/6/2014 at 07:25
I'm trying to get a system set up whereby a water crystal respawns, so that the player can always find one if they run out. I've tried a number of setups, and the best I can get is it respawns once, then never again. I even tried directly ripping all the settings from the respawning spirit fire arrows in Broken Triad, but that didn't work either.
Ideally, I'd want the water crystal to only spawn when the player has none left, but I reckon that's likely to be impossible, so just respawning after a minute or so would be fine.
I've tried:
* Linking the watercrystal archetype to an reloading emitter that fires watercrystals - doesn't work at all, I'm guessing ControlDevice doesn't work from an archetype.
* Using NVRelayTrap to trigger the emitter. Might work, but Slain doesn't, and I don't know what other script messages might be able to be sent when frobbing the crystal.
* Using NVRelayTrap and NVCreateAndLink - the system from Broken Triad that only works once.
Any thoughts on how I could achieve this? It's annoying because it seems like something that should be really simple.
Nameless Voice on 29/6/2014 at 14:00
You will need:NVScript
1x Marker
1x new metaproperty, M-WaterArrow
1x button or other type of trigger
On the marker:Scripts:{ NVRelayTrap; NVRelayTrap2; NVTweqEmit; ; FALSE}
Design note:
Code:
NVRelayTrapDelay=100; NVRelayTrapExclusiveDelay=1; NVRelayTrapTOn="Spawn"; NVRelayTrapTOff="Null"; NVRelayTrapTDest="[me]"; NVRelayTrap2Off="Null"; NVRelayTrap2TDest="@M-WaterArrow"; NVRelayTrap2TOn="WaterCheck"; NVTweqEmitReload=1; NVTweqEmitOn="Spawn"
You will also need to set up Tweq->Emit to emit your water crystal
{ Stop Tweq; Sim; Grav; [None]; 1; 1; watercrystal; 0.00, 0.00, 0.00; 0.00, 0.00, 0.00}
M-WaterArrowScripts: { NVRelayTrap; ; ; ; FALSE}
Design note:
Code:
NVRelayTrapTDest="[source]"; NVRelayTrapOff="watercheck"; NVRelayTrapOn="Null"
Add M-WaterArrow to the
WaterCrystal and
Water archetypes.
CD-Link the button to the marker.
How it works:When you press the button and activate the marker, it will start a timer for 100ms, and also send a "CheckWater" message to everything with the M-WaterArrow metaproperty.
If the metaprop receives that message, it will send a TurnOff back to the marker, which will cancel the delayed message. If there are no objects with the metaproperty in the mission, then the TurnOff won't be sent back and the original delayed message with activate the emitter and spawn a new crystal.
The water arrows and crystals can be anywhere in the mission, including in the player's inventory. A new one will only be spawned if there are none anywhere in the mission.
If you want to have water arrows placed somewhere which don't count, you'd need to rearrange how the metaproperty is applied.
LarryG on 29/6/2014 at 15:06
This may be a little simpler:
1) Create a "RenewableResource" abstract object in the hierarchy as a child of "Marker" with the RenewableResource script on it (miss16.osm 2)
This marker creates new objects periodically. The type of object is specified by
a ScriptParams link to an archetype. The data of the link is the maximum number
of created objects that can be in the player's inventory. When the limit is
reached, no new objects of that archetype will be created until one of the
already existing ones is destroyed or dropped. The object is created with the
same position and orientation as the concrete marker.
The Script\Timing property specifies the number of seconds for the regeneration
timer. The default is 3 minutes. The timer begins at Sim start. When it expires, a
new object will be created if the old object has been picked up or destroyed and
the maximum object limit has not been reached. Then the timer starts over again.
The timer is not interrupted by picking up or destroying the created object.
Created objects will not have a physics model (Physics\Model\Type property) or
an initial velocity (Physics\Projectile\Initial Velocity). The script TrigWorldFrob
will be added to an empty slot in the Scripts property; the script does not clear
the Don't Inherit flag when it adds a Scripts property. A ControlDevice link is
added from the created object to this one and it will be removed when the
object is frobbed.
2. Create concrete RenewableResource objects wherever you want the water crystals to be in the map, and add a ScriptParams link to the "WaterCrystal" abstract object. The data for the ScriptParams link specifies how many of WaterCrystals to allow the player. You can use Script>Timing if you want a different timer than checking every 3 minutes.
That's it.
nicked on 29/6/2014 at 16:11
Thanks very much - I got NV's system implemented and it works great! :)
One strange side effect (and it might have been something else I did) is that each crystal now adds two arrows to the inventory for some reason. That's no problem though, I've just halved the number you start with.
Nameless Voice on 29/6/2014 at 17:43
Maybe you got the Crystal script twice somehow?
nicked on 29/6/2014 at 17:55
Ah yeah, I had Crystal on the Watercrystal with Don't Inherit unchecked, and it was also on the Crystal archetype above. Thanks - Fixed! :)