Home   Help Search Login Register  

Author Topic: [SOLVED] "Detected by" arguments  (Read 1964 times)

0 Members and 1 Guest are viewing this topic.

[SOLVED] "Detected by" arguments
« on: 21 Jan 2012, 15:55:49 »
Hello,
I was wondering if there is any chance to determine who is detecting who via "detected by" trigger because I tried to obtain those info via hint format into activation fied of trigger but I obtained nothing. Is there anyone who is willing to help me? TIA for your reply.
« Last Edit: 22 Jan 2012, 09:35:11 by Doktor Headshot »
? (this == thinkable) : this = scriptable

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: "Detected by" arguments
« Reply #1 on: 22 Jan 2012, 00:07:50 »
Hmm, I had a little think about this but I was wondering, what information do you want the script to return? Do you want the name of the unit? Or the unit type?

What I was going to suggest was monitoring the behaviour of units within an array, and then constantly checking to see if the behaviour changes (from 'safe' to 'combat' for example).

Code: [Select]
((behaviour _u) != "SAFE")
Where '_u' is basically the units within an array. Here's a little snippet from my detection script in my Rattlesnake mission:

Code: [Select]

;rusGroups is an array defined in the init.sqs
_eGroups = rusGroups
_nGroups = count _eGroups
_eUnits = []
_i = 0

#START

_g = units (leader (_eGroups select _i))
_nUnits = count _g
_k = 0

#SUB

_u = _g select _k
_eUnits = _eUnits + [_u]
_k = _k + 1
? (_k < _nUnits) : goto "SUB"
_i = _i + 1
? (_i < _nGroups) : goto "START"

_nLeft = 0
_nTimer = 0
_nUnits = count _eUnits

#CHECK

~_nSec
? Detected : exit
_i = 0

#LOOP

_u = _eUnits select _i
? (alive _u) and ((behaviour _u) != "SAFE") : goto "AWARE"
_i = _i + 1
? (_i < _nUnits) : goto "LOOP"
? (_nTimer > 0) : hint "Alarm start-up has been aborted!"
? (_nLeft > 0) : titleText ["Count down timer has been stopped", "plain down"]
_nLeft = 0
_nTimer = 0

goto "CHECK"

#AWARE

? (_nTimer >= _nMax) : goto "END"
? (_nLeft > 0) : _nLeft = _nLeft - _nSec ; titleText [format ["%1", _nLeft], "plain down"]
? (_nTimer == 0) : hint "You have been detected!" ; _nLeft = _nMax
_nTimer = _nTimer + _nSec

goto "CHECK"

#END

[true] exec "alarmrisen.sqs"

exit


Hopefully this will put you on the right track.

You were on the right lines with 'hint format', you just need to put in the 'AWARE' section something along the lines of:

Code: [Select]
hint format ["%1", name _u]
Syntax not guaranteed. But I think it's something like that.

I know this doesn't give you a straight answer but I hope it makes the solution easier to find  :D

Regards,

Gruntage

EDIT: There's a mission in Mandoble's GruntONE campaign entitled 'urup_blueflag', which makes good use of 'hint format ["%1", name _unit]'. Might be worth checking that mission out  ;)
« Last Edit: 22 Jan 2012, 00:11:32 by Gruntage »
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
Re: "Detected by" arguments
« Reply #2 on: 22 Jan 2012, 00:26:27 »
Hi Doctor check it:
This is my script

1. Add some units, what you want, I put a west soldier with name "aP" and a res soldier with name "ressoldier"
2. Exec the script, to exec it you must put a trigger 'on condition' true and 'on activation' [aP,ressoldier] exec "nameofscript.sqs"

Code: [Select]
;Detectedby script 0.1
;To know who was detected and who detects it
;Made by Aldo15

_victim = _this select 0
_killer = _this select 1

#check
if !((alive _victim) or !(alive _killer)) then {exit}
? (_killer knowsAbout _victim > 0.7) : goto "detected"
goto "check"

#detected
player sidechat format ["%1 was detected by %2" ,name _victim, name _killer]
exit
My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom

Re: "Detected by" arguments
« Reply #3 on: 22 Jan 2012, 02:44:04 »
Hello Gruntage and Aldo15, first of all I would like to thank you again for your replies.
   About my script, here is what I wanted to achieve: player unit is NATO and enemy units are resistance. When player is in certain area, which is covered with "detected by resistance" trigger, player can be detected from any resistance unit and, when it happens, a cutscene must run; since I want a camera that frames the player first and then quietly frames from the player to the resistance unit who detected him, I need a script that returns the name of that resistance unit as argument in order to make use of camSetTarget command properly.
   Solution offered from Gruntage seems to be good because "behaviour" is a good parameter to determine who detected player, among all enemies, by changing his behaviour from "safe" to "aware"; solution offered from Aldo15 seems to be interesting too but it means I have to initialize every enemy units to make the script work and it will result that script can be ran more than once if more than one enemy unit detects the player at the same time thus making a conflict among all those enemy units who really detected player.
   At the end, before reading your solutions (which I found both of them reasonable) and after some racking of my brains, I came up with my comfortable solution and I used nearestObject command to determine the enemy unit who is closer to the player and, for this reason, who is very likely the one who detects player; that unit, then, is the one that gets framed from the camera with camSetTarget command.
« Last Edit: 22 Jan 2012, 09:40:36 by Doktor Headshot »
? (this == thinkable) : this = scriptable

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: [SOLVED] "Detected by" arguments
« Reply #4 on: 26 Feb 2012, 03:41:02 »
Place in the mission init
Code: [Select]
cinema = false
Then in the OnActivation field of the detection trigger execute a script which detects the knowabout level of all group leaders or independent units that could possibly set it off.
Code: [Select]
;This first line checks if the cinema script has already been executed and if so, exits.
?cinema : exit
;The first unit to detect the player will execute the cinema script and then exit this one. Group members will report enemy to the group leader and so the leader will execute the script.
?(leader group1 knowsabout player > .020) : cinema = true; [leader group1] exec "cinema.sqs"; exit
?(unit3 knowsabout player > 0.20) : cinema = true; [unit3] exec "cinema.sqs"; exit
etc.
etc.

The cinema script will start
;This first line will assign a local variable to the unit being passed to the script. Just use that local variable to reference the unit.
Code: [Select]
_unit = _this select 0

;Now the camera scripting fun begins!!!
_camera camSetTarget _unit
_camera camSetPos [12000.54,10875.96,1.84]
_camera camSetFOV 0.700
_camera camCommit 0
@camCommitted _camera

Re: [SOLVED] "Detected by" arguments
« Reply #5 on: 26 Feb 2012, 11:07:06 »
Awwwwww man! I didn't think it was so easy to solve my issue without too much brains-racking! Thank you Savedbygrace, your solution worked flawlessly! :good:
? (this == thinkable) : this = scriptable