Home   Help Search Login Register  

Author Topic: shoot own men only in combat  (Read 796 times)

0 Members and 1 Guest are viewing this topic.

Offline 456820

  • Contributing Member
  • **
shoot own men only in combat
« on: 06 Apr 2005, 20:24:36 »
ok i was wondering what is the way to make a loop checking if the player has shot one of his own men but only when he is not recieving fire from the enemy i saw it in a mission so im sure it is possible.
if you shoot a freindly ai soldier when your not underfire it ends the game
but if you shoot an ai in combat whilst underfire it doesnt care
i un depboed the mission but there is alot of scripts and am not having much look finding it

Offline Blanco

  • Former Staff
  • ****
Re:shoot own men only in combat
« Reply #1 on: 06 Apr 2005, 20:49:15 »
Try this : put this EH in the init of all your men

Code: [Select]
this addeventhandler ["killed", {_this exec "Fr_kill.sqs"}]
;fr_kill.sqs
Code: [Select]
_killed = _this select 0
_killer = _this select 1  

?side _killed == side _killer : hint "friendly kill detected";exit


I dunno how this behave in a MP enviroment tho.

« Last Edit: 06 Apr 2005, 20:49:50 by Blanco »
Search or search or search before you ask.

Offline 456820

  • Contributing Member
  • **
Re:shoot own men only in combat
« Reply #2 on: 06 Apr 2005, 20:50:26 »
but wouldnt that only detect if a man has been shot at anytime not just in combat

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:shoot own men only in combat
« Reply #3 on: 06 Apr 2005, 21:08:46 »
IIRC one of the parameters returned by the EH is the killer.
Plenty of reviewed ArmA missions for you to play

Offline 456820

  • Contributing Member
  • **
Re:shoot own men only in combat
« Reply #4 on: 06 Apr 2005, 21:52:32 »
ohhhh ok i shall try that sometime soon.
but how can i make that EH end the game if a friendly unit is shot from you and also in this mission it had like a custom death screen it said mission failed 'retry' and 'abort' but it had a black screen and said some custom text i think it was 'you shot a team mate in cold blood' wich looked pretty good.
anyway how would i do that aswell

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:shoot own men only in combat
« Reply #5 on: 06 Apr 2005, 23:15:02 »
The EH calls a script, passing its parameters to the script, and the script checks if there is a firefight on and who the killer is.    If it is you then the script calls another script which is a cutscene and ends the mission.
Plenty of reviewed ArmA missions for you to play

Offline 456820

  • Contributing Member
  • **
Re:shoot own men only in combat
« Reply #6 on: 07 Apr 2005, 09:13:17 »
ok i understand that but now for the tricky part well maybe for me it is anyway
how can i make a script wich shows the player and the person he shot then make it game over

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:shoot own men only in combat
« Reply #7 on: 08 Apr 2005, 00:38:20 »
Some strategies for finding 'if a firefight is on'.

Easier one: A script and a trigger: The script awaits a couple of Global variables (say, WestIsFiring and EastIsFiring). When both these bools are true, you've got yourself a firefight. The trigger has a radius of whatever your 'firefight zone' is and is constantly updated to the player's position. Its ctivation is Anyone Present, it adds "fired" eventhandlers for everyone in range (and some checks to make sure it doesn't run more than one per soldier), another script run by the EH checks the side of the firer. If west, set WestIsFiring true, if east set EastIsFiring True.

Harder one: Instead of the trigger, have a script which does a bunch of NearestObject checks in a grid pattern around the player, every so often. This would be more difficult to achieve, but would mean that the script works in any mission, and doesn't require the mission maker to set up a trigger themselves.

On reflection, you probably don't even need checks for each side. The AI don't (normally) fire for no reason, so it would be safe to assume that if ANY ai of ANY side is firing, there is a firefight going on.