Home   Help Search Login Register  

Author Topic: My UDT man and his satchels  (Read 1077 times)

0 Members and 1 Guest are viewing this topic.

klavan

  • Guest
My UDT man and his satchels
« on: 13 Oct 2004, 22:32:05 »

The frogman want to place a satchel charge under a boat, but I don't want to make it happen if the frogman doesn't have a satchel!
I've tried this line:
?! _unit hasweapon "pipepomb" : goto "Home"
Naturally the pipebomb is a magazine and I obtain an error message (type Object needed  Bool...or something like this, I don't remember exactely).
Anyone can help me, please?
Thanks in advance.

Offline Blanco

  • Former Staff
  • ****
Re:My UDT man and his satchels
« Reply #1 on: 13 Oct 2004, 22:48:18 »
Hmmm, could be something stupid...


try

Code: [Select]
?!( _unit hasweapon "pipepomb") : goto "Home"
Search or search or search before you ask.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:My UDT man and his satchels
« Reply #2 on: 14 Oct 2004, 09:10:19 »
A satchel charge counts as a magazine, not a weapon. So maybe something like:

? ! "Pipebomb" in (magazines _unit) : goto "Home"

Just note that the string ("Pipebomb") is case sensitive, and I'm not sure if I got it right :P
So it might be "pipebomb", or "PipeBomb", or "pipeBomb" for all I know :P

Anyway, have a play around and see if you can get it working ;)

klavan

  • Guest
Re:My UDT man and his satchels
« Reply #3 on: 14 Oct 2004, 12:36:29 »
Nothingâ€Â¦
With the line suggested by Blanco I've not received any error message, but the unit didn't have any pipebomb with him!
With the one suggested by Sui, an error message occour (in this case the unit have the pipebombs):
<<"!#"Pipebomb" in (magazine _unit) : goto "Home" : Type Object Needed Bool>>
Follow the entire script:

?Ba:goto "Exit2"
?! "Pipebomb" in (magazines _unit) : goto "Retry"

aa RemoveAction place
aa RemoveMagazine "Pipebomb"
hint "Charge Placed"
Ba=true
~3
hint " "
exit

#Retry
hint "You need a Satchel Charge!"
~3
hint " "
exit

#Exit2
aa RemoveAction place
exit

Note that the script run properly, except for that line.

Kammak

  • Guest
Re:My UDT man and his satchels
« Reply #4 on: 14 Oct 2004, 15:50:25 »
the exact case is PipeBomb

Check for that and the script should work.  Also, here's little snippet that is invaluable when dealing with case sensitive  mags/weapons:

Place in a radio trigger On Activation field:

sText="";{sText=sText+_x+"\n"} foreach magazines player;hint sText

You can change the "magazines player" to "weapons player" if looking for weapons strings.  Of course, change the player if not looking at the player's gear.

This has saved me many hours of grief!  :)


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:My UDT man and his satchels
« Reply #5 on: 14 Oct 2004, 16:15:25 »
OFP code is supposed to be case insensitive, but there are occasional exceptions.
Plenty of reviewed ArmA missions for you to play

Kammak

  • Guest
Re:My UDT man and his satchels
« Reply #6 on: 14 Oct 2004, 17:21:25 »
the code probably is, but any type of string comparison (like "IN", or string "==") is case sensitive.  Why they didn't include a simple LCase/UCase function is beyond me.  It would have proved **very** useful.  :)

I originally ran into this trying to write a GP magazine swapout routine, and finally gave up.  The actual string returned from OPF often times varies from the config-defined name regarding case, and its quite a mess.

I *really* hope OFP2 will include the option to access .dlls from scripts, so users could then program whatever is missing from the default OFP2 script engine...could open up lots of possibilities.


Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:My UDT man and his satchels
« Reply #7 on: 15 Oct 2004, 05:29:22 »
Yeah... this case is as far back as I can remember, the only time I have ever had problems due to things being case sensitive.

I would have loved it if BIS had included the ability to phrase strings...
Boy could I use that to do some fancy scripting ;)

Anyway, I digress... try this line instead, klaven:

? ("_x == {PipeBomb} " count (magazines _unit) == 0): goto "Retry"

Thanks for the correct case, Kammak.
I'm not sure why that first line didn't work... I'm using something very similar to that in an AI 'actions on contact' script in my latest mission :P

klavan

  • Guest
Re:My UDT man and his satchels
« Reply #8 on: 15 Oct 2004, 12:49:06 »
Ok, all now run properly: the second suggestion by Sui is the right one! :)
Thanks to all you guys for the help.

Now i can continue to edit my campaign!!  ;)
Greetings from Italy.