Home   Help Search Login Register  

Author Topic: My Script  (Read 5527 times)

0 Members and 1 Guest are viewing this topic.

Offline rhysduk

  • Former Staff
  • ****
My Script
« on: 03 Jan 2004, 11:47:10 »
HI guys.. wondering if you could help me with script  of mine...

Code: [Select]
_man = _this select 0
_target = _this select 1
_target = bob
;lets first check if the target is alive...
?!alive bob : goto "TargetisDead"

;if the target is not alive then the script carries on...
_man SetCombatMode "Yellow"
_man SetBehaviour "Aware"

#Loop1
_man domove getpos _target
_man dotarget _target
_man dofire _target

?! alive _target : titletext ["Target neutralized.","Plain down"]


;if the target is dead then this part of the script is executed...
#TargetisDead
titletext ["Sir, we have a problem, I cant kill someone who is allready dead.","Plain Down"]
Exit

The problem is that when i exec the script with [man,bob] exec "script1.sqs" it seems as if the script jumps to the very end and displasy the TITLETEXT MSG but then goes back to the COMBAT MODE bit and sends my guy on a search and destroy bit thats mucked it up... me and being alive dont work :)

Help is much appreciated..

Regards Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

gundernak

  • Guest
Re:My Script
« Reply #1 on: 03 Jan 2004, 12:30:32 »
 I guess there is missing: goto "Loop1"

and

I advise to set a few sec delay to the loop section, because when you loop doMove command, the loon can be stucked, go nowhere until you push him or hit him, interesting but sometimes happens

Offline rhysduk

  • Former Staff
  • ****
Re:My Script
« Reply #2 on: 03 Jan 2004, 12:58:37 »
I can see now.. but you see where i have

Code: [Select]
?!alive bob : goto "TargetisDead"

How can i modify this so if the target unit is dead the script goes to TargetisDead but if he is alive the script goes to Loop1 ???

Else sommand im guessing

Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

gundernak

  • Guest
Re:My Script
« Reply #3 on: 03 Jan 2004, 13:34:23 »
Based on you wrote this can be the right from Loop1 (experimenting with delays needed!):

#Loop1
~3
_man domove getpos _target
~1
_man dotarget _target
~1
_man dofire _target
~1
? alive _target : goto "Loop1"

titletext ["Target neutralized.","Plain down"]

goto "end"

;if the target is dead then this part of the script is executed...
#TargetisDead
titletext ["Sir, we have a problem, I cant kill someone who is allready dead.","Plain Down"]

#end

Exit

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:My Script
« Reply #4 on: 03 Jan 2004, 13:40:22 »
Code: [Select]
_man = _this select 0
_target = _this select 1
_target = bob
;lets first check if the target is alive...
?!alive _target : goto "TargetisDead"

;if the target is not alive then the script carries on...
_man SetCombatMode "Yellow"
_man SetBehaviour "Aware"

#Loop1
~10
_man domove getpos _target
_man dotarget _target
_man dofire _target

? alive _target: goto "loop1"
?! alive _target : titletext ["Target neutralized.","Plain down"]; exit


;if the target is dead then this part of the script is executed...
#TargetisDead
titletext ["Sir, we have a problem, I cant kill someone who is allready dead.","Plain Down"]
Exit

Like so?

Oh and you're defining _target twice. First as '_this select 1' and then as 'bob'.
« Last Edit: 03 Jan 2004, 13:41:20 by Artak »
Not all is lost.

Offline rhysduk

  • Former Staff
  • ****
Re:My Script
« Reply #5 on: 03 Jan 2004, 14:47:12 »
Thanks guys... i will experiment witht he delay method Gundernak...

Artak: - your the man :thumbsup:  :cheers:

But.. could someone please explain to me the many uses of the Alive and Not Alive feature in scripting.. it seems that ?Alive is different to ?!Alive ... why ? :(

Thanks

Rhys

(Ill be back  :wave: )
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:My Script
« Reply #6 on: 03 Jan 2004, 15:01:53 »
I think that :

? Alive means "If Alive"

and

? !Alive means "If NOT Alive"


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

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:My Script
« Reply #7 on: 03 Jan 2004, 15:32:54 »
As Planck said.

It doesn't matter wether you use an exlamation mark or just type 'not'.
Thus
!alive tank     is the same thing as     not alive tank
Not all is lost.

Offline rhysduk

  • Former Staff
  • ****
Re:My Script
« Reply #8 on: 03 Jan 2004, 15:40:36 »
Ill experiment and let you know thanks guys :)

Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Quid Novi

  • Guest
Re:My Script
« Reply #9 on: 03 Jan 2004, 15:49:29 »
Quote
_man = _this select 0
_target = _this select 1
_target = bob

and

Quote
[man,bob] exec "script1.sqs"

just wondering why you have defined _target as bob twice? in the execution, and the scipt?

Offline rhysduk

  • Former Staff
  • ****
Re:My Script
« Reply #10 on: 03 Jan 2004, 16:01:06 »
I forgot to mention that this IS MY FRST SCRIPT .. im learning dude :)
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Quid Novi

  • Guest
Re:My Script
« Reply #11 on: 03 Jan 2004, 16:02:18 »
hehehe - thats cool - its quite a advanced first script

*looks at his old ones*

well, you don't need the line _target  = bob because _this select 1 has already defined _target as bob when u wrote him in the script exec line.

Offline rhysduk

  • Former Staff
  • ****
Re:My Script
« Reply #12 on: 03 Jan 2004, 16:06:42 »
Yeah i eventually realised that  :-\  :toocool:

You know the _this select 0 and _this select 1.. this is what the syntax of executing the script takes isnt it...

What i mean is say you have 5 select thingy's (0 to 4) (0,1,2,3,4) this would mean that the [] exec "blahblah.sqs" ....  so it would be somethign like [0,1,2,3,4,5] exec script.sqs" ? Am i right

Maybe you could expand on this please ??

Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:My Script
« Reply #13 on: 03 Jan 2004, 17:32:19 »
Any values passed to the script via an array, thus:

[item0,item1,item2,item3,item4] exec "script.sqs"

can be referenced within the script by using:

select x

x will be 0 for the first value in the array, 1 will be the next etc.

So........select 4 would select the 5th value, which is 'item4' in this case.


Planck
« Last Edit: 03 Jan 2004, 17:35:35 by Planck »
I know a little about a lot, and a lot about a little.

Offline rhysduk

  • Former Staff
  • ****
Re:My Script
« Reply #14 on: 03 Jan 2004, 21:57:35 »
this is what my script look likes now ..

Code: [Select]
_man = _this select 0
_target = _this select 1

;lets first check if the target is alive...
?!alive _target : goto "TargetisDead"

;if the target is not alive then the script carries on...
_man SetCombatMode "Yellow"
_man SetBehaviour "Aware"

#Loop1
~10
_man domove getpos _target
_man dotarget _target
_man dofire _target

? alive _target: goto "loop1"
?! alive _target : titletext [format ["%1 neutralized.","Plain down"],name _target]
Exit

;if the target is dead then this part of the script is executed...
#TargetisDead
titletext [format ["Sir, we have a problem, %1 appears to be dead.","Plain Down"],name _target]
Exit

I get no error messages but nothing appears on screen like it should... why the hell should this happen ??

Rhys *Off to figure it out*
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)