Home   Help Search Login Register  

Author Topic: Detect Nearest Class, that is Dead Script  (Read 1079 times)

0 Members and 1 Guest are viewing this topic.

RunAwayScientist

  • Guest
Detect Nearest Class, that is Dead Script
« on: 02 Feb 2003, 04:22:57 »

  We've all seen it happen. We sip our morning coffee while an ambulance rushes past the local cafe. Ehh...

   But, on the other line, the person you don't see, is that ambulance that's blocking morning traffic to work. You walk out of the cafe, and hop into your car, and then begin your commute to work. The Traffic is jammed, and you can barely see the ambulance up ahead. The usual morning torture...Ehh.....

    But, how did the ambulance know there was an emergeancy? How did the Ambulance Driver know where to go, or if there was even a problem? That, my friends, is another mystery of the human brain, which we'll never figure out...Too bad for us...Which leads me to my question:

    How do I use the "nearestobject" command correctly, or is there such a command? What I want to do, is have an ambulance, I'll use the variable _AmbulanceDriver for an ambulance driver, and _Ambulance for an Ambulance which the _AmbulanceDriver drives.

    What I want to know, is a way to make _AmbulanceDriver, drive that _Ambulance to the nearest dead-body, and when in range, 17 ft. or so, have the body transferred into the _Ambulance, and then the Driver drives back to where he came from, preferably _EMGIN. So, _AmbulanceDriver gets there, the patient is revived (setdammage 0) and is teleported to _EMGOUT.

    Any idea how I do this? If not, how do I use the "NearestObject" command. How do I set that command to a class? Or set it to a certain property, preferrably detecting if something is dead?

     Is this all too complicated? Am I on drugs? Do I need an ambulance? Does everything look dizzy? Why am I steaming? The world may never know? The End? What IS 2+2? 4 = 2+2...Heh...Errr....

      Thank you for any-help, and-or just reading all this...Any comment, even the slightest, would be greatly appreciated!

    -RunAwayScientist (Cheese Please!)




Pointman

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #1 on: 04 Feb 2003, 01:22:21 »
NearestObject is kindof annoying to me, so what i did was something like this:

1. Create an array of names in init.sqs


//init.sqs//
g_aSoliders = [SOL0,SOL1,SOL2 ...

2. Build your mission, name soliders after the naming scheme above. (you DONT have as many soliders as in the array, but be aware that if you have more they won't be in)

3. In your ambulance, when you are looking for dead people:

#lookfordead

 ; SCAN THE SOLIDER ARRAY TO FIND PEOPLE WITH GetDammage == 1
if not found one goto #lookfordead
if found one - drive _ambulance there

When ambulance is there (Ready _driver)
move the body off the map/in the vehicle, or have your ambulance guy run out or whatever.

- drive ambulance back to emergency place
- SetDammage 0 on guy and put him in EMOUT

goto #lookfordead

my take on it.

There might be some other way with ThisList or whatever, but i just found NearestObject too annoying

RunAwayScientist

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #2 on: 07 Feb 2003, 07:31:32 »

    Ehhhh, that didn't really help me much.

     These arn't Soldiers, these are Civillians. Allow me to explain:
 
       I've got a Role-Play map for Northern Everon, called Cessena Fun ( TM ), which simulates basic every-day life, along with your favorite pal (2- Player Type Game). Make up your own elaborate stories, taunt the local police force, or have a drink at the local bar.

       Of course, with all the Traffic in Everon, eventually someone is gonna get run over *cough*.

       I've got ambulance scripts for the two players, but I'm gonna need a General Ambulance (Called _ambulance) and a driver for that ambulance (Named _AmbulanceDriver).

    _AmbulanceDriver is on the Resistance Side, and I need him to drive _Ambulance to the nearest dead body, the body gets transferred into the _ambulance, and he drives off (See Previous Post).

     Using the NearestObject command, how do I use it to detect the Class, because I want him to pick up dead Men instead of Dead Cars, and detect if it is dead or not. If it is dead, then it records the position (getpos) and it drives there (domove), and stores the dead person as _Paitent1. THen, _Paitent1 gets loaded up into the ambulance when it is at least 14 ft. from the victim. Then, the ambulance drives to _EMGIN.

       So, how do I use the NearestObject command, or another method to do it. I do not know how to quote:

      "; SCAN THE SOLIDER ARRAY TO FIND PEOPLE WITH GetDammage == 1"

     If I were to make an "ARRAY" of units, it'd mean I'd have to do it at least 62 Times for each and every civillian.

      So, how do I do it? If you don't under-stand me, or my concept, please contact me.
 
     -RunAWayScientist

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Detect Nearest Class, that is Dead Script
« Reply #3 on: 07 Feb 2003, 11:17:46 »
Hmm... If I were you I'd give nearestobject the flick and use a trigger and two arrays...

Nearestobject only works within 50m, so I'm afraid it wouldn't suit your purposes here... try something like this:

Init.sqs or a unit's init field

areaRA = list AreaTrigger

Trigger

Radius: Covering entire area
Condition: Anybody Present (repeatedly)
name: AreaTrigger
Condition field: (Count areaRA != count thislist)
OnActivation field: [(areaRA - thislist)] exec "script.sqs

Script.sqs

? (_this select 0) = []: areaRA = list AreaTrigger; exit
_deadguy = ((_this select 0) select 0)
Ambulance move (getpos _deadguy)
@ unitready Ambulance
_deadguy moveincargo Ambulance
Ambulance move (getpos EMGIN)
@ unitready Ambulance
_deadguy setdammage 0; _deadguy setpos (getpos EMGOUT)
areaRA = list AreaTrigger
exit

Try something like that...
« Last Edit: 07 Feb 2003, 11:19:53 by Sui »

RunAwayScientist

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #4 on: 08 Feb 2003, 04:09:18 »


     Nope. Didn't seem to work. I set it up correctly, and I changed your "move" command to "domove". Other-wise, I don't see any mistakes. Do you?

      As soon as I hit the Preview Button, and Cessena Fun loads up, I kill the nearest man, preferably someone in the hospital. He dies, and I look back at the Ambulance, and it sits there. Not doing anything.

        Any idea?

     -RunAwayScientist

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Detect Nearest Class, that is Dead Script
« Reply #5 on: 09 Feb 2003, 01:48:45 »
Hmm... I mucked around a bit with that today and unfortunately I couldn't get it to work :(

It doesn't seem to like comparing the list of the trigger to the area array...

Sorry mate....

RunAwayScientist

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #6 on: 10 Feb 2003, 04:06:09 »

   Ehhh, it's alright.

        Still though, is there any way, if possible, to have the computer detect the "man" class, and check if they're dead, or not. If so, then execute "Ambulance" script, and store the dead body as _deadguy . Seems simple enough for our minds, eh?

       I'm begginning to think this post belongs in Advance scripting, eh?

   -RunAWayScientist

Offline alimag

  • Contributing Member
  • **
  • I'm a llama!
Re:Detect Nearest Class, that is Dead Script
« Reply #7 on: 11 Feb 2003, 17:29:41 »
Hi RunAwayScientist,

I had a try on your interesting suggestion yesterday and it worked. Everything is not in it (I didn't have time) but the script detect when a civilian is dead and call the medic. In the example, the medic is just a soldier and the ambulance is just a jeep (this is easy to modify).

You just need a trigger:

size : 10000 by 10000
activated by Civilian

and put this line in the activation box:
thislist exec "initPeople.sqs"

and a script:

;---------- initPeople.sqs ------------------
_ambulPos = getPos ambul
people = []
"if ({man} countType [_x] == 1) then {people = people + [_x]}" forEach _this
_nCount = count people

#MAIN
@ ("alive _x" count people) != _nCount
_i = 0
#FIND_DEAD
   _u = people select _i
   _i = _i + 1
? alive _u : goto "FIND_DEAD"

#AMBULANCE
hint "Ambulance"
ambulDriver assignAsDriver ambul
[ambulDriver] orderGetin true
ambulDriver move getPos _u

@ ambulDriver distance _u < 15
ambulDriver move getPos ambul
[ambulDriver] orderGetin false
unassignVehicle ambulDriver
ambulDriver move getPos _u
people = people - [_u]
_nCount = count people

@ unitReady ambulDriver
~1
deleteVehicle _u
~1
ambulDriver assignAsDriver ambul
[ambulDriver] orderGetin true
ambulDriver move _ambulPos

@ unitReady ambulDriver
[ambulDriver] orderGetin false
unassignVehicle ambulDriver
? _nCount > 0 : player addAction ["* Kill People", "killPeople.sqs"] ; goto "MAIN"

exit

;-------- end script ---------------

ambul = ambulance name (jeep name in example)
ambulDriver = ambulance driver (soldier in example)

The addAction in the last line before the 'exit' statement is for the example purpose only.

Try the sample mission and tell me if it is somehow the squeletton of what you have in mind

Cheers
AliMag

RunAwayScientist

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #8 on: 16 Feb 2003, 08:21:21 »

    Dear Mr. Alimag,

                 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

           Sincerely,
          RunAwayScientist


             Now, that's what I would write if it worked exactly the way I wanted, but not quite.

              Now, I had to change a few of the setting to get what fit my mission you see, changing your script (Above) to the one for my mission. Provided for you, is a list of things I changed, problems, and my newer script.

   CHanged:
- Ambul to Ambulance
- Ambualne 11 is the name of the 'empty' ambulance.
- Ambulance is the AmbulanceDriver
- Where you said it to delete bodies, I changed it so that they were healed, and put into a tent.
- I removed the counter where it would subtract that person from the total people count, cause he could die again.
- I made P2, and P22 (Player's Assistance..Don't ask me) rejoin Player1 and PLayer2 after they were killed. But, it doesn't seem to be working.

Problems:

   -The Script ONLY fires once. I could kill the entire planet, and it only rescues one person...How do I fix it?


_AmbulancePos = getPos Ambulance11
people = []
"if ({man} countType [_x] == 1) then {people = people + [_x]}" forEach _this
_nCount = count people

#MAIN
@ ("alive _x" count people) != _nCount
_i = 0
#FIND_DEAD
   _u = people select _i
   _i = _i + 1
? alive _u : goto "FIND_DEAD"

#Ambulance
Ambulance assignAsDriver Ambulance11
[Ambulance] orderGetin true
Ambulance move getPos _u

@ Ambulance distance _u < 15
Ambulance move getPos Ambulance
[Ambulance] orderGetin false
unassignVehicle Ambulance
Ambulance move getPos _u
people = people - [_u]
_nCount = count people

@ unitReady Ambulance
~1
_u setDammage 0
~1
Ambulance assignAsDriver Ambulance11
[Ambulance] orderGetin true
Ambulance move _AmbulancePos

@ unitReady Ambulance
[Ambulance] orderGetin false
unassignVehicle Ambulance
? (AliveP2 == 1) : P2 Join group Player1; AliveP2 = 0
? (AliveP22 == 1) : P22 Join group Player1; AliveP22 = 0
_u setpos getpos EMGOUT
_u setdir 90
_u switchmove "LyingToTreatedLying"

goto "MAIN"

exit


  Ehh, so how do I fix it? Why does it only fire once? Help?

    -RunAwaySci

RunAwayScientist

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #9 on: 23 Feb 2003, 19:08:16 »

  Ehh, what happened to the one guy? Who answered my question, he seems to know what was going on. I sent him a message...Hmph...I wonder if he still exists...*ponder.wav*

     -RunAwayCientist

RunAwayScientist

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #10 on: 01 Mar 2003, 23:36:24 »

  Uhhh, Alimag? You there?

   -RunAway

toadeater

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #11 on: 02 Mar 2003, 02:50:45 »
The problem is that the trigger is not firing repeatedly. The detected unit(s) must leave the trigger area and return for it to fire again. Maybe the solution is to teleport the trigger away and then back every second or so?

RunAwayScientist

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #12 on: 09 Mar 2003, 02:52:35 »

  Ehhhh, I don't think I know how to do that....

 
-RunAwayScientist

toadeater

  • Guest
Re:Detect Nearest Class, that is Dead Script
« Reply #13 on: 10 Mar 2003, 21:41:33 »

  Ehhhh, I don't think I know how to do that....

 
-RunAwayScientist

I think that the trigger is only firing once, so it doesn't update its list again because the units aren't leaving the trigger area to reset it. So in the script, you need to reset the trigger somehow. I think you can do that by moving it away and moving it back. Create a gamelogic or marker where you want the trigger center to be then add this at the start of the script loop:

triggername setpos [0,0,0]
~1
triggername setpos (getpos gamelogicname)

This should theoretically reset what is in the trigger's list each time, and will only work if the trigger is small enough to be moved away to an empty area.
« Last Edit: 10 Mar 2003, 21:49:40 by toadeater »