X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Felectro.qc;h=46e46c24059660e8fd3b30b7ffe37da13d704d9d;hb=9e84ff8daa3826ef32e2891a7c5224a7cd436d23;hp=2c74b3b451477c364232467a1792826c027cf994;hpb=9185b58da6fe5f2b095d7066577e1e024b4d2798;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 2c74b3b45..46e46c240 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -1,3 +1,4 @@ +#include "electro.qh" #ifndef IMPLEMENTATION CLASS(Electro, Weapon) /* ammotype */ ATTRIB(Electro, ammo_field, .int, ammo_cells); @@ -6,7 +7,7 @@ CLASS(Electro, Weapon) /* rating */ ATTRIB(Electro, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID); /* color */ ATTRIB(Electro, wpcolor, vector, '0 0.5 1'); /* modelname */ ATTRIB(Electro, mdl, string, "electro"); -#ifndef MENUQC +#ifdef GAMEQC /* model */ ATTRIB(Electro, m_model, Model, MDL_ELECTRO_ITEM); #endif /* crosshair */ ATTRIB(Electro, w_crosshair, string, "gfx/crosshairelectro"); @@ -264,7 +265,7 @@ void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity) { entity proj; - W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(electro, ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(electro, ammo), weaponentity); W_SetupShot_ProjectileSize( actor, @@ -300,6 +301,7 @@ void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity) setsize(proj, '0 0 -3', '0 0 -3'); proj.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, proj); + IL_PUSH(g_bot_dodge, proj); proj.missile_flags = MIF_SPLASH; CSQCProjectile(proj, true, PROJECTILE_ELECTRO_BEAM, true); @@ -330,6 +332,7 @@ void W_Electro_Orb_Stick(entity this, entity to) newproj.event_damage = this.event_damage; newproj.spawnshieldtime = this.spawnshieldtime; newproj.damagedbycontents = true; + IL_PUSH(g_damagedbycontents, newproj); set_movetype(newproj, MOVETYPE_NONE); // lock the orb in place newproj.projectiledeathtype = this.projectiledeathtype; @@ -339,6 +342,8 @@ void W_Electro_Orb_Stick(entity this, entity to) newproj.nextthink = this.nextthink; newproj.use = this.use; newproj.flags = this.flags; + IL_PUSH(g_projectiles, newproj); + IL_PUSH(g_bot_dodge, newproj); delete(this); @@ -406,7 +411,7 @@ void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity) { - W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(electro, ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(electro, ammo), weaponentity); W_SetupShot_ProjectileSize( actor, @@ -447,7 +452,10 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity) proj.event_damage = W_Electro_Orb_Damage; proj.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, proj); + IL_PUSH(g_bot_dodge, proj); proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents)); + if(proj.damagedbycontents) + IL_PUSH(g_damagedbycontents, proj); proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor); proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop); @@ -468,12 +476,12 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity) void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire) { - if(actor.electro_count > 1) + if(actor.(weaponentity).electro_count > 1) if(PHYS_INPUT_BUTTON_ATCK2(actor)) if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1)) { W_Electro_Attack_Orb(WEP_ELECTRO, actor, weaponentity); - actor.electro_count -= 1; + actor.(weaponentity).electro_count -= 1; weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); return; } @@ -483,7 +491,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i .float bot_secondary_electromooth; -METHOD(Electro, wr_aim, void(entity thiswep, entity actor)) +METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { PHYS_INPUT_BUTTON_ATCK(actor) = PHYS_INPUT_BUTTON_ATCK2(actor) = false; if(vdist(actor.origin - actor.enemy.origin, >, 1000)) { actor.bot_secondary_electromooth = 0; } @@ -492,9 +500,9 @@ METHOD(Electro, wr_aim, void(entity thiswep, entity actor)) float shoot; if(WEP_CVAR_PRI(electro, speed)) - shoot = bot_aim(actor, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false); + shoot = bot_aim(actor, weaponentity, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false); else - shoot = bot_aim(actor, 1000000, 0, 0.001, false); + shoot = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); if(shoot) { @@ -504,7 +512,7 @@ METHOD(Electro, wr_aim, void(entity thiswep, entity actor)) } else { - if(bot_aim(actor, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true)) + if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true)) { PHYS_INPUT_BUTTON_ATCK2(actor) = true; if(random() < 0.03) actor.bot_secondary_electromooth = 0; @@ -516,9 +524,9 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO { float ammo_amount = 0; - if(actor.clip_load >= WEP_CVAR_PRI(electro, ammo)) + if(actor.(weaponentity).clip_load >= WEP_CVAR_PRI(electro, ammo)) ammo_amount = 1; - if(actor.clip_load >= WEP_CVAR_SEC(electro, ammo)) + if(actor.(weaponentity).clip_load >= WEP_CVAR_SEC(electro, ammo)) ammo_amount += 1; if(!ammo_amount) @@ -538,40 +546,44 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit } else if(fire & 2) { - if(time >= actor.electro_secondarytime) + if(time >= actor.(weaponentity).electro_secondarytime) if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire))) { W_Electro_Attack_Orb(thiswep, actor, weaponentity); - actor.electro_count = WEP_CVAR_SEC(electro, count); + actor.(weaponentity).electro_count = WEP_CVAR_SEC(electro, count); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); - actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor); + actor.(weaponentity).electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor); } } } -METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor)) +METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo); - ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo); return ammo_amount; } -METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor)) +METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { 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 = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); - ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= 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); } else { ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo); - ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo); } return ammo_amount; } METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor)) { - actor.electro_secondarytime = time; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + actor.(weaponentity).electro_secondarytime = time; + } } METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) {