Home   Help Search Login Register  

Author Topic: deleting bodies revisited  (Read 841 times)

0 Members and 1 Guest are viewing this topic.

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
deleting bodies revisited
« on: 06 Dec 2002, 23:07:09 »
I have been trying to use the conversation between hoz and Adam to make this work and still cannot.  As far as I can tell, the removeeventhandlers is my stumbling block, since I have 1.46 and I believe that is for 1.85.  I have also been trying to make it 1 script, and everything works except the bodies don't go away!  Following is what I am trying to do, a compilation of the above mentioned folks and some of mine:

?alive any in (list westbodies): exit
?!alive any in (list westbodies)
~5
?(!local Server): Exit
; Goodbye ALL deaded units
; Only problem I can see is that if a unit is created and killed between the 3
; second period, its corpse will be left behind... but how many units will be
; spawned and killed within 3 seconds? Shorten this delay to remedy this, but
; tie up more resources
_n=-1
#loop
_curlist = list westbodies
#loop2
_n = _n + 1
?(!alive (_curlist select _n)): [(_curlist select _n)] goto delbody
?(_n < (count _curlist)):goto "loop2"
_n=0

?(gamestatus != "FINISHED"): goto "loop"
hint "poo"
#delbody
_body = _this select 0
deletevehicle _body

exit



I see the hint "poo" come up, and don't get any errors, but the body remains, any ideas?  If I try to send it to a delbodies.sqs it goes but the bodies don't disappear
Zombie

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:deleting bodies revisited
« Reply #1 on: 07 Dec 2002, 01:42:57 »
Heres what I did.. I scraped the whole first scripts and came up with this...

Each unit you want to disappear after death add this to thier init field.

this addeventhandler ["killed", {_this exec "dead.sqs"}]

If your creating units on the fly with creatunit then add this to the init field section.

this addeventhandler [""killed"", {_this exec ""dead.sqs""}]



file  dead.sqs

; Select the Unit
_unit = _this select 0
;-Delay the delete after death
~5
; Sink into the ground
_k = (getpos _unit) select 2
#loop
_k = _k - 0.1
_unit setpos [(getpos _unit) select 0,(getpos _unit) select,_k]
?(_k > -1):goto "loop"
; finally delete the vehicle
deletevehicle _unit
exit


Hope that helps.

Hoz

« Last Edit: 07 Dec 2002, 01:43:41 by hoz »
Xbox Rocks

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:deleting bodies revisited
« Reply #2 on: 07 Dec 2002, 11:48:31 »
Thanks, but it still isn't gonna fly.  addeventhandler errors as an unknown operator.  I use 1.46

dreaming_adam

  • Guest
Re:deleting bodies revisited
« Reply #3 on: 07 Dec 2002, 13:15:33 »
Uhmm... you seem to have the old version of the script before I updated it (btw im dreaming_adam under a name change)

You need to place the like GAMESTATUS="RUNNING" somewhere in your mission, or even at the beggining of the tutorial..

HINT "POO" is what is displayed when you dont have the gamestatus variable set to running. Sorry for the sketchy information in the original tutorial.

I will post an example mission on the tutorial if that would be of any help...

And yes, it is backwards compatible all the way down to 1.2 (I think).

There shouldnt be any event handlers in the script tho? If there is, just delete them.

Cheers
Adam

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:deleting bodies revisited
« Reply #4 on: 07 Dec 2002, 14:33:39 »
OK, somehow I'm just not getting it, so I enclosed the mission I am trying to build.  I just have the flags and ammocrates set where they are while I'm getting everything to work.  I will add the east units and all the other neccessary stuff later.  Hope you can figure out where my prob is?!
BTW, I couldn't add my sound files due to size restrictions but all my sounds work

dreaming_adam

  • Guest
Re:deleting bodies revisited
« Reply #5 on: 07 Dec 2002, 16:07:14 »
You made one tiny little mistake... you forgot to call the nocorpse.sqs file.. Ive included a fixed version of your mission, and I have tested it (it works fine)

You may want to remove the "hint 'running'" line from the nocorpse.sqs after you have finished testing it..

Cheers
Adam

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:deleting bodies revisited
« Reply #6 on: 07 Dec 2002, 16:23:08 »
Fantastic!  I knew it was something simple.  Thanks for your help.
Dave