X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fhook.qc;h=d8cebd740ac49fc3daf8ec2c5d5111e30f27a740;hb=a3a388a32d0ea11fe79341ef44edc21c5ba460f4;hp=26c04ad4fa200f536252a5389b5dea089137932b;hpb=63de1215428d078d5fb2021c49edf59a7900cef9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 26c04ad4fa..d8cebd740a 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -1,85 +1,7 @@ #include "hook.qh" -#ifndef IMPLEMENTATION -CLASS(Hook, Weapon) -/* ammotype */ ATTRIB(Hook, ammo_field, .int, ammo_fuel); -/* impulse */ ATTRIB(Hook, impulse, int, 0); -/* flags */ ATTRIB(Hook, spawnflags, int, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); -/* rating */ ATTRIB(Hook, bot_pickupbasevalue, float, 0); -/* color */ ATTRIB(Hook, wpcolor, vector, '0 0.5 0'); -/* modelname */ ATTRIB(Hook, mdl, string, "hookgun"); -#ifdef GAMEQC -/* model */ ATTRIB(Hook, m_model, Model, MDL_HOOK_ITEM); -#endif -/* crosshair */ ATTRIB(Hook, w_crosshair, string, "gfx/crosshairhook"); -/* crosshair */ ATTRIB(Hook, w_crosshair_size, float, 0.5); -/* wepimg */ ATTRIB(Hook, model2, string, "weaponhook"); -/* refname */ ATTRIB(Hook, netname, string, "hook"); -/* wepname */ ATTRIB(Hook, m_name, string, _("Grappling Hook")); - ATTRIB(Hook, ammo_factor, float, 1); - -#define X(BEGIN, P, END, class, prefix) \ - BEGIN(class) \ - P(class, prefix, ammo, float, PRI) \ - P(class, prefix, animtime, float, BOTH) \ - P(class, prefix, damageforcescale, float, SEC) \ - P(class, prefix, damage, float, SEC) \ - P(class, prefix, duration, float, SEC) \ - P(class, prefix, edgedamage, float, SEC) \ - P(class, prefix, force, float, SEC) \ - P(class, prefix, gravity, float, SEC) \ - P(class, prefix, health, float, SEC) \ - P(class, prefix, hooked_ammo, float, PRI) \ - P(class, prefix, hooked_time_free, float, PRI) \ - P(class, prefix, hooked_time_max, float, PRI) \ - P(class, prefix, lifetime, float, SEC) \ - P(class, prefix, power, float, SEC) \ - P(class, prefix, radius, float, SEC) \ - P(class, prefix, refire, float, BOTH) \ - P(class, prefix, speed, float, SEC) \ - P(class, prefix, switchdelay_drop, float, NONE) \ - P(class, prefix, switchdelay_raise, float, NONE) \ - P(class, prefix, weaponreplace, string, NONE) \ - P(class, prefix, weaponstartoverride, float, NONE) \ - P(class, prefix, weaponstart, float, NONE) \ - P(class, prefix, weaponthrowable, float, NONE) \ - END() - W_PROPS(X, Hook, hook) -#undef X - -ENDCLASS(Hook) -REGISTER_WEAPON(HOOK, hook, NEW(Hook)); - -CLASS(OffhandHook, OffhandWeapon) -#ifdef SVQC - METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity actor, bool key_pressed)) - { - Weapon wep = WEP_HOOK; - .entity weaponentity = weaponentities[1]; - wep.wr_think(wep, actor, weaponentity, key_pressed ? 1 : 0); - } -#endif -ENDCLASS(OffhandHook) -OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(OffhandHook); } - -#ifdef SVQC -.float dmg; -.float dmg_edge; -.float dmg_radius; -.float dmg_force; -.float dmg_power; -.float dmg_duration; -.float dmg_last; -.float hook_refire; -.float hook_time_hooked; -.float hook_time_fueldecrease; -#endif -#endif -#ifdef IMPLEMENTATION #ifdef SVQC -spawnfunc(weapon_hook) { weapon_defaultspawnfunc(this, WEP_HOOK); } - void W_Hook_ExplodeThink(entity this) { float dt, dmg_remaining_next, f; @@ -90,7 +12,7 @@ void W_Hook_ExplodeThink(entity this) f = this.dmg_last - dmg_remaining_next; this.dmg_last = dmg_remaining_next; - RadiusDamage(this, this.realowner, this.dmg * f, this.dmg_edge * f, this.dmg_radius, this.realowner, NULL, this.dmg_force * f, this.projectiledeathtype, NULL); + RadiusDamage(this, this.realowner, this.dmg * f, this.dmg_edge * f, this.dmg_radius, this.realowner, NULL, this.dmg_force * f, this.projectiledeathtype, this.weaponentity_fld, NULL); this.projectiledeathtype |= HITTYPE_BOUNCE; //RadiusDamage(this, NULL, this.dmg * f, this.dmg_edge * f, this.dmg_radius, NULL, NULL, this.dmg_force * f, this.projectiledeathtype, NULL); @@ -124,17 +46,17 @@ void W_Hook_Explode2_use(entity this, entity actor, entity trigger) W_Hook_Explode2(this); } -void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { - if(this.health <= 0) + if(GetResource(this, RES_HEALTH) <= 0) return; if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions return; // g_projectiles_damage says to halt - this.health = this.health - damage; + SetResourceExplicit(this, RES_HEALTH, GetResource(this, RES_HEALTH)); - if(this.health <= 0) + if(GetResource(this, RES_HEALTH) <= 0) W_PrepareExplosionByDamage(this, this.realowner, W_Hook_Explode2); } @@ -147,7 +69,7 @@ void W_Hook_Touch2(entity this, entity toucher) void W_Hook_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { //W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb) - W_SetupShot(actor, weaponentity, false, 4, SND_HOOKBOMB_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hook, damage)); + W_SetupShot(actor, weaponentity, false, 4, SND_HOOKBOMB_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hook, damage), WEP_HOOK.m_id | HITTYPE_SECONDARY); entity gren = new(hookbomb); gren.owner = gren.realowner = actor; @@ -156,6 +78,7 @@ void W_Hook_Attack2(Weapon thiswep, entity actor, .entity weaponentity) set_movetype(gren, MOVETYPE_TOSS); PROJECTILE_MAKETRIGGER(gren); gren.projectiledeathtype = WEP_HOOK.m_id | HITTYPE_SECONDARY; + gren.weaponentity_fld = weaponentity; setorigin(gren, w_shotorg); setsize(gren, '0 0 0', '0 0 0'); @@ -165,7 +88,7 @@ void W_Hook_Attack2(Weapon thiswep, entity actor, .entity weaponentity) settouch(gren, W_Hook_Touch2); gren.takedamage = DAMAGE_YES; - gren.health = WEP_CVAR_SEC(hook, health); + SetResourceExplicit(gren, RES_HEALTH, WEP_CVAR_SEC(hook, health)); gren.damageforcescale = WEP_CVAR_SEC(hook, damageforcescale); gren.event_damage = W_Hook_Damage; gren.damagedbycontents = true; @@ -242,7 +165,7 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - if( actor.ammo_fuel >= (time - actor.(weaponentity).hook_time_fueldecrease) * hooked_fuel ) + if( GetResource(actor, RES_FUEL) >= (time - actor.(weaponentity).hook_time_fueldecrease) * hooked_fuel ) { W_DecreaseAmmo(thiswep, actor, (time - actor.(weaponentity).hook_time_fueldecrease) * hooked_fuel, weaponentity); actor.(weaponentity).hook_time_fueldecrease = time; @@ -250,7 +173,7 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, } else { - actor.ammo_fuel = 0; + SetResource(actor, RES_FUEL, 0); actor.(weaponentity).hook_state |= HOOK_REMOVING; if(actor.(weaponentity).m_weapon != WEP_Null) // offhand W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity); @@ -291,9 +214,9 @@ METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor, .entity weaponentit if (!thiswep.ammo_factor) return true; if(actor.(weaponentity).hook) - return actor.ammo_fuel > 0; + return GetResource(actor, RES_FUEL) > 0; - return actor.ammo_fuel >= WEP_CVAR_PRI(hook, ammo); + return GetResource(actor, RES_FUEL) >= WEP_CVAR_PRI(hook, ammo); } METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor, .entity weaponentity)) { @@ -338,11 +261,11 @@ float autocvar_cl_grapplehook_alpha = 1; void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg); entityclass(Hook); -class(Hook) .entity HookType; // ENT_CLIENT_* -class(Hook) .vector origin; -class(Hook) .vector velocity; -class(Hook) .float HookSilent; -class(Hook) .float HookRange; +classfield(Hook) .entity HookType; // ENT_CLIENT_* +classfield(Hook) .vector origin; +classfield(Hook) .vector velocity; +classfield(Hook) .float HookSilent; +classfield(Hook) .float HookRange; string Draw_GrapplingHook_trace_callback_tex; float Draw_GrapplingHook_trace_callback_rnd; @@ -358,7 +281,7 @@ void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end) Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8; } -class(Hook) .float teleport_time; +classfield(Hook) .float teleport_time; void Draw_GrapplingHook(entity this) { vector a, b, atrans; @@ -396,8 +319,8 @@ void Draw_GrapplingHook(entity this) { default: case NET_ENT_CLIENT_HOOK: - if(autocvar_chase_active > 0) - a = csqcplayer.origin; + if(autocvar_chase_active) + a = csqcplayer.origin + csqcplayer.view_ofs; else a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z; b = this.origin; @@ -543,16 +466,12 @@ NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew) } if(sf & 2) { - this.origin_x = ReadCoord(); - this.origin_y = ReadCoord(); - this.origin_z = ReadCoord(); + this.origin = ReadVector(); setorigin(this, this.origin); } if(sf & 4) { - this.velocity_x = ReadCoord(); - this.velocity_y = ReadCoord(); - this.velocity_z = ReadCoord(); + this.velocity = ReadVector(); } InterpolateOrigin_Note(this); @@ -583,5 +502,3 @@ NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew) // TODO: hook: temporarily transform this.origin for drawing the model along warpzones! #endif - -#endif