#ifdef SVQC
void spawnfunc_weapon_tuba(void) { weapon_defaultspawnfunc(WEP_TUBA); }
-float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo)
+bool W_Tuba_HasPlayed(entity pl, string melody, int instrument, bool ignorepitch, float mintempo, float maxtempo)
{
float i, j, mmin, mmax, nolength;
float n = tokenize_console(melody);
if(n > pl.tuba_lastnotes_cnt)
- return FALSE;
+ return false;
float pitchshift = 0;
if(instrument >= 0)
if(pl.tuba_instrument != instrument)
- return FALSE;
+ return false;
// verify notes...
- nolength = FALSE;
+ nolength = false;
for(i = 0; i < n; ++i)
{
- vector v = pl.(tuba_lastnotes[mod(pl.tuba_lastnotes_last - i + MAX_TUBANOTES, MAX_TUBANOTES)]);
+ vector v = pl.(tuba_lastnotes[(pl.tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
float ai = stof(argv(n - i - 1));
float np = floor(ai);
if(ai == np)
- nolength = TRUE;
+ nolength = true;
// n counts the last played notes BACKWARDS
// _x is start
// _y is end
// _z is note pitch
if(ignorepitch && i == 0)
{
- pitchshift = np - v_z;
+ pitchshift = np - v.z;
}
else
{
- if(v_z + pitchshift != np)
- return FALSE;
+ if(v.z + pitchshift != np)
+ return false;
}
}
for(i = 0; i < n; ++i)
{
- vector vi = pl.(tuba_lastnotes[mod(pl.tuba_lastnotes_last - i + MAX_TUBANOTES, MAX_TUBANOTES)]);
+ vector vi = pl.(tuba_lastnotes[(pl.tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
float ai = stof(argv(n - i - 1));
ti -= 1 / (ai - floor(ai));
float tj = ti;
for(j = i+1; j < n; ++j)
{
- vector vj = pl.(tuba_lastnotes[mod(pl.tuba_lastnotes_last - j + MAX_TUBANOTES, MAX_TUBANOTES)]);
+ vector vj = pl.(tuba_lastnotes[(pl.tuba_lastnotes_last - j + MAX_TUBANOTES) % MAX_TUBANOTES]);
float aj = stof(argv(n - j - 1));
tj -= (aj - floor(aj));
//printf("second note: %f to %f, should be %f\n", vj_x, vj_y, tj);
//printf("m1 = %f\n", (vi_x - vj_y) / (ti - tj));
//printf("m2 = %f\n", (vi_y - vj_x) / (ti - tj));
- mmin = max(mmin, (vi_x - vj_y) / (ti - tj)); // lower bound
- mmax = min(mmax, (vi_y - vj_x) / (ti - tj)); // upper bound
+ mmin = max(mmin, (vi.x - vj.y) / (ti - tj)); // lower bound
+ mmax = min(mmax, (vi.y - vj.x) / (ti - tj)); // upper bound
}
}
if(mmin > mmax) // rhythm fail
- return FALSE;
+ return false;
}
pl.tuba_lastnotes_cnt = 0;
- return TRUE;
+ return true;
}
void W_Tuba_NoteOff(void)
// note: self.cnt
if(self.owner.tuba_note == self)
{
- self.owner.tuba_lastnotes_last = mod(self.owner.tuba_lastnotes_last + 1, MAX_TUBANOTES);
+ self.owner.tuba_lastnotes_last = (self.owner.tuba_lastnotes_last + 1) % MAX_TUBANOTES;
self.owner.(tuba_lastnotes[self.owner.tuba_lastnotes_last]) = eX * self.spawnshieldtime + eY * time + eZ * self.cnt;
self.owner.tuba_note = world;
self.owner.tuba_lastnotes_cnt = bound(0, self.owner.tuba_lastnotes_cnt + 1, MAX_TUBANOTES);
remove(self);
}
-float W_Tuba_GetNote(entity pl, float hittype)
+int W_Tuba_GetNote(entity pl, int hittype)
{
- float note;
- float movestate;
- movestate = 5;
- if(pl.movement_x < 0) movestate -= 3;
- if(pl.movement_x > 0) movestate += 3;
- if(pl.movement_y < 0) movestate -= 1;
- if(pl.movement_y > 0) movestate += 1;
-#ifdef GMQCC
- note = 0;
-#endif
+ 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;
+
+ int note = 0;
switch(movestate)
{
// layout: originally I wanted
return note;
}
-float W_Tuba_NoteSendEntity(entity to, float sf)
+bool W_Tuba_NoteSendEntity(entity to, int sf)
{
- float f;
+ int f;
msg_entity = to;
if(!sound_allowed(MSG_ONE, self.realowner))
- return FALSE;
+ return false;
WriteByte(MSG_ENTITY, ENT_CLIENT_TUBANOTE);
WriteByte(MSG_ENTITY, sf);
}
if(sf & 2)
{
- WriteCoord(MSG_ENTITY, self.origin_x);
- WriteCoord(MSG_ENTITY, self.origin_y);
- WriteCoord(MSG_ENTITY, self.origin_z);
+ WriteCoord(MSG_ENTITY, self.origin.x);
+ WriteCoord(MSG_ENTITY, self.origin.y);
+ WriteCoord(MSG_ENTITY, self.origin.z);
}
- return TRUE;
+ return true;
}
void W_Tuba_NoteThink(void)
vector o;
float n;
- W_SetupShot(self, FALSE, 2, "", 0, WEP_CVAR(tuba, damage));
+ W_SetupShot(self, false, 2, "", 0, WEP_CVAR(tuba, damage));
n = W_Tuba_GetNote(self, hittype);
self.tuba_note.think = W_Tuba_NoteThink;
self.tuba_note.nextthink = time;
self.tuba_note.spawnshieldtime = time;
- Net_LinkEntity(self.tuba_note, FALSE, 0, W_Tuba_NoteSendEntity);
+ Net_LinkEntity(self.tuba_note, false, 0, W_Tuba_NoteSendEntity);
}
self.tuba_note.teleport_time = time + WEP_CVAR(tuba, refire) * 2 * W_WeaponRateFactor(); // so it can get prolonged safely
}
}
-float W_Tuba(float req)
+bool W_Tuba(int req)
{
switch(req)
{
else
self.BUTTON_ATCK2 = 1;
}
-
- return TRUE;
+
+ return true;
}
case WR_THINK:
{
self = oldself;
}
}
-
- return TRUE;
+
+ return true;
}
case WR_INIT:
{
precache_model("models/weapons/h_akordeon.iqm");
precache_model("models/weapons/v_kleinbottle.md3");
precache_model("models/weapons/h_kleinbottle.iqm");
- TUBA_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
- return TRUE;
+ TUBA_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
+ return true;
}
case WR_SETUP:
{
self.ammo_field = ammo_none;
self.tuba_instrument = 0;
- return TRUE;
+ return true;
}
case WR_RELOAD:
{
self.weaponname = "tuba";
break;
}
- W_SetupShot(self, FALSE, 0, "", 0, 0);
+ W_SetupShot(self, false, 0, "", 0, 0);
pointparticles(particleeffectnum("teleport"), w_shotorg, '0 0 0', 1);
self.weaponentity.state = WS_INUSE;
weapon_thinkf(WFRAME_RELOAD, 0.5, w_ready);
}
-
- return TRUE;
+
+ return true;
}
case WR_CHECKAMMO1:
case WR_CHECKAMMO2:
{
- return TRUE; // tuba has infinite ammo
+ return true; // tuba has infinite ammo
}
case WR_CONFIG:
{
- TUBA_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
- return TRUE;
+ TUBA_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
+ return true;
}
case WR_SUICIDEMESSAGE:
{
return WEAPON_TUBA_MURDER;
}
}
- return FALSE;
+ return false;
}
#endif
#ifdef CSQC
-float W_Tuba(float req)
+bool W_Tuba(int req)
{
// nothing to do here; particles of tuba are handled differently
// WEAPONTODO
case WR_ZOOMRETICLE:
{
// no weapon specific image for this weapon
- return FALSE;
+ return false;
}
}
- return FALSE;
+ return false;
}
#endif
#endif