Home   Help Search Login Register  

Author Topic: Soldiers Crouching at Defense Positions  (Read 1752 times)

0 Members and 2 Guests are viewing this topic.

Javito

  • Guest
Soldiers Crouching at Defense Positions
« on: 11 Aug 2006, 20:38:07 »
Okay, here's what I've done. Beginning testing for the second mission of my little campaign and I've created a soldier (his name is Name) and, using two triggers, have set him on a loop that will -force- him to maintain in a crouched position. If said soldiers tried to stand up, lay down, move, or do anything the triggers will just force him to stay in a crouched position.


The soldier has a move waypoint on him with this in the activation line NAME setbehaviour "COMBAT"; NAME setunitpos "UP"; NAME switchmove "crouch"; FIRST=true .

The first trigger around him is timed to 1 second and repeated. In the condition line I've replaced "this" with "FIRST" and in the activation line it reads NAME setunitpos "UP"; NAME switchmove "crouch"; FIRST=false; SECOND=true.

The second trigger is also timed to 1 second repeated. "SECOND" is in the condition line, the activation reads NAME setunitpos "UP"; NAME switchmove "crouch"; SECOND=false; FIRST=true .

This works beautifully but it looks horrible if he gets shot and his dead body is constantly trying to crouch. Also if he gets wounded. So I think the solution is to have a third trigger, with THIRD in its condition, time set to 0, and set to activate only once. Next to THIRD in the condition I would like to put two Event Handlers, one if he gets damaged and another if he gets killed. The trouble is I don't know the right command to do that with. And on the activation line... this part I don't know, something to break the loop and make him act normally.


ps. I did not suddenly become good at scripting, I got the above idea from searching old posts on the BIS forums.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Soldiers Crouching at Defense Positions
« Reply #1 on: 11 Aug 2006, 20:46:38 »
change your conditions to

Code: [Select]
first and (alive name)
and

Code: [Select]
second and (alive name)
and change the unit's name to something more significant than "name". you'll thank yourself later ;)

Javito

  • Guest
Re: Soldiers Crouching at Defense Positions
« Reply #2 on: 11 Aug 2006, 21:03:14 »
 Is there anything in OFP you -can't- do with scripting? That works beautifully, thank you.  ;D


Is there something similar I can use if the unit is just damaged? "First and (alive name) and _____"?

Some kind of "Name Damage > 0" to make the loop end if he gets hit -at all-? Lib '41 has an effect where sometimes if a soldier is wounded badly enough they will start rolling around on the ground moaning, and that will conflict with this loop as well.


Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Soldiers Crouching at Defense Positions
« Reply #3 on: 11 Aug 2006, 21:11:28 »
Code: [Select]
first and (alive name) and ((getdammage name) <=0.1)
Code: [Select]
second and (alive name) and ((getdammage name) <=0.1)
you may need to play with that value a bit.

Javito

  • Guest
Re: Soldiers Crouching at Defense Positions
« Reply #4 on: 11 Aug 2006, 21:38:26 »
Eh. 0.1 is a fine value I think. If I were crouched behind a little fortification and I got shot in the arm, I sure wouldn't sit still. Thanks a lot, huge help.  ;D

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: Soldiers Crouching at Defense Positions
« Reply #5 on: 11 Aug 2006, 21:59:31 »
This may "look" good, but that crouched soldier will not be able to defend himself. The switchmove will make him frozen, unable to aim and fire. This is fine if it is only for a cutscene, but if you really want him to be a functional unit that will be a problem.

Javito

  • Guest
Re: Soldiers Crouching at Defense Positions
« Reply #6 on: 11 Aug 2006, 22:13:10 »
Well, i just did some testing and he defends himself well enough. He shoots and he throws grenades. It varies though, sometimes he will remain in the crouched position and sometimes he'll make himself stand up and stay that way. I'm not exactly sure what variable is effecting what.

Edit - Ran some more testing and I think what makes him stand pretty consistantly is when he throws a grenade. Unless you can let them throw their grenade and then have them crouch again without breakings something, what I could try is remove the grenades on some defenders and leave them on others. "Removeweapon grenade" isn't it?

Edit2 - Nope, they sometimes stand up and shoot at you. This seems to happen because the soldier stands up when he turns to aim at you. But if you're infront of him he will mostly shoot at you and remain crouched.


Can you make them go back to crouching after they throw their grenades/fire?
« Last Edit: 11 Aug 2006, 22:23:24 by Javito1986 »

Javito

  • Guest
Re: Soldiers Crouching at Defense Positions
« Reply #7 on: 12 Aug 2006, 00:33:33 »
Update - Just ran a test with this AI vs AI with the USSR AI in a crouched position. Confirmed Raptorsaurus' comment that the defenders would not open fire. Which is very odd because they sure shot at -me- when I tried this earlier today.

Is there a better way to have soldiers remain crouched without trapping them w/ code? Or perhaps a better way to use this script I found?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Soldiers Crouching at Defense Positions
« Reply #8 on: 12 Aug 2006, 00:40:10 »
edit your previous post rather than double-posting, unless it's been several days.

as far as i know there's no reliable way to keep ai crouched. you've laid the groundwork by using combat behaviour and unitpos "up"... other than that there's not much else to be done  :-\

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Soldiers Crouching at Defense Positions
« Reply #9 on: 12 Aug 2006, 04:13:40 »
Check out Blanco's work using ICPanims (an addon I believe).  He has many soldiers behind a barricade firing from the crouch position.  See this thread:

http://www.ofpec.com/forum/index.php?topic=18098.0

I downloaded his sample mission, and it works really well.
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 Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: Soldiers Crouching at Defense Positions
« Reply #10 on: 12 Aug 2006, 13:37:59 »
Hi, here is an example of what I did:

How you can make AI soldiers crouch when they are not moving

Works pretty well and doesn't tie them, they can move normally and will crouch when they stop.

Javito

  • Guest
Re: Soldiers Crouching at Defense Positions
« Reply #11 on: 12 Aug 2006, 20:13:55 »
Ah ha, Baddo that script does work very well. So I've done some testing with it and found that the AI, for some reason, has trouble aiming and firing from behind a barricade when they're crouched (and the enemy AI has trouble shooting at them). They're constantly standing up to fire and then crouching back down. Which is fine by me. The only issue is that they only shoot enemies when they're really close up, i.e. in grenade range. And it is cool to watch these soldiers behind barricades suddenly stand up and toss grenades then crouch again, but I'd like it if they fired their weapons more consistantly at longer ranges.

So I wonder, is there a way to control the "Stand/Crouch" motion when they're firing? I don't know, make them only stand up when they want to shoot and then crouch back down? Just throwing out ideas here. Or is there a better fortifcation than "Wood Fence" that will let them shoot more? I'm trying really hard to create a better defense than we normally see in OFP (soldiers standing straight up behind defenses and whatnot).