Jump to content
Sign in to follow this  
theavonlady

createVehicle for a plane plus waypoints

Recommended Posts

T_D @ Sep. 26 2004,16:18)]Is the groupAlpha present on the map? because you need an existing group on the map in which you can create the pilot. you can also take a unit instead of a group. After the createunit command you should write "[vpilot] join grpnull" to get him out of the group.

I tried this and it didn't help but that might be for another reason. Here's the current script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_apos = [getmarkerpos "VplaneStart" select 0,getmarkerpos "VplaneStart" select 1,(getmarkerpos "VplaneStart" select 2) + 1000]

_aSpd = 600

_aDir = 220

_aVel = [sin(_aDir)*_aSpd, cos(_aDir)*_aSpd,0]

vpilot = []

"SoldierWPilot" createUnit [getmarkerpos "VplaneStart",groupAlpha,"vpilot=this",1]

vpilot join grpNull

_plane = "A10" createVehicle [0,0]

_plane setPos _apos

vpilot moveInDriver _plane

_plane engineOn true

_plane setDir _aDir

_plane setVelocity _aVel

while {(speed _plane)<_aSpd} do {_aVel=velocity _plane; _plane setVelocity [1.05*_aVel select 0, 1.05*_aVel select 1, 0]}

_plane setBehaviour "Combat"

_plane setCombatMode "RED"

#targeth1

? not (canMove h1) : goto "targeth2"

_plane domove (getpos h1)

_plane dotarget h1

_plane dofire h1

~1

goto "targeth1"

#targeth2

? not (canMove h2) : goto "exit"

_plane domove (getpos h2)

_plane dotarget h2

_plane dofire h2

~1

goto "targeth2"

#exit

exit

I added a WEST soldier somewhere on the map and set his INIT field to:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init="group this setgroupID [""Alpha"",""GroupColor0""]; [] exec ""vplanesetpos.sqs""";

On the statement:

vpilot moveInDriver _plane

I'm getting an error message:

error MoveInDriver: type array; expected object

on the use of "_plane" in the statement. What's wrong with my moveInDriver statement? rock.gif

Share this post


Link to post
Share on other sites

@drill sergeant: no.

write in the init of the WEST soldier<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">groupAlpha = group this

Share this post


Link to post
Share on other sites
I think you need to get rid of the _ infront of plane.

Nope. Globally changed all references of _plane to vplane. Same error. I've posted the script above.

Here's the mission.sqm. Runs on OFP's Desert Island. See for yourself:

EDIT:This is the final corrected sample mission.sqm file that works with the script that follows a few posts down.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">version=11;

class Mission

{

randomSeed=12114947;

class Intel

{

};

class Groups

{

items=3;

class Item0

{

side="WEST";

class Vehicles

{

items=1;

class Item0

{

position[]={11714.632813,9.441871,4158.756348};

azimut=20.000000;

id=1;

side="WEST";

vehicle="SoldierWB";

leader=1;

skill=0.600000;

init="groupAlpha = group this; [] exec ""vplanesetpos.sqs""";

};

};

};

class Item1

{

side="EAST";

class Vehicles

{

items=1;

class Item0

{

position[]={9509.833984,29.834999,3665.956787};

azimut=25.000000;

id=2;

side="EAST";

vehicle="SoldierEB";

player="PLAYER COMMANDER";

leader=1;

skill=0.600000;

text="h1";

};

};

};

class Item2

{

side="EAST";

class Vehicles

{

items=1;

class Item0

{

position[]={9481.033203,29.834999,3685.156738};

azimut=35.000000;

id=3;

side="EAST";

vehicle="T72";

leader=1;

skill=0.600000;

text="h1";

};

};

};

};

class Vehicles

{

items=1;

class Item0

{

position[]={9912.736328,26.730000,4163.301270};

id=0;

side="EMPTY";

vehicle="FlagCarrier";

skill=0.600000;

};

};

class Markers

{

items=1;

class Item0

{

position[]={9905.240234,26.730000,4155.040039};

name="VplaneStart";

type="Flag";

};

};

};

class Intro

{

randomSeed=13170179;

class Intel

{

};

};

class OutroWin

{

randomSeed=4969987;

class Intel

{

};

};

class OutroLoose

{

randomSeed=10701315;

class Intel

{

};

};

Share this post


Link to post
Share on other sites
@drill sergeant: no.

write in the init of the WEST soldier<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">groupAlpha = group this

How will that resolve the MoveInDriver error? rock.gif

Share this post


Link to post
Share on other sites

BINGO! THANKS, RAEDOR! WORKS!

Here's what's needed:

In the mission, a dummy unit (i.e., useless, defined but not actually needed for the mission play itself) on the same side at the vehicle to be created, with the following in its INIT field:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">groupAlpha = group this

NOTE: any OFP group name can be used but the one used above and the one used in the script's "createUnit" statement must be the same.

The mission.sqm must also contain a marker, indicating the start position of the aircraft. For this example, the marker name is VplaneStart.

Then execute the following script as an example:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_apos = [getmarkerpos "VplaneStart" select 0,getmarkerpos "VplaneStart" select 1,(getmarkerpos "VplaneStart" select 2) + 1500]

_aSpd = 600

_aDir = 220

_aVel = [sin(_aDir)*_aSpd, cos(_aDir)*_aSpd,0]

vpilot = []

"SoldierWPilot" createUnit [getmarkerpos "VplaneStart",groupAlpha,"vpilot=this",1]

_plane = "A10" createVehicle [0,0]

_plane setPos _apos

vpilot moveInDriver _plane

_plane engineOn true

_plane setSkill 1

_plane setDir _aDir

_plane setVelocity _aVel

while {(speed _plane)<_aSpd} do {_aVel=velocity _plane; _plane setVelocity [1.05*_aVel select 0, 1.05*_aVel select 1, 0]}

_plane setBehaviour "Combat"

_plane setCombatMode "RED"

#target1

? not (canMove h1) : goto "target2"

_plane domove (getpos h1)

_plane dotarget h1

_plane dofire h1

~1

goto "target1"

#target2

? not (canMove h2) : goto "target3"

_plane domove (getpos h2)

_plane dotarget h2

_plane dofire h2

~1

goto "target2"

#target3

? not (canMove h3) : goto "exit"

_plane domove (getpos h3)

_plane dotarget h3

_plane dofire h3

~1

goto "target3"

#exit

exit

smile_o.gif

Share this post


Link to post
Share on other sites
@drill sergeant: no.

write in the init of the WEST soldier<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">groupAlpha = group this

How will that resolve the MoveInDriver error? rock.gif

because group "groupAlpha" is existing then and you can createUnit the pilot into this group wink_o.gif

/edit: ah, ok, this time I was too late biggrin_o.gif

Share this post


Link to post
Share on other sites

One last question:

What is this line in the script needed for? rock.gif

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {(speed _plane)<_aSpd} do {_aVel=velocity _plane; _plane setVelocity [1.05*_aVel select 0, 1.05*_aVel select 1, 0]}

OK, I lied - another question: tounge_o.gif

When a plane is spawned like this, are the flaps in optimal position or does the AI pilot make sure they are?

I'm asking because when I start as player in a plane in FLYING formation, the flaps are sometimes/always not level.

Share this post


Link to post
Share on other sites

you could change _aSpd to 300 or 350... can a A10 fly 600km/h in OFP?

the line accelerates the plane until its speed is higher than _aSpd.

the flaps are like when you put a plane on ground. but the AI pilot knows what to do i guess.

Share this post


Link to post
Share on other sites
you could change _aSpd to 300 or 350... can a A10 fly 600km/h in OFP?

Diesel's can. smile_o.gif

But I'm not using the script for an A10 now.

Did some testing and found that the dotarget/dofire commands do not work for a target which is defined as EMPTY and is not manned.

Is that correct or might there be another problem here? Could it have to do that AI pilots and/or anti-air missile ordnance don't/can't target grounded empty vehicles? rock.gif

Share this post


Link to post
Share on other sites

A small update to the script, above. Added in the following line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_plane setSkill 1

Share this post


Link to post
Share on other sites
Quote[/b] ]Could it have to do that AI pilots and/or anti-air missile ordnance don't/can't target grounded empty vehicles?

yes...you can bypass this by either have a guy jump into the vehicle or edit the mission.sqm. Search the vehicle and set it´s side from empty to the side you need.

You could try to use setrating also, but I´m not sure if that will work.

Share this post


Link to post
Share on other sites

Let me see. You want to create a plane and pilot runtime and target empty vehicles. This is so easy and can all be done with 2 triggers and a few waypoints. What in the he|| is all this complex scripting for ? Keep things simple dudes. Here's how it's done...you can thank me l8r.

First make your dummy group by putting a west soldier on the map and give him a groupname (November or whatever) and deletevehicle him (all in his ini.). Give him a move waypoint followed by destroy wp's placed directly on the empty vehicles he will engage. Make a trigger and syncronize it to his move wp and make the trigger a switch type. This trigger will be used to create plane and pilot. When he's created, the trigger completes its switch and the destroy waypoints become active....woohoo! (and yes they work on empty vehicles)

example trigger:

condition- your choice(whatever you used to call your script before.)

onactivation-

hog = "A10" createvehicle getpos trig1; "SoldierWPilot" createunit [getpos trig1,November,"p1=this",1,"CAPTAIN"]

At the location he's being created at, put another trigger of type- West, present. When he's created, this trigger will activate immediately. In this triggers onactivation box we'll get the pilot in the plane and get it flying-

p1 moveindriver hog; hog setpos [getpos hog select 0, getpos hog select 1, 300]; hog setvelocity [400,0,0]

Ok, so we created a plane, a pilot, he has destroy wp's to work with and he's flying at 400 kph at 300 meters. In a few more seconds, 2 empty T72 tanks are going to be burning heaps of junk.

This is all thats needed. I even named the first trigger and used it as a spawn location so no markers or logics are needed. The less items you place in the editor the faster your mission will load and play. Yup, just 2 triggers, a couple waypoints and 1 "template" soldier. Done deal in less than 5 minutes. It all works and the A10 blew up 2 empty T72 tanks moments after being created in my quick test mission. Since both unit and vehicle have global names, you can do anything you want with them when you're done with them.

Now if you'll excuse me I have QeRadiant open and things to do. Crashy out-

Share this post


Link to post
Share on other sites

Crashy, much appreciate the effort. I wish you would have posted earlier. Right now the scripts work and I don't want to try fixing what isn't broken.

Share this post


Link to post
Share on other sites

Hi Avon!

Glad to have come across this post as this is sort-of  biggrin_o.gif  exactly what im doing.

First of all <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">dotarget/dofire commands never work  biggrin_o.gif  or at least not for planes as they go to quick and they usualy do what they want anyway.  mad_o.gif

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_apos = [getpos soldier select 0,(getpos soldier select 1) - 1100,(getpos soldier select 2)+900]; this just sets the plane to spawn behind soldier

vpilot = []

"SoldierWPilot" createUnit [getmarkerPos "start",GROUPp51,"vpilot=this",1]

_p51 = "ECA_P51Dstrike" createVehicle _apos

;WW2EC_D3A1

_p51 setpos [getpos _p51 select 0, getpos _p51 select 1, (getpos_p51 select 2)+900];sets plane height to make sure its there

[_p51] exec "marker.sqs"; this just shows the planes position on the map

_p51 setdir (getdir soldier)

_p51 engineon true

vpilot moveInDriver _p51

_p51 setpos _apos

~1

GROUPp51 setSpeedMode "Normal"

_p51 domove (getpos soldier)

_p51 setBehaviour "Combat"

_p51 setCombatMode "RED"

_apos2 = [getpos soldier select 0,(getpos soldier select 1) + 100,getpos soldier select 2]

~5

_target = "LesIAETA" createVehicle _apos2;see below

_p51 dotarget _target

_p51 dofire _target

exit

Being playing around with your script. And this is what i have. Its a script that i hope to use with the onmapsingleclick but i need help. For now its set up for testing

Ok so its very much a carbon copy  biggrin_o.gif  (i would ask for permission before releaseing wink_o.gif  )

Now LesIAETA is an East Armoured target, which spaws invisable, which makes the plane appear to the player, to be attacking a defined spot. (so to indicate a targeted strike by the plane)

Have you thought of doing something like this? where the player clicks his target on the map and the plane then attacks? instead of those waypoints.

Does anyone know of onmapsingleclick tutorials? i need to know how to get the position of the click and create a marker/icon.

Thanks

TF

edit: Forgot to say BTW this script works %110 of the time for divebombers biggrin_o.gif

Share this post


Link to post
Share on other sites
Ok so its very much a carbon copy  biggrin_o.gif  (i would ask for permission before releaseing wink_o.gif  )

I simple thank you is more than enough. wink_o.gif

And I couldn't have put it together without everyone's help here anyway.

Share this post


Link to post
Share on other sites

@ Trenchfeet

I have been looking into this exact same idea for a short while now. I stopped looking into this as I quickly realized that I would like it to spawn an enemy to whoever clicks on the map and that would take a little more than my current level of scripting ability will permit. My very first script was made to attach one of Lester's invisible targets close to a unit and when that unit is eliminated, it would then attack the next group leader. I actually wanted it to attach an invisible target that was an enemy to the clicker's (players) side to a unit in the group closest to a singlemapclick and have it randomly attack a unit in that group until the group is destroyed or the player stops the attack. As this was beyond my means, I was happy to get a scaled down version to work by pre-placing the invis targets and then initiating the script bt way of a trigger of some sort. I was looking at skumball's napalm script that LCD updated as he used a singlemapclick initiate the script but have not had the time to implement this portion into my script. As I would like to pursue this further, perhaps PM me or start a new topic so we will not continue to hijack AL's topic.   tounge_o.gif

Wadmann

Share this post


Link to post
Share on other sites

(check your pm Wadmann)

hope this isn't off topic biggrin_o.gif but did anyone notice that planes will always attack an AA soldier after destroying any armour target?

are we able to make all soldiers have the AA soldiers class?

Share this post


Link to post
Share on other sites

Ive spent over 2 hours on a useless ADSL connection reading around this forum for help

and in fear of "not asking for help" and avoiding the usual noob bash lmao

im completly at a loss

I don't know whats happend with most the topics on this site... but the information has become a Useless Jumbled up Mess ..... the first post in this thread is a nightmare to understand :'(

For Exmple... that below is now total giberish...

hm AFAIK you can't dynamically create WPs

but you can do it like that:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_aPos = [1,2,3]

_aSpd = 400

_aDir = 0

_tPos1 = [1,2,3]

t1destroyed = false

_tPos2 = [1,2,3]

t2destroyed = false

_aVel = [sin(_aDir)*_aSpd, cos(_aDir)*_aSpd,0]

_plane = "A10" createVehicle _aPos

_plane engineOn true

_plane setDir _aDir

_plane setVelocity _aVel

while {(speed _plane)<_aSpd} do {_aVel=velocity _plane; _plane setVelocity [1.05*_aVel select 0, 1.05*_aVel select 1, 0]}

_plane setBehaviour "Combat"

_plane setCombatMode "RED"

;; WP 1 ---------------------

_plane doMove _tPos1

#wait1

~0.5

?! (t1destroyed) : goto "wait1"

;; WP 2 ---------------------

_plane doMove _tPos2

#wait2

~0.5

?! (t2destroyed) : goto "wait2"

That's just a simple example for how to do the whole thing with two waypoints. Of course you have to change the position arrays in the beginning of the script. You can also include dynamically moving of the waypoint positions, maybe also moving of a preset trigger for the conditions.

Note that the boolean t1destroyed has to be true to let the plane move on to the next waypoint.

Edit: changed a bit of the script

---------- Post added at 16:47 ---------- Previous post was at 16:46 ----------

WTF... you have to quote reply with someones quote to be able to read it?

ok well now thats just weird...

but me thinks the code still has issues

i just want to spawn an enemy "unit" and enemy "vehichle" and assign them both names, locations, and optional sqs in their INT's

this sites a nightmare :'(

Edited by TheWraith
total utter confusion...

Share this post


Link to post
Share on other sites
e first post in this thread is a nightmare to understand :'(

That's because the first post was nearly 8 years ago and uses an outdated tag. Perhaps code tags weren't in use then. The search engine can play tricks on you like that if you're not careful.

Share this post


Link to post
Share on other sites

Exactly that. And please stop digging out 8 year old threads when you have nothing important to add to them. Instead, you could have asked one of the moderators about this.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×