#ifdef SVQC
.float metertime = _STAT(NB_METERSTART);
+.entity ballcarried;
+
int autocvar_g_nexball_goalleadlimit;
#define autocvar_g_nexball_goallimit cvar("g_nexball_goallimit")
{
ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
ownr.ballcarried = NULL;
+ GameRules_scoring_vip(ownr, false);
if(ownr.metertime)
{
ownr.metertime = 0;
ball.weaponentity_fld = weaponentity;
ball.team = plyr.team;
plyr.ballcarried = ball;
+ GameRules_scoring_vip(plyr, true);
ball.nb_dropper = plyr;
plyr.effects |= autocvar_g_nexball_basketball_effects_default;
WaypointSprite_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please
WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
- ball.owner.ballcarried = NULL;
- ball.owner = NULL;
+ entity e = ball.owner; ball.owner = NULL;
+ e.ballcarried = NULL;
+ GameRules_scoring_vip(e, false);
}
void InitBall(entity this)
{
ScoreRules_basics_end();
}
+
+.bool m_GameRules_scoring_vip;
+void GameRules_scoring_vip(entity player, bool value)
+{
+ player.m_GameRules_scoring_vip = value;
+}
+bool GameRules_scoring_is_vip(entity player)
+{
+ return player.m_GameRules_scoring_vip;
+}
*/
void GameRules_limit_fallbacks();
-// derive score_enabled from !frags_enabled
-
/**
* @param teams a bitmask of active teams
* @param spprio player score priority (if frags aren't enabled)
void _GameRules_scoring_field(entity i, string label, int scoreflags);
void _GameRules_scoring_field_team(float i, string label, int scoreflags);
void _GameRules_scoring_end();
+
+/**
+ * Mark a player as being 'important' (flag carrier, ball carrier, etc)
+ * @param player the entity to mark
+ * @param value VIP status
+ */
+void GameRules_scoring_vip(entity player, bool value);
+bool GameRules_scoring_is_vip(entity player);
FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
float time_score;
- if(player.flagcarried || player.ballcarried) // this player is important
+ if(GameRules_scoring_is_vip(player))
time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
else
time_score = autocvar_g_nades_bonus_score_time;
if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
nades_RemoveBonus(frag_attacker);
- else if(frag_target.flagcarried)
+ else if(GameRules_scoring_is_vip(frag_target))
nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
{
.float bulletcounter;
// Nexball
-.entity ballcarried; // Also used for keepaway
float g_nexball_meter_period;
void SUB_DontUseTargets(entity this, entity actor, entity trigger);
// transfer flag to player
flag.owner = player;
flag.owner.flagcarried = flag;
+ GameRules_scoring_vip(player, true);
// reset flag
if(player.vehicle)
setattachment(flag, NULL, "");
setorigin(flag, player.origin + FLAG_DROP_OFFSET);
flag.owner.flagcarried = NULL;
+ GameRules_scoring_vip(flag.owner, false);
flag.owner = NULL;
flag.solid = SOLID_TRIGGER;
flag.ctf_dropper = player;
// attach the flag to the player
flag.owner = player;
player.flagcarried = flag;
+ GameRules_scoring_vip(player, true);
if(player.vehicle)
{
setattachment(flag, player.vehicle, "");
WaypointSprite_Kill(flag.wps_flagcarrier);
flag.owner.flagcarried = NULL;
+ GameRules_scoring_vip(flag.owner, false);
if(flag.speedrunning)
ctf_FakeTimeLimit(flag.owner, -1);
#include <common/effects/all.qh>
+.entity ballcarried;
+
int autocvar_g_keepaway_ballcarrier_effects;
float autocvar_g_keepaway_ballcarrier_damage;
float autocvar_g_keepaway_ballcarrier_force;
// attach the ball to the player
this.owner = toucher;
toucher.ballcarried = this;
+ GameRules_scoring_vip(toucher, true);
setattachment(this, toucher, "");
setorigin(this, '0 0 0');
ball.effects &= ~EF_NODRAW;
setorigin(ball, plyr.origin + '0 0 10');
ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom();
- ball.owner.ballcarried = world; // I hope nothing checks to see if the world has the ball in the rest of my code :P
- ball.owner = NULL;
+ entity e = ball.owner; ball.owner = NULL;
+ e.ballcarried = NULL;
+ GameRules_scoring_vip(e, false);
navigation_dynamicgoal_set(ball);
// reset the player effects
// Initialization
// ==============
+MODEL(KA_BALL, "models/orbs/orbblue.md3");
+
void ka_SpawnBall() // loads various values for the ball, runs only once at start of match
{
entity e = new(keepawayball);
- e.model = "models/orbs/orbblue.md3";
- precache_model(e.model);
- _setmodel(e, e.model);
+ setmodel(e, MDL_KA_BALL);
setsize(e, '-16 -16 -20', '16 16 20'); // 20 20 20 was too big, player is only 16 16 24... gotta cheat with the Z (20) axis so that the particle isn't cut off
e.damageforcescale = autocvar_g_keepawayball_damageforcescale;
e.takedamage = DAMAGE_YES;
InitializeEntity(e, ka_RespawnBall, INITPRIO_SETLOCATION); // is this the right priority? Neh, I have no idea.. Well-- it works! So.
}
-void ka_ScoreRules()
+void ka_Initialize() // run at the start of a match, initiates game mode
{
GameRules_scoring(0, SFL_SORT_PRIO_PRIMARY, 0, {
field(SP_KEEPAWAY_PICKUPS, "pickups", 0);
field(SP_KEEPAWAY_CARRIERKILLS, "bckills", 0);
field(SP_KEEPAWAY_BCTIME, "bctime", SFL_SORT_PRIO_SECONDARY);
- });
-}
-
-void ka_Initialize() // run at the start of a match, initiates game mode
-{
- ka_ScoreRules();
+ });
ka_SpawnBall();
}