Home   Help Search Login Register  

Author Topic: Behavior script issue  (Read 1501 times)

0 Members and 1 Guest are viewing this topic.

Offline Flauta

  • Members
  • *
  • There is no knownledge, that is no power
    • Chek mi FLog
Behavior script issue
« on: 08 Aug 2005, 01:53:14 »
Hello there, im here again whit more stuid qestions :o ;D ;D

Im making now a mission that you are a Skilled Sniper,  and you must kill (like allwyse ¨:P) a important russian man... but when you where inserted by UH-60 everybody dies execept you. you must find a radio for contacting alieds and leave the island.. and optional, kill the russian, and on the island, there is a lott of Russian patrols everywhere. I thought a good way to add action to the mission, is a script wich detects the distance from the player of every grup leader, and if it is under 150m, do something, (like dotarget player, domove getpos player setcombatmode "red", etc)
this is  the idea... but it dont work at all (its only for infantry, the tanks shoul'nt exec this script)
Exequed by: [leader this] exec "ceek.sqs" on any member of every group

(Now edited)
Code: [Select]
#loop
_l = _this select 0
? _l  distance player <150 or ? _l knowsabout player > 0.2 : goto "destroy"
? isnull _l : exit
~2
goto "loop"
#destroy
? isnull _l : exit
{_x dotarget player} foreach units group _l
group _l setcombatmode "red"

;// in case there are on any cargo of a URAL/UAZ
{unassignvehicle _x} foreach units _l

_l domove getpos player
? _l distance player < 20 : _l domove getpos _l
? ! alive player : goto "exit"
? isnull _l : exit

~1
goto "destroy"
#exit
_l setbehavior "aware"
exit


EDIT
[/b]

Ok, I still needing help whit this...

Why it dosnt works?
   because it dont change anyting, I tried putting a group of 4 russian in a UAZ, and me as a sniper a few blocks away, and I put a trigger that the UAZ come to me and go a few blocks away of me... when it is closer, i shot, (not to the UAZ, but near)  and everyvody gets out and start shoting me, but the leader keeps on the UAZ..  and goes to the waypoint...
I have experienced the same thing Whitout exequing the script..... so in fact it dosnt work  

Note
I'll be exequing the script via [Leader this] because I dont alwise exec the script on the Leader's Init field, It must end when the leader is dead... so it appears that the leader is the only who  konws what the hell is happenging, when the others are just rokie loons...
« Last Edit: 11 Aug 2005, 06:08:37 by Flauta »

Dane

  • Guest
Re:Behavior script issue
« Reply #1 on: 08 Aug 2005, 03:26:55 »
I don't understand this:
Quote
Exequed by: [leader this] exec "ceek.sqs" on any member of every group

If you want the script executed on every unit in a group, just write [this] exec "ceek.sqs" in every unuts initfield.

If you only want it executed on leader of the group, then write
[this] exec "ceek.sqs" in groupleaders initfield.

UNN

  • Guest
Re:Behavior script issue
« Reply #2 on: 08 Aug 2005, 07:01:40 »
Quote
If you want the script executed on every unit in a group,

He wants to execute a script for every group, so running it from each Squad leader is the best way.

Quote
but it dont work at all

But what part exactly does not work.

The script never runs?

Units _l does not return a array of units?

Setcombatmode is never execute?

DoMove is never executed?

The loop only runs once?

Offline Blanco

  • Former Staff
  • ****
Re:Behavior script issue
« Reply #3 on: 08 Aug 2005, 09:48:29 »
K, few things I've noticed...
_l is the leader of a group huh?

Here's a problem :

Code: [Select]
{_x dotarget player} foreach units _lWhen you use the units command it must be followed by a group.
Code: [Select]
{_x dotarget player} foreach units group _l
also
Code: [Select]
group _l setcombatmode "red"Because Setcombatmode is a group command

Code: [Select]
?isnull _l : exit
The script exit when _l doesn't exist anymore. I suppose you want the script to exit when that whole group of _l is dead?
If so, this should work then :

Code: [Select]
?"alive _x" count units group _l <= 0 : exit
In your first loop change this :
Code: [Select]
...
? _l  distance player <150 : goto "destroy"
? _l knowsabout player > 0.2 : goto "destroy"
...

into this :
Code: [Select]
...
? _l  distance player < 150 OR _l knowsabout player > 0.2 : goto "destroy"
...
It does the same but with less code.

Code: [Select]
;// in case there are on any cargo of a URAL/UAZ
{_x unassignvehicle _x} foreach units _l

In case of in a URAL/UAZ or in case of in any vehicle?

Btw : Have you tried Skumball hunted script?
http://www.ofpec.com/editors/resource_view.php?id=692



Search or search or search before you ask.

Offline 456820

  • Contributing Member
  • **
Re:Behavior script issue
« Reply #4 on: 08 Aug 2005, 10:10:16 »
Quote
;// in case there are on any cargo of a URAL/UAZ
{_x unassignvehicle _x} foreach units _l

shouldnt that be before the dotarget commands so they get out then target not target then get out ?

also this
Quote
? _l  distance player < 150 OR _l knowsabout player > 0.2 : goto "destroy"
could also be
Code: [Select]
@ _l  distance player < 150 OR _l knowsabout player > 0.2 : goto "destroy"
then you can get rif of the loop
as the @ command waits until that statement is true then carrys on with the script its basically does the same but with less code like blanco said above

also it would help if you told us what doesnt work

Offline Blanco

  • Former Staff
  • ****
Re:Behavior script issue
« Reply #5 on: 08 Aug 2005, 10:56:14 »
Quote
@ _l  distance player < 150 OR _l knowsabout player > 0.2 : goto "destroy"

I'm pretty sure that won't work,  456820  :)
You can't put a goto command behind a @ condition.

Code: [Select]
@ _l  distance player < 150 OR _l knowsabout player > 0.2
#destroy
...

...and I always learned that @ commands must be avoided when you can...
Quote
also it would help if you told us what doesnt work

True






 :P
« Last Edit: 08 Aug 2005, 10:58:47 by Blanco »
Search or search or search before you ask.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Behavior script issue
« Reply #6 on: 08 Aug 2005, 21:45:43 »
you can however put that as the last line(of the "loop") and then let it go to destroy just by running through the script

Offline Flauta

  • Members
  • *
  • There is no knownledge, that is no power
    • Chek mi FLog
Re:Behavior script issue
« Reply #7 on: 08 Aug 2005, 21:45:44 »
@All

It dosnt work, because it dosnt changed anyting, I tried putting a group of 4 russian in a UAZ, and me as a sniper a few blocks away, and I put a trigger that the UAZ come to me and go a few blocks away of me... when it is closer, i shot, (not to the UAZ, but near)  and everyvody gets out and start shoting me, but the leader keeps on the UAZ..  and goes to the waypoint...
I have experienced the same thing Whitout exequing the script..... so in fact it dosnt work  :-\

@DaneDK; UNN; Blanco

its [Leader this] because I dont alwise exec the script on the Leader's Init field, It must end when the leader is dead... so it appears that the leader is the only who  konws what the hell is happenging, when the others are just rokie loons...

@Blanco

OK, i'll chek teh mistakes... and it is on ANY vehicle, but if there is a way to detect if it is a tank, and avoyd disembarking the crew... you are wellcome  ;)




And also, check that its my fisrt time using the Konwsabout command... so the 0.2 is pure "Imustwritesomething" shit... if some of you can tellme a good nuber, for it  ;D
« Last Edit: 08 Aug 2005, 21:54:16 by Flauta »

Offline 456820

  • Contributing Member
  • **
Re:Behavior script issue
« Reply #8 on: 09 Aug 2005, 08:24:18 »
i would use 0.85 thats what i do for my scripts the enemy gets identified just before being identified as an actual enemy so the way the ai put it would be
man i think as in not sure who just a person

play around it might not be what you want depends on what you want
should they get out after just hearing a shot
should they get out after actually identifying the person and so on

Offline Flauta

  • Members
  • *
  • There is no knownledge, that is no power
    • Chek mi FLog
Re:Behavior script issue
« Reply #9 on: 11 Aug 2005, 06:01:02 »
The tread stills unsolved, now Ill edit the first post..

Offline 456820

  • Contributing Member
  • **
Re:Behavior script issue
« Reply #10 on: 11 Aug 2005, 11:30:18 »
how about awell as unassign try
"_x action [{eject}, vehicle _x]" forEach units group grp_name

try that they should all eject (that may wound them so you might want to use
truck setvelocity [0,0,0] to stop it)

hope that helps