-void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, int slot, int fire) func);
+void weapon_thinkf(entity actor, int slot, float fr, float t,
+ void(Weapon thiswep, entity actor, int slot, int fire) func);
_setmodel(this, W_Model(strcat("v_", name, ".md3")));
int v_shot_idx = gettagindex(this, "shot"); // used later
if (!v_shot_idx) v_shot_idx = gettagindex(this, "tag_shot");
_setmodel(this, W_Model(strcat("v_", name, ".md3")));
int v_shot_idx = gettagindex(this, "shot"); // used later
if (!v_shot_idx) v_shot_idx = gettagindex(this, "tag_shot");
// if we don't, this is a "real" animated model
if (gettagindex(this, "weapon"))
{
// if we don't, this is a "real" animated model
if (gettagindex(this, "weapon"))
{
- if (!this.weaponentity) this.weaponentity = spawn();
- _setmodel(this.weaponentity, W_Model(strcat("v_", name, ".md3")));
- setattachment(this.weaponentity, this, "weapon");
+ if (!this.weaponentity[slot]) this.weaponentity[slot] = spawn();
+ _setmodel(this.weaponentity[slot], W_Model(strcat("v_", name, ".md3")));
+ setattachment(this.weaponentity[slot], this, "weapon");
- if (!this.weaponentity) this.weaponentity = spawn();
- _setmodel(this.weaponentity, W_Model(strcat("v_", name, ".md3")));
- setattachment(this.weaponentity, this, "tag_weapon");
+ if (!this.weaponentity[slot]) this.weaponentity[slot] = spawn();
+ _setmodel(this.weaponentity[slot], W_Model(strcat("v_", name, ".md3")));
+ setattachment(this.weaponentity[slot], this, "tag_weapon");
- idx = gettagindex(this.weaponentity, "shell");
- if (!idx) idx = gettagindex(this.weaponentity, "tag_shell");
- if (idx) this.spawnorigin = gettaginfo(this.weaponentity, idx);
+ idx = gettagindex(this.weaponentity[slot], "shell");
+ if (!idx) idx = gettagindex(this.weaponentity[slot], "tag_shell");
+ if (idx) this.spawnorigin = gettaginfo(this.weaponentity[slot], idx);
{
idx = gettagindex(this, "weapon");
if (!idx) idx = gettagindex(this, "tag_weapon");
{
idx = gettagindex(this, "weapon");
if (!idx) idx = gettagindex(this, "tag_weapon");
- this.weaponentity.effects = this.effects;
- this.weaponentity.alpha = this.alpha;
- this.weaponentity.colormap = this.colormap;
- this.weaponentity.glowmod = this.glowmod;
+ this.weaponentity[slot].effects = this.effects;
+ this.weaponentity[slot].alpha = this.alpha;
+ this.weaponentity[slot].colormap = this.colormap;
+ this.weaponentity[slot].glowmod = this.glowmod;
- entity exterior = e.exteriorweaponentity = spawn();
- exterior.classname = "exteriorweaponentity";
- exterior.solid = SOLID_NOT;
- exterior.exteriorweaponentity = exterior;
- exterior.owner = e;
- setorigin(exterior, '0 0 0');
- exterior.angles = '0 0 0';
- exterior.think = CL_ExteriorWeaponentity_Think;
- exterior.nextthink = time;
-
- CSQCMODEL_AUTOINIT(exterior);
+ if (slot == 0)
+ {
+ entity exterior = e.exteriorweaponentity = spawn();
+ exterior.classname = "exteriorweaponentity";
+ exterior.solid = SOLID_NOT;
+ exterior.exteriorweaponentity = exterior;
+ exterior.owner = e;
+ setorigin(exterior, '0 0 0');
+ exterior.angles = '0 0 0';
+ exterior.think = CL_ExteriorWeaponentity_Think;
+ exterior.nextthink = time;
+
+ CSQCMODEL_AUTOINIT(exterior);
+ }
}
}
void w_ready(Weapon thiswep, entity actor, int slot, int fire)
{
}
}
void w_ready(Weapon thiswep, entity actor, int slot, int fire)
{
- if (actor.weaponentity) actor.weaponentity.state = WS_READY;
- weapon_thinkf(actor, WFRAME_IDLE, 1000000, w_ready);
+ if (actor.weaponentity[slot]) actor.weaponentity[slot].state = WS_READY;
+ weapon_thinkf(actor, slot, WFRAME_IDLE, 1000000, w_ready);
-bool weapon_prepareattack_check(Weapon thiswep, entity actor, bool secondary, float attacktime)
+bool weapon_prepareattack_check(Weapon thiswep, entity actor, int slot, bool secondary, float attacktime)
-void weapon_prepareattack_do(entity actor, bool secondary, float attacktime)
+void weapon_prepareattack_do(entity actor, int slot, bool secondary, float attacktime)
actor.spawnshieldtime = min(actor.spawnshieldtime, time); // kill spawn shield when you fire
// if the weapon hasn't been firing continuously, reset the timer
if (attacktime >= 0)
{
actor.spawnshieldtime = min(actor.spawnshieldtime, time); // kill spawn shield when you fire
// if the weapon hasn't been firing continuously, reset the timer
if (attacktime >= 0)
{
- // dprint("attack finished ", ftos(ATTACK_FINISHED(actor)), "\n");
+ // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n");
-bool weapon_prepareattack(Weapon thiswep, entity actor, bool secondary, float attacktime)
+bool weapon_prepareattack(Weapon thiswep, entity actor, int slot, bool secondary, float attacktime)
- if (weapon_prepareattack_check(thiswep, actor, secondary, attacktime))
+ if (weapon_prepareattack_check(thiswep, actor, slot, secondary, attacktime))
- weapon_prepareattack_do(actor, secondary, attacktime);
+ weapon_prepareattack_do(actor, slot, secondary, attacktime);
-void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, int slot, int fire) func)
+void weapon_thinkf(entity actor, int slot, float fr, float t,
+ void(Weapon thiswep, entity actor, int slot, int fire) func)
- if (fr == WFRAME_IDLE) a = actor.weaponentity.anim_idle;
- else if (fr == WFRAME_FIRE1) a = actor.weaponentity.anim_fire1;
- else if (fr == WFRAME_FIRE2) a = actor.weaponentity.anim_fire2;
+ if (fr == WFRAME_IDLE) a = actor.weaponentity[slot].anim_idle;
+ else if (fr == WFRAME_FIRE1) a = actor.weaponentity[slot].anim_fire1;
+ else if (fr == WFRAME_FIRE2) a = actor.weaponentity[slot].anim_fire2;
- setanim(actor.weaponentity, a, restartanim == false, restartanim, restartanim);
+ setanim(actor.weaponentity[slot], a, restartanim == false, restartanim, restartanim);
"Tried to override initial weapon think function - should this really happen?");
t *= W_WeaponRateFactor();
"Tried to override initial weapon think function - should this really happen?");
t *= W_WeaponRateFactor();
{
Weapon wpn = get_weaponinfo(actor.weapon);
w_ready(wpn, actor, 0, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
{
Weapon wpn = get_weaponinfo(actor.weapon);
w_ready(wpn, actor, 0, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
// set our clip load to the load of the weapon we switched to, if it's reloadable
if (newwep.spawnflags & WEP_FLAG_RELOADABLE && newwep.reloading_ammo) // prevent accessing undefined cvars
// set our clip load to the load of the weapon we switched to, if it's reloadable
if (newwep.spawnflags & WEP_FLAG_RELOADABLE && newwep.reloading_ammo) // prevent accessing undefined cvars
- weapon_thinkf(actor, WFRAME_IDLE, newwep.switchdelay_raise, w_ready);
+ weapon_thinkf(actor, slot, WFRAME_IDLE, newwep.switchdelay_raise, w_ready);
#endif
)
{
sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
#endif
)
{
sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
- actor.weaponentity.state = WS_DROP;
- weapon_thinkf(actor, WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear);
+ actor.weaponentity[slot].state = WS_DROP;
+ weapon_thinkf(actor, slot, WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear);
- // print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor)), " >= ", ftos(actor.weapon_nextthink), "\n");
+ // print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor, slot)), " >= ", ftos(actor.weapon_nextthink), "\n");
- if (gettagindex(actor.weaponentity, "shot")) setattachment(flash, actor.weaponentity, "shot");
- else setattachment(flash, actor.weaponentity, "tag_shot");
+ if (gettagindex(actor.weaponentity[slot], "shot")) setattachment(flash, actor.weaponentity[slot], "shot");
+ else setattachment(flash, actor.weaponentity[slot], "tag_shot");
// then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
// so your weapon is disabled for a few seconds without reason
// then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
// so your weapon is disabled for a few seconds without reason
Weapon wpn = get_weaponinfo(actor.weapon);
w_ready(wpn, actor, slot, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
Weapon wpn = get_weaponinfo(actor.weapon);
w_ready(wpn, actor, slot, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
// then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
// so your weapon is disabled for a few seconds without reason
// then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
// so your weapon is disabled for a few seconds without reason
- weapon_thinkf(actor, WFRAME_RELOAD, actor.reload_time, W_ReloadedAndReady);
+ weapon_thinkf(actor, slot, WFRAME_RELOAD, actor.reload_time, W_ReloadedAndReady);