Home   Help Search Login Register  

Author Topic: watch out OFP pedestrians!!!  (Read 2518 times)

0 Members and 1 Guest are viewing this topic.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
watch out OFP pedestrians!!!
« on: 09 Dec 2004, 01:24:36 »
hello,
i thought of a way to make AI cars, tanks, and anything else with wheels purposly atempt to hit an enemy Man.

it uses set velocity and set dir

make a 15 m radius around the vehicle u want.
any enemy man class unit detected in that radius will make the vehicle face the direction of the enemy unit. using faceDirection or somthing. then the vehicle will be ordered, using domove to go to the enemy man. right when the vehicle gets close enough to the man that it would be stopping due to collision avoidence give it a quick set velocity in increments in the dir its facing, maby

car setVelocity 3
~.3
car setVelocity 6
~.3
car setvelocity 9
~.3
car setVelocity 12
~.3
car setVelocity 15
~.3
car setVelocity 18
~.3
car setVelocity 21
~.3
car setVelocity 25

that would make it get a speed boost with out being able to even avoid him, and then well, no more enemy man. but ud have to add a part that cancels all that if the driver is killed.

thanks
i would script it my self but, I cant script to save my life.

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:watch out OFP pedestrians!!!
« Reply #1 on: 09 Dec 2004, 02:11:25 »
its a good idea, but the problem is that it would be really hard to determine whether the person was hiding behind something, and so the car could end up crashing into a wall or tree instead of the person.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:watch out OFP pedestrians!!!
« Reply #2 on: 09 Dec 2004, 06:05:50 »
thats ok because
1. men dont activly find cover in ofp.
2. it would look funny if it crashed, and in reall life there is a good chance that would happen

i think this script will work unless u are in a dense city

Bluelikeu

  • Guest
Re:watch out OFP pedestrians!!!
« Reply #3 on: 10 Dec 2004, 18:56:20 »
Well, this is easy to script. These are the scripting steps.

1.) Find the nearest unit withing a radius
2.) Find the angular difference between the two units
3.) Order the tank to rotate to this angle
4.) Increase the velocity of the tank
5.) Check to see say after 6 seconds if the unit is dead
6.) If not, please try again

This is like crossing the road in Egypt.

bored_onion

  • Guest
Re:watch out OFP pedestrians!!!
« Reply #4 on: 10 Dec 2004, 19:43:27 »
would you need to use the dirtoobj function?

Bluelikeu

  • Guest
Re:watch out OFP pedestrians!!!
« Reply #5 on: 10 Dec 2004, 19:45:16 »
Probably ::)

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:watch out OFP pedestrians!!!
« Reply #6 on: 10 Dec 2004, 22:25:02 »
what is the dirtoobj function?

all you really need for this is basic trig and setvelocity

lets say you have a tank and a unit

_tPos = getpos tank
_uPos = getpos unit
_xdiff = _tPos select 0 - _uPos select 0
_ydiff = _tPos select 1 - _uPos select 1
?_xdiff == 0:goto "EW"
?_ydiff == 0:goto "NS"
_dir = abs (atan ((_xdiff)/(_ydiff)))
?_xdiff < 0 && !(_ydiff < 0):_dir = _dir + 270
?_xdiff < 0 && _ydiff < 0:_dir = _dir + 180
?!(_xdiff < 0) && _ydiff <0:_dir = _dir + 90
[_dir,tank unit] exec "runover.sqs"
exit

#EW
?_ydiff < 0:_dir = 180;exit
_dir = 0
[_dir,tank unit] exec "runover.sqs"
exit

#NS
?_xdiff < 0:_dir = 270;exit
_dir = 90
[_dir,tank unit] exec "runover.sqs"
exit

and then runover would set the tanks direction and make him run stuff over and all the other stuff

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:watch out OFP pedestrians!!!
« Reply #7 on: 11 Dec 2004, 04:31:03 »
ohh neat.

but i may be mistaken but isint that 3 different scripts,
isnt there a way to do it in only one and a little simpler.

i will try it but im not even quite sure what to put to init it.
thanks trigg

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:watch out OFP pedestrians!!!
« Reply #8 on: 11 Dec 2004, 04:37:02 »
actually i only posted one
if you wanted to put the runover thing into it, you would just change all the exits to gotos to the same label, where you would make them run over stuff

Bluelikeu

  • Guest
Re:watch out OFP pedestrians!!!
« Reply #9 on: 11 Dec 2004, 07:40:19 »
From the way the script looks. The change in direction is not smooth, but rather instant.

Thanks,
Bluelikeu

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:watch out OFP pedestrians!!!
« Reply #10 on: 11 Dec 2004, 16:28:23 »
i didn't do the change in the script, all i did was get the direction it needs to face

Bluelikeu

  • Guest
Re:watch out OFP pedestrians!!!
« Reply #11 on: 11 Dec 2004, 18:31:51 »
The dir-to-obj function does the same thing. But the thing is that the the vehicle should seemingly rotate towards the person and then move forward. I know that you script got the direction, but it would be more compact and smooth if you could add the slow rotation towards the target to the script.

Thanks,
Bluelikeu

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:watch out OFP pedestrians!!!
« Reply #12 on: 11 Dec 2004, 21:03:24 »
Couldn't you just turn off AI movement and use a DoMove?
urp!

Bluelikeu

  • Guest
Re:watch out OFP pedestrians!!!
« Reply #13 on: 12 Dec 2004, 09:13:00 »
Sadly, I think that the vehicle will stop just before the unit, and go around it or something. Velocity is the only way to make sure.


Oh, and it is possible to find out if there are objects blocking a path towards the pedestrian.
« Last Edit: 12 Dec 2004, 09:13:41 by Bluelikeu »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:watch out OFP pedestrians!!!
« Reply #14 on: 12 Dec 2004, 20:27:59 »
perhaps nearestbuilding (i think thats the command - this is off the top of my head)