X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fgamemodes%2Fgamemode%2Fonslaught%2Fsv_onslaught.qc;h=06fb06d185e5786d3a5ebd3205293be5a7bbdfe3;hb=b8ad7477ca022feff76a1634c7ca8dcaaf54937c;hp=5525c4d6a8f5d72e24acda5f2f96aae1b45b899a;hpb=f134a25da56d9f4c3452cbd47a7ee97d795fc759;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 5525c4d6a..06fb06d18 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -38,9 +38,7 @@ bool clientcamera_send(entity this, entity to, int sf) { WriteHeader(MSG_ENTITY, ENT_ONSCAMERA); - WriteCoord(MSG_ENTITY, this.origin_x); - WriteCoord(MSG_ENTITY, this.origin_y); - WriteCoord(MSG_ENTITY, this.origin_z); + WriteVector(MSG_ENTITY, this.origin); WriteAngle(MSG_ENTITY, this.angles_x); WriteAngle(MSG_ENTITY, this.angles_y); @@ -68,7 +66,7 @@ void ons_CaptureShield_Touch(entity this, entity toucher) vector mymid = (this.absmin + this.absmax) * 0.5; vector theirmid = (toucher.absmin + toucher.absmax) * 0.5; - Damage(toucher, this, this, 0, DEATH_HURTTRIGGER.m_id, mymid, normalize(theirmid - mymid) * ons_captureshield_force); + Damage(toucher, this, this, 0, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, mymid, normalize(theirmid - mymid) * ons_captureshield_force); if(IS_REAL_CLIENT(toucher)) { @@ -143,8 +141,8 @@ void onslaught_updatelinks() { l.islinked = false; l.isshielded = true; - int i; - for(i = 0; i < 17; ++i) { l.isgenneighbor[i] = false; l.iscpneighbor[i] = false; } + l.aregensneighbor = 0; + l.arecpsneighbor = 0; LOG_DEBUG(etos(l), " (point) belongs to team ", ftos(l.team)); l.sprite.SendFlags |= 16; } @@ -188,9 +186,9 @@ void onslaught_updatelinks() l.enemy.isshielded = false; } if(l.goalentity.classname == "onslaught_generator") - l.enemy.isgenneighbor[l.goalentity.team] = true; + l.enemy.aregensneighbor |= BIT(l.goalentity.team); else - l.enemy.iscpneighbor[l.goalentity.team] = true; + l.enemy.arecpsneighbor |= BIT(l.goalentity.team); } if (l.enemy.islinked) { @@ -200,9 +198,9 @@ void onslaught_updatelinks() l.goalentity.isshielded = false; } if(l.enemy.classname == "onslaught_generator") - l.goalentity.isgenneighbor[l.enemy.team] = true; + l.goalentity.aregensneighbor |= BIT(l.enemy.team); else - l.goalentity.iscpneighbor[l.enemy.team] = true; + l.goalentity.arecpsneighbor |= BIT(l.enemy.team); } } // now update the generators @@ -272,15 +270,11 @@ bool ons_Link_Send(entity this, entity to, int sendflags) WriteByte(MSG_ENTITY, sendflags); if(sendflags & 1) { - WriteCoord(MSG_ENTITY, this.goalentity.origin_x); - WriteCoord(MSG_ENTITY, this.goalentity.origin_y); - WriteCoord(MSG_ENTITY, this.goalentity.origin_z); + WriteVector(MSG_ENTITY, this.goalentity.origin); } if(sendflags & 2) { - WriteCoord(MSG_ENTITY, this.enemy.origin_x); - WriteCoord(MSG_ENTITY, this.enemy.origin_y); - WriteCoord(MSG_ENTITY, this.enemy.origin_z); + WriteVector(MSG_ENTITY, this.enemy.origin); } if(sendflags & 4) { @@ -328,8 +322,8 @@ void ons_DelayedLinkSetup(entity this) int ons_ControlPoint_CanBeLinked(entity cp, int teamnumber) { - if(cp.isgenneighbor[teamnumber]) { return 2; } - if(cp.iscpneighbor[teamnumber]) { return 1; } + if(cp.aregensneighbor & BIT(teamnumber)) return 2; + if(cp.arecpsneighbor & BIT(teamnumber)) return 1; return 0; } @@ -381,7 +375,7 @@ int ons_ControlPoint_Attackable(entity cp, int teamnumber) return 0; } -void ons_ControlPoint_Icon_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void ons_ControlPoint_Icon_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { if(damage <= 0) { return; } @@ -426,8 +420,8 @@ void ons_ControlPoint_Icon_Damage(entity this, entity inflictor, entity attacker pointparticles(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_CPDESTROYED), this.owner.message, attacker.netname); - PlayerScore_Add(attacker, SP_ONS_TAKES, 1); - PlayerScore_Add(attacker, SP_SCORE, 10); + GameRules_scoring_add(attacker, ONS_TAKES, 1); + GameRules_scoring_add(attacker, SCORE, 10); this.owner.goalentity = NULL; this.owner.islinked = false; @@ -479,7 +473,7 @@ void ons_ControlPoint_Icon_Think(entity this) this.SendFlags |= CPSF_STATUS; if(this.health <= 0) { - ons_ControlPoint_Icon_Damage(this, this, this, 1, 0, this.origin, '0 0 0'); + ons_ControlPoint_Icon_Damage(this, this, this, 1, 0, DMG_NOWEP, this.origin, '0 0 0'); return; } } @@ -555,8 +549,8 @@ void ons_ControlPoint_Icon_BuildThink(entity this) Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, this.owner.ons_toucher.netname, this.owner.message); Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE_TEAM), this.owner.message); Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message); - PlayerScore_Add(this.owner.ons_toucher, SP_ONS_CAPS, 1); - PlayerTeamScore_AddScore(this.owner.ons_toucher, 10); + GameRules_scoring_add(this.owner.ons_toucher, ONS_CAPS, 1); + GameRules_scoring_add_team(this.owner.ons_toucher, SCORE, 10); } this.owner.ons_toucher = NULL; @@ -841,7 +835,7 @@ void ons_camSetup(entity this) float best_trace_fraction = 0; while(ang.y < 360) { - dir = eX * cos(ang.y * DEG2RAD) + eY * sin(ang.y * DEG2RAD); + dir = vec2(cos(ang.y * DEG2RAD), sin(ang.y * DEG2RAD)); dir *= 500; traceline(this.origin, this.origin - dir, MOVE_WORLDONLY, this); if(trace_fraction > best_trace_fraction) @@ -868,7 +862,7 @@ void ons_camSetup(entity this) WriteAngle(MSG_ALL, cam.angles_z); } -void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { if(damage <= 0) return; if(warmup_stage || game_stopped) return; @@ -911,7 +905,7 @@ void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float d else { Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_GENDESTROYED)); - PlayerScore_Add(attacker, SP_SCORE, 100); + GameRules_scoring_add(attacker, SCORE, 100); } this.iscaptured = false; this.islinked = false; @@ -1081,46 +1075,52 @@ int total_generators; void Onslaught_count_generators() { entity e; - total_generators = redowned = blueowned = yellowowned = pinkowned = 0; + total_generators = 0; + for (int i = 1; i <= NUM_TEAMS; ++i) + { + Team_SetNumberOfControlPoints(Team_GetTeamFromIndex(i), 0); + } for(e = ons_worldgeneratorlist; e; e = e.ons_worldgeneratornext) { ++total_generators; - redowned += (e.team == NUM_TEAM_1 && e.health > 0); - blueowned += (e.team == NUM_TEAM_2 && e.health > 0); - yellowowned += (e.team == NUM_TEAM_3 && e.health > 0); - pinkowned += (e.team == NUM_TEAM_4 && e.health > 0); + if (GetResourceAmount(e, RESOURCE_HEALTH) < 1) + { + continue; + } + entity team_ = Entity_GetTeam(e); + int num_control_points = Team_GetNumberOfControlPoints(team_); + ++num_control_points; + Team_SetNumberOfControlPoints(team_, num_control_points); } } int Onslaught_GetWinnerTeam() { int winner_team = 0; - if(redowned > 0) - winner_team = NUM_TEAM_1; - if(blueowned > 0) + if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(1)) >= 1) { - if(winner_team) return 0; - winner_team = NUM_TEAM_2; + winner_team = NUM_TEAM_1; } - if(yellowowned > 0) + for (int i = 2; i <= NUM_TEAMS; ++i) { - if(winner_team) return 0; - winner_team = NUM_TEAM_3; + if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(i)) >= 1) + { + if (winner_team != 0) + { + return 0; + } + winner_team = Team_IndexToTeam(i); + } } - if(pinkowned > 0) + if (winner_team) { - if(winner_team) return 0; - winner_team = NUM_TEAM_4; - } - if(winner_team) return winner_team; + } return -1; // no generators left? } void nades_Clear(entity e); -#define ONS_OWNED_GENERATORS() ((redowned > 0) + (blueowned > 0) + (yellowowned > 0) + (pinkowned > 0)) -#define ONS_OWNED_GENERATORS_OK() (ONS_OWNED_GENERATORS() > 1) bool Onslaught_CheckWinner() { if ((autocvar_timelimit && time > game_starttime + autocvar_timelimit * 60) || (round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)) @@ -1155,7 +1155,7 @@ bool Onslaught_CheckWinner() else d = d * tmp_entity.max_health / max(30, 60 * autocvar_timelimit_suddendeath); - Damage(tmp_entity, tmp_entity, tmp_entity, d, DEATH_HURTTRIGGER.m_id, tmp_entity.origin, '0 0 0'); + Damage(tmp_entity, tmp_entity, tmp_entity, d, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, tmp_entity.origin, '0 0 0'); tmp_entity.sprite.SendFlags |= 16; @@ -1166,8 +1166,10 @@ bool Onslaught_CheckWinner() Onslaught_count_generators(); - if(ONS_OWNED_GENERATORS_OK()) + if (Team_GetNumberOfTeamsWithControlPoints() > 1) + { return 0; + } int winner_team = Onslaught_GetWinnerTeam(); @@ -1308,7 +1310,7 @@ void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale continue; // Ignore owned controlpoints - if(!(cp2.isgenneighbor[this.team] || cp2.iscpneighbor[this.team])) + if(!((cp2.aregensneighbor & BIT(this.team)) || (cp2.arecpsneighbor & BIT(this.team)))) continue; // Count team mates interested in this control point @@ -1377,8 +1379,8 @@ void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale best.cnt += 1; this.havocbot_attack_time = 0; - if(checkpvs(this.view_ofs,cp)) - if(checkpvs(this.view_ofs,best)) + if(checkpvs(this.origin + this.view_ofs, cp)) + if(checkpvs(this.origin + this.view_ofs, best)) this.havocbot_attack_time = time + 2; } else @@ -1448,8 +1450,8 @@ bool havocbot_goalrating_ons_generator_attack(entity this, float ratingscale) bestwp.cnt += 1; this.havocbot_attack_time = 0; - if(checkpvs(this.view_ofs,g)) - if(checkpvs(this.view_ofs,bestwp)) + if(checkpvs(this.origin + this.view_ofs, g)) + if(checkpvs(this.origin + this.view_ofs, bestwp)) this.havocbot_attack_time = time + 5; return true; @@ -1488,7 +1490,7 @@ void havocbot_role_ons_offense(entity this) if(this.havocbot_attack_time>time) return; - if (this.bot_strategytime < time) + if (navigation_goalrating_timeout(this)) { navigation_goalrating_start(this); havocbot_goalrating_enemyplayers(this, 20000, this.origin, 650); @@ -1497,7 +1499,7 @@ void havocbot_role_ons_offense(entity this) havocbot_goalrating_ons_offenseitems(this, 10000, this.origin, 10000); navigation_goalrating_end(this); - this.bot_strategytime = time + autocvar_bot_ai_strategyinterval; + navigation_goalrating_timeout_set(this); } } @@ -1928,17 +1930,14 @@ MUTATOR_HOOKFUNCTION(ons, HavocBot_ChooseRole) return true; } -MUTATOR_HOOKFUNCTION(ons, CheckAllowedTeams) +MUTATOR_HOOKFUNCTION(ons, TeamBalance_CheckAllowedTeams) { // onslaught is special for(entity tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext) { - switch(tmp_entity.team) + if (Team_IsValidTeam(tmp_entity.team)) { - case NUM_TEAM_1: c1 = 0; break; - case NUM_TEAM_2: c2 = 0; break; - case NUM_TEAM_3: c3 = 0; break; - case NUM_TEAM_4: c4 = 0; break; + M_ARGV(0, float) |= Team_TeamToBit(tmp_entity.team); } } @@ -2168,17 +2167,14 @@ spawnfunc(onslaught_generator) // scoreboard setup void ons_ScoreRules() { - CheckAllowedTeams(NULL); - int teams = 0; - if(c1 >= 0) teams |= BIT(0); - if(c2 >= 0) teams |= BIT(1); - if(c3 >= 0) teams |= BIT(2); - if(c4 >= 0) teams |= BIT(3); - ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true); - ScoreInfo_SetLabel_TeamScore (ST_ONS_CAPS, "destroyed", SFL_SORT_PRIO_PRIMARY); - ScoreInfo_SetLabel_PlayerScore(SP_ONS_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); - ScoreInfo_SetLabel_PlayerScore(SP_ONS_TAKES, "takes", 0); - ScoreRules_basics_end(); + entity balance = TeamBalance_CheckAllowedTeams(NULL); + int teams = TeamBalance_GetAllowedTeams(balance); + TeamBalance_Destroy(balance); + GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, { + field_team(ST_ONS_CAPS, "destroyed", SFL_SORT_PRIO_PRIMARY); + field(SP_ONS_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); + field(SP_ONS_TAKES, "takes", 0); + }); } void ons_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up