Home   Help Search Login Register  

Author Topic: Flare colour recognition  (Read 884 times)

0 Members and 3 Guests are viewing this topic.

Newmazz

  • Guest
Flare colour recognition
« on: 27 May 2003, 18:08:55 »
basically, i need some help on a certain script [no surprise] i need it to detect the colour of a flare. im using the "onflare.sqs" that automatically runs when a flare is launched, but i need some code that will identify what colour the flare is, so that i can set different colour flares to different actions.

what ive written so far is:



?(_color == "red"): goto "1"
?(_color == "green"): goto "2"
exit

#1

_helo1 LockWP False
_helo2 LockWP False
_helo1 dotarget _BMP1
_helo2 dotarget _BRDM1
exit

#2

_uh60 LockWP False
_uh60g dotarget _esquad
exit



any help will be much appreciated for my coop mission. thanks.

deaddog

  • Guest
Re:Flare colour recognition
« Reply #1 on: 27 May 2003, 23:13:04 »
What you might need to do is assign a "fired" event handler to the unit that launches the flares.  you can then extract the ammo type and determine what type of flare was used:

Script name=gunfired.sqs

?(count _this)!=5:exit

_weapon = _this select 1
_muzzle = _this select 2
_mode = _this select 3
_ammo = _this select 4

player globalchat format["%1,%2,%3,%4",_weapon,_muzzle,_mode,_ammo]

exit

Put the following in the init line of the unit firing the flare:

this addEventHandler ["fired",{_this exec "gunfired.sqs"}]

Every time that unit fires, the script will tell you what type of ammo.

Hope this helps.  :)


PS.  An event handler only works on the local computer is was executed on.  You may to have to broadcast the variable using the publicvariable command if the other computers or server need to know that information.

« Last Edit: 27 May 2003, 23:15:23 by deaddog »

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Flare colour recognition
« Reply #2 on: 28 May 2003, 01:53:23 »
Code: [Select]
onFlare.sqs - launched when illuminating shell is lit(since 1.45)
    - arguments: [[r, g, b], gunner] - r, g, b is light color
So in onFlare.sqs:
Code: [Select]
_color = _this select 0
player sideChat format ["%1", _color]
?_color == [0, 1, 1] : hint "You die now!"
?_color == [1, 0, 0] : hint "I am blue, I think!!"
Fire off each flare to see what the color codes are.

Doolittle

deaddog

  • Guest
Re:Flare colour recognition
« Reply #3 on: 28 May 2003, 03:36:51 »
Excellent, much simpler  ;D

Newmazz

  • Guest
Re:Flare colour recognition
« Reply #4 on: 28 May 2003, 14:37:04 »
thanks a lot guys, i really appreciate the help. but are there any variables in that script that i need to make public, or are there none?

Newmazz

  • Guest
Re:Flare colour recognition
« Reply #5 on: 28 May 2003, 15:03:12 »
Code: [Select]
onFlare.sqs - launched when illuminating shell is lit(since 1.45)
    - arguments: [[r, g, b], gunner] - r, g, b is light color
So in onFlare.sqs:
Code: [Select]
_color = _this select 0
player sideChat format ["%1", _color]
?_color == [0, 1, 1] : hint "You die now!"
?_color == [1, 0, 0] : hint "I am blue, I think!!"
Fire off each flare to see what the color codes are.

Doolittle




well, when i use the script, when i fire a flare, it shows the colour code in teh sidechat, and doesnt show the hint. if you could fix it so that it has a goto "1", "2" command after every colour, id be much appreciative.
ps. colour codes are
red 1,0,0
yello 1,1,0
green 0,1,0
white 1,1,1

deaddog

  • Guest
Re:Flare colour recognition
« Reply #6 on: 28 May 2003, 19:43:24 »
The == operator does not work with arrays.  Try assigning each color component to a separate variable:

_r=_color select 0
_g=_color select 1
_b=_color select 2

?_r==1 and _g==0 and _b==0:hint "you die now"


Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Flare colour recognition
« Reply #7 on: 29 May 2003, 00:03:31 »
Woops, you're right.  I was just doing that from the top of my head.

"You die now!"

Doolittle

Newmazz

  • Guest
Re:Flare colour recognition
« Reply #8 on: 29 May 2003, 13:29:35 »
thanks guys, thats was a real help, i really appreciate it.

ps. im looking fior beta testers for my coop mission, anyone interested ?