Advertisement

Author Topic: Car teleport/move problem  (Read 370 times)

0 Members and 1 Guest are viewing this topic.

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
Car teleport/move problem
« on: 25 Feb 2012, 16:45:46 »
Unfotunately, I have run into another problem..... Getting a car to teleport, and to move to another point.
Now there are a few men (drivers for the vehicles) with this in their init field:
Code: [Select]
this moveindriver redcarthe names for each of the vehicles are: redcar, greencar, yellowcar, bluecar, sport1, sport2, and carsm.
Each of the drivers for the vehicles have the same name, but with d (for driver) at the end.
So the code above would be for redcard, putting him into redcar which is a skoda red.
Sport1 and sport2 are sportscars, and carsm is car small.

So here is the code that detects where the player is, and randomly selects a car to put near the player.
Code: [Select]
\\This basically detects which point the player (actme) is closest to.
? ((actme Distance south) <=20) : goto "south"
? ((actme Distance patwest) <=20) : goto "west"
? ((actme Distance east) <=20) : goto "east"
? ((actme Distance slapy) <=20) : goto "slap"
? ((actme Distance air) <=20) : goto "air"
? ((actme Distance bridge) <=20) : got "bridge"
? ((actme Distance soro) <=20) : got "soro"

#south
\\this randomly selects a car, and moves it to the said locations. I only used the south one, all the other ones \\are basically the same except for the positions. The other ones are air1, air2, bridge1, bridge2 and so forth. \\all the positions are game logics (south1, south2)
\\ignore the scripts executed for each car, thats for later in the game, no problems there.
_NUMBERS = 7
_NUMB = random _NUMBERS

?(_numb < 1): actme exec "patrol1\red.sqs"; redcar setpos getpos south1; redcard setpos getpos south1; [redcard, 1] setwppos getpos south2; goto "xit"
?( (_numb > 1) and (_numb <= 2) ): actme exec "patrol1\green.sqs"; greencar setpos getpos south1; greencard setpos getpos south1; [greencard, 1] setwppos getpos south2; goto "xit"
?( (_numb > 2) and (_numb <= 3) ): actme exec "patrol1\yellow.sqs"; yellowcar setpos getpos south1; yellowcard setpos getpos south1; [yellowcard, 1] setwppos getpos south2; goto "xit"
?( (_numb > 3) and (_numb <= 4) ): actme exec "patrol1\blue.sqs"; bluecar setpos getpos south1; bluecard setpos getpos south1; [bluecard, 1] setwppos getpos south2; goto "xit"
?( (_numb > 4) and (_numb <= 5) ): actme exec "patrol1\sport1.sqs"; sport1 setpos getpos south1; sport1d setpos getpos south1; [sport1d, 1] setwppos getpos south2; goto "xit"
?( (_numb > 5) and (_numb <= 6) ): actme exec "patrol1\sport2.sqs"; sport2 setpos getpos south1; sport2d setpos getpos south1; [sport2d, 1] setwppos getpos south2; goto "xit"
?( (_numb > 6) and (_numb <= 7) ): actme exec "patrol1\carsm.sqs"; carsm setpos getpos south1; carsmd setpos getpos south1; [carsmd, 1] setwppos getpos south2; goto "xit"

#xit
exit

So after this is executed, sometimes theres a car there, and sometimes theres not. And when there is, he doesn't move, even though I set a waypoint for him. so is there a teleporting issue, when I tell the driver and the empty car to move?

Sorry if this is a little confusing. If you have any questions, obviously feel free to ask about this.
Thanks for taking the time to read it.

-Mad Pup
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

STiT/LK

  • Guest
Re: Car teleport/move problem
« Reply #1 on: 25 Feb 2012, 21:38:12 »
If I correctly understood what you meant, do as I suggest.

You should have on the map:
- two game logics named "south1" and "south2";
- some cars; I assume you named them "redcar","bluecar","greencar","yellowcar", ...
- some men which you don't need to give a name to; just write this in their init fields:
Code: [Select]
this moveInDriver car remember to change car with the respective car name: i.e. redcar, greencar, and so on.

Now, execute this script:
Code: [Select]
_cars = [redcar,bluecar,greencar,yellowcar]
_carToMove = _cars select random (count _cars)
_d = driver _carToMove

_carToMove setPos (getPos south1)
~0.1
_d MOVE (getPos south2)
exit

This will select randomly a car, teleport it to south1 position and make its driver reach the south2 position.
If you want to add more vehicles, just add them to the _carToMove array.

If you need, I can modify the script so that it automatically creates a driver for the car, saving you from placing every single driver in the OFP editor.

Also, if you need it, I can modify the script in order to prevent a car from being selected twice.
Just let me know!  ;)

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
Re: Car teleport/move problem
« Reply #2 on: 25 Feb 2012, 22:33:42 »
STiT/LK that makes total sense.  :clap:
Thanks for the quick response!
One question though.
How do I make it so that it teleports to the right gamelogic? If I'm at a different one than south, do I have to make a different script for each location? Or could I just somehow combine it?

-Mad Pup
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

STiT/LK

  • Guest
Re: Car teleport/move problem
« Reply #3 on: 26 Feb 2012, 18:35:02 »
So, if I correctly understand, you need a script that creates cars in the game logics near to the player?

I made a test mission where you have two zones:
- if you are in the first zone (let's call it "north zone"), cars will be spawned next to the game logics in the nearby;
- if you instead are in the second zone ("south"), cars will be created in the appropriate game logics.

I hope this solved your problem! ;) If not, don't hesistate to ask further!

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
Re: Car teleport/move problem
« Reply #4 on: 03 Mar 2012, 18:36:36 »
If I use

Quote
_cars
_carToMove
_d

and define them. Are they defined in other scripts as well? Or just the one script where they're defined?

Thanks

-Mad Pup
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

Offline Gruntage

  • Moderator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Car teleport/move problem
« Reply #5 on: 03 Mar 2012, 18:45:35 »
What you defined there Madpup are just local variables so they can only be used within the script they are created. To define a global variable you just need to get rid of the underscore. An example of a global variable (used everywhere) would be:

Code: [Select]
unitseast = [e1, e2, e3]
...or something like that. Be careful you don't have too many global variables within a mission otherwise you'll experience probs down the line.
Some of the most memorable missions made involve the player doing very little...

"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
Re: Car teleport/move problem
« Reply #6 on: 04 Mar 2012, 04:37:21 »
Alright. thanks Gruntage. It's appreciated.

-Mad Pup

EDIT: New problems arising. Everything seems to work up to the point after the car teleports. The car teleports, and he either goes EXTREMELY slow, and doesn't take the road, and goes in a straight line, until he hits a building, OR he doesn't move at all.........

I am using:

Code: [Select]
_cars = [redcar,bluecar,greencar,yellowcar]
_carToMove = _cars select random (count _cars)
_d = driver _carToMove
_carToMove setPos (getPos south1)
~0.1
_d MOVE (getPos south2)
_d setSpeedMode "FULL"

If the SpeedMode command is incorrect, I'm sorry, it's correct in the script. It used to work, and stopped working for some reason. Also this isn't the computer I use for OFP.

When I first started using the script, the car teleported, the car speed by me, and the mission continued. However about two days ago, they started doing this. So I adjusted drivers's skill levels all the way to the right, it has no effect. No sure whats going on.

Thanks!

-Mad Pup
« Last Edit: 09 Mar 2012, 23:21:40 by Mad Pup »
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: Car teleport/move problem
« Reply #7 on: 24 Mar 2012, 01:35:58 »
Mad Pup,

You are doing it right, but you also have to set the behavior to "safe" or "careless' if you want them to only stay on roads. Cars are slow on rough terrain, but if their behaviour is safe or careless, they will find the nearest road path to reach the destination. In behaviour "safe" they will use roads and turn the lights on at night, but if they see an enemy they will go into combat mode and turn off the lights and leave the road. If you use "careless" then they will ignore enemies and follow the road with lights on even if it attracts all the bullets in the world.

Code: [Select]
_d setBehaviour "careless"