X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Felectro.qc;h=46e46c24059660e8fd3b30b7ffe37da13d704d9d;hp=07c8aa85e25604a3e3f050086256994027f77bf9;hb=64f2b309aa5be8aafb9ad2137174bb6d99aeb876;hpb=eac60648c4017e495060dd3ba9e50ac4bad5000a diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 07c8aa85e..46e46c240 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -1,12 +1,13 @@ +#include "electro.qh" #ifndef IMPLEMENTATION CLASS(Electro, Weapon) -/* ammotype */ ATTRIB(Electro, ammo_field, .int, ammo_cells) -/* impulse */ ATTRIB(Electro, impulse, int, 5) +/* ammotype */ ATTRIB(Electro, ammo_field, .int, ammo_cells); +/* impulse */ ATTRIB(Electro, impulse, int, 5); /* flags */ ATTRIB(Electro, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); /* 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"); @@ -50,6 +51,7 @@ CLASS(Electro, Weapon) P(class, prefix, speed_up, float, SEC) \ P(class, prefix, speed_z, float, SEC) \ P(class, prefix, spread, float, BOTH) \ + P(class, prefix, stick, float, SEC) \ P(class, prefix, switchdelay_drop, float, NONE) \ P(class, prefix, switchdelay_raise, float, NONE) \ P(class, prefix, touchexplode, float, SEC) \ @@ -134,29 +136,29 @@ void W_Electro_ExplodeCombo(entity this) WEP_CVAR(electro, combo_damage), WEP_CVAR(electro, combo_edgedamage), WEP_CVAR(electro, combo_radius), - world, - world, + NULL, + NULL, WEP_CVAR(electro, combo_force), WEP_ELECTRO.m_id | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce - world + NULL ); - remove(this); + delete(this); } -void W_Electro_Explode(entity this) +void W_Electro_Explode(entity this, entity directhitentity) { - if(other.takedamage == DAMAGE_AIM) - if(IS_PLAYER(other)) - if(DIFF_TEAM(this.realowner, other)) - if(!IS_DEAD(other)) - if(IsFlying(other)) + if(directhitentity.takedamage == DAMAGE_AIM) + if(IS_PLAYER(directhitentity)) + if(DIFF_TEAM(this.realowner, directhitentity)) + if(!IS_DEAD(directhitentity)) + if(IsFlying(directhitentity)) Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH); this.event_damage = func_null; this.takedamage = DAMAGE_NO; - if(this.movetype == MOVETYPE_BOUNCE) + if(this.move_movetype == MOVETYPE_BOUNCE || this.classname == "electro_orb") // TODO: classname is more reliable anyway? { RadiusDamage( this, @@ -164,11 +166,11 @@ void W_Electro_Explode(entity this) WEP_CVAR_SEC(electro, damage), WEP_CVAR_SEC(electro, edgedamage), WEP_CVAR_SEC(electro, radius), - world, - world, + NULL, + NULL, WEP_CVAR_SEC(electro, force), this.projectiledeathtype, - other + directhitentity ); } else @@ -180,30 +182,34 @@ void W_Electro_Explode(entity this) WEP_CVAR_PRI(electro, damage), WEP_CVAR_PRI(electro, edgedamage), WEP_CVAR_PRI(electro, radius), - world, - world, + NULL, + NULL, WEP_CVAR_PRI(electro, force), this.projectiledeathtype, - other + directhitentity ); } - remove(this); + delete(this); } void W_Electro_Explode_use(entity this, entity actor, entity trigger) { - W_Electro_Explode(this); + W_Electro_Explode(this, trigger); } -void W_Electro_TouchExplode(entity this) +void W_Electro_TouchExplode(entity this, entity toucher) { - PROJECTILE_TOUCH(this); - W_Electro_Explode(this); + PROJECTILE_TOUCH(this, toucher); + W_Electro_Explode(this, toucher); } + +void sys_phys_update_single(entity this); + void W_Electro_Bolt_Think(entity this) { + // sys_phys_update_single(this); if(time >= this.ltime) { this.use(this, NULL, NULL); @@ -252,16 +258,18 @@ void W_Electro_Bolt_Think(entity this) { this.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), this.ltime); } } else { this.nextthink = this.ltime; } + // this.nextthink = time; } -void W_Electro_Attack_Bolt(Weapon thiswep, entity actor) +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, + weaponentity, '0 0 -3', '0 0 -3', false, @@ -285,29 +293,77 @@ void W_Electro_Attack_Bolt(Weapon thiswep, entity actor) proj.projectiledeathtype = WEP_ELECTRO.m_id; setorigin(proj, w_shotorg); - proj.movetype = MOVETYPE_FLY; + // if (IS_CSQC) + set_movetype(proj, MOVETYPE_FLY); W_SetupProjVelocity_PRI(proj, electro); proj.angles = vectoangles(proj.velocity); settouch(proj, W_Electro_TouchExplode); 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); MUTATOR_CALLHOOK(EditProjectile, actor, proj); + // proj.com_phys_pos = proj.origin; + // proj.com_phys_vel = proj.velocity; +} + +void W_Electro_Orb_Stick(entity this, entity to) +{ + entity newproj = spawn(); + newproj.classname = this.classname; + + newproj.bot_dodge = this.bot_dodge; + newproj.bot_dodgerating = this.bot_dodgerating; + + newproj.owner = this.owner; + newproj.realowner = this.realowner; + setsize(newproj, this.mins, this.maxs); + setorigin(newproj, this.origin); + setmodel(newproj, MDL_PROJECTILE_ELECTRO); + newproj.angles = vectoangles(-trace_plane_normal); // face against the surface + + newproj.takedamage = this.takedamage; + newproj.damageforcescale = this.damageforcescale; + newproj.health = this.health; + 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; + + settouch(newproj, func_null); + setthink(newproj, getthink(this)); + 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); + + if(to) + SetMovetypeFollow(this, to); } -void W_Electro_Orb_Touch(entity this) +void W_Electro_Orb_Touch(entity this, entity toucher) { - PROJECTILE_TOUCH(this); - if(other.takedamage == DAMAGE_AIM) - { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(this); } } + PROJECTILE_TOUCH(this, toucher); + if(toucher.takedamage == DAMAGE_AIM) + { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(this, toucher); } } else { //UpdateCSQCProjectile(this); spamsound(this, CH_SHOTS, SND(ELECTRO_BOUNCE), VOL_BASE, ATTEN_NORM); this.projectiledeathtype |= HITTYPE_BOUNCE; + + if(WEP_CVAR_SEC(electro, stick)) + W_Electro_Orb_Stick(this, toucher); } } @@ -353,14 +409,15 @@ void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float } } -void W_Electro_Attack_Orb(Weapon thiswep, entity actor) +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, - '0 0 -4', - '0 0 -4', + weaponentity, + '-4 -4 -4', + '4 4 4', false, 2, SND_ELECTRO_FIRE2, @@ -385,16 +442,20 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor) //proj.glow_size = 50; //proj.glow_color = 45; - proj.movetype = MOVETYPE_BOUNCE; + set_movetype(proj, MOVETYPE_BOUNCE); W_SetupProjVelocity_UP_SEC(proj, electro); settouch(proj, W_Electro_Orb_Touch); - setsize(proj, '0 0 -4', '0 0 -4'); + setsize(proj, '-4 -4 -4', '4 4 4'); proj.takedamage = DAMAGE_YES; proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale); proj.health = WEP_CVAR_SEC(electro, health); 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); @@ -415,12 +476,12 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor) 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); - actor.electro_count -= 1; + W_Electro_Attack_Orb(WEP_ELECTRO, actor, weaponentity); + actor.(weaponentity).electro_count -= 1; weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); return; } @@ -430,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; } @@ -439,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) { @@ -451,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; @@ -463,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) @@ -479,50 +540,54 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { - W_Electro_Attack_Bolt(thiswep, actor); + W_Electro_Attack_Bolt(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } } 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); - actor.electro_count = WEP_CVAR_SEC(electro, count); + W_Electro_Attack_Orb(thiswep, actor, weaponentity); + 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)) { - W_Reload(actor, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD); + W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD); } METHOD(Electro, wr_suicidemessage, Notification(entity thiswep)) {