#include "sv_ttt.qh"
-float autocvar_g_ttt_detective_count = 0.125;
+//set g_ttt_detective_count 0.125 "number of players who will become detectives, set between 0 and 0.9 to use a multiplier of the current players, or 1 and above to specify an exact number of players"
+//float autocvar_g_ttt_detective_count = 0.125; //I don't think that it won't be used...
+float autocvar_g_ttt_innocent_count = 0.625;
float autocvar_g_ttt_traitor_count = 0.25;
float autocvar_g_ttt_round_timelimit = 180;
float autocvar_g_ttt_warmup = 10;
-bool autocvar_g_ttt_punish_teamkill = false;
+bool autocvar_g_ttt_punish_teamkill = 0; //false by default
bool autocvar_g_ttt_reward_innocent = true;
float autocvar_g_ttt_max_karma_points = 1000; //LegendGuard sets Karma points 21-02-2021
-float autocvar_g_ttt_min_karma_points = 200;
-//TODO: when finished new cvars, add them to gamemodes-server.cfg 22-02-2021
+float autocvar_g_ttt_min_karma_points = 400;
//TODO: add Detective and corpse function if a player is DEAD
-//TOFIX: Problems: Detective is a created team, this team is added inside Innocents team
-// when there's a detective and a traitor and no innocent in the round, round ends.
+//TODO: Problems: Detective is a created team, this team is added inside Innocents team
// detective shouldn't be attacked by innocent bots.
// detective should detect the point of the corpses (new function).
{
GameRules_scoring_add(it, SCORE, it.ttt_validkills);
}
- //LOG_INFOF("^3it.karmapoints^7: ^8%f", it.karmapoints);
it.ttt_validkills = 0;
// player survived the round
- if(IS_PLAYER(it) && !IS_DEAD(it)) //TODO: LegendGuard, add something for Karma if possible 21-02-2021
+ if(IS_PLAYER(it) && !IS_DEAD(it)) // LegendGuard adds something for Karma 21-02-2021
{
//TODO: Detective doesn't need scores, but if investigated a corpse maybe yes 22-02-2021
if(autocvar_g_ttt_reward_innocent && timed_out && it.ttt_status == TTT_STATUS_INNOCENT && it.ttt_status == TTT_STATUS_DETECTIVE)
{
GameRules_scoring_add(it, SCORE, 1); // reward innocents who make it to the end of the round time limit
- float increasekarma = 25; //25 points lol //autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) );
- PrintToChatAll(sprintf("^2REWARD ^7increasekarma: ^2%f", increasekarma));
+ float increasekarma = 15; //15 points lol //autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) );
+ //PrintToChatAll(sprintf("^2REWARD ^7increasekarma: ^2%f", increasekarma));
GameRules_scoring_add(it, TTT_KARMA, increasekarma);
it.karmapoints = it.karmapoints + increasekarma;
- PrintToChatAll(sprintf("^2REWARD ^7it.karmapoints: ^1%f", it.karmapoints));
+ //PrintToChatAll(sprintf("^2REWARD ^7it.karmapoints: ^1%f", it.karmapoints));
if(it.karmapoints >= autocvar_g_ttt_max_karma_points)
{
- //RESETS KARMAPOINTS TO MAINTAIN THE MAXIMUM
- PrintToChatAll("^3REWARD ^1MAXIMUM RESET");
+ //Resets karmapoints to maintain the maximum
+ //PrintToChatAll("^3REWARD ^1MAXIMUM RESET");
GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints);
it.karmapoints = autocvar_g_ttt_max_karma_points;
}
else if(it.karmapoints <= autocvar_g_ttt_min_karma_points)
- PrintToChatAll("kick kick kick GET OUT!!");
+ dropclient(it); //PrintToChatAll("GET OUT!!");
}
if(it.ttt_status == TTT_STATUS_INNOCENT)
{
GameRules_scoring_add(it, TTT_RESISTS, 1);
- float increasekarma = 50; //autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) );
- PrintToChatAll(sprintf("^2INNOCENT ^7increasekarma: ^2%f", increasekarma));
+ float increasekarma = 35; //autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) );
+ //PrintToChatAll(sprintf("^2INNOCENT ^7increasekarma: ^2%f", increasekarma));
GameRules_scoring_add(it, TTT_KARMA, increasekarma);
it.karmapoints = it.karmapoints + increasekarma;
- PrintToChatAll(sprintf("^2INNOCENT ^7it.karmapoints: ^1%f", it.karmapoints));
+ //PrintToChatAll(sprintf("^2INNOCENT ^7it.karmapoints: ^1%f", it.karmapoints));
if(it.karmapoints >= autocvar_g_ttt_max_karma_points)
{
- //RESETS KARMAPOINTS TO MAINTAIN THE MAXIMUM
+ //Resets karmapoints to maintain the maximum
//PrintToChatAll("^3INNOCENT ^1MAXIMUM RESET");
GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints);
it.karmapoints = autocvar_g_ttt_max_karma_points;
}
else if(it.karmapoints <= autocvar_g_ttt_min_karma_points)
- PrintToChatAll("kick kick kick GET OUT!!");
+ dropclient(it); //PrintToChatAll("GET OUT!!");
}
else if(it.ttt_status == TTT_STATUS_TRAITOR)
{
GameRules_scoring_add(it, TTT_HUNTS, 1);
- float increasekarma = 50; //autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) );
- PrintToChatAll(sprintf("^1TRAITOR ^7increasekarma: ^2%f", increasekarma));
+ float increasekarma = 35; //autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) );
+ //PrintToChatAll(sprintf("^1TRAITOR ^7increasekarma: ^2%f", increasekarma));
GameRules_scoring_add(it, TTT_KARMA, increasekarma);
it.karmapoints = it.karmapoints + increasekarma;
- PrintToChatAll(sprintf("^1TRAITOR ^7it.karmapoints: ^1%f", it.karmapoints));
+ //PrintToChatAll(sprintf("^1TRAITOR ^7it.karmapoints: ^1%f", it.karmapoints));
if(it.karmapoints >= autocvar_g_ttt_max_karma_points)
{
//RESETS KARMAPOINTS TO MAINTAIN THE MAXIMUM
- PrintToChatAll("^3TRAITOR ^1MAXIMUM RESET");
+ //PrintToChatAll("^3TRAITOR ^1MAXIMUM RESET");
GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints);
it.karmapoints = autocvar_g_ttt_max_karma_points;
}
else if(it.karmapoints <= autocvar_g_ttt_min_karma_points)
- PrintToChatAll("kick kick kick GET OUT!!");
+ dropclient(it); //PrintToChatAll("GET OUT!!");
}
}
});
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_TTT_INNOCENT_WIN);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_TTT_INNOCENT_WIN);
}
- else if (detective_count > 0) // detectives are same as innocents win
+ else if (detective_count > 0 && innocent_count > 0) // detectives are same as innocents win
{
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_TTT_INNOCENT_WIN);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_TTT_INNOCENT_WIN);
FOREACH_CLIENT(true,
{
if(IS_PLAYER(it))
+ {
+ it.respawn_flags = RESPAWN_SILENT; //CSQC print output respawn lib.qh error fix
+ it.damagedbycontents = true;
nades_Clear(it);
+ }
ttt_FakeTimeLimit(it, -1);
});
{
allowed_to_spawn = boolean(warmup_stage);
int playercount = 0;
+
+ // Fix number of detectives to 1
FOREACH_CLIENT(true,
{
if(IS_PLAYER(it) && !IS_DEAD(it))
it.ttt_validkills = 0;
});
+ int innocent_count = bound(1, ((autocvar_g_ttt_innocent_count >= 1) ? autocvar_g_ttt_innocent_count : floor(playercount * autocvar_g_ttt_innocent_count)), playercount - 1); // 20%, but ensure at least 1 and less than total
+ int total_innocents = 0;
int traitor_count = bound(1, ((autocvar_g_ttt_traitor_count >= 1) ? autocvar_g_ttt_traitor_count : floor(playercount * autocvar_g_ttt_traitor_count)), playercount - 1); // 20%, but ensure at least 1 and less than total
int total_traitors = 0;
+ //int detective_count = bound(1, ((autocvar_g_ttt_detective_count >= 1) ? autocvar_g_ttt_detective_count : floor(playercount * autocvar_g_ttt_detective_count)), playercount - 1); // 20%, but ensure at least 1 and less than total
+ int total_detectives = 0;
+ //innocents TOTAL
+ FOREACH_CLIENT_RANDOM(IS_PLAYER(it) && !IS_DEAD(it),
+ {
+ if(total_innocents >= innocent_count)
+ break;
+ total_innocents++;
+ //LegendGuard fixes the round start 26-02-2021
+ if (total_innocents <= 1)
+ {
+ if (total_traitors <= 1)
+ it.ttt_status = TTT_STATUS_TRAITOR;
+ }
+ else if (total_innocents == 3) // test this? && total_traitors >= 1)
+ {
+ if (total_detectives >= 1)
+ break;
+ else
+ {
+ total_detectives++;
+ it.ttt_status = TTT_STATUS_DETECTIVE;
+ }
+ }
+ else if (total_innocents >= 5)
+ {
+ if (total_detectives >= 2)
+ break;
+ else
+ {
+ total_detectives++;
+ it.ttt_status = TTT_STATUS_DETECTIVE;
+ }
+ }
+ else
+ it.ttt_status = TTT_STATUS_INNOCENT;
+ });
+
+ //traitors TOTAL
FOREACH_CLIENT_RANDOM(IS_PLAYER(it) && !IS_DEAD(it),
{
if(total_traitors >= traitor_count)
it.ttt_status = TTT_STATUS_TRAITOR;
});
- int detective_count = bound(1, ((autocvar_g_ttt_detective_count >= 1) ? autocvar_g_ttt_detective_count : floor(playercount * autocvar_g_ttt_detective_count)), playercount - 1); // 20%, but ensure at least 1 and less than total
- int total_detectives = 0;
- FOREACH_CLIENT_RANDOM(IS_PLAYER(it) && !IS_DEAD(it),
+ //detectives TOTAL //Hey, is necessary? I don't think so...
+ /*FOREACH_CLIENT_RANDOM(IS_PLAYER(it) && !IS_DEAD(it),
{
if(total_detectives >= detective_count)
break;
total_detectives++;
- it.ttt_status = TTT_STATUS_DETECTIVE;
- });
+ //ROUND FIX
+ if (total_detectives <= 1)
+ {
+ if (total_traitors <= 1)
+ it.ttt_status = TTT_STATUS_INNOCENT;
+ }
+ else
+ it.ttt_status = TTT_STATUS_DETECTIVE;
+ });*/
FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it),
{
- PrintToChatAll(sprintf("it.karmapoints ^5begin: ^3%f",it.karmapoints));
+ //PrintToChatAll(sprintf("it.karmapoints ^5begin: ^3%f",it.karmapoints));
if(it.karmapoints <= 0)
{
- //RESETS KARMAPOINTS WHEN MATCH STARTS
- PrintToChatAll("^2ZERO RESET");
+ //Resets karmapoints when match starts
+ //PrintToChatAll("^2ZERO RESET");
GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints);
it.karmapoints = autocvar_g_ttt_max_karma_points;
}
else if(it.karmapoints >= autocvar_g_ttt_max_karma_points)
{
- //RESETS KARMAPOINTS TO MAINTAIN THE MAXIMUM
- PrintToChatAll("^1MAXIMUM RESET");
+ //Resets karmapoints to maintain the maximum
+ //PrintToChatAll("^1MAXIMUM RESET");
GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints);
it.karmapoints = autocvar_g_ttt_max_karma_points;
}
else if(it.karmapoints <= autocvar_g_ttt_min_karma_points)
- PrintToChatAll("kick kick kick GET OUT!!");
- PrintToChatAll(sprintf("it.karmapoints ^6end: ^3%f",it.karmapoints));
+ dropclient(it); //PrintToChatAll("GET OUT!!");
+ //PrintToChatAll(sprintf("it.karmapoints ^6end: ^3%f",it.karmapoints));
if(it.ttt_status == TTT_STATUS_INNOCENT)
{
{
Send_Notification(NOTIF_ONE_ONLY, it, MSG_CENTER, CENTER_TTT_DETECTIVE); //Detective notification should be sent to all players to see who is
PrintToChatAll(sprintf("%s is ^4Detective^7!", it.netname));
- // LegendGuard asks a POLL: Should notify in the center for everyone about who is Detective?
- //Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_TTT_DETECTIVE, 1);
}
ttt_FakeTimeLimit(it, round_handler_GetEndTime());
// unless the player is going to be punished for suicide, in which case just remove one
if(frag_attacker.ttt_status == frag_target.ttt_status)
{
- PrintToChatAll("^1DEBUG^7: A ^2PLAYER^7 has fragged a ^2PLAYER OF HIS OWN TEAM^7, TOO BAD!");
- float decreasekarma = -( autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) * 0.1 );
+ //PrintToChatAll("^1DEBUG^7: A ^2PLAYER^7 has fragged a ^2PLAYER OF HIS OWN TEAM^7, TOO BAD!");
+ float decreasekarma = -( autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) * 0.25 );
//PrintToChatAll(sprintf("decreasekarma: ^1%f", decreasekarma));
GameRules_scoring_add(frag_attacker, TTT_KARMA, decreasekarma);
frag_attacker.karmapoints = frag_attacker.karmapoints + decreasekarma;
//PrintToChatAll(sprintf("frag_attacker.karmapoints: ^1%f", frag_attacker.karmapoints));
GiveFrags(frag_attacker, frag_target, ((autocvar_g_ttt_punish_teamkill) ? -1 : -2), frag_deathtype, wep_ent.weaponentity_fld);
if(frag_attacker.karmapoints <= autocvar_g_ttt_min_karma_points)
- PrintToChatAll("kick kick kick GET OUT!!");
- //MATH THEORY: example: 1000 * 0.3 * (0.1 + 0.4) * 0.1 // karma points reduce when player attacked to other player
+ dropclient(frag_attacker); //PrintToChatAll("GET OUT!!");
+ //BASIC MATH THEORY: example: 1000 * 0.3 * (0.1 + 0.4) * 0.25 // karma points reduce when player attacked to other player
}
if(frag_attacker.ttt_status == TTT_STATUS_DETECTIVE)
{
if (frag_target.ttt_status == TTT_STATUS_INNOCENT)
{
- PrintToChatAll("^1DEBUG^7: A ^4Detective^7 fragged an ^2Innocent^7, TOO BAD!");
- float decreasekarma = -( autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) * 0.1 );
+ //PrintToChatAll("^1DEBUG^7: A ^4Detective^7 fragged an ^2Innocent^7, TOO BAD!");
+ float decreasekarma = -( autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) * 0.25 );
//PrintToChatAll(sprintf("decreasekarma: ^1%f", decreasekarma));
GameRules_scoring_add(frag_attacker, TTT_KARMA, decreasekarma);
frag_attacker.karmapoints = frag_attacker.karmapoints + decreasekarma;
//PrintToChatAll(sprintf("frag_attacker.karmapoints: ^1%f", frag_attacker.karmapoints));
GiveFrags(frag_attacker, frag_target, ((autocvar_g_ttt_punish_teamkill) ? -1 : -2), frag_deathtype, wep_ent.weaponentity_fld);
if(frag_attacker.karmapoints <= autocvar_g_ttt_min_karma_points)
- PrintToChatAll("kick kick kick GET OUT!!");
+ dropclient(frag_attacker); //PrintToChatAll("GET OUT!!");
}
}
{
if (frag_target.ttt_status == TTT_STATUS_DETECTIVE)
{
- PrintToChatAll("^1DEBUG^7: An ^2Innocent^7 fragged a ^4Detective^7, TOO BAD!");
- float decreasekarma = -( autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) * 0.1 );
+ //PrintToChatAll("^1DEBUG^7: An ^2Innocent^7 fragged a ^4Detective^7, TOO BAD!");
+ float decreasekarma = -( autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) * 0.25 );
//PrintToChatAll(sprintf("decreasekarma: ^1%f", decreasekarma));
GameRules_scoring_add(frag_attacker, TTT_KARMA, decreasekarma);
frag_attacker.karmapoints = frag_attacker.karmapoints + decreasekarma;
GiveFrags(frag_attacker, frag_target, ((autocvar_g_ttt_punish_teamkill) ? -1 : -2), frag_deathtype, wep_ent.weaponentity_fld);
if(frag_attacker.karmapoints <= autocvar_g_ttt_min_karma_points)
- PrintToChatAll("kick kick kick GET OUT!!");
+ dropclient(frag_attacker); //PrintToChatAll(" GET OUT!!");
}
}
//if ttt_status is 1, means innocent, 2 means traitor, 3 means detective, TODO: the bots: frag_attacker(1) shouldn't attack to frag_target(3)
MUTATOR_HOOKFUNCTION(ttt, PlayerPreThink)
{
entity player = M_ARGV(0, entity);
-
+
if(IS_PLAYER(player) || player.caplayer)
{
// update the scoreboard colour display to out the real killer at the end of the round
// running this every frame to avoid cheats
int plcolor = TTT_COLOR_INNOCENT;
+ if(player.ttt_status == TTT_STATUS_INNOCENT && game_stopped) //Innocent status by default
+ plcolor = TTT_COLOR_INNOCENT;
if(player.ttt_status == TTT_STATUS_TRAITOR && game_stopped)
plcolor = TTT_COLOR_TRAITOR;
//LegendGuard adds for Detective 21-02-2021
- if(player.ttt_status == TTT_STATUS_DETECTIVE && game_stopped)
+ if(player.ttt_status == TTT_STATUS_DETECTIVE)// && game_stopped)
plcolor = TTT_COLOR_DETECTIVE;
setcolor(player, plcolor);
}
{
TRANSMUTE(Player, it);
it.caplayer = 1;
+ it.respawn_flags = RESPAWN_SILENT; //CSQC print output respawn lib.qh error fix
+ it.damagedbycontents = true;
PutClientInServer(it);
}
});
if (!IS_DEAD(it) && this.ttt_status == it.ttt_status)
{
if (!last_pl)
+ {
last_pl = it;
+ }
else
return NULL;
}
entity frag_attacker = M_ARGV(1, entity);
entity frag_target = M_ARGV(2, entity);
float frag_deathtype = M_ARGV(3, float);
+ //float is_player = (IS_PLAYER(frag_target) || frag_target.classname == "body" || IS_MONSTER(frag_target));
+ // Corpse should stay in the round 23-02-2021
+ // issues: when use DAMAGE_NO, makes unmovable and if shotgun shots, corpse crushes and disappears
+ // try to do something for corpse, outside this mutator, try in the event where updates
ttt_LastPlayerForTeam_Notify(frag_target);
if (!allowed_to_spawn)
{
- frag_target.respawn_flags = RESPAWN_SILENT;
+ frag_target.respawn_flags = RESPAWN_DENY;
// prevent unwanted sudden rejoin as spectator and movement of spectator camera
frag_target.respawn_time = time + 2;
}
- frag_target.respawn_flags |= RESPAWN_FORCE;
+ frag_target.respawn_flags |= RESPAWN_SILENT;
+ //CORPSE TEST 24-02-2021
+ //frag_target.respawn_flags |= RESPAWN_DENY;
+ //frag_target.deadflag = DEAD_NO;
+ //frag_target.solid = SOLID_SLIDEBOX;
+ //frag_target.solid = SOLID_CORPSE;
+ //set_movetype(frag_target, MOVETYPE_NONE);
+ //frag_target.takedamage = DAMAGE_NO; //it works but it doesn't move... and can be crushed to disappear
+ frag_target.damagedbycontents = false;
+ //LOG_DEBUG("CORPSE CLASSNAME: %s", frag_target.classname);
+ //PrintToChatAll(sprintf("^1fragtarget_classname: ^3%s",frag_target.classname));
if (!warmup_stage)
{
eliminatedPlayers.SendFlags |= 1;
bot_clear(frag_target);
}
- //TODO: LegendGuard, here is where maybe karma points should be outputted 21-02-2021
- //TODO: a if for if innocent attacks detective, then reduce points, death_punishment should be disabled for TTT 21-02-2021
//if(frag_attacker.ttt_status == frag_target.ttt_status)
// killed an ally! punishment is death
if(autocvar_g_ttt_punish_teamkill && frag_attacker != frag_target && IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target) && frag_attacker.ttt_status == frag_target.ttt_status && !ITEM_DAMAGE_NEEDKILL(frag_deathtype))
if (frag_target.ttt_status == TTT_STATUS_INNOCENT)
{
//PrintToChatAll("^1DEBUG^7: ^4DETECTIVE ^1DAMAGE/DEAD^7 HAS TAKEN!");
- //50 damage points deal
- Damage(frag_attacker, frag_attacker, frag_attacker, 50, DEATH_MIRRORDAMAGE.m_id, DMG_NOWEP, frag_attacker.origin, '0 0 0');
+ //30 damage points deal
+ Damage(frag_attacker, frag_attacker, frag_attacker, 30, DEATH_MIRRORDAMAGE.m_id, DMG_NOWEP, frag_attacker.origin, '0 0 0');
}
}
if (frag_attacker.ttt_status == TTT_STATUS_INNOCENT)
if (frag_target.ttt_status == TTT_STATUS_DETECTIVE)
{
//PrintToChatAll("^1DEBUG^7: ^2INNOCENT ^1DAMAGE/DEAD^7 HAS TAKEN!");
- //50 damage points deal
- Damage(frag_attacker, frag_attacker, frag_attacker, 50, DEATH_MIRRORDAMAGE.m_id, DMG_NOWEP, frag_attacker.origin, '0 0 0');
+ //30 damage points deal
+ Damage(frag_attacker, frag_attacker, frag_attacker, 30, DEATH_MIRRORDAMAGE.m_id, DMG_NOWEP, frag_attacker.origin, '0 0 0');
}
}
return true;