Home   Help Search Login Register  

Author Topic: Force Units To Stay  (Read 717 times)

0 Members and 1 Guest are viewing this topic.

RedBaron 13

  • Guest
Force Units To Stay
« on: 24 Mar 2004, 17:20:13 »
I want to build a mission in a city and behind nearly every door should be an enemy. My problem: The placed enemy soldiers move away from there waypoints (placed exacly where I placed the soldiers). So the soldiers lay down or just walk some steps away from there perfect positions. I tried dostop this, this dohalt and setbehavior "secure" ..... Nothing worked...


I NEED THEM TO STAY EXACTLY WHERE THEY ARE AND THEY SHOULD STAND AND NOT LAY DOWN OR SOMETHING.
HELP!!!!  ???

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Force Units To Stay
« Reply #1 on: 24 Mar 2004, 17:39:52 »
If there are several loons in the same group ... make sure the special field is set to "none" (not formation) and in the init field write

doStop this; this setUnitPos "up"

syntax not guaranteed.     The dostop command will only work till the group spots the enemy, I think.    I wouldn't give the group any waypoints:  if you need to, give the group leader a waypoint right where he starts and synch it to a trigger.
Plenty of reviewed ArmA missions for you to play

RedBaron 13

  • Guest
Re:Force Units To Stay
« Reply #2 on: 24 Mar 2004, 17:42:47 »
I need them to stay where they are (eg. behind a door/a window...). Even when enemys are coming....


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Force Units To Stay
« Reply #3 on: 24 Mar 2004, 17:46:21 »
setPos loop?
Plenty of reviewed ArmA missions for you to play

RedBaron 13

  • Guest
Re:Force Units To Stay
« Reply #4 on: 24 Mar 2004, 17:49:24 »
Doing a loop in a scrip?

RedBaron 13

  • Guest
Re:Force Units To Stay
« Reply #5 on: 24 Mar 2004, 17:50:47 »
(scrip = script)


I think I am not able to programm such a script in the next hour.
I'm a rookie!

RedBaron 13

  • Guest
Re:Force Units To Stay
« Reply #6 on: 24 Mar 2004, 18:00:23 »
doStop this; this setUnitPos "up" works pretty good. Even without a loup.
thanx

Mujahedeen

  • Guest
Re:Force Units To Stay
« Reply #7 on: 24 Mar 2004, 21:32:17 »
Hi!

This works fine:

Code: [Select]
this disableAI "MOVE"; this setUnitPos "UP"
The only "problem" is that the unit cannot move...
...but that's what you want, right?  ;)

Mujahedeen

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Force Units To Stay
« Reply #8 on: 31 Mar 2004, 06:04:14 »
Mujahedeen is on the right track. "Dostop" will only stop the unit until his group spots the enemy; then he will move around again at his leader's orders. Usually the leader will order the guy back into formation; then when the enemy is close enough, the leader will order his men to engage the enemy (meaning MOVE out and attack the enemy)

DisableAI "MOVE" will keep the guy from falling back into formation. With "MOVE" disabled, the unit cannot move from waypoint to waypoint, or via the "domove" command, or whatnot. However, he still can move (read on).

If the AI leader of his group (the guy with his "move" AI disabled) orders him to engage the enemy, he can still move, oddly enough. Ever seen the AI try to flank you? That is the movement I am talking about; they are 'engaging' you. As a side note, when the AI 'engages' you like this, the group leader stays put; only his men move to flank/assualt you.

So if an entire group has "move" ai disabled, then when the enemy is spotted, after a while the group members will move after the enemy, but the leader will stay put. I know this via painful experience with this problem myself, trying to figure out why some guys were still moving when "move" ai was disabled.

One fix is to make everybody their own leader, meaning making groups of one unit each. In this case you only need to disable "move" ai. Keep in mind that in this case there is no sharing of enemy positions between units near each other (see my script in the pending section for an example). So guy A in one window may shoot at the player, while guy B in the next window may be looking off to the side and never know anything is going on.


A better fix is to make everyone in large groups, so when one guy sees the player, his whole squad knows about him. To do this, you need to fix the problem I described above with guys moving to engage the enemy. This is a simple fix. Just add in this next line:

this disableAI "TARGET"

Disabling "target" doesn't mean the AI can't pick targets and shoot at them on their own; that is "AUTOTARGET". "Target" means they can't move when engaging the enemy, as described above. Nothing more. So in combination, disabling "move" and "target" will give you a guy who will never be able to move again.


Sorry for the short novel, but in the past I have had such a frustrating experence, learning the above the hard way, and I don't want anyone else going through what I went through :P In summary, put this in the guys init fields:

this disableAI "MOVE"; this disableAI "TARGET"; this setunitpos "UP"
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Force Units To Stay
« Reply #9 on: 31 Mar 2004, 06:17:48 »
It is also easy and useful to make units start off in a crouched position, for better cover behind smaller walls/objects. They often stand up after a little bit of fighting, but it still makes things very difficult for the player. To do so, you need to set the guy's behavior to "combat", and then via a script you need:

man playmove "crouch"

To simplify things, I made this simple script a while ago. It will do all the disabling of AI and setting positions for you, in one short line in the guys init field. To call it:

[man, position#, <building position>] exec "cover.sqs"

Man is the guy to execute the script on
Building position is optional. See below.
Position# is an integer determining what position the guy is going to be in:

0) SITTING
1) PRONE
2) CROUCHING
3) STANDING
4) STANDING IN THE NEAREST BUILDING
    For #4, you must provide a building position, which is a number telling the script which window or door to hide the guy behind. Put your mouse over the grey blocks for buildings in the editor and it will say "Position #2" or something similar. This is helpful for putting guys on the second floor of a building, since you don't have to mess with setpos. But otherwise you could just manually place the guy near the window, and use the STANDING position of the script.
    #0 (sitting) makes the guy sit down on the ground, in safe mode. It is just there for convenience, in case you want to make some guys sitting around a campfire or something (which has to be done via script).

Hope that's useful!


HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Kammak

  • Guest
Re:Force Units To Stay
« Reply #10 on: 07 Apr 2004, 05:24:33 »
General Barron this is a fantastic script, thanks for posting it.  But it seems to have a few issues?

I've only played with it on Everon, using 1.96 - the building position in the editor won't work unless you *subtract 1* from what it indicates - if it says Pos #8, you have to use 7 to get the guy there.  If you try to place a guy in the highest numbered position in the building (and don't subtract one) I have no clue where the guy goes, but he isn't anywhere near the building!  I'm assuming thats an OFP issue not anything to do with your script...but the doWatch aspect of cover.sqs doesn't seem to work correctly.  Sometimes it does, but usually the guy is not facing the right way.  To be honest, I haven't gone through that line to figure out what it is doing, but I'm guessing it doesn't work properly due to the same issue as above - the positions in the editor being 1 higher than the in-game position?

Do you have an updated version and/or have you noticed these issues yourself?

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Force Units To Stay
« Reply #11 on: 07 Apr 2004, 05:31:40 »
The building position # issue must be OFPs problem. I didn't ever realize that, but to fix it, change the second to last line in the script to this:

_man setpos ((nearestbuilding _man) buildingPos ((_this select 2)-1))

Its been a while, so I don't exactly remember what the "dowatch" thing is about in the script. I assume that it is supposed to make the guys face out the windows/doors. Basically it draws a line from the unit to the center of the building, and makes the unit face along that line (away from the center of the building). This would work well with round buildings, but the less circular/square the building is, the less likely this method would work well. To fix, you could comment out or delete that line, and just manually make the guys facing the right direction in the editor.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Kammak

  • Guest
Re:Force Units To Stay
« Reply #12 on: 07 Apr 2004, 06:01:03 »
Yeah thats just what I did.  I removed the DoWatch line and set the facing with the compass in editor.  I also changed it and added a fourth param for the building ID, so I don't have to place the units near the building (I'm a slight control freak, this way I KNOW they will go in the building I want).   :)

Thanks for posting it!



Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Force Units To Stay
« Reply #13 on: 07 Apr 2004, 06:48:12 »
Thanks for the heads up on the bugs. I just submitted it to the ed depot now, along with an example mission (its hard). Hopefully others will get some use out of this too.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!