#include "../common/deathtypes/all.qc"
#include "../common/effects/all.qc"
#include "../common/gamemodes/all.qc"
+#include "../common/impulses/all.qc"
#include "../common/items/all.qc"
#include "../common/monsters/all.qc"
#include "../common/mutators/all.qc"
--- /dev/null
+#include "all.qh"
--- /dev/null
+#ifndef IMPULSES_ALL_H
+#define IMPULSES_ALL_H
+
+REGISTRY(IMPULSES, 255)
+REGISTER_REGISTRY(IMPULSES)
+REGISTRY_SORT(IMPULSES)
+STATIC_INIT(IMPULSES_renumber)
+{
+ FOREACH(IMPULSES, true, LAMBDA(it.m_id = i));
+}
+REGISTRY_CHECK(IMPULSES)
+
+.void(entity this) impulse_handle;
+
+#if defined(CSQC)
+#define IMPULSE_ALIAS(alias, id) localcmd("\nalias " #alias " \"" id "\"\n")
+#else
+#define IMPULSE_ALIAS(alias, id)
+#endif
+
+#define REGISTER_IMPULSE(id, n) _REGISTER_IMPULSE(IMP_##id, id, n)
+#define _REGISTER_IMPULSE(id, alias, n) \
+ REGISTER(IMPULSES, id, m_id, new(Impulse)) \
+ { \
+ make_pure(this); \
+ this.impulse = n; \
+ IMPULSE_ALIAS(alias, "impulse " #n); \
+ }
+
+#define LEGACY_IMPULSE(alias, id, new) \
+ STATIC_INIT(legacy_##alias) { IMPULSE_ALIAS(alias, new); } \
+ SHUTDOWN(legacy_##alias) { IMPULSE_ALIAS(alias, "impulse " #id); }
+
+#define X(slot, imp) \
+ REGISTER_IMPULSE(weapon_group_##slot, imp) LEGACY_IMPULSE(weapon_group_##slot, imp, "impulse" #imp)
+X(1, 1)
+X(2, 2)
+X(3, 3)
+X(4, 4)
+X(5, 5)
+X(6, 6)
+X(7, 7)
+X(8, 8)
+X(9, 9)
+X(0, 14)
+#undef X
+
+REGISTER_IMPULSE(weapon_next_byid, 10)
+LEGACY_IMPULSE(_weapnext_2, 10, "weapon_next_byid")
+
+REGISTER_IMPULSE(weapon_prev_byid, 12)
+LEGACY_IMPULSE(_weapprev_2, 12, "weapon_prev_byid")
+
+REGISTER_IMPULSE(weapon_next_bygroup, 18)
+LEGACY_IMPULSE(_weapnext_0, 18, "weapon_next_bygroup")
+
+REGISTER_IMPULSE(weapon_prev_bygroup, 19)
+LEGACY_IMPULSE(_weapprev_0, 19, "weapon_prev_bygroup")
+
+REGISTER_IMPULSE(weapon_next_bypriority, 15)
+LEGACY_IMPULSE(_weapnext_1, 15, "weapon_next_bypriority")
+
+REGISTER_IMPULSE(weapon_prev_bypriority, 16)
+LEGACY_IMPULSE(_weapprev_1, 16, "weapon_prev_bypriority")
+
+REGISTER_IMPULSE(weapon_last, 11)
+LEGACY_IMPULSE(weaplast, 11, "weapon_last")
+
+REGISTER_IMPULSE(weapon_best, 13)
+LEGACY_IMPULSE(weapbest, 13, "weapon_best")
+
+REGISTER_IMPULSE(weapon_drop, 17)
+LEGACY_IMPULSE(dropweapon, 17, "weapon_drop")
+
+REGISTER_IMPULSE(weapon_reload, 20)
+LEGACY_IMPULSE(reload, 20, "weapon_reload")
+
+REGISTER_IMPULSE(use, 21)
+LEGACY_IMPULSE(use, 21, "use")
+
+REGISTER_IMPULSE(waypoint_personal_here, 30)
+LEGACY_IMPULSE(g_waypointsprite_personal, 30, "waypoint_personal_here")
+
+REGISTER_IMPULSE(waypoint_personal_crosshair, 31)
+LEGACY_IMPULSE(g_waypointsprite_personal_p, 31, "waypoint_personal_crosshair")
+
+REGISTER_IMPULSE(waypoint_personal_death, 32)
+LEGACY_IMPULSE(g_waypointsprite_personal_d, 32, "waypoint_personal_death")
+
+REGISTER_IMPULSE(waypoint_here_follow, 33)
+LEGACY_IMPULSE(g_waypointsprite_team_helpme, 33, "waypoint_here_follow")
+
+REGISTER_IMPULSE(waypoint_here_here, 34)
+LEGACY_IMPULSE(g_waypointsprite_team_here, 34, "waypoint_here_here")
+
+REGISTER_IMPULSE(waypoint_here_crosshair, 35)
+LEGACY_IMPULSE(g_waypointsprite_team_here_p, 35, "waypoint_here_crosshair")
+
+REGISTER_IMPULSE(waypoint_here_death, 36)
+LEGACY_IMPULSE(g_waypointsprite_team_here_d, 36, "waypoint_here_death")
+
+REGISTER_IMPULSE(waypoint_danger_here, 37)
+LEGACY_IMPULSE(g_waypointsprite_team_danger, 37, "waypoint_danger_here")
+
+REGISTER_IMPULSE(waypoint_danger_crosshair, 38)
+LEGACY_IMPULSE(g_waypointsprite_team_danger_p, 38, "waypoint_danger_crosshair")
+
+REGISTER_IMPULSE(waypoint_danger_death, 39)
+LEGACY_IMPULSE(g_waypointsprite_team_danger_d, 39, "waypoint_danger_death")
+
+REGISTER_IMPULSE(waypoint_clear_personal, 47)
+LEGACY_IMPULSE(g_waypointsprite_clear_personal, 47, "waypoint_clear_personal")
+
+REGISTER_IMPULSE(waypoint_clear, 48)
+LEGACY_IMPULSE(g_waypointsprite_clear, 48, "waypoint_clear")
+
+REGISTER_IMPULSE(navwaypoint_spawn, 103)
+LEGACY_IMPULSE(g_waypointeditor_spawn, 103, "navwaypoint_spawn")
+
+REGISTER_IMPULSE(navwaypoint_remove, 104)
+LEGACY_IMPULSE(g_waypointeditor_remove, 104, "navwaypoint_remove")
+
+REGISTER_IMPULSE(navwaypoint_relink, 105)
+LEGACY_IMPULSE(g_waypointeditor_relinkall, 105, "navwaypoint_relink")
+
+REGISTER_IMPULSE(navwaypoint_save, 106)
+LEGACY_IMPULSE(g_waypointeditor_saveall, 106, "navwaypoint_save")
+
+REGISTER_IMPULSE(navwaypoint_unreachable, 107)
+LEGACY_IMPULSE(g_waypointeditor_unreachable, 107, "navwaypoint_unreachable")
+
+#define CHIMPULSE(id, n) _CHIMPULSE(CHIMPULSE_##id, n)
+#define _CHIMPULSE(id, n) \
+ REGISTER(IMPULSES, id, m_id, new(Impulse)) \
+ { \
+ make_pure(this); \
+ this.impulse = n; \
+ }
+
+CHIMPULSE(SPEEDRUN_INIT, 30)
+CHIMPULSE(GIVE_ALL, 99)
+CHIMPULSE(CLONE_MOVING, 140)
+CHIMPULSE(SPEEDRUN, 141)
+CHIMPULSE(CLONE_STANDING, 142)
+CHIMPULSE(TELEPORT, 143)
+CHIMPULSE(R00T, 148)
+
+#endif
return world;
}
-bool MinigameImpulse(int imp)
-{SELFPARAM();
- entity e = minigame_find_player(self);
- if ( imp && self.active_minigame && e )
+bool MinigameImpulse(entity this, int imp)
+{
+ if (!this.active_minigame) return false;
+ entity e = minigame_find_player(this);
+ if ( imp && this.active_minigame && e )
{
- return self.active_minigame.minigame_event(self.active_minigame,"impulse",e,imp);
+ return this.active_minigame.minigame_event(this.active_minigame,"impulse",e,imp);
}
return false;
}
bool minigame_CheckSend();
// Check for minigame impulses
-bool MinigameImpulse(int imp);
+bool MinigameImpulse(entity this, int imp);
// Parse a client command ( cmd minigame ... )
void ClientCommand_minigame(int request, int argc, string command);
vehicles_enter(other, self);
}
-bool vehicle_impulse(int imp)
-{SELFPARAM();
- switch(imp)
+bool vehicle_impulse(entity this, int imp)
+{
+ entity v = this.vehicle;
+ if (!v) return false;
+ if (v.deadflag != DEAD_NO) return false;
+ bool(int) f = v.vehicles_impulse;
+ if (f && f(imp)) return true;
+ switch (imp)
{
case 17:
{
return true;
}
}
-
return false;
}
void vehicles_exit(float eject);
float vehicle_initialize(entity vehicle, float nodrop);
-bool vehicle_impulse(int imp);
+bool vehicle_impulse(entity this, int imp);
bool vehicles_crushable(entity e);
#endif
return 0;
// sv_clones
- if(i == CHIMPULSE_CLONE_MOVING || i == CHIMPULSE_CLONE_STANDING)
+ if(i == CHIMPULSE_CLONE_MOVING.impulse || i == CHIMPULSE_CLONE_STANDING.impulse)
if(self.lip < sv_clones)
return 1;
{
entity e, e2;
- case CHIMPULSE_SPEEDRUN_INIT: // deploy personal waypoint
+ case CHIMPULSE_SPEEDRUN_INIT.impulse: // deploy personal waypoint
// shared with regular waypoint init, so this is not a cheat by itself
if(!self.personal)
{
self.personal.invincible_finished = self.invincible_finished;
self.personal.teleport_time = time;
break; // this part itself doesn't cheat, so let's not count this
- case CHIMPULSE_CLONE_MOVING:
+ case CHIMPULSE_CLONE_MOVING.impulse:
IS_CHEAT(i, 0, 0);
makevectors (self.v_angle);
self.velocity = self.velocity + v_forward * 300;
self.velocity = self.velocity - v_forward * 300;
DID_CHEAT();
break;
- case CHIMPULSE_CLONE_STANDING:
+ case CHIMPULSE_CLONE_STANDING.impulse:
IS_CHEAT(i, 0, 0);
CopyBody(0);
self.lip += 1;
DID_CHEAT();
break;
- case CHIMPULSE_GIVE_ALL:
+ case CHIMPULSE_GIVE_ALL.impulse:
IS_CHEAT(i, 0, 0);
CheatCommand(tokenize_console("give all"));
break; // already counted as cheat
- case CHIMPULSE_SPEEDRUN:
+ case CHIMPULSE_SPEEDRUN.impulse:
IS_CHEAT(i, 0, 0);
if(self.personal)
{
else
sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
break;
- case CHIMPULSE_TELEPORT:
+ case CHIMPULSE_TELEPORT.impulse:
IS_CHEAT(i, 0, 0);
if(self.movetype == MOVETYPE_NOCLIP)
{
}
sprint(self, "Emergency teleport could not find a good location, forget it!\n");
break;
- case CHIMPULSE_R00T:
+ case CHIMPULSE_R00T.impulse:
IS_CHEAT(i, 0, 0);
RandomSelection_Init();
FOR_EACH_PLAYER(e)
#ifndef CHEATS_H
#define CHEATS_H
+#include "../common/impulses/all.qh"
+
//float autocvar_sv_cheats; // must... declare... global
float cheatcount_total;
float CheatCommand(float argc);
float CheatFrame();
-const float CHIMPULSE_SPEEDRUN_INIT = 30;
-const float CHIMPULSE_GIVE_ALL = 99;
-const float CHIMPULSE_CLONE_MOVING = 140;
-const float CHIMPULSE_SPEEDRUN = 141;
-const float CHIMPULSE_CLONE_STANDING = 142;
-const float CHIMPULSE_TELEPORT = 143;
-const float CHIMPULSE_R00T = 148;
-
const float CHRAME_DRAG = 8;
void Drag_MoveDrag(entity from, entity to); // call this from CopyBody
{SELFPARAM();
if ( self.impulse )
{
- MinigameImpulse(self.impulse);
+ MinigameImpulse(self, self.impulse);
self.impulse = 0;
}
float prefered_movetype;
{SELFPARAM();
if ( self.impulse )
{
- if(MinigameImpulse(self.impulse))
+ if(MinigameImpulse(self, self.impulse))
self.impulse = 0;
}
if (self.flags & FL_JUMPRELEASED) {
.entity vehicle;
-REGISTRY(IMPULSES, 255)
-REGISTER_REGISTRY(IMPULSES)
-REGISTRY_SORT(IMPULSES)
-STATIC_INIT(IMPULSES_renumber)
-{
- FOREACH(IMPULSES, true, LAMBDA(it.m_id = i));
-}
-REGISTRY_CHECK(IMPULSES)
-
-.void(entity this) impulse_handle;
-
#define IMPULSE(id, n) _IMPULSE(IMP_##id, n)
#define _IMPULSE(id, n) \
void id##_handle(entity this); \
- REGISTER(IMPULSES, id, m_id, new(Impulse)) \
+ STATIC_INIT_LATE(id) \
{ \
- make_pure(this); \
- this.impulse = n; \
- this.impulse_handle = id##_handle; \
+ id.impulse_handle = id##_handle; \
} \
void id##_handle(entity this)
if (this.deadflag != DEAD_NO) return;
W_NextWeapon(1);
}
+
IMPULSE(weapon_prev_bygroup, 19)
{
if (this.vehicle) return;
if (this.deadflag != DEAD_NO) return;
W_NextWeapon(2);
}
+
IMPULSE(weapon_prev_bypriority, 16)
{
if (this.vehicle) return;
W_SwitchWeapon(w_getbestweapon(this));
}
-IMPULSE(weapon_throw, 17)
+IMPULSE(weapon_drop, 17)
{
if (this.vehicle) return;
if (this.deadflag != DEAD_NO) return;
if (!imp) return;
this.impulse = 0;
- if (this.active_minigame && MinigameImpulse(imp)) return;
+ if (MinigameImpulse(this, imp)) return;
if (timeout_status == TIMEOUT_ACTIVE) return; // don't allow any impulses while the game is paused
if (round_handler_IsActive() && !round_handler_IsRoundStarted())
if (imp == 17 || (imp >= 20 && imp < 200) || imp > 253) return;
- if (this.vehicle && this.vehicle.deadflag == DEAD_NO)
- {
- bool(int) f = this.vehicle.vehicles_impulse;
- if (f && f(imp)) return;
- if (vehicle_impulse(imp)) return;
- }
+ if (vehicle_impulse(this, imp)) return;
if (CheatImpulse(imp)) return;
FOREACH(IMPULSES, it.impulse == imp, {
- it.impulse_handle(this);
+ void(entity) f = it.impulse_handle;
+ if (!f) continue;
+ f(this);
return;
});
sprint(this, "personal waypoint cleared\n");
}
-IMPULSE(waypoint_clear_team, 48)
+IMPULSE(waypoint_clear, 48)
{
WaypointSprite_ClearOwned();
if (this.personal)
waypoint_saveall();
}
-IMPULSE(navwaypoint_debug, 107)
+IMPULSE(navwaypoint_unreachable, 107)
{
if (!autocvar_g_waypointeditor) return;
for (entity e = findchain(classname, "waypoint"); e; e = e.chain)
ctf_CheckFlagReturn(self, RETURN_SPEEDRUN);
setself(self.owner);
- self.impulse = CHIMPULSE_SPEEDRUN; // move the player back to the waypoint they set
+ self.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
ImpulseCommands(self);
setself(this);
}
#include "../common/deathtypes/all.qc"
#include "../common/effects/all.qc"
#include "../common/gamemodes/all.qc"
+#include "../common/impulses/all.qc"
#include "../common/items/all.qc"
#include "../common/monsters/all.qc"
#include "../common/turrets/all.qc"