Home   Help Search Login Register  

Author Topic: CurrentCommand "HEAL"?  (Read 1827 times)

0 Members and 1 Guest are viewing this topic.

Offline myke13021

  • Contributing Member
  • **
  • Myke
CurrentCommand "HEAL"?
« on: 01 Jul 2007, 03:57:50 »
I'm tryin to make a realistic injuries script which lets medic only heal light injuries but for heavy injuries you have to go to a MASH tent. If you're heavy injured, Medic Soldiers can heal you up to 50% but not more. So far the Situation.

As it is not possible to remove hardcoded Actions and replacing them with own (except by making an addon), the idea was to check if injured Units dammage level suddenly is 0, which impliments that a MASH or Medic is near and then just "step in" with the own script. A perfect way seemed to be "currentCommand". But after some testing i'm a little lost. As BIWIKI and COMREF says, one of the returned values can be "HEAL", some testing didn't gave any usable results.

What i've tested:
me injured, AI teammate Medic. returned value of currentcommand: empty string for both
me Medic, AI teammate injured, ordered him to heal. returned value for AI = "ACTION", empty string for me
AI Medic, AI Teammate injured, ordered to heal. returned value for injured = "ACTION" and empty string for medic.

I've never got "HEAL" as returned value. What am i doing wrong or how can i intercept the healing and step in with own script. Doesn't matter if healing procedure can't be stopped as my script will immediately reset dammage level as needed. I just need a way to get the moment when a Unit is healing.

Thx in advance.

Myke

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: CurrentCommand "HEAL"?
« Reply #1 on: 01 Jul 2007, 04:13:02 »
i think currentcommand works 4 wen leader orders unit 2 do someting... dats y it wont work wen u was da player... donno bout wat it returns tho...

now u can use a simple script 2 check if da damage has sudenly changed 2 zero... i dont know functions yet (gonna start learnin tho) but it gos along dis lines (itll work 4 simple old fashioned scripts)

Code: [Select]
@ getdammage player > 0

@ getdammage player == 0

after dat u can use nearestobject 2 check if player is near mash tent or near a medic...

cant think of nytin else :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: CurrentCommand "HEAL"?
« Reply #2 on: 04 Jul 2007, 17:45:01 »
Here's an approach that should work (if I understand your problem correctly).  Exact syntax not guaranteed...

1. Add a HIT or DAMMAGED eventhandler to the desired units.  When a unit is hit, you the eventHandler will call the unitHealedDetector.sqs script.

Code: [Select]
this addEventHandler ["hit", {[_this select 0] exec "unitHealedDetector.sqs"}]
2. The script:

Code: [Select]
;*****************************************************************************
; unitHealedDetector.sqs
;*****************************************************************************
_unit = _this select 0;

;*****************************************************************************
; Remove EH so it only runs once per Heal tracking usage.  After unit goes to MASH unit for
; serious healing, you can re-add the eventhandler to the unit.
;*****************************************************************************

 _unit  removeEventHandler ["hit", 0]

_damageBeforeHeal := getDammage _unit;

;*****************************************************************************
; Use loop to wait until unit has been healed (i.e., dammage reset to zero). Sleep 1 second for each
; loop iteration.
;*****************************************************************************
#loop1
~1
? (getDammage _unit >= 0):  goto "loop1"

;*****************************************************************************
; If damage was light  (<=.5) then unit was healed by medic, but does not need to go to the MASH,
; so we skip the MASH code, and jump to bottom of script to re-add the eventhandler.
;*****************************************************************************
?(_damageBeforeHeal <= .5): goto "AddEH"

;*****************************************************************************
; Injury is a Heavy Injury, so put your code here that sends unit to MASH.
;*****************************************************************************

<MASH code goes here>

;*****************************************************************************
; After unit is healed (at MASH, or light injury healed by medic), we  re-add the EventHandler.
;*****************************************************************************
#AddEH
_unit addEventHandler ["hit", {[_this select 0] exec "unitHealedDetector.sqs"}]
exit
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: CurrentCommand "HEAL"?
« Reply #3 on: 04 Jul 2007, 18:06:25 »
@Myke13021
currentCommand returns HEAL only when the unit to be healed is ordered by the AI..
Whether this is a bug or feature can be debated, IMO it's a bug...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: CurrentCommand "HEAL"?
« Reply #4 on: 05 Jul 2007, 04:58:54 »
It occurred to me later, that my previously posted script suggestion should be modified to test if  unit is alive or not, and exit without re-adding an eventhandler if the unit is dead...
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline CrashDome

  • Members
  • *
Re: CurrentCommand "HEAL"?
« Reply #5 on: 05 Jul 2007, 17:10:08 »
Are you sure it's a bug?

If you order via the action menu, IMO it's an ACTION.

Isn't there another command that orders a unit to heal? Like through the support command menu or something? I cannot recall.... (i.e. the "Unit X Heal at ...." you here over the global channel from other squads)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: CurrentCommand "HEAL"?
« Reply #6 on: 05 Jul 2007, 17:38:03 »
No, you can not make the AI to call support, for example a medic with support WP, the support unit will come to you and it's currentCommand is MOVE while moving and nothing after that, even if it heals you..

The only way to order an AI to such a unit is again via the radio menu and it returns ACTION for the unit and SUPPORT for the medic.

If not a bug, then at least an oversight because if any action (haven't tested them all) you assign to an AI via the radio menu returns ACTION what use has such a value in any situation because you can't know which action is being performed (you might want to know that info even from player controlled groups)..  ???
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.