Summon Creature script, needs a timer

Post » Mon Mar 14, 2011 3:45 pm

Summon Creature script, needs a timer.
Here's an object script.
------------------

Scriptname TIE1SummonTrainingSkeletonSCRIPTTESTA

ref SkelFighter
short button
short menu

begin onactivate
If menu < 1

MessageBox "Summon the Opponent?", "Swordsman Skeleton", "Cancel"

set menu to 1
endif

end

begin gamemode

set Button to getButtonPressed

if button == 0
set SkelFighter to TIEskelREF.createfullactorcopy
SkelFighter.AddItem TIEtrainWeapSteelLongsword, 1
Skelfighter.AddItem TIEtrainIronShield, 1
SkelFighter.moveto TIE1SkelmarkerREF
Message "Skeleton Fighter Summoned."
endif

if SkelFighter.getdead
SkelFighter.moveto TIE1SkelDeadmarkerREF
SkelFighter.resurrect
SkelFighter.RemoveItem TIEtrainWeapSteelLongsword, 1
SkelFighter.RemoveItem TIEtrainIronShield, 1
set menu to 0
SkelFighter.deletefullactorcopy
endif

elseif button == 1
set menu to 0
endif

End
--------------------
The above script shown works great. There is a
new form ID creature (skeleton) dropped in
a hidden room within the cell.
The creature is copied and moved to
the heading marker and new form ID sword and shield
are added to the creature.

Then on death it is removed to another "unseen" xmarker,
resurrected and deleted. This is done to get rid of the
weapon and shield it would otherwise drop
on death.

Now, all of this works great, the thing is
that no matter how I add in a timer that would
control creature move to the xmarker,
then deletion, on X number of seconds if it ISN'T dead,
I can't get the timer to work.

Either the timer doesn't work at all in-game, or
it breaks the copied actor removal.
Then I have a dead skeleton, loose sword and
shield on the floor, in one of the scripts, for example.

The timer in the below script change just doesn't work,
in-game the activator works like the timer just
isn't there. I added in the "float timer" reference to the list,
and did a "Set timer to 10" just under the
Messagebox function.
--------------------------
if SkelFighter.getdead
SkelFighter.moveto TIE1SkelDeadmarkerREF
SkelFighter.resurrect
SkelFighter.RemoveItem TIEtrainWeapSteelLongsword, 1
SkelFighter.RemoveItem TIEtrainIronShield, 1
set menu to 0
Message "Skeleton Destroyed!"
SkelFighter.deletefullactorcopy
Return
elseif timer > 0
set timer to timer - getsecondspassed
elseif timer == 0
SkelFighter.moveto TIE1SkelDeadmarkerREF
SkelFighter.RemoveItem TIEtrainWeapSteelLongsword, 1
SkelFighter.RemoveItem TIEtrainIronShield, 1
set menu to 0
Message "Summon time is up."
SkelFighter.deletefullactorcopy
endif
--------------------------
Like I said, I've tried the timer add-in every way I
can think of.
I've gotta be missing something either really simple/stupid,
or this is a problem I haven't seen before (something I'm ignorant of).
Any ideas welcome,
Thanks.
User avatar
Ysabelle
 
Posts: 3413
Joined: Sat Jul 08, 2006 5:58 pm

Post » Tue Mar 15, 2011 12:17 am

Oh, BTW, a workaround that uses OBSE is OK too.
User avatar
Heather Dawson
 
Posts: 3348
Joined: Sun Oct 15, 2006 4:14 pm

Post » Mon Mar 14, 2011 9:42 pm

Possibly change this line:
elseif timer == 0
to:
elseif timer < 0

It is difficult to get 'timer == 0' to be true with floats.
User avatar
Mr.Broom30
 
Posts: 3433
Joined: Thu Nov 08, 2007 2:05 pm

Post » Mon Mar 14, 2011 10:05 pm

Thumper, You are the man. The script works perfectly now. Thanks a bunch!
I remember reading the CS wiki on floats (calcs to seven decimals, i think it was?)
but I must not have got a good mind-rap on the implications of usage. Again, thanks.

Any other comments on the script itself, like save game bloat, etc ?
I'm fairly new to scripting.
User avatar
Loane
 
Posts: 3411
Joined: Wed Apr 04, 2007 6:35 am


Return to IV - Oblivion