Jump to content
Sign in to follow this  
XSOF - Toxx

Team Deathmatch with Kill Streaks

Recommended Posts

Hey guys,

I'm currently trying to make a team deathmatch mission including various kill streaks and I have a few questions.

I need a global variable per player to count his kills until he dies.

Something like:

_player1KillCount = 0;

player addMPEventHandler ["MPKilled",{_player1KillCount = 0;}];

// I couldn't find an Event Handler that fires when a Player kills somebody else, to increase _playerKillCount?! Should I use "_this select 1" to check for the killer and execute a script which increases the killers killcount?

Question 1: Where (in which file) would I put the counter variables and how would I have to make them count up?

Kill streaks:

Kill Streak 1) Giving the player a RPG

player addMagazine "M_RPG32_F";
player addWeapon "launch_RPG32_F";

Question 2: Does it work like this and where do I have to put this code?

Kill Streak 2) Spawn an AI subordinate next to the player, have him follow the player and engage at will. Kills of the AI should account to the players kill streak counter.

_spawnedAI = [getPos _player, playerSide, 1] call BIS_fnc_spawnGroup;
_spawnedAI setRank "PRIVATE";
_spawnedAI setCombatMode "RED";

Question 3: How do I add the number of kills of the AI to the players kill count and where do I put this code?

Kill Streak 3) Let the player choose a location for 1 volley of mortar strike

Question 4: Using the artillery module is not a problem but how do I enable it only if the player meets the required kills?

Kill Streak 4) Let the player choose a location for a Little Bird CAS for 1 minute

Question 5: There are also tutorials for CAS via Little Bird but how do I enable it only if the player meets the required kills?

Kill Streak 5) Let the player choose a location for a Little Bird CAS for 2 minutes

Question 6: Is it possible to make kill streak 4) be 1 minute CAS and kill streak 5) be 2 minutes CAS?

Question 7: Do I need to place 1 chopper per player on the map or just 1 per side?

Question 8: How do I make sure, the support is only available once and gets disabled again after using it?

Question 9: How do I add the number of kills of the choppers to the players kill count

I'm not looking for complete solutions but I'd be very thankful for any help or tips.

Thank you and best regards

Toxx

Edited by Toxx

Share this post


Link to post
Share on other sites

1) You're better off using setVariable on a specific unit.

player setVariable["killStreak", 0]; // Init

Then when they get a kill:

player setVariable["killStreak", (player getVariable["killStreak", 0]) + 1];

2) You put the code in the init file (and maybe respawn event handler?), but you should call removeAllWeapons (and items)

You can view the API resources here:

http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2

https://community.bistudio.com/wiki/Category:Arma_3:_New_Scripting_Commands_List

3) You can increase the user's "killStreak" variable in the "Killed" event handler. You can check if they are an actual player or AI in that callback.

4)

if((player getVariable["killSreak", 0]) > 10) then { /*allow them in things*/ } else { /*don't*/ };

5) Same as above.

6) Can't answer

7) You can place as many choppers as you want?...

8) You would have to make specific variables per each "support" thing. "hasUsedChopper", "hasUsedArty" and set them to true/false accordingly.

9) That... I'm not sure about. I'm almost certain there's a way to add to the score but I don't remember the API for it right now.

All that said, you should practice the fundamentals before trying to take on something like this.

Share this post


Link to post
Share on other sites

Thank you sic, I really appreciate your help!

I am indeed pretty new to scripting for Arma but I like to learn things by setting ambitious goals, rather than trying things I don't really need right now :)

I will try your suggestions and keep the community posted about the progress.

---------- Post added at 04:44 PM ---------- Previous post was at 03:34 PM ----------

So, this is what I have so far:

/*
SET AMOUNT OF KILLS NEEDED PER KILL STREAK
*/

_killStreakRPG = 3;
_killStreakAI = 5;
_killStreakMortar = 7;
_killStreakLittleBird = 10;

/*
INITIALIZE KILL COUNT PER PLAYER
*/

_player1blu setVariable["killstreak", 0];
_player2blu setVariable["killstreak", 0];
_player3blu setVariable["killstreak", 0];
_player4blu setVariable["killstreak", 0];
_player5blu setVariable["killstreak", 0];
_player6blu setVariable["killstreak", 0];
_player7blu setVariable["killstreak", 0];
_player8blu setVariable["killstreak", 0];
_player1red setVariable["killstreak", 0];
_player2red setVariable["killstreak", 0];
_player3red setVariable["killstreak", 0];
_player4red setVariable["killstreak", 0];
_player5red setVariable["killstreak", 0];
_player6red setVariable["killstreak", 0];
_player7red setVariable["killstreak", 0];
_player8red setVariable["killstreak", 0];

/*
ADD KILLED-EVENTHANDLERS
*/

_player1blu addMPEventHandler ["MPKilled",
{
// reset the players kill count as he got killed
_player1blu setVariable["killstreak", 0];

// TODO: Kill players AI subordinate

// TODO: Remove RPG from the player

// TODO: Deactivate Artillery module for the player

// TODO: Deactivate CAS module for the player

// increase the killers kill count
_this select 1 setVariable["killStreak", (player getVariable["killStreak", 0]) + 1];

// check for RPG-killstreak
if((_this select 1 getVariable["killStreak", 0]) >= _killStreakRPG) then
{
 // add a RPG rocket to the killers inventory
 _this select 1 addMagazine "M_RPG32_F";

 // add a RPG to the killers inventory
 _this select 1 addWeapon "launch_RPG32_F";
} else { };

// check for AI-killstreak
if((_this select 1 getVariable["killStreak", 0]) >= _killStreakAI) then
{
// spawn an AI soldier next to the killer
_spawnedAI = [getPos this select 1, side this select 1, 1] call BIS_fnc_spawnGroup;

// set the AI soldiers rank to PRIVATE
_spawnedAI setRank "PRIVATE";

// set ROE for the AI soldier to fire at will
_spawnedAI setCombatMode "RED";

//TODO: Count AI kills
} else { };

// check for mortar-killstreak
if((_this select 1 getVariable["killStreak", 0]) >= _killStreakMortar) then
{
 // TODO: Activate artillery module for the killer
} else { };

// check for Little Bird 1min-killstreak
if((_this select 1 getVariable["killStreak", 0]) >= _killStreakLittleBird) then
{
 // TODO: Activate CAS module for the killer
} else { };
}];

Share this post


Link to post
Share on other sites

You don't need to set variables for each player unless they're on the server.

When code is executed on the client, just use "player".

If you need the variable broadcasted to other players/the server use:

player setVariable["killstreak", 0, true];

Share this post


Link to post
Share on other sites

Thank you again Sic, this helps a lot!

I have now managed to count a players kills, show them as a hint and give the player a RPG after 3 kills.

On to my next questions.

Question 10: Adding a RPG does work, however, adding ammo doesn't. I've tried to put it into the inventory directly and into the backpack. Neither worked:

player addMagazine "RPG32_F";

I just found the following in another thread and have to test it when I'm at home:

player addMagazine _magazine; 
waitUntil {(_magazine in (magazines player))}; 
player addWeapon _weapon;

Question 11: For testing purposes, I want to use unarmed AIs which I can shoot and check the kill streaks. Do I have to name them all and add an EventHandler per AI soldier, or is there something like the keyword "player" which referes to ALL opponents, too?

Question 12: The EventHandler "Killed" returns 2 Objects:[0] Unit, [1] Killer. Within the code of the EventHandler I'd like to increase the Killers kill count. Now my question is, how do I correctly address the return value "Killer", as in the following Script:

_this select 1 addWeapon "launch_RPG32_F"; //this does NOT work
player addWeapon "launch_RPG32_F"; //this works, but doesn't serve the purpose

Edited by Toxx

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×