Home   Help Search Login Register  

Author Topic: Making any unit medic?  (Read 1937 times)

0 Members and 1 Guest are viewing this topic.

Offline Rathgrith

  • Members
  • *
Making any unit medic?
« on: 06 Jun 2009, 16:53:55 »
For a mission I'm working on, I want to have a civilian man serve as a medic. I also plan on doing the same with addon-related soldiers in the future. Is there a way to add medic ability to any unit like so?

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Making any unit medic?
« Reply #1 on: 07 Jun 2009, 14:18:51 »
In the medic's config, it is done with "attendant = 1;". This is the only way to add medic ability in Arma1.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Making any unit medic?
« Reply #2 on: 13 Jun 2009, 19:17:03 »
Read: it's not possible from script. You'd have to create your own addon to do so.
try { return true; } finally { return false; }

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Making any unit medic?
« Reply #3 on: 13 Jun 2009, 20:40:39 »
You can script something up most likely, depending on how you want it to work.  Attached is a first aid script I used in Last Tango in Bagango (I got it from SharkAttack, and he couldn't remember where he got it).

In its first incarnation, when a unit was hit I would addAction to the unit to the call the script.  Player as leader could then order any unit to perform the heal action (including the hit unit).  When an action is attached to a unit (or any object), the unit ordered to perform the action moves to the location of the object the Action is attached to.  That is good for moving a "medic unit" to a wounded unit (who has the action attached).  Problem is that Actions are available to ALL units, so ALL units become potential medics using this technique.

 I changed it to be activated via radio instead, so when a unit was hit, the radio heal action would be named specific to the man hit (easier for player to order man to heal himself).  For my purposes, this was so any unit could heal themselves (not a medic).

You could script a unit to serve as medic for other units by doing the following:

1. Add Hit Eventhandlers on those units medic would serve.  The EH would add the hit unit to a global WoundedUnit unit array.

2.  Write a MEDIC script with this logic:

Code: [Select]
[b]Input variables:[/b]
- medicUnit (pass in unit you want to be medic)

vTrys = 0
While Alive medicUnit
LOOP
   IF  unit found in WoundedUnit Array THEN
       medicUnit move to position of wounded unit.
       WHILE Distance between medic Unit and wounded Unit > 2 AND vTrys < X (how long should medic
                   attempt to reach the wounded unit?)
       LOOP
           vTrys = vTrys + 1;
           sleep 4;
       END LOOP
       IF medicUnit within 1 meter of woundedUnit then
           medicUnit say "I gotcha buddy, u gonna be alright"
           play healing animations
           sleep long enough for animations
           woundedUnit say "u rock doc, thanks",
        ELSE
           medicUnit says "I can't get to him, sorry", and gives up trying
        END IF
        remove wounded unit from woundedUnit array
   END IF
   sleep 5;
END LOOP

To get the unit to the wounded unit, you might use Hoz's DoFollowUnit script, and end that script when medic close enough to wounded man.   This would be helpful if he is going to heal a wounded that is upright and mobile (you wouldn't have to re-invent follow logic).  Maybe the doFollowUnit script should be run on the wounded unit also, so they both move toward each other.

Lots o' options.  This would be fun to write, and I'm tempted, but I just got ARMA2 so...I have no time for anything else.  You understand.   :D

Good luck sir.
« Last Edit: 13 Jun 2009, 21:18:57 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...