Home   Help Search Login Register  

Author Topic: Creating Units  (Read 562 times)

0 Members and 1 Guest are viewing this topic.

45mDex

  • Guest
Creating Units
« on: 27 Feb 2004, 21:58:29 »
Any way to create units that appear to be dead, and then will come alive and attack the players in a coop mission??

Any thoughts??

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:Creating Units
« Reply #1 on: 29 Feb 2004, 02:38:44 »
Code: [Select]
_c = 0
#createloop
? (local Server) : "soldierEB" createUnit [[_x0r,y0r,z0r],rusleader,"deadguy=this",.4,"Private"]
[deadguy] join grpNull
deadguy switchMove "CombatDead"
deadguy disableAI "autotarget"
_deadguys = _deadguys + [deadguy]
_c = _c + 1
~.5+(random .5)
? (_c < 5) : goto "createloop"

#initloop
_d = 0
#booyaloop
~5
? ({alive _x} count _deadguys == 0) : exit
? ({_x distance (_deadguys select _d) < 25} count (units group player) == 0) : _d = _d + 1; goto "booyaloop"


(deadguys select _d) switchMove "stand"
_deadguys = _deadguys - [(deadguys select _d)]

? ({alive _x} count _deadguys > 0) : goto "initloop"
exit

Oh, you asked for this only:
deadguy switchMove "CombatDead" and
(deadguys select _d) switchMove "stand"  ;D
 
But nevertheless, that's a worthwile system lagwise I'd imagine, you create all the dead guys in that script (5 of em), add them to an array which is dealth with in the loop while they are alive. The only prob is that it'll detect only the players group and the dead guys might turn around while laying on the ground. disableAI "autotarget" might prevent that but also a watch command might do. As in:
deadguy doWatch [(getpos deadguy select 0) + sin (getdir deadguy + 0) * 20, (getpos deadguy select 1) + cos (getdir deadguy + 0) * 20, 0]

Ofcourse, if they are created as the player closes in (to avoid lag), he might catch a glimpse of them dropping dead. So you can create them below ground and raise them slowly...
« Last Edit: 29 Feb 2004, 02:41:11 by MI_Fred »
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

45mDex

  • Guest
Re:Creating Units
« Reply #2 on: 01 Mar 2004, 21:19:35 »
Interesting idea, I'll have to play with it some. I also thought about another way, what about using the sleep script?? That might work, but won't the enemy still have thier eyes open with the sleep script?? Goog job coming up with that script though, I sure would'nt have figured that out.  

One other question though, in your script, what names will I have to give to all of my rising from the dead units, i'm not too keen on syntax.

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:Creating Units
« Reply #3 on: 02 Mar 2004, 03:18:51 »
The naming is the tricky part if you really wan't to micro-manage single units. You'd have to determine them with querying who is closest to a playable unit for example. But you can give an infinite amount of the same name to created units in scripts tho, the last just overwrites the one before, thus making the last one the unit to which external commands apply. But that is not elegant.

I left them as separate units in my example for a reason, it would be more efficient to create the units into a group with a function that returns that group name (a temporary one that gets overwritten too). You run the function whenever you want to spawn more groups, and while doing so exec a script for the created group (that for instance setPosses the guys within a random radius and stops and switchMoves them then loops that booyahloop).
« Last Edit: 02 Mar 2004, 03:20:47 by MI_Fred »
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.