Home   Help Search Login Register  

Author Topic: ID killer group  (Read 2294 times)

0 Members and 1 Guest are viewing this topic.

Offline CaptainBravo

  • Members
  • *
ID killer group
« on: 14 Aug 2009, 17:40:36 »
I have a couple of questions that I could not find answers for after doing search.

I am designing a mission where a civilian is being hunted by 2 grps (east and west)
Both groups can only win if they kill him.

The challange is: How do you know which group killed him? as this will determin the group that wins.

Thanks in advance for your help.


Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: ID killer group
« Reply #1 on: 14 Aug 2009, 18:24:22 »
You need the 'killed' event handler.  Add it using addEventHandler and do something like this in the action script:

Code: [Select]
_sideKilled = side (_this select 1);
You can then use that to follow your logic through :)

Offline CaptainBravo

  • Members
  • *
Re: ID killer group
« Reply #2 on: 18 Aug 2009, 11:03:10 »
Thanks James, I appreciate your quick answer. I have looked the add eventhandler and I am not sure how to implment in mission (noob effect!). Any possibilty of a simple example?

Thanks again for your help.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: ID killer group
« Reply #3 on: 18 Aug 2009, 11:44:41 »
Okay, let's say you placed this in the init line of the civilian:
Code: [Select]
this addEventHandler ["killed", {_this execVM "whoKilledHim.sqf";}];
Then you put this in a file called "whoKilledHim.sqf" in your main mission directory:
Code: (whoKilledHim.sqf) [Select]
_sideKiller = side (_this select 1);
hint format["Civilian killed by %1 side!", _sideKiller];

This would say "Civilian killed by <side who killed him>" in a hint box when the civilian was shot.  You can then extend this logic further to end a mission using the endMission command and a simple if statement in the "whoKilledHim.sqf" file.

I've left the last little bit for you to do yourself (after all, you learn best by working some things out), but if you have trouble with it, let me know :)

Offline CaptainBravo

  • Members
  • *
Re: ID killer group
« Reply #4 on: 18 Aug 2009, 19:22:07 »
Thanks James for your help. I have tried the suggestions you mentioned and although it seemed easy on the surface, I am afraid my scripting skill is almost non exisitant.

I usually use trigger to end mission and I am not sure how do you get trig to recognize who killed civ.
Anything = if (condition) then {Code} else {Code} is the part I am not sure I understand.

Any more simplification (like 1st grade level) is highly appreciated :)

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: ID killer group
« Reply #5 on: 18 Aug 2009, 20:25:44 »
Right - you don't need a trigger for this. :)

Double-click on your civilian unit, and paste this into his "Init" box:
Code: [Select]
this addEventHandler ["killed", {_this execVM "whoKilledHim.sqf";}];
Now, in your mission directory, make a file called "whoKilledHim.sqf", and put this in it:
Code: (whoKilledHim.sqf) [Select]
_sideKiller = side (_this select 1);

if(_sideKiller==west) then { endMission "END1"; };
if(_sideKiller==east) then { endMission "END2"; };

This will cause the mission to end if he is killed by one of those two sides.  Also in your mission directory, make a file called "Briefing.html", and put this in it:
Code: (Briefing.html) [Select]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>

<body bgcolor="#FFFFFF">
<! -----DEBRIEFING----->
<hr>
<br>
<h2><a name="Debriefing:End1">West Wins!</a></h2>
<br>
<p>
West killed the civilian!
</p>
<br>

<hr>
<br>
<h2><a name="Debriefing:End2">East Wins!</a></h2>
<br>
<p>
East killed the civilian!
</p>
<br>

<! -----DEBRIEFING END----->

</body>
</html>

Hope that helps :)

Offline mikey

  • Former Staff
  • ****
  • Whitespace Whore
Re: ID killer group
« Reply #6 on: 18 Aug 2009, 23:38:04 »
Hey, don't forget that endMission is local effect, so you need to broadcast the command to everyone (server + clients).

edit: nvm, just saw you add the killed EH on every machine.
« Last Edit: 18 Aug 2009, 23:40:20 by mikey »

Offline CaptainBravo

  • Members
  • *
Re: ID killer group
« Reply #7 on: 20 Aug 2009, 13:37:28 »
Thanks James, it works like a charm now. Only related question is how do you add time delay before mission ends like you would in a trigger, so if west wins, the mission waits 10 seconds before ending?

Thanks for your great help.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: ID killer group
« Reply #8 on: 20 Aug 2009, 15:16:08 »
Change this:
Code: (whoKilledHim.sqf) [Select]
_sideKiller = side (_this select 1);

if(_sideKiller==west) then { endMission "END1"; };
if(_sideKiller==east) then { endMission "END2"; };

To this:
Code: (whoKilledHim.sqf) [Select]
_sideKiller = side (_this select 1);

if(_sideKiller==west) then { sleep 10; endMission "END1"; };
if(_sideKiller==east) then { sleep 10; endMission "END2"; };

Offline CaptainBravo

  • Members
  • *
Re: ID killer group
« Reply #9 on: 21 Aug 2009, 12:44:36 »
Thanks James, I appreciate your great help.  :good: