X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Felectro.qc;h=61acc0dd75eec382c186983fb98cd6923c0ee3db;hb=53c87b81040e9c1d52320952a9c3a06d3429be3b;hp=89738289f2b84b0205020e9ae0b4f33eeca05afb;hpb=ea08a566448645c9363cb429cd6b1bd9d95d470c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 89738289f..61acc0dd7 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -154,27 +154,46 @@ void W_Electro_Bolt_Think(entity this) { if(e.classname == "electro_orb") { - // change owner to whoever caused the combo explosion - e.realowner = this.realowner; - e.takedamage = DAMAGE_NO; - e.classname = "electro_orb_chain"; - - // now set the next one to trigger as well - setthink(e, W_Electro_ExplodeCombo); + bool explode; + if (this.owner == e.owner) + { + explode = WEP_CVAR_PRI(electro, midaircombo_own); + } + else if (SAME_TEAM(this.owner, e.owner)) + { + explode = WEP_CVAR_PRI(electro, midaircombo_teammate); + } + else + { + explode = WEP_CVAR_PRI(electro, midaircombo_enemy); + } - // delay combo chains, looks cooler - e.nextthink = + if (explode) + { + // change owner to whoever caused the combo explosion + e.realowner = this.realowner; + e.takedamage = DAMAGE_NO; + e.classname = "electro_orb_chain"; + + // Only first orb explosion uses midaircombo_speed, others use the normal combo_speed. + // This allows to avoid the delay on the first explosion which looks better + // (the bolt and orb should explode together because they interacted together) + // while keeping the chaining delay. + setthink(e, W_Electro_ExplodeCombo); + e.nextthink = ( time + - (WEP_CVAR(electro, combo_speed) ? - (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed)) + (WEP_CVAR_PRI(electro, midaircombo_speed) ? + (vlen(e.WarpZone_findradius_dist) / WEP_CVAR_PRI(electro, midaircombo_speed)) : 0 ) ); - ++found; + + ++found; + } } e = e.chain; } @@ -205,10 +224,10 @@ void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity) SND_ELECTRO_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(electro, damage), - WEP_ELECTRO.m_id + thiswep.m_id ); - Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); + W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir); proj = new(electro_bolt); proj.owner = proj.realowner = actor; @@ -219,7 +238,7 @@ void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity) proj.nextthink = time; proj.ltime = time + WEP_CVAR_PRI(electro, lifetime); PROJECTILE_MAKETRIGGER(proj); - proj.projectiledeathtype = WEP_ELECTRO.m_id; + proj.projectiledeathtype = thiswep.m_id; proj.weaponentity_fld = weaponentity; setorigin(proj, w_shotorg); @@ -258,7 +277,7 @@ void W_Electro_Orb_Stick(entity this, entity to) newproj.takedamage = this.takedamage; newproj.damageforcescale = this.damageforcescale; - SetResourceAmountExplicit(newproj, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH)); + SetResourceExplicit(newproj, RES_HEALTH, GetResource(this, RES_HEALTH)); newproj.event_damage = this.event_damage; newproj.spawnshieldtime = this.spawnshieldtime; newproj.damagedbycontents = true; @@ -279,14 +298,14 @@ void W_Electro_Orb_Stick(entity this, entity to) delete(this); if(to) - SetMovetypeFollow(this, to); + SetMovetypeFollow(newproj, to); } void W_Electro_Orb_Touch(entity this, entity toucher) { PROJECTILE_TOUCH(this, toucher); - if(toucher.takedamage == DAMAGE_AIM) - { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(this, toucher); } } + if(toucher.takedamage == DAMAGE_AIM && WEP_CVAR_SEC(electro, touchexplode)) + { W_Electro_Explode(this, toucher); } else if(toucher.owner != this.owner && toucher.classname != this.classname) // don't stick to player's other projectiles! { //UpdateCSQCProjectile(this); @@ -300,7 +319,7 @@ void W_Electro_Orb_Touch(entity this, entity toucher) void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { - if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0) + if(GetResource(this, RES_HEALTH) <= 0) return; // note: combos are usually triggered by W_Electro_TriggerCombo, not damage @@ -309,8 +328,8 @@ void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_combo ? 1 : -1))) return; // g_projectiles_damage says to halt - TakeResource(this, RESOURCE_HEALTH, damage); - if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0) + TakeResource(this, RES_HEALTH, damage); + if(GetResource(this, RES_HEALTH) <= 0) { this.takedamage = DAMAGE_NO; this.nextthink = time; @@ -354,12 +373,12 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity) SND_ELECTRO_FIRE2, CH_WEAPON_A, WEP_CVAR_SEC(electro, damage), - WEP_ELECTRO.m_id | HITTYPE_SECONDARY + thiswep.m_id | HITTYPE_SECONDARY ); w_shotdir = v_forward; // no TrueAim for grenades please - Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); + W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir); entity proj = new(electro_orb); proj.owner = proj.realowner = actor; @@ -369,7 +388,7 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity) proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage); proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime); PROJECTILE_MAKETRIGGER(proj); - proj.projectiledeathtype = WEP_ELECTRO.m_id | HITTYPE_SECONDARY; + proj.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY; proj.weaponentity_fld = weaponentity; setorigin(proj, w_shotorg); @@ -381,7 +400,7 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity) setsize(proj, '-4 -4 -4', '4 4 4'); proj.takedamage = DAMAGE_YES; proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale); - SetResourceAmountExplicit(proj, RESOURCE_HEALTH, WEP_CVAR_SEC(electro, health)); + SetResourceExplicit(proj, RES_HEALTH, WEP_CVAR_SEC(electro, health)); proj.event_damage = W_Electro_Orb_Damage; proj.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, proj); @@ -394,14 +413,6 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity) proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop); proj.missile_flags = MIF_SPLASH | MIF_ARC; -#if 0 - entity p2; - p2 = spawn(); - copyentity(proj, p2); - setmodel(p2, MDL_PROJECTILE_ELECTRO); - setsize(p2, proj.mins, proj.maxs); -#endif - CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound MUTATOR_CALLHOOK(EditProjectile, actor, proj); @@ -413,7 +424,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i if(PHYS_INPUT_BUTTON_ATCK2(actor)) if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1)) { - W_Electro_Attack_Orb(WEP_ELECTRO, actor, weaponentity); + W_Electro_Attack_Orb(thiswep, actor, weaponentity); actor.(weaponentity).electro_count -= 1; weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); return; @@ -491,8 +502,8 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit } METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo); - ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo); + float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(electro, ammo); return ammo_amount; } METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) @@ -500,13 +511,13 @@ METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapon float ammo_amount; if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false. { - ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); - ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); + ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); } else { - ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo); - ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo); + ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo); } return ammo_amount; }