S
sivispacem
Guest
I wanted to post some code to assist others and to seek refinement.
I humbly admit I am a beginner and that there is likely a better way to code for this than I have presented.
However, it does work. Please feel free to comment and/or modify.
1) Created an object - obj_kill_streak - persistent - placed in title room
2) obj_kill_streak - Create
3)obj_kill_streak - Step
4)obj_kill_streak - Alarm[0]
5) In the Destroy events for the enemy parent/objects (however you choose)
I used global variables because I am drawing to the GUI in a separate object, and, yes, I can use with but this was easier for me.
I humbly admit I am a beginner and that there is likely a better way to code for this than I have presented.
However, it does work. Please feel free to comment and/or modify.
1) Created an object - obj_kill_streak - persistent - placed in title room
2) obj_kill_streak - Create
GML:
/// @desc Init Vars for Kill Streak
global.total_kills = 0;
global.kill_streak = 0;
global.kill_points_add = 0;
global.kill_streak_bonus = 0;
global.kill_streak_state = false;
//give a bonus to the timer based on kill streak and difficulty level
{
if(global.kill_streak <= 14)
{global.kill_streak_bonus = 0}
else if(global.kill_streak >= 15) and (global.kill_streak < 29)
{global.kill_streak_bonus = 0.5}
else if(global.kill_streak >= 30) and (global.kill_streak < 64)
{global.kill_streak_bonus = 1}
else if(global.kill_streak >= 65) and (global.kill_streak < 99)
{global.kill_streak_bonus = 1.5}
else if(global.kill_streak >= 100)
{global.kill_streak_bonus = 2}
else {exit};
}
global.kill_streak_timer = (room_speed * (3 + global.kill_streak_bonus));
GML:
/// @desc Logic for Checking Player Kills in x Time
if(global.kill_streak_timer > 0)
{
//obj_enemy_parent user events (damage/destroy) add to global.total_kills
//obj_enemy_parent user events (damage/destroy) add to global.skill_streak
global.kill_points_add = global.kill_streak;
//global timer is reset in obj_enemy_parent user events (damage/destroy)
global.kill_streak_state = true;
}
else
{
global.player_1_score += global.kill_points_add;
alarm[0] = 1;
//set kill streak and points added to zero in alarm[0]
}
//count timer down and keep at zero if no qualifying event
global.kill_streak_timer -= 1;
if(global.kill_streak_timer <= 0)
{global.kill_streak_timer = 0};
GML:
/// @desc Set Kill Streak and Points Added to Zero
global.kill_streak = 0;
global.kill_points_add = 0;
global.kill_streak_state = false;
GML:
{
global.total_kills +=1;
global.kill_streak +=1;
global.kill_streak_timer = (room_speed * (3 + global.kill_streak_bonus));
}