]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/tuba.qc
Port movement and movement_old to ClientState
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / tuba.qc
index 48469864ce22b42c47a1927eb8bb874a83d91b3a..0b43a24c15640c23b3b6e655b5c76b5c301db2bb 100644 (file)
@@ -2,8 +2,8 @@
 #ifndef IMPLEMENTATION
 CLASS(Tuba, Weapon)
 /* impulse   */ ATTRIB(Tuba, impulse, int, 1);
-/* flags     */ ATTRIB(Tuba, spawnflags, int, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH);
-/* rating    */ ATTRIB(Tuba, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
+/* flags     */ ATTRIB(Tuba, spawnflags, int, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH | WEP_FLAG_NODUAL);
+/* rating    */ ATTRIB(Tuba, bot_pickupbasevalue, float, 2000);
 /* color     */ ATTRIB(Tuba, wpcolor, vector, '0 1 0');
 /* modelname */ ATTRIB(Tuba, mdl, string, "tuba");
 #ifdef GAMEQC
@@ -47,7 +47,6 @@ REGISTER_WEAPON(TUBA, tuba, NEW(Tuba));
 
 .entity tuba_note;
 .float tuba_smoketime;
-.float tuba_instrument;
 
 #define MAX_TUBANOTES 32
 .float tuba_lastnotes_last;
@@ -158,7 +157,7 @@ void W_Tuba_NoteOff(entity this)
        if (actor.(weaponentity).tuba_note == this)
        {
                actor.(weaponentity).tuba_lastnotes_last = (actor.(weaponentity).tuba_lastnotes_last + 1) % MAX_TUBANOTES;
-               actor.(weaponentity).(tuba_lastnotes[actor.(weaponentity).tuba_lastnotes_last]) = eX * this.spawnshieldtime + eY * time + eZ * this.cnt;
+               actor.(weaponentity).(tuba_lastnotes[actor.(weaponentity).tuba_lastnotes_last]) = vec3(this.spawnshieldtime, time, this.cnt);
                actor.(weaponentity).tuba_note = NULL;
                actor.(weaponentity).tuba_lastnotes_cnt = bound(0, actor.(weaponentity).tuba_lastnotes_cnt + 1, MAX_TUBANOTES);
 
@@ -187,10 +186,10 @@ void W_Tuba_NoteOff(entity this)
 int W_Tuba_GetNote(entity pl, int hittype)
 {
        float movestate = 5;
-       if (pl.movement.x < 0)          movestate -= 3;
-       else if (pl.movement.x > 0)     movestate += 3;
-       if (pl.movement.y < 0)          movestate -= 1;
-       else if (pl.movement.y > 0)     movestate += 1;
+       if (CS(pl).movement.x < 0)              movestate -= 3;
+       else if (CS(pl).movement.x > 0) movestate += 3;
+       if (CS(pl).movement.y < 0)              movestate -= 1;
+       else if (CS(pl).movement.y > 0) movestate += 1;
 
        int note = 0;
        switch (movestate)
@@ -363,7 +362,7 @@ void W_Tuba_NoteOn(entity actor, .entity weaponentity, float hittype)
 #endif
 
 #ifdef SVQC
-METHOD(Tuba, wr_aim, void(Tuba this, entity actor))
+METHOD(Tuba, wr_aim, void(Tuba this, entity actor, .entity weaponentity))
 {
        // bots cannot play the Tuba well yet
        // I think they should start with the recorder first
@@ -403,41 +402,7 @@ METHOD(Tuba, wr_setup, void(Tuba this, entity actor, .entity weaponentity))
 {
        actor.(weaponentity).tuba_instrument = 0;
 }
-#endif
 
-REGISTER_NET_S2C(tuba_instrument)
-#ifdef CSQC
-NET_HANDLE(tuba_instrument, bool)
-{
-       int i = ReadByte();
-       int slot = ReadByte();
-       return = true;
-       string s = (i == 0) ? "tuba" :
-                  (i == 1) ? "akordeon" :
-                             "kleinbottle" ;
-
-    entity wep = viewmodels[slot];
-    CL_WeaponEntity_SetModel(wep, s, true);
-}
-#endif
-#ifdef SVQC
-void tuba_instrument_send(entity this, .entity weaponentity, int instr)
-{
-       msg_entity = this;
-       int chan = MSG_ONE;
-       WriteHeader(chan, tuba_instrument);
-       WriteByte(chan, instr);
-       WriteByte(chan, weaponslot(weaponentity));
-}
-SPECTATE_COPY()
-{
-       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-       {
-               .entity weaponentity = weaponentities[slot];
-               if(this.(weaponentity).tuba_instrument != spectatee.(weaponentity).tuba_instrument)
-                       tuba_instrument_send(this, weaponentity, this.(weaponentity).tuba_instrument = spectatee.(weaponentity).tuba_instrument);
-       }
-}
 METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity))
 {
        // switch to alternate instruments :)
@@ -458,7 +423,6 @@ METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity))
                                actor.(weaponentity).weaponname = "tuba";
                                break;
                }
-               tuba_instrument_send(actor, weaponentity, actor.(weaponentity).tuba_instrument);
                W_SetupShot(actor, weaponentity, false, 0, SND_Null, 0, 0);
                Send_Effect(EFFECT_TELEPORT, w_shotorg, '0 0 0', 1);
                actor.(weaponentity).state = WS_INUSE;
@@ -492,6 +456,15 @@ METHOD(Tuba, wr_killmessage, Notification(Tuba this))
                return WEAPON_TUBA_MURDER;
 }
 
+#elif defined(CSQC)
+
+METHOD(Tuba, wr_viewmodel, string(Tuba this, entity wep))
+{
+       return (wep.tuba_instrument == 0) ? "tuba" :
+              (wep.tuba_instrument == 1) ? "akordeon" :
+                                           "kleinbottle";
+}
+
 #endif
 
 #ifdef CSQC
@@ -502,13 +475,6 @@ const int TUBA_MIN = -18;
 const int TUBA_MAX = 27;
 const int TUBA_INSTRUMENTS = 3;
 
-entityclass(Tuba);
-class(Tuba) .int note;
-class(Tuba) .bool tuba_attenuate;
-class(Tuba) .float tuba_volume;
-class(Tuba) .float tuba_volume_initial;
-class(Tuba) .int tuba_instrument;
-
 int Tuba_PitchStep;
 
 void tubasound(entity e, bool restart)
@@ -527,23 +493,23 @@ void tubasound(entity e, bool restart)
                                if (restart) {
                                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m + Tuba_PitchStep);
                                }
-                               speed1 = pow(2.0, (m - Tuba_PitchStep) / 12.0);
+                               speed1 = (2.0 ** ((m - Tuba_PitchStep) / 12.0));
                        } else if (e.note - m + Tuba_PitchStep > TUBA_MAX) {
                                if (restart) {
                                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m);
                                }
-                               speed1 = pow(2.0, m / 12.0);
+                               speed1 = (2.0 ** (m / 12.0));
                        } else {
                                if (restart) {
                                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m);
                                }
                                vol1 = cos(M_PI_2 * m / Tuba_PitchStep);
-                               speed1 = pow(2.0, m / 12.0);
+                               speed1 = (2.0 ** (m / 12.0));
                                if (restart) {
                                        snd2 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m + Tuba_PitchStep);
                                }
                                vol2 = sin(M_PI_2 * m / Tuba_PitchStep);
-                               speed2 = pow(2.0, (m - Tuba_PitchStep) / 12.0);
+                               speed2 = (2.0 ** ((m - Tuba_PitchStep) / 12.0));
                        }
                } else if (restart) {
                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note);