Hi, I'm trying to create a script for a weapon that leaves an energy charge at a target location (trying to use a modified plasma projectile right now), then after 5 seconds it detonates with an energy blast (plasma grenade explosion).
scn 1MODReactiveLaserExplosion
;this script places a timed explosion at the reticle
float timer
float fQuestDelayTime
short aTarget
begin OnFire
set fQuestDelayTime to 0.001
set aTarget to PlaceAtReticle
aTarget.placeatme 1MODReactivelaserpulse
if ( timer < 5 )
set timer to timer + getSecondsPassed
else
aTarget.placeatme GrenadePlasmaExplosion 1
endif
end
notes:
{1MODReactivelaserpulse} is my custom projectile with a speed of 0 and a fade of 5.0
{GrenadePlasmaExplosion} is the default explosion for plasma grenades
The problems I have come across so far is:
a. the test script for timers on the bethesda walkthrough doesn't work in the first place.
b. the placeAtReticle command places the detonation in your face, not at the target location.
c. none of my code works anyway because I have no idea what I'm doing.
I dont think begin on fire run every frame, so your timer isn't being continuallly counted down, run maybe twice, probably once.
normally a timer script have the timer evaluations in a gamemode block, because gamemode blocks run every frame.
float timer
begin onactivate
set timer to 10
if timer > 0
set timer to timer - getsecondspassed
endif
if timer <= 0
do something
endif
end
that wont work, but is written fairly correctly.
float timer
short triggerd
begin onactivate
set timer to 10
set triggerd to 1
end
begin Gamemode
if timer > 0 && triggerd == 1
set timer to timer - getsecondspassed
endif
if timer <= 0 && triggered == 1
do something
endif
end
that why the activate (or onhit in your case) starts the gamemode block.
I've done this with target bottles (so after they spawn you can shoot them and they time out, and then "teleport" to a garbage collection cell/container.)
the onhit block only set everything in motion. the magic is done in gamemode blocks (in order words add a gamemode block to your script and just put the timer in there)
hopefully that helps
Edited by xab666, 03 June 2011 - 03:14 PM.