bool onground = 0;
if(self == csqcplayer)
{
- if(self.flags & FL_ONGROUND)
+ if(IS_ONGROUND(self))
onground = 1;
self.anim_prev_pmove_flags = self.flags;
if(self.flags & FL_DUCKED)
{
self.move_angles_x = 0;
self.move_angles_z = 0;
- self.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self);
}
Movetype_Physics_MatchTicrate(self, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
DropBall(self, ownr.origin, ownr.velocity);
makevectors(ownr.v_angle.y * '0 1 0');
ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
- ownr.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(ownr);
}
void GiveBall(entity plyr, entity ball)
setattachment(ball, world, "");
setorigin(ball, org);
ball.movetype = MOVETYPE_BOUNCE;
- ball.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(ball);
ball.scale = ball_scale;
ball.velocity = vel;
ball.nb_droptime = time;
void InitBall()
{SELFPARAM();
if(gameover) return;
- self.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self);
self.movetype = MOVETYPE_BOUNCE;
if(self.classname == "nexball_basketball")
self.touch = basketball_touch;
if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
{
other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
- other.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(other);
if(!attacker.ballcarried)
{
LogNB("stole", attacker);
float randomness = random(), enemy_len = vlen(self.enemy.origin - self.origin);
if(time >= self.shambler_lastattack) // shambler doesn't attack much
- if(self.flags & FL_ONGROUND)
+ if(IS_ONGROUND(self))
if(randomness <= 0.5 && enemy_len <= autocvar_g_monster_shambler_attack_smash_range)
{
setanim(self, self.anim_melee2, true, true, false);
{SELFPARAM();
if(self.state && (self.flags & FL_MONSTER))
return false; // already attacking
- if(!(self.flags & FL_ONGROUND))
+ if(!(IS_ONGROUND(self)))
return false; // not on the ground
if(self.health <= 0)
return false; // called when dead?
self.touch = touchfunc;
self.origin_z += 1;
self.velocity = vel;
- self.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self);
return true;
}
self.last_enemycheck = time + 1; // check for enemies every second
}
- if(self.state == MONSTER_ATTACK_RANGED && (self.flags & FL_ONGROUND))
+ if(self.state == MONSTER_ATTACK_RANGED && (IS_ONGROUND(self)))
{
self.state = 0;
self.touch = Monster_Touch;
if(vlen(self.origin - self.moveto) > 100)
{
float do_run = (self.enemy || self.monster_moveto);
- if((self.flags & FL_ONGROUND) || ((self.flags & FL_FLY) || (self.flags & FL_SWIM)))
+ if((IS_ONGROUND(self)) || ((self.flags & FL_FLY) || (self.flags & FL_SWIM)))
Monster_CalculateVelocity(self, self.moveto, self.origin, true, ((do_run) ? runspeed : walkspeed));
if(time > self.pain_finished) // TODO: use anim_finished instead!
if(self.crouch)
animbits |= ANIMSTATE_DUCK; // not that monsters can crouch currently...
animdecide_setstate(self, animbits, false);
- animdecide_setimplicitstate(self, (self.flags & FL_ONGROUND));
+ animdecide_setimplicitstate(self, (IS_ONGROUND(self)));
/* // weapon entities for monsters?
if (self.weaponentity)
MUTATOR_HOOKFUNCTION(midair, PlayerPowerups)
{SELFPARAM();
if(time >= game_starttime)
- if(self.flags & FL_ONGROUND)
+ if(IS_ONGROUND(self))
{
self.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
self.midair_shieldtime = max(self.midair_shieldtime, time + autocvar_g_midair_shieldtime);
self.velocity += force;
UpdateCSQCProjectile(self);
- if(damage <= 0 || ((self.flags & FL_ONGROUND) && IS_PLAYER(attacker)))
+ if(damage <= 0 || ((IS_ONGROUND(self)) && IS_PLAYER(attacker)))
return;
if(self.health == self.max_health)
else
acceleration = vlen(force);
- if (self.flags & FL_ONGROUND)
+ if (IS_ONGROUND(self))
{
if (breakforce)
{
acceleration += self.buoyancy * '0 0 1';
}
else
- if(self.flags & FL_ONGROUND)
+ if(IS_ONGROUND(self))
ffriction = self.ground_friction;
else
ffriction = self.air_friction;
self.velocity = self.velocity * (1 - blendrate) + (newdir * blendrate) * velo
#define movelib_move_simple_gravity(newdir,velo,blendrate) \
- if(self.flags & FL_ONGROUND) movelib_move_simple(newdir,velo,blendrate)
+ if(IS_ONGROUND(self)) movelib_move_simple(newdir,velo,blendrate)
void movelib_brake_simple(float force);
#ifndef MOVETYPES_H
#define MOVETYPES_H
+#define IS_ONGROUND(s) boolean((s).flags & FL_ONGROUND)
+#define SET_ONGROUND(s) ((s).flags |= FL_ONGROUND)
+#define UNSET_ONGROUND(s) ((s).flags &= ~FL_ONGROUND)
+
.float move_ltime;
.void()move_think;
.float move_nextthink;
#define SET_JUMP_HELD(s) ((s).flags &= ~FL_JUMPRELEASED)
#define UNSET_JUMP_HELD(s) ((s).flags |= FL_JUMPRELEASED)
-#define IS_ONGROUND(s) boolean((s).flags & FL_ONGROUND)
-#define SET_ONGROUND(s) ((s).flags |= FL_ONGROUND)
-#define UNSET_ONGROUND(s) ((s).flags &= ~FL_ONGROUND)
-
#define WAS_ONGROUND(s) boolean((s).lastflags & FL_ONGROUND)
#define ITEMS_STAT(s) ((s).items)
tdeath(player, teleporter, telefragger, telefragmin, telefragmax);
// player no longer is on ground
- player.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(player);
// reset tracking of oldvelocity for impact damage (sudden velocity changes)
player.oldvelocity = player.velocity;
prep = pre_pos + (self.enemy.velocity * (impact_time + mintime));
if(self.aim_flags & TFL_AIM_ZPREDICT)
- if(!(self.enemy.flags & FL_ONGROUND))
+ if(!IS_ONGROUND(self.enemy))
if(self.enemy.movetype == MOVETYPE_WALK || self.enemy.movetype == MOVETYPE_TOSS || self.enemy.movetype == MOVETYPE_BOUNCE)
{
float vz;
//veh.exteriormodeltoclient = veh.owner;
//veh.tur_head.exteriormodeltoclient = veh.owner;
- pl.flags &= ~FL_ONGROUND;
- veh.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(pl);
+ UNSET_ONGROUND(veh);
veh.team = pl.team;
veh.flags -= FL_NOTARGET;
movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
- if(spider.flags & FL_ONGROUND)
+ if(IS_ONGROUND(spider))
spider.jump_delay = time; // reset now so movement can begin
- //if(spider.flags & FL_ONGROUND)
+ //if(IS_ONGROUND(spider))
{
- if(spider.flags & FL_ONGROUND)
+ if(IS_ONGROUND(spider))
if(spider.frame == 4 && self.tur_head.wait != 0)
{
sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
if(!player.BUTTON_JUMP)
spider.BUTTON_JUMP = 0;
- if((spider.flags & FL_ONGROUND) && player.BUTTON_JUMP && !spider.BUTTON_JUMP && self.tur_head.wait < time)
+ if((IS_ONGROUND(spider)) && player.BUTTON_JUMP && !spider.BUTTON_JUMP && self.tur_head.wait < time)
{
sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
//dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
if(movefix_y == 0 && movefix_x == 0)
sd = v_forward; // always do forward
- spider.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(spider);
spider.velocity = sd * 700 + rt * 600 + v_up * 600;
spider.frame = 4;
{
if(vlen(player.movement) == 0)
{
- if(spider.flags & FL_ONGROUND)
+ if(IS_ONGROUND(spider))
{
if(self.sound_nexttime < time || self.delay != 3)
{
if(player.movement_x > 0)
{
player.movement_x = 1;
- if(spider.flags & FL_ONGROUND)
+ if(IS_ONGROUND(spider))
spider.frame = 0;
}
else if(player.movement_x < 0)
{
player.movement_x = -1;
- if(spider.flags & FL_ONGROUND)
+ if(IS_ONGROUND(spider))
spider.frame = 1;
}
player.movement_y = 0;
float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
if(spider.velocity_z <= 20) // not while jumping
spider.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
- if(spider.flags & FL_ONGROUND)
+ if(IS_ONGROUND(spider))
if(self.sound_nexttime < time || self.delay != 1)
{
self.delay = 1;
if(player.movement_y < 0)
{
player.movement_y = -1;
- if(spider.flags & FL_ONGROUND)
+ if(IS_ONGROUND(spider))
spider.frame = 2;
}
else if(player.movement_y > 0)
{
player.movement_y = 1;
- if(spider.flags & FL_ONGROUND)
+ if(IS_ONGROUND(spider))
spider.frame = 3;
}
float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
if(spider.velocity_z <= 20) // not while jumping
spider.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
- if(spider.flags & FL_ONGROUND)
+ if(IS_ONGROUND(spider))
if(self.sound_nexttime < time || self.delay != 2)
{
self.delay = 2;
}
METHOD(Spiderbot, vr_think, void(Spiderbot thisveh))
{
- if(self.flags & FL_ONGROUND)
+ if(IS_ONGROUND(self))
movelib_brake_simple(autocvar_g_vehicle_spiderbot_speed_stop);
}
METHOD(Spiderbot, vr_death, void(Spiderbot thisveh))
//this.move_movetype = MOVETYPE_WALK; // temp
this.move_velocity = this.velocity;
this.move_avelocity = this.avelocity;
- this.move_flags = BITSET(this.move_flags, FL_ONGROUND, boolean(this.flags & FL_ONGROUND));
+ this.move_flags = BITSET(this.move_flags, FL_ONGROUND, IS_ONGROUND(this));
this.move_flags = BITSET(this.move_flags, FL_WATERJUMP, boolean(this.flags & FL_WATERJUMP));
this.move_waterlevel = this.waterlevel;
this.move_watertype = this.watertype;
this.pmove_flags =
((this.flags & FL_DUCKED) ? PMF_DUCKED : 0) |
(!(this.flags & FL_JUMPRELEASED) ? PMF_JUMP_HELD : 0) |
- ((this.flags & FL_ONGROUND) ? PMF_ONGROUND : 0);
+ ((IS_ONGROUND(this)) ? PMF_ONGROUND : 0);
}
}
const vector o = e.origin;
csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
CSQCPlayer_PredictTo(e, servercommandframe + 1, false);
- CSQCPlayer_SetPredictionError(e.origin - o, e.velocity - v0, pmove_onground - boolean(e.flags & FL_ONGROUND));
+ CSQCPlayer_SetPredictionError(e.origin - o, e.velocity - v0, pmove_onground - IS_ONGROUND(e));
e.origin = o;
e.velocity = v0;
bunnyhopdistance = vlen(self.origin - gco);
// Run only to visible goals
- if(self.flags & FL_ONGROUND)
+ if(IS_ONGROUND(self))
if(self.speed==maxspeed)
if(checkpvs(self.origin + self.view_ofs, self.goalcurrent))
{
#if 0
// Release jump button
if(!cvar("sv_pogostick"))
- if((self.flags & FL_ONGROUND) == 0)
+ if((IS_ONGROUND(self)) == 0)
{
if(self.velocity.z < 0 || vlen(self.velocity)<maxspeed)
self.BUTTON_JUMP = false;
// If there is a trigger_hurt right below try to use the jetpack or make a rocketjump
if(skill>6)
- if (!(self.flags & FL_ONGROUND))
+ if (!(IS_ONGROUND(self)))
{
tracebox(self.origin, self.mins, self.maxs, self.origin + '0 0 -65536', MOVE_NOMONSTERS, self);
if(tracebox_hits_trigger_hurt(self.origin, self.mins, self.maxs, trace_endpos ))
self.aistatus &= ~AI_STATUS_DANGER_AHEAD;
if(trace_fraction == 1 && self.jumppadcount == 0 && !self.goalcurrent.wphardwired )
- if((self.flags & FL_ONGROUND) || (self.aistatus & AI_STATUS_RUNNING) || self.BUTTON_JUMP == true)
+ if((IS_ONGROUND(self)) || (self.aistatus & AI_STATUS_RUNNING) || self.BUTTON_JUMP == true)
{
// Look downwards
traceline(dst_ahead , dst_down, true, world);
if(skill+self.bot_moveskill >= autocvar_bot_ai_bunnyhop_skilloffset)
havocbot_bunnyhop(dir);
- if ((dir * v_up) >= autocvar_sv_jumpvelocity*0.5 && (self.flags & FL_ONGROUND)) self.BUTTON_JUMP=1;
+ if ((dir * v_up) >= autocvar_sv_jumpvelocity*0.5 && (IS_ONGROUND(self))) self.BUTTON_JUMP=1;
if (((dodge * v_up) > 0) && random()*frametime >= 0.2*bound(0,(10-skill-self.bot_dodgeskill)*0.1,1)) self.BUTTON_JUMP=true;
if (((dodge * v_up) < 0) && random()*frametime >= 0.5*bound(0,(10-skill-self.bot_dodgeskill)*0.1,1)) self.havocbot_ducktime=time+0.3/bound(0.1,skill+self.bot_dodgeskill,10);
}
continue;
// not falling
- if((it.flags & FL_ONGROUND) == 0)
+ if((IS_ONGROUND(it)) == 0)
{
traceline(it.origin, it.origin + '0 0 -1500', true, world);
t = pointcontents(trace_endpos + '0 0 1');
// try a short range search for the nearest waypoints, and expand the search repeatedly if none are found
// as this search is expensive we will use lower values if the bot is on the air
float i, increment, maxdistance;
- if(self.flags & FL_ONGROUND)
+ if(IS_ONGROUND(self))
{
increment = 750;
maxdistance = 50000;
while (player)
{
if (!player.isbot)
- if (player.flags & FL_ONGROUND || player.waterlevel > WATERLEVEL_NONE)
+ if (IS_ONGROUND(player) || player.waterlevel > WATERLEVEL_NONE)
{
//navigation_testtracewalk = true;
head = navigation_findnearestwaypoint(player, false);
draggee.draggravity = draggee.gravity;
draggee.movetype = MOVETYPE_WALK;
draggee.gravity = 0.00001;
- draggee.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(draggee);
draggee.draggedby = dragger;
dragger.dragentity = draggee;
if((draggee.flags & FL_ITEM) && (vlen(draggee.velocity) < 32))
{
draggee.velocity = '0 0 0';
- draggee.flags |= FL_ONGROUND; // floating items are FUN
+ SET_ONGROUND(draggee); // floating items are FUN
}
}
entity draggee;
draggee = dragger.dragentity;
- draggee.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(draggee);
curorigin = gettaginfo(draggee, 0);
curorigin = curorigin + v_forward * dragger.draglocalvector.x + v_right * dragger.draglocalvector.y + v_up * dragger.draglocalvector.z;
if(self.crouch)
animbits |= ANIMSTATE_DUCK;
animdecide_setstate(self, animbits, false);
- animdecide_setimplicitstate(self, (self.flags & FL_ONGROUND));
+ animdecide_setimplicitstate(self, (IS_ONGROUND(self)));
}
void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
self.solid = SOLID_CORPSE;
self.ballistics_density = autocvar_g_ballistics_density_corpse;
// don't stick to the floor
- self.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self);
// dying animation
self.deadflag = DEAD_DYING;
self.velocity = self.velocity + farce;
self.move_velocity = self.velocity;
}
- self.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self);
self.move_flags &= ~FL_ONGROUND;
UpdateCSQCProjectile(self);
}
if((frozen_pulling && self.aiment.frozen) || !frozen_pulling)
{
self.aiment.velocity = self.aiment.velocity - dv * 0.5;
- self.aiment.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self.aiment);
if(self.aiment.flags & FL_PROJECTILE)
UpdateCSQCProjectile(self.aiment);
}
}
}
- pull_entity.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(pull_entity);
}
if(!frozen_pulling && !(self.aiment.flags & FL_PROJECTILE))
self.realowner.velocity = dir*spd;
self.realowner.movetype = MOVETYPE_FLY;
- self.realowner.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self.realowner);
}
}
void adaptor_think2use_hittype_splash() // for timed projectile detonation
{SELFPARAM();
- if(!(self.flags & FL_ONGROUND)) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING
+ if(!(IS_ONGROUND(self))) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING
self.projectiledeathtype |= HITTYPE_SPLASH;
adaptor_think2use();
}
if(self.csqcprojectile_clientanimate)
sf |= 0x80; // client animated, not interpolated
- if(self.flags & FL_ONGROUND)
+ if(IS_ONGROUND(self))
sf |= 0x40;
ft = fr = 0;
void CSQCProjectile_Check(entity e)
{
if(e.csqcprojectile_clientanimate)
- if(e.flags & FL_ONGROUND)
+ if(IS_ONGROUND(e))
if(e.origin != e.csqcprojectile_oldorigin)
UpdateCSQCProjectile(e);
e.csqcprojectile_oldorigin = e.origin;