Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
kevbaz

checking Flyinheight?

Recommended Posts

Hi guys

Currently trying to get a script that checks the players vehicle flying height and if its above a set limit i would like to have a weapon fire at it. need it to keep checking untill it reaches a certain waypoint.

any ideas?

many thanks

---------- Post added at 11:33 PM ---------- Previous post was at 09:46 PM ----------

answer to the first part of my question

(getPos chop1 select 2) > 100

now to just figure out how to then create something to fire at the vehicle...

Share this post


Link to post
Share on other sites

Getpos is above ground

GetposASL is above sea level

I use this to obtain x,y,z of objects when creating a mission you could modify it for your needs.

;[this] exec "coords.sqs"

_unit = _This Select 0;


#loopit
_xcoor = getPos _unit select 0;
_ycoor = getPos _unit select 1;
_zcoor = getPos _unit select 2;
_dir   = getdir _unit 

hint format ["X:%1 Y:%2 Z:%3 D%4", _xcoor, _ycoor, _zcoor, _dir];
~2
goto "loopit"

Share this post


Link to post
Share on other sites

Hmm so far i have this in a trigger but no joy

cond

(getPos ap select 2) > 100

act

sam = createVehicle ["stinger_pod", getpos player]; "RUS_Soldier2" createUnit [position sam, group red,"this moveingunner sam; sam dotarget ap; sam dofire ap"];

Edited by KEVBAZ

Share this post


Link to post
Share on other sites

Trigger Conditions are best left for simple true or false conditions.

As for the code it's not right this part

"this moveingunner sam; sam dotarget ap; sam dofire ap"

is in "" for some reason so can't be right.

You should look at calling a script it's much easier to see the problems.

Share this post


Link to post
Share on other sites

the condition works fine, i can get it to dispaly a hint etc, just having trouble spawning the vehicle when the player is

anyone?

Share this post


Link to post
Share on other sites

Well I got a bit further, it does everything except fire at the target.

It has ammo and it does track the target but won't shoot.

// nul=[target] execVM"spawn.sqf"

_target = _this select 0;

_unit = "RUS_Soldier2";
mygroup = creategroup side player;
_sam = createVehicle ["stinger_pod", getpos player,[],0,"fly"]; 
_unit createUnit [(getpos player), mygroup,"man=this;"];
_unit = man;
_unit moveingunner _sam;
_sam reveal _target;
_sam dotarget _target; 
_sam dofire _target;

Place

nul=[ap] execVM"spawn.sqs"

in the On act of the trigger and save the scrpit as spawn.sqf

Edited by F2k Sel

Share this post


Link to post
Share on other sites

ah excellent, atleast now its spawning the unit, howefver is there a way of spawning it on the ground within a certain raduis of the players location?

and theres still the issue of makin it fire

Share this post


Link to post
Share on other sites

It does spawn on the ground I just don't know the correct syntax.

Share this post


Link to post
Share on other sites

odd mine spawned ontop of my helo....

thanks

Share this post


Link to post
Share on other sites

The syntax is none,fly,form I was a ground unit so change it to none.

I found the firing bug, I was on the same side as the target so it spawned a Russian as friend.

I changed myself to Russian and it worked.

It still spawns on the chopper though.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

ive changed it to none, yet it still spanws right on me

is there a way of telling to get the players position then to -100 from the height?

Edited by KEVBAZ

Share this post


Link to post
Share on other sites

Sorted it.

// nul=[target,caller] execVM"spawn.sqf"

_target = _this select 0;
_caller = _this select 1;

_temppos = 0;
_unit = "RUS_Soldier2";
mygroup = creategroup side player;
_temppos = [getpos _caller select 0,getpos _caller select 1, 0];
_sam = createVehicle ["stinger_pod",_temppos,[],0,"none"];

_unit createUnit [_temppos, mygroup,"man=this;"];
_unit = man;
_unit moveingunner _sam;
_sam reveal _target;
_sam dotarget _target; 
_sam dofire _target;

I've included another parameter to be passed "caller" who's doing the spawning.

Set that to the name of the AI or player ie in your case Chop1 or player

Share this post


Link to post
Share on other sites

cant get it to do anything, ive tried _player and _ap yet still nothing spawns.

this makes an east controlled stinger spawn and shoot the west player right?

Share this post


Link to post
Share on other sites

try without the _ you need [ap,chop1]

east shoots west

Share this post


Link to post
Share on other sites

so..

[ap,chop1] = _this select 1;

tried that but still nothing?

// nul=[target,caller] execVM"spawn.sqf"

_target = _this select 0;

[ap,chop1] = _this select 1;

_temppos = 0;

_unit = "RUS_Soldier2";

mygroup = creategroup side player;

_temppos = [getpos [ap,chop1] select 0,getpos [ap,chop1] select 1, 0];

_sam = createVehicle ["stinger_pod",_temppos,[],0,"none"];

_unit createUnit [_temppos, mygroup,"man=this;"];

_unit = man;

_unit moveingunner _sam;

_sam reveal _target;

_sam dotarget _target;

_sam dofire _target;

Share this post


Link to post
Share on other sites

No, in your trigger in the On Act box it should be

nul=[ap,chop1] execVM"spawn.sqf"

I forgot your using getpos in your trigger cond , I couldn't get it to work with that so I changed it to getposASL and it works well.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

hmm i have that set already, its just not spawning anything?

Share this post


Link to post
Share on other sites

hmm your using gamelogics fr the spawn points, i cant as i dont know where on the map the player will be when he goes over his height limit?

Share this post


Link to post
Share on other sites
hmm your using gamelogics fr the spawn points, i cant as i dont know where on the map the player will be when he goes over his height limit?

Logics work as well, I thought I'd removed them.

This should be it.

http://www.sendspace.com/file/qicuhe

Share this post


Link to post
Share on other sites

cool almost there with it.

in my mission, you are the pilot, you are a us pilot in a cobra, if you fly to high iwant this script to kick in and punish you

at the moment its spawning but not firing on me, i delted the russian chopper and soldier you had, made my pilot of the cobra and flew about, it spawned but as i said never fired?

MANY thanks for your help though, so close to getting it working because of you thanks

Share this post


Link to post
Share on other sites

I'm a bit stuck now, if I change

mygroup = creategroup side player;

to

mygroup = creategroup east;

I get no error and the sam spawns but not the man and there are no error reported.

---------- Post added at 07:22 PM ---------- Previous post was at 06:13 PM ----------

Ok this is it, I found the problem.

http://www.sendspace.com/file/e7hx2h

For it to work it needs a Russian unit somewhere on the Island otherwise nothing will happen.

There is a command to fix this called createcenter so you don't need the unit but I don't know how to implement it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×