Home   Help Search Login Register  

Author Topic: Making cars run people over  (Read 2074 times)

0 Members and 1 Guest are viewing this topic.

Father.Jack

  • Guest
Making cars run people over
« on: 02 May 2004, 20:59:49 »
I want to make a car run someone over. I have tried everything but the ass inside the car has to slow down and pass the guy. Any ideas?

PsyWarrior

  • Guest
Re:Making cars run people over
« Reply #1 on: 02 May 2004, 21:49:51 »
Greetings, Father.

I think setVelocity might be of use here. I'm not a mathmatician, so I'm not really suited to working the details of this out without considerable deliberation, but you may want to try a forum/ COMREF/ Editors Depot search for "setVelocity".

In theory, when the AI starts to slow down, you could give the car an accelleration burst with setVelocity, causing the AI to run straight into whoever is unlucky enough to be in the way.

I have a couple of self-crafted NOS scripts somewhere, actually, which use directional velocities ( ??? ) to accellerate vehicles - I could dig them out for you to take a look at, if you like. Detecting when someone is standing in the way is going to be tricky, however...

-Supreme Commander PsyWarrior
-Psychic Productions Studios

P.S. - You missed "GIRLS!" out of your signature...

Father.Jack

  • Guest
Re:Making cars run people over
« Reply #2 on: 03 May 2004, 10:25:12 »
Thanks that would be great if you could get some of those things for me.

PS. That would be an ecumenical matter!

PsyWarrior

  • Guest
Re:Making cars run people over
« Reply #3 on: 03 May 2004, 17:10:40 »
Roger, I'll just have to hunt those scripts down.

Failing that (as my associate PsySniper may have deleted all trace of them when he decided to spontaneously format his hard drive) I'll have to recreate them. Which will be fun... :P

Also:
COMREF Entry: setVelocity:
Quote
vehicle setVelocity [x, z, y]
Operand types:
    vehicle: Object
    [x, z, y]: Array
Compatibility:
    Version 1.8 required.
Type of returned value:
    Nothing
Description:
    Set velocity (speed vector) of vehicle.

And an Ed Depot resource:
http://www.ofpec.com/editors/resource_view.php?id=570

-Psy|W
P.S. - Indeed... I suppose it would be.

[EDIT:] Nyaaagh! This is going to take a little while longer, as the scripts do seem to have gone into oblivion. I'll have something soon...
« Last Edit: 04 May 2004, 18:30:31 by PsyWarrior »

Komuna

  • Guest
Re:Making cars run people over
« Reply #4 on: 05 May 2004, 14:12:07 »
Errr... Lets see. I've coded this a long time ago, but I think it is not difficult at all.

We need two things:
 - a function that checks the direction that the car should take to run over the unit
 - a loop that sets the velocity of the car according to the direction

Errr....
Code: [Select]
_unit = _this select 1
_car = _this select 0

;This is the distance when the car is going to be forced to crash with the unit
_dis = 20

_getRelDir = { private ["_unit","_car"]; _car = _this select 0; _unit = _this select 1; ((position _unit select 1)-(position _car select 1)) atan2 ((position _unit select 0)-(position _car select 0)) }

;Wait until the car is _dis meters close to the unit
@_unit distance _car < _dis

;velocity in m/s: 20 is 72Kmh, which is quite fast!
;_vel = (speed _car)/3.6
_vel = 20

#setVel

_car setVelocity [_vel*(sin ([_car,_unit] call _getRelDir)),_vel*(cos ([_car,_unit] call _getRelDir)),velocity _car select 2]
~0
? _unit distance _car > 1: goto "setVel"
exit

OK. I think it would work... Of course, I don't have OFP here to test it... :P ::)

Anyway, the possible bugs are:

#_getRelDir (get relative direction, in other words, it is the declivity of the line that unites both positions) might have switched coordinates.

A fast and reliable way of debugging it, is making an unit's direction to the value returned and check if it is looking at the other unit.
E.g.:

Code: [Select]
MyUnit setDir ([MyUnit,player] call { private ["_unit","_car"]; _car = _this select 0; _unit = _this select 1; ((position _unit select 1)-(position _car select 1)) atan2 ((position _unit select 0)-(position _car select 0)) })
Place the code in the editor and then check if the unit is looking at you.
If not, try switching the arguments - [MyUnit,player] to [player,MyUnit]

#Car is too fast or it accelerates too much instantaneously...

Well, this bug is due to the _vel variable defined in the script. If you don't want to set your own velocity for the car, uncomment the line "_vel = (speed _car)/3.6" and remove/comment the next one. It will check the current velocity of the car and then will force it to drive at that velocity.

#Car is approaching the unit in the right direction, but it is facing another direction...

Sometimes, the vehicles (often choppers) will head a different direction if they're forced to move along an user-defined direction. That happens because they want to stop - as if they had their own personality ;D.

In order to avoid it, add the following line to the loop:

_car setDir ([_car,_unit] call _getRelDir)

#Unit doesn't get killed after being run over

It doesn't?? Damn...
EhEhEh! :D :P
« Last Edit: 05 May 2004, 14:17:27 by Komuna »

_hammy_

  • Guest
Re:Making cars run people over
« Reply #5 on: 10 May 2004, 23:02:58 »
you can also download a command reference in a .exe format, click the link thats in my sig

PsyWarrior

  • Guest
Re:Making cars run people over
« Reply #6 on: 12 May 2004, 00:02:20 »
Greets,

Dang, I give up. I can't find any trace of the script, and Komuna has beaten me to it (although judging by the time it took me to even realise that I couldn't find it, that wasn't really too hard ::)).

But anyway: As Hammy says: Command Reference. Vital for any OFP Editor using .sqs. Vital.

Quote
they want to stop - as if they had their own personality
You mean... Vehicles in OFP don't have their own personality? Can it be?

Sorry. Rather random post there, but it seems to contain most of the stuff I wanted to say...maybe... :P

-Psy|W

Komuna

  • Guest
Re:Making cars run people over
« Reply #7 on: 12 May 2004, 14:11:07 »
You mean... Vehicles in OFP don't have their own personality? Can it be?

C'mon.... Make a script that forces a chopper to move towards its active WP - using the setVelocity command. You will notice that the chopper will try to stop at the WP, but, as the speed is too high (is forced!), it will start changing its direction like a car making a 360... This is what I mean by their own personality.

Q: What script are you trying to find?

I haven't tested my sample (and I won't, since I have other things to do) but I think that after some debugging, it will fit its purposes ;)
« Last Edit: 12 May 2004, 14:11:47 by Komuna »

DBR_ONIX

  • Guest
Re:Making cars run people over
« Reply #8 on: 12 May 2004, 16:52:41 »
Hey
I've attached a simple eg. mission that I made ages ago of a soldier getting run over
It's okay, but the speed needs to be changed down a bit, it looks a bit weird
But works..
- Ben

PsyWarrior

  • Guest
Re:Making cars run people over
« Reply #9 on: 12 May 2004, 22:36:34 »
Greets,

Sorry  Komuna, sarcasm really doesn't translate well into text... ::)

The worst thing about choppers is that when you finally get it working, next time you start OFP, a new RandomSeed is generated, and nothing works as it did before ;D

Quote
Q: What script are you trying to find?
See above:
Quote
I have a couple of self-crafted NOS scripts somewhere,
Quote
Failing that (as my associate PsySniper may have deleted all trace of them when he decided to spontaneously format his hard drive)

So no point looking in the Ed-Depot for them... ;D ::)

-Psy|W

Komuna

  • Guest
Re:Making cars run people over
« Reply #10 on: 13 May 2004, 09:26:25 »
Sorry  Komuna, sarcasm really doesn't translate well into text... ::)

Yes it does:

 :) ;) :D ;D >:( :( :o 8) ??? ::) :P :-[ :-X :-\ :-* :'( :afro: :beat: :cheers: :gunman: :help: :tomato: :wave: :toocool: :moon: :booty: :noo: :joystick: :thumbsup: :wow:

One of the above will perfectly fit any kind of sarcasm ;)

PsyWarrior

  • Guest
Re:Making cars run people over
« Reply #11 on: 13 May 2004, 12:05:17 »
:hmm:

Sorry, just trying to work out if that reply was sarcastic or not... :P

But none of this has anything to do with Cars running people over, or velocity any more...

See what happens when you don't click solve... ;D ::) :P :hmm: :tomato: :beat:

*^SARCASM! IRONY!^*

I think we should stop now.
I apologise for the inconvenience... ::)

-Psy|W

Komuna

  • Guest
Re:Making cars run people over
« Reply #12 on: 13 May 2004, 14:10:26 »
But none of this has anything to do with Cars running people over, or velocity any more...

See what happens when you don't click solve... ;D ::) :P :hmm: :tomato: :beat:

Indeed ::)

After all, where are you Father.Jack?


Anyway, a hint about avoiding vehicles (actually their drivers) acting by their selves:

camCreate an unit (not vehicleCreate/unitCreate) and set it as driver of the vehicle. It will work fine, since the unit becomes a "zombie" and doesn't care about any threats, obstacles or waypoints.

Note: Those units won't react (still will be considered enemy or friendly) to any situation as they don't have AI, but I haven't tested if they would drive along their WP... Maybe the whole scripting is unnecessary...

Note2: camCreated units (dum bots) are usefull for situations that require vehicle lights to be on, static sentries, etc, as they won't act at all.