Home   Help Search Login Register  

Author Topic: Creating Fightposistion  (Read 4332 times)

0 Members and 1 Guest are viewing this topic.

Robinhansen

  • Guest
Creating Fightposistion
« on: 12 Feb 2005, 11:14:04 »
I would like to allowed my engineres to build fightposistions at random places. For that I use this script:

[eng, "cover4"] exec "create_object.sqs".

_eng = _this select 0
_cover4 = _this select 1

_mydistance = 5

_180 = getdir _eng

_5 = ((sin 0) *1) + (getpos _eng select 0)
_5 = ((cos 0) *1) + (getpos _eng select 1)

_fightpos = _cover4  createVehicle [2, 2, 0]

_fightpos setdir _180

hint "object placed"

exit


eng is the name of the player ang cover4 is the name of the fightposistion.

The only thing that works seems to be the hitn ??? ???

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Creating Fightposistion
« Reply #1 on: 12 Feb 2005, 12:31:10 »
Bad luck.   ;D   We all know how that feels.

Use hint format commands to check that your variable values are what you think they are.

I can't remember the syntax but it seems to be that you are creating the cover in the sea at the bottom left hand corner of the map.
« Last Edit: 12 Feb 2005, 12:31:40 by macguba »
Plenty of reviewed ArmA missions for you to play

Robinhansen

  • Guest
Re:Creating Fightposistion
« Reply #2 on: 12 Feb 2005, 14:13:00 »
okaay? Hint Format means what? And what do I write then if I whant to create the cover in front of the player? :-\

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Plenty of reviewed ArmA missions for you to play

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Creating Fightposistion
« Reply #4 on: 12 Feb 2005, 14:39:04 »
Looking at your script.........

Why have you defined a variable _5 as:

_5 = ((sin 0) *1) + (getpos _eng select 0)

And then immediately changed it with the next line:

_5 = ((cos 0) *1) + (getpos _eng select 1)


However, the variable is never used anyway, so I don't understand why you defined it. Also the _mydistance variable doesn't seem to be used either.

Try this version and see if it is any better:
Code: [Select]
_eng = _this select 0
_cover4 = _this select 1

_mydistance = 5

_heading = getdir _eng

_x = ((sin 0) *1) + (getpos _eng select 0)
_y = ((cos 0) *1) + (getpos _eng select 1)

_fightpos = _cover4  createVehicle [_x, _y, 0]

_fightpos setdir _heading

hint "object placed"

exit

I changed some of the variable names because I don't like variables with numeric names, it can be confusing to read.

Anyway, hope some of that helps.


Planck
I know a little about a lot, and a lot about a little.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Creating Fightposistion
« Reply #5 on: 12 Feb 2005, 14:59:27 »
what is "cover4"

i dont recognise it as an object/vehicle class
and from what you posted, you havent shown that you have declared it as anything

eg cover4 = "classname of object"

and it needs to be either the real classname of an object, or a variable that has been declared as one


*****************************************************

To know how to use  titletext format  or hint format to debug a script, is propabably the most useful weapon  in a scripters arsenal.


i give you an example.

A fired event handler, returns an array of various elements every trime it is triggered.

say for instance we didnt know what those elements were or how many there were

we can find out in the following way


INIT.sqs
Quote
player addEventHandler ["Fired", {_this exec "debug.sqs"}]

DEBUG.sqs
Quote
_A = _this select 0;  
_B = _this select 1
_C = _this select 2
_D = _this select 3
_E = _this select 4
_F = _this select 5
_G = _this select 6

hint format ["A = %1\n\nB = %2\n\nC = %3\n\nD = %4\n\nE %5\n\nF=%6\n\nG=%7",_A,_B,_C,_D,_E,_F,_G]

when you as a player fire a weapon a hint box will appear and the following will be displayed

A= Terox
B= M16Grenadelauncher
C= M16Muzzle
D= Burst
E= M16
F = stringoxcliffee etc etc
G = stringoxcliffee etc etc


we can then see that there are only 5 elements
first element = players name
2cnd element = weapon name etc.


Now that we have this info, we can further debug the script we are working on.

Lets say for instance, that we are developing a weapon jamming system

and we are trying to remove and re add the magazine for the M16grenadelauncher when the weapon is fired using the standard rifle, not the grenade launcher part

we find that in our script, when we fire the weapon normally, the script doesnt remove the mag

and are sure that the line
?(_C == "M16muzzlemode"): Player removemagazines "M16"
is correct.

So we run another hint format in our debug script

hint format ["Muzzle Type  = %1",_C]

hey presto, it returns
Muzzletype = M16muzzle"

debugged and so we change the line
to
?(_C == "M16muzzle"): Player removemagazines "M16"







Additional items you can use in debugging is
Have a radio trigger that when activated causes a boolean to become true
Then you know, that even if the trigger didnt activate the boolean, you did

or a marker that you setmarkerpos to an object, so that you can see where that object is etc etc

Hope that helps a bit
« Last Edit: 12 Feb 2005, 15:04:22 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Creating Fightposistion
« Reply #6 on: 12 Feb 2005, 15:06:17 »
I'm guessing here Terox......but it might be the class name of a third party addon he is using, although I'm not sure whether that has to be declared by using the class name or if putting the class name into a variable and using the variable works correctly.


Planck
I know a little about a lot, and a lot about a little.

Robinhansen

  • Guest
Re:Creating Fightposistion
« Reply #7 on: 12 Feb 2005, 15:13:30 »
TY Planck! The modyfied script works the way it's supposed to! Next problem is to add it to the playeres action menu...  ;)

The script used is Devilchaser's Mission/Scripting Guide
http://www.ofpec.com/editors/browse.php?searchopts=&start=125

Cover4 is the classnavn (at least I think it is) of Sparks fightposistions
http://ofp.gamezone.cz/index.php?showthis=7368

I hope that ironed out most doubt.. ;)
« Last Edit: 12 Feb 2005, 15:23:06 by Robinhansen »

Robinhansen

  • Guest
Re:Creating Fightposistion
« Reply #8 on: 12 Feb 2005, 15:37:09 »
Ok - even though it works I'm still not satisfied. I whant to turn the posistion 180 degrees and I whant it to be placed aprox 5-10 meters in front of me, everytime. At the moment it places itself at random places all around me... :-\
« Last Edit: 12 Feb 2005, 16:05:30 by Robinhansen »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Creating Fightposistion
« Reply #9 on: 12 Feb 2005, 16:48:29 »
180 degrees from the engineers direction right?

Code: [Select]
_eng = _this select 0
_cover4 = _this select 1

_dir= getdir _eng

_x = ((sin _dir) *(5 + (random 5))) + (getpos _eng select 0)
_y = ((cos _dr) *(5 + (random 5))) + (getpos _eng select 1)

_fightpos = _cover4  createVehicle [_x, _y, 0]

_fightpos setdir (_dir +180)

hint "object placed"

exit

or if you want it alwasys at 180:


Code: [Select]
_eng = _this select 0
_cover4 = _this select 1

_dir= getdir _eng

_x = ((sin _dir) *(5 + (random 5))) + (getpos _eng select 0)
_y = ((cos _dr) *(5 + (random 5))) + (getpos _eng select 1)

_fightpos = _cover4  createVehicle [_x, _y, 0]

_fightpos setdir 180

hint "object placed"

exit
« Last Edit: 12 Feb 2005, 16:49:36 by Triggerhappy »

Robinhansen

  • Guest
Re:Creating Fightposistion
« Reply #10 on: 12 Feb 2005, 19:40:55 »
Now we got the direction under control! ;D but I still can't figuer out the random placement... ???
I've been planing to expand the script with sandbags, wires ect. so they must be placed at the exact same place from the engenieer every time  :-\

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Creating Fightposistion
« Reply #11 on: 12 Feb 2005, 20:21:52 »
Try this function I wrote for geting a postition relative to a reference object.  The function is: PosAtAngDirDis.sqf.  If you call it like this:

_pos = [_eng, 0, 180, 5] call PosAtAngDirDis

The _pos will be the 3D position at the same elevation (0) as the engineer (_eng), behind the engineer (180) and 5 meters away from the engineer (5).

Then do:

_obj setPos _pos (where _obj is the object you want to place).

The function file is attached.

Robinhansen

  • Guest
Re:Creating Fightposistion
« Reply #12 on: 12 Feb 2005, 20:56:47 »
I like it, but due to the face that I'm a total idiot when it comes to scripting  I need a lot more of informations of exactly what to do.

Thanks for spending your time solving this "mess"

 ;D

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Creating Fightposistion
« Reply #13 on: 13 Feb 2005, 12:50:34 »
I'm guessing here Terox......but it might be the class name of a third party addon he is using, although I'm not sure whether that has to be declared by using the class name or if putting the class name into a variable and using the variable works correctly.


Planck

either are fine m8
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Creating Fightposistion
« Reply #14 on: 14 Feb 2005, 02:03:32 »
ok i thought you wanted it randomly between 5-10 m in front
here you go:
Code: [Select]
_eng = _this select 0
_cover4 = _this select 1

_dir= getdir _eng

_x = (((sin _dir) *5) + (getpos _eng select 0))
_y = (((cos _dr) *5) + (getpos _eng select 1))

_fightpos = _cover4  createVehicle [_x, _y, 0]

_fightpos setdir (_dir +180)

hint "object placed"

exit

i saw in another post that you wanted these as user actions right?

heres how you do that:

create an action for each of the different things you want to build
and execute your build script from those action scripts
for example

player addaction [{Build "cover4"},"cover4.sqs"]

cover4.sqs:
Code: [Select]
_eng = _this select 0
[_eng,"cover4"] exec "create_object.sqs"
exit

and just make a seperate script like that for each of the things you want to build (each being its own action) or you could add an action "Build Something" which then gives you the actions of what to build (that would be more complicated because you would have to remove the actions once used
you could also try to make a dialog but thats a lot harder