Home   Help Search Login Register  

Author Topic: setWPpos problem in Armed Assault  (Read 3813 times)

0 Members and 1 Guest are viewing this topic.

Offline Arkon

  • Members
  • *
setWPpos problem in Armed Assault
« on: 01 Mar 2007, 22:33:47 »


Hi,

Been struggling with this bit of script that used to work in Flashpoint:
where _civ = a civillian and
_me = the player:

[_civ,2] setWPpos getpos _me

Gives an error: object expected group:
if I change _me to a group the error reverses saying:
group expected object:

Probably summint obvious...

Any ideas would be gratefully recieved...

Thanks

Arkon

Offline Cheetah

  • Former Staff
  • ****
Re: setWPpos problem in Armed Assault
« Reply #1 on: 01 Mar 2007, 23:52:52 »
With the setWPPos command you can only change the position of an already made waypoint.
In the attached mission I made what you want to do, but with a my own names, variables and way of execution.
See if it's of any use to you.

Note: you can use the radio to activate the .sqf script which will let the civilian run towards you instead of his waypoint to the east.
Do note, that once he reaches his waypoint, activating the script won't make him run to you. The waypoint made with the editor has to be active.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Arkon

  • Members
  • *
Re: setWPpos problem in Armed Assault
« Reply #2 on: 02 Mar 2007, 00:00:05 »


Hi Cheetah,

Thanks I'll give it a try...

Regards

Arkon

Offline Arkon

  • Members
  • *
Re: setWPpos problem in Armed Assault
« Reply #3 on: 02 Mar 2007, 00:18:03 »
Hi Cheetah,

How do you activate a trigger by radio?

I was gonna set the trigger off by the civilian walking through it, but
({[civilian,player] execVM "test.sqf";})
throws up a: type code expected nothing error...

and this: _moveToObject = _this select 1;
is saying invalid number in expression

Oh yes, and thanks for the trouble you went to with the zip and stuff!  :)

Regards

Arkon

Offline Cheetah

  • Former Staff
  • ****
Re: setWPpos problem in Armed Assault
« Reply #4 on: 02 Mar 2007, 00:26:49 »
How to activate a trigger by radio? Press 0-0-x ingame, here press 0-0-0 to activate the trigger thus activating the script.

You're using this: ({[civilian,player] execVM "test.sqf";})
Should be this: call {[civilian,player] execVM "test.sqf";}
And use it on the On Activation field of a trigger.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Arkon

  • Members
  • *
Re: setWPpos problem in Armed Assault
« Reply #5 on: 02 Mar 2007, 00:32:52 »
Hi again

{[civilian,player] execVM "test.sqf";}

still getting type code expected nothing:

Just so you can see what I'm trying to do:
set off by Civillian walking through a trigger:
This worked a treat in Flashpoint:
_____________________________________________________________________
; this homes the Civilian in on the Player, when close enough he sez his bit and leaves

_civ = _this select 0
_me = _this select 1


#loop

[_civ,2] setWPpos getpos _me

_range1 = 1
_range2 = 5

? (not alive _civ) : exit

? (_civ distance _me) >=_range1 and (_civ distance _me) <=_range2 : goto "talk"


goto "loop"

#talk

~1

hintc "Carlo approaches..."

~1
hintc "Carlo: Thought I'd never catch up with you. \n I recognised the man who fired the Flare his name is Draco and he is a traitor...carlo leaves...)"

~1

[_civ,2] setWPpos getpos resistanceleader

exit

Arkon

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: setWPpos problem in Armed Assault
« Reply #6 on: 02 Mar 2007, 07:36:10 »
The _civ needs to be a group, as the BIKI states quite explicitly. So instead write [group _civ, 2] blablabla.

Should work.  :D

Good luck.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Cheetah

  • Former Staff
  • ****
Re: setWPpos problem in Armed Assault
« Reply #7 on: 02 Mar 2007, 08:57:33 »
Please use code and /code next time when posting a script, it's easier to read that way.
Are you using this code: {[civilian,player] execVM "test.sqf";}
to execute your script?

If you do that, stop right there. First, you're executing a sqf syntax script while you're using #loop in the script. Second, you should write: Call {[civilian,player] execVM "test.sqf";}
Without call, it won't work.

Are you using a .sqs script? Then use the following code: [civilian,player] exec "YourFile.sqs";

Does the script itself work? If not, try what wolfrug suggested.

EDIT: Sorry, have no time to check your script / make it work. Have to leave for college soon.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Arkon

  • Members
  • *
Re: setWPpos problem in Armed Assault
« Reply #8 on: 02 Mar 2007, 14:29:16 »
Hi,

And thanks to both of you.

Yes, I am using  .sqs and I am not getting the previous error in the init field now.

I have added Wolfrug's [group _civ, 2] to the script (not sure if the group part has to be passed in the init field though, or wether the
Civilian has to be assigned as a group with group this earlier)

Script now giving error for this line:

? (group _civ,2 distance _me) >=_range1 and (_civ distance _me) <=_range2 : goto "talk"

It says missing ")"

Here is the latest code:
_____________________________

Code: [Select]

group _civ = _this select 0
_me = _this select 1

[group _civ,2] setWPpos getpos _me

_range1 = 1
_range2 = 5

? (group _civ,2 distance _me) >=_range1 and (_civ distance _me) <=_range2 : goto "talk"

goto "loop"

#talk

~3

hintc "Carlo approaches..."

hintc "Carlo: Thought I'd never catch up with you. \n I think i recognised the man who fired the Flare his name is Draco\n (Carlo leaves...)"

~1

[group _civ,2] setWPpos getpos civmarker

exit

_______________________________

Regards

Arkon

 
Added code box.... Planck
« Last Edit: 02 Mar 2007, 15:20:06 by Planck »

Offline Cheetah

  • Former Staff
  • ****
Re: setWPpos problem in Armed Assault
« Reply #9 on: 02 Mar 2007, 15:32:28 »
Made a possible map set-up and tried to reproduce the error. Indeed, I get the error "Missing )".
How to fix it? See attached file, the updated script is in the zip file.

Note:
Now that I know what you want, I think that your scripts will fail doing so and could be easier. I suggest using the command DoMove next time. It is a lot easier to use then setWPPos in my opinion.

Second, the civilian walks to the position where you are once the script starts running, but when you move that position doesn't get updated. Say, you're near a house but on the move. The civilian walks to the first house, while you might be three blocks further, thus never activating the hints.

Third, I changed your hintc to hint. As I think I read somewhere that hintc gives errors in ArmA (will be fixed in 1.05) and I don't like hintc ;).

Fourth, you forgot to add: #loop, which meant that your script couldn't keep checking the distance between the player and civilian.

Fifth and last, only the syntax of the command setWPPos required the group input, but you changed "_civ" to "group _civ" almost anywhere (forgot one in the second distance check) which produced the error you got.

If you still run into problems / need help. Just post a reply, I just want to give you room to try several things yourself.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Arkon

  • Members
  • *
Re: setWPpos problem in Armed Assault
« Reply #10 on: 02 Mar 2007, 15:56:23 »


Hi Cheetah,

Thanks... em I think you put my original script in the .zip file.

I used Hintc as it pauses the action allowing the player to read the text or write something down
in there own time.

Yes... forgot to put the #loop in the copy i posted...

regards

Arkon


Offline Cheetah

  • Former Staff
  • ****
Re: setWPpos problem in Armed Assault
« Reply #11 on: 02 Mar 2007, 15:59:01 »
Are you sure you downloaded the file from my last post and opened the right one, both had the name: setWPPos.zip so it could be that you downloaded both to the same location, so the last would've been named: setWPPos-1.zip

Because I'm sure that when I download the file in the last post I made, I don't see "hintc" but "hint".
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: setWPpos problem in Armed Assault
« Reply #12 on: 02 Mar 2007, 16:25:49 »
Arkon : what I said about "group _civ" is not something you can apply like you applied it there. I guess I need to be more specific:

group is a command you use, obviously, to refer to the group of any unit. Every unit has a group, even if they're alone. Back in OFP, max group size used to be 12, now it's AFAIK endless. Group have many functions, and are central to a lot of scripting commands, including the various set/add/removeWaypoint ones. The most common use of group is the one where you make a variable name carry the group's data, by putting
Code: [Select]
GroupOne = group this in the init field of the group leader (or any group member in fact, but it makes for ease of editing to put it in the group leader's init field).

In your case, what you need to do is simply retain the
Code: [Select]
[group _civ, 2] setWppos getpos _me, and remove all the other instances of group (such as in group _civ = _this select 0, and group _civ distance...). Also this : ?
Code: [Select]
(group _civ,2 distance _me) >=_range1 and (_civ distance _me) <=_range2 : goto "talk" makes no sense. Why the
Code: [Select]
group _civ, 2 distance _me ? :
Code: [Select]
_civ [b]distance [/b]_me does, however. Distance is NOT a command that needs the group parameter, but rather explicitly needs singular units.

Cheetah is right, however, it's much better to use DoMove in this case. Much, much, better, since moving waypoints with scripting does not, unfortunately, change their actual destination (i.e., they'll still move to the original position of the waypoint).  :) Hope this makes things at least a little clearer.


Good luck,

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Arkon

  • Members
  • *
Re: setWPpos problem in Armed Assault
« Reply #13 on: 03 Mar 2007, 12:25:49 »


Hi, Cheetah, Wolfrug and anyone else interested...

Cheetah: Sorry, yes I got me zips mixed up. Iv'e tried using domove as you suggested (_civ doMove getPos player) this seems to work
fairly well with my re-jigged code.

Wolfrug: Thanks for your imput I reailze now about the Group command and how I was missusing it.
Although the script does work upto a point I accept your questioning of the logic of some parts (group _civ, 2 distance _me) I
thought this simply compared the distance between Civilian and Player and I am usure what you mean by (_civ distance _me) where does the "b"
come from?
I have added the latest code below:

Code

_civ = _this select 0

_range1 = 1
_range2 = 7

#loop

_civ doMove getPos player

~2

? (_civ distance player) >=_range1 and (_civ distance player) <=_range2 : goto "talk"

goto "loop"

#talk

hint "Carlo approaches..."

_civ doMove getPos player

~5

hint "Carlo: I think i saw the man who fired the Flare his name is Draco and he is a traitor.\n (Carlo leaves...)"

~8

exit

Code/

It does seem to work, except in a few situations the main one being whenever the civilian gets anywhere near OPFOR men - then he either
stands still or lies down and forgets all about finding the Player (found this also when a Civilian driving a vehicle will refuse to drive
past OPFOR forces and gets out and lies on the ground!).

The script is part of a very long mission I am doing (more like an RPG or Adventure game) and this type of script will be needed
for Player and Enemy interactions as the Player will also become hunted himself be it by men, heli's, boats or whatever.
So really looking for a basic generic script with lots of similar uses.

Anyways any improvements suggestions etc would be greatly appreciated.

Really learning alot from u guys :)

Thanks again to both of you for your time and efforts.

Regards

Arkon






Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: setWPpos problem in Armed Assault
« Reply #14 on: 03 Mar 2007, 12:36:17 »
The distance command only works between two UNITS (or objects), such as _me and _civ in your script, or in for instance a trigger/waypoint something like
Code: [Select]
UnitOne Distance UnitTwo. Using the group parameter in such a case should generate an error (something like "expected object, type group" or somesuch).

As to the problems with the civilian lying down and whatnot : this is something to do with the new way to script AI BIS has implemented, I believe. The civilians seem to have scripts entirely of their own, making them slightly unreliable in all kinds of combat situations.  :dry: I suggest you try making the civilian's behaviour "careless" (check out command setBehaviour), that should make him entirely ignorant of anything happening around him. You can also try a setUnitpos "UP" (check out the SetUnitPos command) to force him to stand. Ain't easy gettin' 'em civvies to do what ye want 'em to!

Good luck anyway!

Wolfrug out.

"When 900 years YOU reach, look as good you will not!"

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: setWPpos problem in Armed Assault
« Reply #15 on: 03 Mar 2007, 13:06:32 »
Arkon, the codes for code are

[code%]
write the stuff here
[/code%]

Without the %, obviously.     ;)   
Plenty of reviewed ArmA missions for you to play

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: setWPpos problem in Armed Assault
« Reply #16 on: 03 Mar 2007, 19:41:39 »
They're also visible in the collection of icons up there, above the row of emoticons. The # sign is the code one: what I do is I write things in normal text, then highlight it, and then click the appropriate icon up there, and it makes automatic [start] and [/end] metacode things ^_^

*randomly pokes MacGuba, for no reason, in his official status as Old Timer* 

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"