X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fnades%2Fnades.qc;h=38510ac00d6ed61cd6e759c2680a9bcc7082c9b3;hb=0a980f57412cf2253cfd73c8c01a26fb04c87189;hp=8faebab0b07955b84908d506503ed8b9543bbd96;hpb=011697b6da16f1d95db88065ab99f38d5828cfd8;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 8faebab0b..38510ac00 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -38,10 +38,19 @@ entity Nade_TrailEffect(int proj, int nade_team) REGISTER_MUTATOR(cl_nades, true); MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay) { - if (STAT(HEALING_ORB) <= time) return false; - M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color; - M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA); - return true; + if (STAT(HEALING_ORB) > time) + { + M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color; + M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA); + return true; + } + if (STAT(ENTRAP_ORB) > time) + { + M_ARGV(0, vector) = NADE_TYPE_ENTRAP.m_color; + M_ARGV(1, float) = STAT(ENTRAP_ORB_ALPHA); + return true; + } + return false; } MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile) { @@ -85,7 +94,7 @@ MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile) proj.maxs = '16 16 16'; } proj.colormod = nade_type.m_color; - proj.move_movetype = MOVETYPE_BOUNCE; + set_movetype(proj, MOVETYPE_BOUNCE); settouch(proj, func_null); proj.scale = 1.5; proj.avelocity = randomvec() * 720; @@ -154,7 +163,7 @@ void nade_timer_think(entity this) this.skin = 8 - (this.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10); this.nextthink = time; if(!this.owner || wasfreed(this.owner)) - remove(this); + delete(this); } void nade_burn_spawn(entity _nade) @@ -223,13 +232,13 @@ void napalm_ball_think(entity this) if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) { - remove(this); + delete(this); return; } if(time > this.pushltime) { - remove(this); + delete(this); return; } @@ -264,7 +273,7 @@ void nade_napalm_ball(entity this) proj.team = this.owner.team; proj.bot_dodge = true; proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage; - proj.movetype = MOVETYPE_BOUNCE; + set_movetype(proj, MOVETYPE_BOUNCE); proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id; PROJECTILE_MAKETRIGGER(proj); setmodel(proj, MDL_Null); @@ -297,13 +306,13 @@ void napalm_fountain_think(entity this) if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) { - remove(this); + delete(this); return; } if(time >= this.ltime) { - remove(this); + delete(this); return; } @@ -347,7 +356,7 @@ void nade_napalm_boom(entity this) fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime; fountain.pushltime = fountain.ltime; fountain.team = this.team; - fountain.movetype = MOVETYPE_TOSS; + set_movetype(fountain, MOVETYPE_TOSS); fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id; fountain.bot_dodge = true; fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage; @@ -370,7 +379,7 @@ void nade_ice_think(entity this) if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) { - remove(this); + delete(this); return; } @@ -383,11 +392,11 @@ void nade_ice_think(entity this) sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, - autocvar_g_nades_nade_radius, this, world, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy); + autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy); Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this); } - remove(this); + delete(this); return; } @@ -417,16 +426,13 @@ void nade_ice_think(entity this) float current_freeze_time = this.ltime - time - 0.1; - entity e; - for(e = findradius(this.origin, autocvar_g_nades_nade_radius); e; e = e.chain) - if(e != this) - if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(e, this.realowner) || e == this.realowner)) - if(e.takedamage && !IS_DEAD(e)) - if(e.health > 0) - if(!e.revival_time || ((time - e.revival_time) >= 1.5)) - if(!STAT(FROZEN, e)) - if(current_freeze_time > 0) - nade_ice_freeze(this, e, current_freeze_time); + FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && current_freeze_time > 0, + { + if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner)) + if(!it.revival_time || ((time - it.revival_time) >= 1.5)) + if(!STAT(FROZEN, it)) + nade_ice_freeze(this, it, current_freeze_time); + }); } void nade_ice_boom(entity this) @@ -442,7 +448,7 @@ void nade_ice_boom(entity this) fountain.ltime = time + autocvar_g_nades_ice_freeze_time; fountain.pushltime = fountain.wait = fountain.ltime; fountain.team = this.team; - fountain.movetype = MOVETYPE_TOSS; + set_movetype(fountain, MOVETYPE_TOSS); fountain.projectiledeathtype = DEATH_NADE_ICE.m_id; fountain.bot_dodge = false; setsize(fountain, '-16 -16 -16', '16 16 16'); @@ -488,7 +494,7 @@ void nade_spawn_boom(entity this) entity spawnloc = spawn(); setorigin(spawnloc, this.origin); setsize(spawnloc, this.realowner.mins, this.realowner.maxs); - spawnloc.movetype = MOVETYPE_NONE; + set_movetype(spawnloc, MOVETYPE_NONE); spawnloc.solid = SOLID_NOT; spawnloc.drawonlytoclient = this.realowner; spawnloc.effects = EF_STARDUST; @@ -496,18 +502,18 @@ void nade_spawn_boom(entity this) if(this.realowner.nade_spawnloc) { - remove(this.realowner.nade_spawnloc); - this.realowner.nade_spawnloc = world; + delete(this.realowner.nade_spawnloc); + this.realowner.nade_spawnloc = NULL; } this.realowner.nade_spawnloc = spawnloc; } -void nade_heal_think(entity this) +void nades_orb_think(entity this) { if(time >= this.ltime) { - remove(this); + delete(this); return; } @@ -522,72 +528,125 @@ void nade_heal_think(entity this) this.nade_show_particles = 0; } -void nade_heal_touch(entity this) +entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad) +{ + // NOTE: this function merely places an orb + // you must add a custom touch function to the returned entity if desired + // also set .colormod if you wish to have it colorized + entity orb = spawn(); // Net_LinkEntity sets the classname (TODO) + orb.owner = own; + orb.realowner = realown; + setorigin(orb, org); + + orb.orb_lifetime = orb_ltime; // required for timers + orb.ltime = time + orb.orb_lifetime; + orb.bot_dodge = false; + orb.team = realown.team; + orb.solid = SOLID_TRIGGER; + + setmodel(orb, MDL_NADE_ORB); + orb.skin = 1; + orb.orb_radius = orb_rad; // required for fading + vector size = '1 1 1' * orb.orb_radius / 2; + setsize(orb, -size, size); + + Net_LinkEntity(orb, true, 0, orb_send); + orb.SendFlags |= 1; + + setthink(orb, nades_orb_think); + orb.nextthink = time; + + return orb; +} + +void nade_entrap_touch(entity this, entity toucher) +{ + if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects? + { + if (!isPushable(toucher)) + return; + + float pushdeltatime = time - toucher.lastpushtime; + if (pushdeltatime > 0.15) pushdeltatime = 0; + toucher.lastpushtime = time; + if(!pushdeltatime) return; + + // div0: ticrate independent, 1 = identity (not 20) + toucher.velocity = toucher.velocity * pow(autocvar_g_nades_entrap_strength, pushdeltatime); + + #ifdef SVQC + UpdateCSQCProjectile(toucher); + #endif + } + + if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) ) + { + entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher; + STAT(ENTRAP_ORB, show_tint) = time + 0.1; + + float tint_alpha = 0.75; + if(SAME_TEAM(toucher, this.realowner)) + tint_alpha = 0.45; + STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime; + } +} + +void nade_entrap_boom(entity this) +{ + entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius); + + settouch(orb, nade_entrap_touch); + orb.colormod = NADE_TYPE_ENTRAP.m_color; +} + +void nade_heal_touch(entity this, entity toucher) { float maxhealth; float health_factor; - if(IS_PLAYER(other) || IS_MONSTER(other)) - if(!IS_DEAD(other)) - if(!STAT(FROZEN, other)) + if(IS_PLAYER(toucher) || IS_MONSTER(toucher)) + if(!IS_DEAD(toucher)) + if(!STAT(FROZEN, toucher)) { health_factor = autocvar_g_nades_heal_rate*frametime/2; - if ( other != this.realowner ) + if ( toucher != this.realowner ) { - if ( SAME_TEAM(other,this) ) + if ( SAME_TEAM(toucher,this) ) health_factor *= autocvar_g_nades_heal_friend; else health_factor *= autocvar_g_nades_heal_foe; } if ( health_factor > 0 ) { - maxhealth = (IS_MONSTER(other)) ? other.max_health : g_pickup_healthmega_max; - if ( other.health < maxhealth ) + maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max; + if ( toucher.health < maxhealth ) { if ( this.nade_show_particles ) - Send_Effect(EFFECT_HEALING, other.origin, '0 0 0', 1); - other.health = min(other.health+health_factor, maxhealth); + Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1); + toucher.health = min(toucher.health+health_factor, maxhealth); } - other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot); + toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot); } else if ( health_factor < 0 ) { - Damage(other,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,other.origin,'0 0 0'); + Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,toucher.origin,'0 0 0'); } } - if ( IS_REAL_CLIENT(other) || IS_VEHICLE(other) ) + if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) ) { - entity show_red = (IS_VEHICLE(other)) ? other.owner : other; + entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher; show_red.stat_healing_orb = time+0.1; - show_red.stat_healing_orb_alpha = 0.75 * (this.ltime - time) / this.healer_lifetime; + show_red.stat_healing_orb_alpha = 0.75 * (this.ltime - time) / this.orb_lifetime; } } void nade_heal_boom(entity this) { - entity healer; - healer = spawn(); - healer.owner = this.owner; - healer.realowner = this.realowner; - setorigin(healer, this.origin); - healer.healer_lifetime = autocvar_g_nades_heal_time; // save the cvar - healer.ltime = time + healer.healer_lifetime; - healer.team = this.realowner.team; - healer.bot_dodge = false; - healer.solid = SOLID_TRIGGER; - settouch(healer, nade_heal_touch); - - setmodel(healer, MDL_NADE_HEAL); - healer.healer_radius = autocvar_g_nades_nade_radius; - vector size = '1 1 1' * healer.healer_radius / 2; - setsize(healer,-size,size); - - Net_LinkEntity(healer, true, 0, healer_send); - - setthink(healer, nade_heal_think); - healer.nextthink = time; - healer.SendFlags |= 1; + entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius); + + settouch(orb, nade_heal_touch); + orb.colormod = '1 0 0'; } void nade_monster_boom(entity this) @@ -634,6 +693,11 @@ void nade_boom(entity this) expef = EFFECT_SPAWN_RED; break; + case NADE_TYPE_ENTRAP: + nade_blast = false; + expef = EFFECT_SPAWN_YELLOW; + break; + default: case NADE_TYPE_NORMAL: expef = EFFECT_NADE_EXPLODE(this.realowner.team); @@ -651,7 +715,7 @@ void nade_boom(entity this) if(nade_blast) { RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, - autocvar_g_nades_nade_radius, this, world, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy); + autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy); Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this); } @@ -664,6 +728,7 @@ void nade_boom(entity this) case NADE_TYPE_SPAWN: nade_spawn_boom(this); break; case NADE_TYPE_HEAL: nade_heal_boom(this); break; case NADE_TYPE_MONSTER: nade_monster_boom(this); break; + case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break; } FOREACH_ENTITY_ENT(aiment, this, @@ -672,7 +737,7 @@ void nade_boom(entity this) RemoveGrapplingHook(it.realowner); }); - remove(this); + delete(this); } void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype); @@ -689,24 +754,24 @@ void nade_pickup(entity this, entity thenade) } bool CanThrowNade(entity this); -void nade_touch(entity this) +void nade_touch(entity this, entity toucher) { - if(other) + if(toucher) UpdateCSQCProjectile(this); - if(other == this.realowner) + if(toucher == this.realowner) return; // no this impacts if(autocvar_g_nades_pickup) if(time >= this.spawnshieldtime) - if(!other.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much - if(!other.frozen) - if(CanThrowNade(other)) // prevent some obvious things, like dead players - if(IS_REAL_CLIENT(other)) // above checks for IS_PLAYER, don't need to do it here + if(!toucher.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much + if(!STAT(FROZEN, toucher)) + if(CanThrowNade(toucher)) // prevent some obvious things, like dead players + if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here { - nade_pickup(other, this); + nade_pickup(toucher, this); sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); - remove(this); + delete(this); return; } /*float is_weapclip = 0; @@ -721,11 +786,11 @@ void nade_touch(entity this) if(it.classname == "grapplinghook") RemoveGrapplingHook(it.realowner); }); - remove(this); + delete(this); return; } - PROJECTILE_TOUCH(this); + PROJECTILE_TOUCH(this, toucher); //setsize(this, '-2 -2 -2', '2 2 2'); //UpdateCSQCProjectile(this); @@ -735,7 +800,7 @@ void nade_touch(entity this) return; } - this.enemy = other; + this.enemy = toucher; nade_boom(this); } @@ -813,14 +878,14 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i void toss_nade(entity e, bool set_owner, vector _velocity, float _time) { - if(e.nade == world) + if(e.nade == NULL) return; entity _nade = e.nade; - e.nade = world; + e.nade = NULL; - remove(e.fake_nade); - e.fake_nade = world; + delete(e.fake_nade); + e.fake_nade = NULL; makevectors(e.v_angle); @@ -836,13 +901,13 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time) setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1); //setmodel(_nade, MDL_PROJECTILE_NADE); - //setattachment(_nade, world, ""); + //setattachment(_nade, NULL, ""); PROJECTILE_MAKETRIGGER(_nade); if(STAT(NADES_SMALL, e)) setsize(_nade, '-8 -8 -8', '8 8 8'); else setsize(_nade, '-16 -16 -16', '16 16 16'); - _nade.movetype = MOVETYPE_BOUNCE; + set_movetype(_nade, MOVETYPE_BOUNCE); tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade); if (trace_startsolid) @@ -867,7 +932,7 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time) _nade.takedamage = DAMAGE_AIM; _nade.event_damage = nade_damage; setcefc(_nade, func_null); - _nade.exteriormodeltoclient = world; + _nade.exteriormodeltoclient = NULL; _nade.traileffectnum = 0; _nade.teleportable = true; _nade.pushable = true; @@ -932,10 +997,10 @@ MUTATOR_HOOKFUNCTION(nades, PutClientInServer) nades_RemoveBonus(player); } -float nade_customize(entity this) +bool nade_customize(entity this, entity client) { - //if(IS_SPEC(other)) { return false; } - if(other == this.exteriormodeltoclient || (IS_SPEC(other) && other.enemy == this.exteriormodeltoclient)) + //if(IS_SPEC(client)) { return false; } + if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient)) { // somewhat hide the model, but keep the glow //this.effects = 0; @@ -1000,10 +1065,10 @@ void nade_prime(entity this) return; // only allow bonus nades if(this.nade) - remove(this.nade); + delete(this.nade); if(this.fake_nade) - remove(this.fake_nade); + delete(this.fake_nade); int ntype; string pntype = this.pokenade_type; @@ -1084,11 +1149,11 @@ void nades_CheckThrow(entity this) void nades_Clear(entity player) { if(player.nade) - remove(player.nade); + delete(player.nade); if(player.fake_nade) - remove(player.fake_nade); + delete(player.fake_nade); - player.nade = player.fake_nade = world; + player.nade = player.fake_nade = NULL; player.nade_timer = 0; } @@ -1197,7 +1262,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) } float n = 0; - entity o = world; + entity o = NULL; if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout) n = -1; else @@ -1239,6 +1304,28 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) } } +MUTATOR_HOOKFUNCTION(nades, PlayerPhysics) +{ + entity player = M_ARGV(0, entity); + + if (STAT(ENTRAP_ORB, player) > time) + { + player.stat_sv_maxspeed *= autocvar_g_nades_entrap_speed; + player.stat_sv_airspeedlimit_nonqw *= autocvar_g_nades_entrap_speed; + } +} + +MUTATOR_HOOKFUNCTION(nades, MonsterMove) +{ + entity mon = M_ARGV(0, entity); + + if (STAT(ENTRAP_ORB, mon) > time) + { + M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed + M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed + } +} + MUTATOR_HOOKFUNCTION(nades, PlayerSpawn) { entity player = M_ARGV(0, entity); @@ -1262,8 +1349,8 @@ MUTATOR_HOOKFUNCTION(nades, PlayerSpawn) if(player.nade_spawnloc.cnt <= 0) { - remove(player.nade_spawnloc); - player.nade_spawnloc = world; + delete(player.nade_spawnloc); + player.nade_spawnloc = NULL; } } } @@ -1321,7 +1408,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate) Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3); M_ARGV(4, float) = 0; M_ARGV(6, vector) = '0 0 0'; - Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname); Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF); } } @@ -1373,6 +1460,8 @@ MUTATOR_HOOKFUNCTION(nades, SpectateCopy) client.bonus_nade_score = spectatee.bonus_nade_score; client.stat_healing_orb = spectatee.stat_healing_orb; client.stat_healing_orb_alpha = spectatee.stat_healing_orb_alpha; + STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee); + STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee); } REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");