X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fgamemodes%2Fgamemode%2Fnexball%2Fnexball.qc;h=07479cc19714a13487c7ed49fc49ae41bc93e089;hb=2300937585fd409c578a516ed5e051ba389646d4;hp=6ef9ca5ab66fec9fcd082ff0a5333a69622b894f;hpb=8cbf0e84432e075e617f43c037c645ea9846eba0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 6ef9ca5ab..07479cc19 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -52,8 +52,8 @@ float autocvar_g_balance_nexball_secondary_lifetime; float autocvar_g_balance_nexball_secondary_refire; float autocvar_g_balance_nexball_secondary_speed; -void basketball_touch(entity this); -void football_touch(entity this); +void basketball_touch(entity this, entity toucher); +void football_touch(entity this, entity toucher); void ResetBall(entity this); const int NBM_NONE = 0; const int NBM_FOOTBALL = 2; @@ -63,7 +63,7 @@ float nexball_mode; float OtherTeam(float t) //works only if there are two teams on the map! { entity e; - e = find(world, classname, "nexball_team"); + e = find(NULL, classname, "nexball_team"); if(e.team == t) e = find(e, classname, "nexball_team"); return e.team; @@ -87,7 +87,7 @@ void LogNB(string mode, entity actor) if(!autocvar_sv_eventlog) return; s = strcat(":nexball:", mode); - if(actor != world) + if(actor != NULL) s = strcat(s, ":", ftos(actor.playerid)); GameLogEcho(s); } @@ -150,7 +150,7 @@ void GiveBall(entity plyr, entity ball) if(ownr) { ownr.effects &= ~autocvar_g_nexball_basketball_effects_default; - ownr.ballcarried = world; + ownr.ballcarried = NULL; if(ownr.metertime) { ownr.metertime = 0; @@ -207,7 +207,7 @@ void DropBall(entity ball, vector org, vector vel) ball.effects &= ~EF_NOSHADOW; ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default; - setattachment(ball, world, ""); + setattachment(ball, NULL, ""); setorigin(ball, org); ball.movetype = MOVETYPE_BOUNCE; UNSET_ONGROUND(ball); @@ -226,11 +226,11 @@ void DropBall(entity ball, vector org, vector vel) } WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier); - WaypointSprite_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please + 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 = world; - ball.owner = world; + ball.owner.ballcarried = NULL; + ball.owner = NULL; } void InitBall(entity this) @@ -246,11 +246,11 @@ void InitBall(entity this) setthink(this, ResetBall); this.nextthink = time + autocvar_g_nexball_delay_idle + 3; this.teamtime = 0; - this.pusher = world; + this.pusher = NULL; this.team = false; _sound(this, CH_TRIGGER, this.noise1, VOL_BASE, ATTEN_NORM); WaypointSprite_Ping(this.waypointsprite_attachedforcarrier); - LogNB("init", world); + LogNB("init", NULL); } void ResetBall(entity this) @@ -264,7 +264,7 @@ void ResetBall(entity this) this.movetype = MOVETYPE_NOCLIP; this.velocity = '0 0 0'; // just in case? if(!this.cnt) - LogNB("resetidle", world); + LogNB("resetidle", NULL); this.cnt = 2; this.nextthink = time; } @@ -278,7 +278,7 @@ void ResetBall(entity this) else // step 4 { // dprint("Step 4: time: ", ftos(time), "\n"); - if(vlen(this.origin - this.spawnorigin) > 10) // should not happen anymore + if(vdist(this.origin - this.spawnorigin, >, 10)) // should not happen anymore LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ", vtos(this.origin - this.spawnorigin), " Velocity: ", vtos(this.velocity), "\n"); this.velocity = '0 0 0'; @@ -289,9 +289,9 @@ void ResetBall(entity this) } } -void football_touch(entity this) +void football_touch(entity this, entity toucher) { - if(other.solid == SOLID_BSP) + if(toucher.solid == SOLID_BSP) { if(time > this.lastground + 0.1) { @@ -302,78 +302,78 @@ void football_touch(entity this) this.nextthink = time + autocvar_g_nexball_delay_idle; return; } - if (!IS_PLAYER(other)) + if (!IS_PLAYER(toucher)) return; - if(other.health < 1) + if(toucher.health < 1) return; if(!this.cnt) this.nextthink = time + autocvar_g_nexball_delay_idle; - this.pusher = other; - this.team = other.team; + this.pusher = toucher; + this.team = toucher.team; if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original { - if(vlen(other.velocity)) - this.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up; + if(toucher.velocity) + this.velocity = toucher.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up; } else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point { - makevectors(other.v_angle); - this.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up; + makevectors(toucher.v_angle); + this.velocity = toucher.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up; } else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable! { - makevectors(other.v_angle.y * '0 1 0'); - this.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up; + makevectors(toucher.v_angle.y * '0 1 0'); + this.velocity = toucher.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up; } else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant) { - makevectors(other.v_angle); - this.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up; + makevectors(toucher.v_angle); + this.velocity = toucher.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up; } this.avelocity = -250 * v_forward; // maybe there is a way to make it look better? } -void basketball_touch(entity this) +void basketball_touch(entity this, entity toucher) { - if(other.ballcarried) + if(toucher.ballcarried) { - football_touch(this); + football_touch(this, toucher); return; } - if(!this.cnt && IS_PLAYER(other) && !STAT(FROZEN, other) && !IS_DEAD(other) && (other != this.nb_dropper || time > this.nb_droptime + autocvar_g_nexball_delay_collect)) + if(!this.cnt && IS_PLAYER(toucher) && !STAT(FROZEN, toucher) && !IS_DEAD(toucher) && (toucher != this.nb_dropper || time > this.nb_droptime + autocvar_g_nexball_delay_collect)) { - if(other.health <= 0) + if(toucher.health <= 0) return; - LogNB("caught", other); - GiveBall(other, this); + LogNB("caught", toucher); + GiveBall(toucher, this); } - else if(other.solid == SOLID_BSP) + else if(toucher.solid == SOLID_BSP) { _sound(this, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM); - if(vlen(this.velocity) && !this.cnt) + if(this.velocity && !this.cnt) this.nextthink = min(time + autocvar_g_nexball_delay_idle, this.teamtime); } } -void GoalTouch(entity this) +void GoalTouch(entity this, entity toucher) { entity ball; float isclient, pscore, otherteam; string pname; if(gameover) return; - if((this.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried) - ball = other.ballcarried; + if((this.spawnflags & GOAL_TOUCHPLAYER) && toucher.ballcarried) + ball = toucher.ballcarried; else - ball = other; + ball = toucher; if(ball.classname != "nexball_basketball") if(ball.classname != "nexball_football") return; if((!ball.pusher && this.team != GOAL_OUT) || ball.cnt) return; - EXACTTRIGGER_TOUCH; + EXACTTRIGGER_TOUCH(this, toucher); if(nb_teams == 2) @@ -473,7 +473,7 @@ void nb_spawnteams() { bool t_red = false, t_blue = false, t_yellow = false, t_pink = false; entity e; - for(e = world; (e = find(e, classname, "nexball_goal"));) + for(e = NULL; (e = find(e, classname, "nexball_goal"));) { switch(e.team) { @@ -511,7 +511,7 @@ void nb_spawnteams() void nb_delayedinit(entity this) { - if(find(world, classname, "nexball_team") == world) + if(find(NULL, classname, "nexball_team") == NULL) nb_spawnteams(); nb_ScoreRules(nb_teams); } @@ -609,11 +609,10 @@ spawnfunc(nexball_football) SpawnBall(this); } -float nb_Goal_Customize(entity this) +bool nb_Goal_Customize(entity this, entity client) { - entity e, wp_owner; - e = WaypointSprite_getviewentity(other); - wp_owner = this.owner; + entity e = WaypointSprite_getviewentity(client); + entity wp_owner = this.owner; if(SAME_TEAM(e, wp_owner)) { return false; } return true; @@ -730,32 +729,32 @@ void W_Nexball_Think(entity this) this.nextthink = time; } -void W_Nexball_Touch(entity this) +void W_Nexball_Touch(entity this, entity toucher) { entity ball, attacker; attacker = this.owner; //this.think = func_null; - //this.enemy = world; + //this.enemy = NULL; - PROJECTILE_TOUCH(this); - if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal) - if((ball = other.ballcarried) && !STAT(FROZEN, other) && !IS_DEAD(other) && (IS_PLAYER(attacker))) + PROJECTILE_TOUCH(this, toucher); + if(attacker.team != toucher.team || autocvar_g_nexball_basketball_teamsteal) + if((ball = toucher.ballcarried) && !STAT(FROZEN, toucher) && !IS_DEAD(toucher) && (IS_PLAYER(attacker))) { - other.velocity = other.velocity + normalize(this.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force; - UNSET_ONGROUND(other); + toucher.velocity = toucher.velocity + normalize(this.velocity) * toucher.damageforcescale * autocvar_g_balance_nexball_secondary_force; + UNSET_ONGROUND(toucher); if(!attacker.ballcarried) { LogNB("stole", attacker); - _sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM); + _sound(toucher, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM); - if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain) + if(SAME_TEAM(attacker, toucher) && time > attacker.teamkill_complain) { attacker.teamkill_complain = time + 5; attacker.teamkill_soundtime = time + 0.4; - attacker.teamkill_soundsource = other; + attacker.teamkill_soundsource = toucher; } - GiveBall(attacker, other.ballcarried); + GiveBall(attacker, toucher.ballcarried); } } remove(this); @@ -769,7 +768,7 @@ void W_Nexball_Attack(entity actor, float t) return; W_SetupShot(actor, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0); - tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world); + tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, NULL); if(trace_startsolid) { if(actor.metertime) @@ -838,7 +837,7 @@ void W_Nexball_Attack2(entity actor) CSQCProjectile(missile, true, PROJECTILE_ELECTRO, true); } -float ball_customize(entity this) +bool ball_customize(entity this, entity client) { if(!this.owner) { @@ -848,7 +847,7 @@ float ball_customize(entity this) return true; } - if(other == this.owner) + if(client == this.owner) { this.scale = autocvar_g_nexball_viewmodel_scale; if(this.enemy) @@ -968,7 +967,7 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink) if(player.ballcarried.wait < time && player.ballcarried.enemy) { //centerprint(player, sprintf("Lost lock on %s", player.ballcarried.enemy.netname)); - player.ballcarried.enemy = world; + player.ballcarried.enemy = NULL; } @@ -1073,6 +1072,17 @@ MUTATOR_HOOKFUNCTION(nb, FilterItem) return false; } +MUTATOR_HOOKFUNCTION(nb, ItemTouch) +{ + entity item = M_ARGV(0, entity); + entity toucher = M_ARGV(1, entity); + + if(item.weapon && toucher.ballcarried) + return MUT_ITEMTOUCH_RETURN; // no new weapons for you, mister! + + return MUT_ITEMTOUCH_CONTINUE; +} + MUTATOR_HOOKFUNCTION(nb, GetTeamCount) { M_ARGV(1, string) = "nexball_team"; @@ -1118,7 +1128,7 @@ REGISTER_MUTATOR(nb, g_nexball) */ radar_showennemies = autocvar_g_nexball_radar_showallplayers; - InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE); + InitializeEntity(NULL, nb_delayedinit, INITPRIO_GAMETYPE); WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED; ActivateTeamplay();