]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/tuba.qc
Weapons: pass weaponentity field instead of slot
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / tuba.qc
index bf2372c7d5c4d069c824a41b0f4f8ca6c21f5c2b..130edaaf58bef62debd1a9dc3e66b9804b1c0e1d 100644 (file)
@@ -14,7 +14,7 @@ CLASS(Tuba, Weapon)
 /* wepimg    */ ATTRIB(Tuba, model2, string, "weapontuba");
 /* refname   */ ATTRIB(Tuba, netname, string, "tuba");
 /* xgettext:no-c-format */
-/* wepname   */ ATTRIB(Tuba, message, string, _("@!#%'n Tuba"));
+/* wepname   */ ATTRIB(Tuba, m_name, string, _("@!#%'n Tuba"));
 ENDCLASS(Tuba)
 REGISTER_WEAPON(TUBA, NEW(Tuba));
 
@@ -56,7 +56,7 @@ float W_Tuba_MarkClientOnlyFieldsAsUsed() {
 #endif
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void spawnfunc_weapon_tuba(void) { weapon_defaultspawnfunc(WEP_TUBA.m_id); }
+spawnfunc(weapon_tuba) { weapon_defaultspawnfunc(this, WEP_TUBA); }
 
 bool W_Tuba_HasPlayed(entity pl, string melody, int instrument, bool ignorepitch, float mintempo, float maxtempo)
 {
@@ -253,8 +253,8 @@ int W_Tuba_GetNote(entity pl, int hittype)
        return note;
 }
 
-bool W_Tuba_NoteSendEntity(entity to, int sf)
-{SELFPARAM();
+bool W_Tuba_NoteSendEntity(entity this, entity to, int sf)
+{
        int f;
 
        msg_entity = to;
@@ -367,7 +367,7 @@ void W_Tuba_NoteOn(float hittype)
        }
 }
 
-               METHOD(Tuba, wr_aim, bool(entity thiswep))
+               METHOD(Tuba, wr_aim, void(entity thiswep))
                {
                        // bots cannot play the Tuba well yet
                        // I think they should start with the recorder first
@@ -378,50 +378,45 @@ void W_Tuba_NoteOn(float hittype)
                                else
                                        self.BUTTON_ATCK2 = 1;
                        }
-
-                       return true;
                }
-               METHOD(Tuba, wr_think, bool(entity thiswep, bool fire1, bool fire2))
+               METHOD(Tuba, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
-                       if(fire1)
-                       if(weapon_prepareattack(0, WEP_CVAR(tuba, refire)))
+                       if(fire & 1)
+                       if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(tuba, refire)))
                        {
                                W_Tuba_NoteOn(0);
-                               //weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
-                               weapon_thinkf(WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
+                               //weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
+                               weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
                        }
-                       if(fire2)
-                       if(weapon_prepareattack(1, WEP_CVAR(tuba, refire)))
+                       if(fire & 2)
+                       if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR(tuba, refire)))
                        {
                                W_Tuba_NoteOn(HITTYPE_SECONDARY);
-                               //weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
-                               weapon_thinkf(WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
+                               //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
+                               weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
                        }
-                       if(self.tuba_note)
+                       if(actor.tuba_note)
                        {
-                               if(!fire1 && !fire2)
+                               if(!(fire & 1) && !(fire & 2))
                                {
-                                       WITH(entity, self, self.tuba_note, W_Tuba_NoteOff());
+                                       WITH(entity, self, actor.tuba_note, W_Tuba_NoteOff());
                                }
                        }
-
-                       return true;
                }
-               METHOD(Tuba, wr_init, bool(entity thiswep))
+               METHOD(Tuba, wr_init, void(entity thiswep))
                {
                        TUBA_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
-                       return true;
                }
-               METHOD(Tuba, wr_setup, bool(entity thiswep))
+               METHOD(Tuba, wr_setup, void(entity thiswep))
                {
                        self.ammo_field = ammo_none;
                        self.tuba_instrument = 0;
-                       return true;
                }
-               METHOD(Tuba, wr_reload, bool(entity thiswep))
+               METHOD(Tuba, wr_reload, void(entity thiswep))
                {
+                       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                        // switch to alternate instruments :)
-                       if(self.weaponentity.state == WS_READY)
+                       if(self.(weaponentity).state == WS_READY)
                        {
                                switch(self.tuba_instrument)
                                {
@@ -440,11 +435,9 @@ void W_Tuba_NoteOn(float hittype)
                                }
                                W_SetupShot(self, false, 0, "", 0, 0);
                                Send_Effect(EFFECT_TELEPORT, w_shotorg, '0 0 0', 1);
-                               self.weaponentity.state = WS_INUSE;
-                               weapon_thinkf(WFRAME_RELOAD, 0.5, w_ready);
+                               self.(weaponentity).state = WS_INUSE;
+                               weapon_thinkf(self, weaponentity, WFRAME_RELOAD, 0.5, w_ready);
                        }
-
-                       return true;
                }
                METHOD(Tuba, wr_checkammo1, bool(entity thiswep))
                {
@@ -454,12 +447,11 @@ void W_Tuba_NoteOn(float hittype)
                {
                        return true; // tuba has infinite ammo
                }
-               METHOD(Tuba, wr_config, bool(entity thiswep))
+               METHOD(Tuba, wr_config, void(entity thiswep))
                {
                        TUBA_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
-                       return true;
                }
-               METHOD(Tuba, wr_suicidemessage, bool(entity thiswep))
+               METHOD(Tuba, wr_suicidemessage, int(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_BOUNCE)
                                return WEAPON_KLEINBOTTLE_SUICIDE;
@@ -468,7 +460,7 @@ void W_Tuba_NoteOn(float hittype)
                        else
                                return WEAPON_TUBA_SUICIDE;
                }
-               METHOD(Tuba, wr_killmessage, bool(entity thiswep))
+               METHOD(Tuba, wr_killmessage, int(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_BOUNCE)
                                return WEAPON_KLEINBOTTLE_MURDER;
@@ -478,14 +470,5 @@ void W_Tuba_NoteOn(float hittype)
                                return WEAPON_TUBA_MURDER;
                }
 
-#endif
-#ifdef CSQC
-
-               METHOD(Tuba, wr_zoomreticle, bool(entity thiswep))
-               {
-                       // no weapon specific image for this weapon
-                       return false;
-               }
-
 #endif
 #endif