X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fshockwave.qc;h=8fe3a4866e941f66e4abd5ac0aac183f25fc7151;hp=b190cce69f11271046de2ba7cb21a1df957f7dfb;hb=991de5e6922cd3c283de56c3249624f0f1bfe767;hpb=83e2013a3aa40f8e5cfeac82e83c9abdd7a038b8 diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index b190cce69f..8fe3a4866e 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -3,16 +3,14 @@ REGISTER_NET_TEMP(TE_CSQC_SHOCKWAVEPARTICLE) #ifdef SVQC -spawnfunc(weapon_shockwave) +METHOD(Shockwave, m_spawnfunc_hookreplace, Weapon(Shockwave this, entity e)) { //if(autocvar_sv_q3acompat_machineshockwaveswap) // WEAPONTODO - if(autocvar_sv_q3acompat_machineshotgunswap) - if(this.classname != "droppedweapon") + if (autocvar_sv_q3acompat_machineshotgunswap && !Item_IsLoot(e)) { - weapon_defaultspawnfunc(this, WEP_MACHINEGUN); - return; + return WEP_MACHINEGUN; } - weapon_defaultspawnfunc(this, WEP_SHOCKWAVE); + return this; } const float MAX_SHOCKWAVE_HITS = 10; @@ -101,23 +99,24 @@ void W_Shockwave_Melee_Think(entity this) this.realowner, swing_damage, (WEP_SHOCKWAVE.m_id | HITTYPE_SECONDARY), + this.weaponentity_fld, (this.realowner.origin + this.realowner.view_ofs), (v_forward * WEP_CVAR(shockwave, melee_force)) ); // handle accuracy if(accuracy_isgooddamage(this.realowner, target_victim)) - { accuracy_add(this.realowner, WEP_SHOCKWAVE.m_id, 0, swing_damage); } + { accuracy_add(this.realowner, WEP_SHOCKWAVE, 0, swing_damage); } #ifdef DEBUG_SHOCKWAVE - LOG_INFO(sprintf( - "MELEE: %s hitting %s with %f damage (factor: %f) at %f time.\n", + LOG_INFOF( + "MELEE: %s hitting %s with %f damage (factor: %f) at %f time.", this.realowner.netname, target_victim.netname, swing_damage, swing_factor, time - )); + ); #endif // allow multiple hits with one swing, but not against the same player twice @@ -157,7 +156,8 @@ void W_Shockwave_Melee(Weapon thiswep, entity actor, .entity weaponentity, int f meleetemp.owner = meleetemp.realowner = actor; setthink(meleetemp, W_Shockwave_Melee_Think); meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor(actor); - W_SetupShot_Range(actor, weaponentity, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range)); + meleetemp.weaponentity_fld = weaponentity; + W_SetupShot_Range(actor, weaponentity, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range), thiswep.m_id | HITTYPE_SECONDARY); } // SHOCKWAVE ATTACK MODE @@ -257,19 +257,15 @@ float W_Shockwave_Attack_CheckHit( void W_Shockwave_Send(entity actor) { WriteHeader(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE); - WriteCoord(MSG_BROADCAST, w_shotorg.x); - WriteCoord(MSG_BROADCAST, w_shotorg.y); - WriteCoord(MSG_BROADCAST, w_shotorg.z); - WriteCoord(MSG_BROADCAST, w_shotdir.x); - WriteCoord(MSG_BROADCAST, w_shotdir.y); - WriteCoord(MSG_BROADCAST, w_shotdir.z); + WriteVector(MSG_BROADCAST, w_shotorg); + WriteVector(MSG_BROADCAST, w_shotdir); WriteShort(MSG_BROADCAST, WEP_CVAR(shockwave, blast_distance)); WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_max), 255)); WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_min), 255)); WriteByte(MSG_BROADCAST, etof(actor)); } -void W_Shockwave_Attack(entity actor, .entity weaponentity) +void W_Shockwave_Attack(Weapon thiswep, entity actor, .entity weaponentity) { // declarations float multiplier, multiplier_from_accuracy, multiplier_from_distance; @@ -280,7 +276,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity) float i, queue = 0; // set up the shot direction - W_SetupShot(actor, weaponentity, true, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage)); + W_SetupShot(actor, weaponentity, true, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage), thiswep.m_id); vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance))); WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, actor); vector attack_hitpos = trace_endpos; @@ -296,7 +292,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity) WEP_CVAR(shockwave, blast_splash_edgedamage), WEP_CVAR(shockwave, blast_splash_radius), w_shotdir * WEP_CVAR(shockwave, blast_splash_force), - WEP_SHOCKWAVE.m_id, + thiswep.m_id, 0, actor ); @@ -318,13 +314,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity) if(autocvar_g_antilag == 0 || noantilag) lag = 0; // only do hitscan, but no antilag if(lag) - { - FOREACH_CLIENT(IS_PLAYER(it) && it != actor, antilag_takeback(it, CS(it), time - lag)); - IL_EACH(g_monsters, it != actor, - { - antilag_takeback(it, it, time - lag); - }); - } + antilag_takeback_all(actor, lag); while(head) { @@ -391,21 +381,22 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity) actor, actor, final_damage, - WEP_SHOCKWAVE.m_id, + thiswep.m_id, + weaponentity, head.origin, final_force ); #ifdef DEBUG_SHOCKWAVE - LOG_INFO(sprintf( + LOG_INFOF( "SELF HIT: multiplier = %f, damage = %f, force = %f... " - "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n", + "multiplier_from_accuracy = %f, multiplier_from_distance = %f.", multiplier, final_damage, vlen(final_force), multiplier_from_accuracy, multiplier_from_distance - )); + ); #endif } else if(distance_to_head <= WEP_CVAR(shockwave, blast_splash_radius)) @@ -460,15 +451,15 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity) if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); } #ifdef DEBUG_SHOCKWAVE - LOG_INFO(sprintf( + LOG_INFOF( "SPLASH HIT: multiplier = %f, damage = %f, force = %f... " - "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n", + "multiplier_from_accuracy = %f, multiplier_from_distance = %f.", multiplier, final_damage, vlen(final_force), multiplier_from_accuracy, multiplier_from_distance - )); + ); #endif } } @@ -549,15 +540,15 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity) if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); } #ifdef DEBUG_SHOCKWAVE - LOG_INFO(sprintf( + LOG_INFOF( "BLAST HIT: multiplier = %f, damage = %f, force = %f... " - "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n", + "multiplier_from_accuracy = %f, multiplier_from_distance = %f.", multiplier, final_damage, vlen(final_force), multiplier_from_accuracy, multiplier_from_distance - )); + ); #endif } } @@ -575,21 +566,22 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity) actor, actor, final_damage, - WEP_SHOCKWAVE.m_id, + thiswep.m_id, + weaponentity, head.origin, final_force ); if(accuracy_isgooddamage(actor, head)) - accuracy_add(actor, WEP_SHOCKWAVE.m_id, 0, final_damage); + accuracy_add(actor, thiswep, 0, final_damage); #ifdef DEBUG_SHOCKWAVE - LOG_INFO(sprintf( - "SHOCKWAVE by %s: damage = %f, force = %f.\n", + LOG_INFOF( + "SHOCKWAVE by %s: damage = %f, force = %f.", actor.netname, final_damage, vlen(final_force) - )); + ); #endif shockwave_hit[i-1] = NULL; @@ -598,13 +590,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity) } if(lag) - { - FOREACH_CLIENT(IS_PLAYER(it) && it != actor, antilag_restore(it, CS(it))); - IL_EACH(g_monsters, it != actor, - { - antilag_restore(it, it); - }); - } + antilag_restore_all(actor); } METHOD(Shockwave, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) @@ -622,7 +608,7 @@ METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponent { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(shockwave, blast_animtime))) { - W_Shockwave_Attack(actor, weaponentity); + W_Shockwave_Attack(thiswep, actor, weaponentity); actor.(weaponentity).shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready); } @@ -672,14 +658,12 @@ void Draw_Shockwave(entity this) if(a < ALPHA_MIN_VISIBLE) { delete(this); } // WEAPONTODO: save this only once when creating the entity - vector sw_color = entcs_GetColor(this.sv_entnum - 1); // GetTeamRGB(entcs_GetTeam(this.sv_entnum)); + vector sw_color = entcs_GetColor(this.sv_entnum - 1); // Team_ColorRGB(entcs_GetTeam(this.sv_entnum)); // WEAPONTODO: trace to find what we actually hit vector endpos = (this.sw_shotorg + (this.sw_shotdir * this.sw_distance)); - vectorvectors(this.sw_shotdir); - vector right = v_right; // save this for when we do makevectors later - vector up = v_up; // save this for when we do makevectors later + VECTOR_VECTORS_NEW(this.sw_shotdir, _forward, right, up); // WEAPONTODO: combine and simplify these calculations vector min_end = ((this.sw_shotorg + (this.sw_shotdir * SW_DISTTOMIN)) + (up * this.sw_spread_min)); @@ -776,8 +760,8 @@ void Net_ReadShockwaveParticle() shockwave.draw = Draw_Shockwave; IL_PUSH(g_drawables, shockwave); - shockwave.sw_shotorg_x = ReadCoord(); shockwave.sw_shotorg_y = ReadCoord(); shockwave.sw_shotorg_z = ReadCoord(); - shockwave.sw_shotdir_x = ReadCoord(); shockwave.sw_shotdir_y = ReadCoord(); shockwave.sw_shotdir_z = ReadCoord(); + shockwave.sw_shotorg = ReadVector(); + shockwave.sw_shotdir = ReadVector(); shockwave.sw_distance = ReadShort(); shockwave.sw_spread_max = ReadByte();