X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcheats.qc;h=9167ca5e7753cb165b52474559df0223c4a0cbc1;hb=969dc49d01d650a812706aba16c765af488605d0;hp=1e3b9e51022685e1eeae3fc94a6778e4eba53fd0;hpb=338f8f4862627b3ee04cbdd20dc5590973614e01;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 1e3b9e510..9167ca5e7 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -4,8 +4,10 @@ #include #include #include +#include #include "g_damage.qh" +#include "clientkill.qh" #include "player.qh" #include "race.qh" #include "../common/mapobjects/teleporters.qh" @@ -61,13 +63,11 @@ void CheatShutdown() float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets passed as argument for possible future ACL checking { - // dead people cannot cheat if(IS_DEAD(this)) return 0; if(gamestart_sv_cheats < 2 && !IS_PLAYER(this)) return 0; - // sv_clones if(i == CHIMPULSE_CLONE_MOVING.impulse || i == CHIMPULSE_CLONE_STANDING.impulse) if(this.lip < sv_clones) return 1; @@ -76,7 +76,6 @@ float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets if(this.maycheat) return 1; - // sv_cheats if(gamestart_sv_cheats && autocvar_sv_cheats) return 1; @@ -94,8 +93,7 @@ float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets } #define BEGIN_CHEAT_FUNCTION() \ - float cheating, attempting; \ - cheating = 0; attempting = 0 + float cheating = 0, attempting = 0 #define DID_CHEAT() \ ++cheating #define ADD_CHEATS(e,n) \ @@ -126,6 +124,7 @@ void info_autoscreenshot_findtarget(entity this) } spawnfunc(info_autoscreenshot) { + // this one just has to exist if(++num_autoscreenshot > autocvar_g_max_info_autoscreenshot) { objerror(this, "Too many info_autoscreenshot entitites. FAIL!"); @@ -133,7 +132,6 @@ spawnfunc(info_autoscreenshot) } if(this.target != "") InitializeEntity(this, info_autoscreenshot_findtarget, INITPRIO_FINDTARGET); - // this one just has to exist } float CheatImpulse(entity this, int imp) @@ -152,22 +150,24 @@ float CheatImpulse(entity this, int imp) this.personal.origin = this.origin; this.personal.v_angle = this.v_angle; this.personal.velocity = this.velocity; - SetResourceAmount(this.personal, RESOURCE_ROCKETS, GetResourceAmount(this, RESOURCE_ROCKETS)); - SetResourceAmount(this.personal, RESOURCE_BULLETS, GetResourceAmount(this, RESOURCE_BULLETS)); - SetResourceAmount(this.personal, RESOURCE_CELLS, GetResourceAmount(this, RESOURCE_CELLS)); - SetResourceAmount(this.personal, RESOURCE_PLASMA, GetResourceAmount(this, RESOURCE_PLASMA)); - SetResourceAmount(this.personal, RESOURCE_SHELLS, GetResourceAmount(this, RESOURCE_SHELLS)); - SetResourceAmount(this.personal, RESOURCE_FUEL, GetResourceAmount(this, RESOURCE_FUEL)); - SetResourceAmount(this.personal, RESOURCE_HEALTH, max(1, GetResourceAmount(this, RESOURCE_HEALTH))); - SetResourceAmount(this.personal, RESOURCE_ARMOR, GetResourceAmount(this, RESOURCE_ARMOR)); + SetResource(this.personal, RES_ROCKETS, GetResource(this, RES_ROCKETS)); + SetResource(this.personal, RES_BULLETS, GetResource(this, RES_BULLETS)); + SetResource(this.personal, RES_CELLS, GetResource(this, RES_CELLS)); + SetResource(this.personal, RES_PLASMA, GetResource(this, RES_PLASMA)); + SetResource(this.personal, RES_SHELLS, GetResource(this, RES_SHELLS)); + SetResource(this.personal, RES_FUEL, GetResource(this, RES_FUEL)); + SetResource(this.personal, RES_HEALTH, max(1, GetResource(this, RES_HEALTH))); + SetResource(this.personal, RES_ARMOR, GetResource(this, RES_ARMOR)); STAT(WEAPONS, this.personal) = STAT(WEAPONS, this); + STAT(BUFFS, this.personal) = STAT(BUFFS, this); + STAT(BUFF_TIME, this.personal) = STAT(BUFF_TIME, this); this.personal.items = this.items; this.personal.pauserotarmor_finished = this.pauserotarmor_finished; this.personal.pauserothealth_finished = this.pauserothealth_finished; this.personal.pauserotfuel_finished = this.pauserotfuel_finished; this.personal.pauseregen_finished = this.pauseregen_finished; - this.personal.strength_finished = this.strength_finished; - this.personal.invincible_finished = this.invincible_finished; + STAT(STRENGTH_FINISHED, this.personal) = STAT(STRENGTH_FINISHED, this); + STAT(INVINCIBLE_FINISHED, this.personal) = STAT(INVINCIBLE_FINISHED, this); this.personal.teleport_time = time; break; // this part itself doesn't cheat, so let's not count this case CHIMPULSE_CLONE_MOVING.impulse: @@ -211,22 +211,24 @@ float CheatImpulse(entity this, int imp) MUTATOR_CALLHOOK(AbortSpeedrun, this); } - SetResourceAmount(this, RESOURCE_ROCKETS, GetResourceAmount(this.personal, RESOURCE_ROCKETS)); - SetResourceAmount(this, RESOURCE_BULLETS, GetResourceAmount(this.personal, RESOURCE_BULLETS)); - SetResourceAmount(this, RESOURCE_CELLS, GetResourceAmount(this.personal, RESOURCE_CELLS)); - SetResourceAmount(this, RESOURCE_PLASMA, GetResourceAmount(this.personal, RESOURCE_PLASMA)); - SetResourceAmount(this, RESOURCE_SHELLS, GetResourceAmount(this.personal, RESOURCE_SHELLS)); - SetResourceAmount(this, RESOURCE_FUEL, GetResourceAmount(this.personal, RESOURCE_FUEL)); - SetResourceAmount(this, RESOURCE_HEALTH, GetResourceAmount(this.personal, RESOURCE_HEALTH)); - SetResourceAmount(this, RESOURCE_ARMOR, GetResourceAmount(this.personal, RESOURCE_ARMOR)); + SetResource(this, RES_ROCKETS, GetResource(this.personal, RES_ROCKETS)); + SetResource(this, RES_BULLETS, GetResource(this.personal, RES_BULLETS)); + SetResource(this, RES_CELLS, GetResource(this.personal, RES_CELLS)); + SetResource(this, RES_PLASMA, GetResource(this.personal, RES_PLASMA)); + SetResource(this, RES_SHELLS, GetResource(this.personal, RES_SHELLS)); + SetResource(this, RES_FUEL, GetResource(this.personal, RES_FUEL)); + SetResource(this, RES_HEALTH, GetResource(this.personal, RES_HEALTH)); + SetResource(this, RES_ARMOR, GetResource(this.personal, RES_ARMOR)); STAT(WEAPONS, this) = STAT(WEAPONS, this.personal); + STAT(BUFFS, this) = STAT(BUFFS, this.personal); + STAT(BUFF_TIME, this) = STAT(BUFF_TIME, this.personal); this.items = this.personal.items; this.pauserotarmor_finished = time + this.personal.pauserotarmor_finished - this.personal.teleport_time; this.pauserothealth_finished = time + this.personal.pauserothealth_finished - this.personal.teleport_time; this.pauserotfuel_finished = time + this.personal.pauserotfuel_finished - this.personal.teleport_time; this.pauseregen_finished = time + this.personal.pauseregen_finished - this.personal.teleport_time; - this.strength_finished = time + this.personal.strength_finished - this.personal.teleport_time; - this.invincible_finished = time + this.personal.invincible_finished - this.personal.teleport_time; + STAT(STRENGTH_FINISHED, this) = time + STAT(STRENGTH_FINISHED, this.personal) - this.personal.teleport_time; + STAT(INVINCIBLE_FINISHED, this) = time + STAT(INVINCIBLE_FINISHED, this.personal) - this.personal.teleport_time; if(!autocvar_g_allow_checkpoints) DID_CHEAT(); @@ -355,7 +357,7 @@ float CheatCommand(entity this, int argc) entity e = spawn(); e.model = strzone(argv(1)); e.mdl = "rocket_explode"; - SetResourceAmountExplicit(e, RESOURCE_HEALTH, 1000); + SetResourceExplicit(e, RES_HEALTH, 1000); setorigin(e, trace_endpos); e.effects = EF_NOMODELFLAGS; if(f == 1) @@ -559,7 +561,7 @@ float CheatCommand(entity this, int argc) effectnum = 0; for(entity ent = NULL; (ent = find(ent, classname, "dragbox_box")); ) { - if(e.cnt <= 0 && ent.cnt == 0 || e.cnt == ent.cnt) + if((e.cnt <= 0 && ent.cnt == 0) || e.cnt == ent.cnt) { start = start + ent.origin; ++effectnum; @@ -799,59 +801,51 @@ float Drag(entity this, float force_allow_pick, float ischeat) Drag_Finish(this); } } - else + else if(Drag_CanDrag(this) && PHYS_INPUT_BUTTON_DRAG(this)) { - if(Drag_CanDrag(this)) - if(PHYS_INPUT_BUTTON_DRAG(this)) - { - crosshair_trace_plusvisibletriggers(this); - entity e = trace_ent; - float pick = force_allow_pick; - if (e && !pick) - { - // pick is true if the object can be picked up. While an object is being carried, the Drag() function - // must execute for it either way, otherwise it would cause bugs if it went out of the player's trace. - // This also makes sure that an object can only pe picked up if in range, but does not get dropped if - // it goes out of range while slinging it around. + crosshair_trace_plusvisibletriggers(this); + entity e = trace_ent; + float pick = force_allow_pick; + if (e && !pick && vdist(this.origin - e.origin, <=, autocvar_g_grab_range)) + { + // pick is true if the object can be picked up. While an object is being carried, the Drag() function + // must execute for it either way, otherwise it would cause bugs if it went out of the player's trace. + // This also makes sure that an object can only pe picked up if in range, but does not get dropped if + // it goes out of range while slinging it around. - if(vdist(this.origin - e.origin, <=, autocvar_g_grab_range)) - { - switch(e.grab) - { - case 0: // can't grab - break; - case 1: // owner can grab - if(e.owner == this || e.realowner == this) - pick = true; - break; - case 2: // owner and team mates can grab - if(SAME_TEAM(e.owner, this) || SAME_TEAM(e.realowner, this) || e.team == this.team) - pick = true; - break; - case 3: // anyone can grab - pick = true; - break; - default: - break; - } - } - } - // Find e and pick - if(e && pick) - if(Drag_IsDraggable(e)) - { - if(ischeat) - IS_CHEAT(this, 0, 0, CHRAME_DRAG); - if(e.draggedby) - Drag_Finish(e.draggedby); - if(e.tag_entity) - detach_sameorigin(e); - Drag_Begin(this, e, trace_endpos); - if(ischeat) - DID_CHEAT(); - return true; - } + switch(e.grab) + { + case 0: // can't grab + break; + case 1: // owner can grab + if(e.owner == this || e.realowner == this) + pick = true; + break; + case 2: // owner and team mates can grab + if(SAME_TEAM(e.owner, this) || SAME_TEAM(e.realowner, this) || e.team == this.team) + pick = true; + break; + case 3: // anyone can grab + pick = true; + break; + default: + break; } + } + // Find e and pick + if(e && pick && Drag_IsDraggable(e, this)) + { + if(ischeat) + IS_CHEAT(this, 0, 0, CHRAME_DRAG); + if(e.draggedby) + Drag_Finish(e.draggedby); + if(e.tag_entity) + detach_sameorigin(e); + Drag_Begin(this, e, trace_endpos); + if(ischeat) + DID_CHEAT(); + return true; + } } break; } @@ -914,31 +908,24 @@ void Drag_Finish(entity dragger) } } -float Drag_IsDraggable(entity draggee) +bool drag_undraggable(entity draggee, entity dragger) +{ + // stuff probably shouldn't need this, we should figure out why they do! + // exceptions of course are observers and weapon entities, where things mess up + return false; +} + +float Drag_IsDraggable(entity draggee, entity dragger) { // TODO add more checks for bad stuff here if(draggee == NULL) return false; - if(draggee.classname == "func_bobbing") - return false; if(draggee.classname == "door") // FIXME find out why these must be excluded, or work around the problem (trying to drag these causes like 4 fps) - return false; - if(draggee.classname == "plat") - return false; - if(draggee.classname == "func_button") - return false; -// if(draggee.model == "") -// return false; - if(IS_SPEC(draggee)) - return false; - if(IS_OBSERVER(draggee)) - return false; - if(draggee.classname == "exteriorweaponentity") - return false; - if(draggee.classname == "weaponentity") - return false; + return false; // probably due to BSP collision + //if(draggee.model == "") + // return false; - return true; + return ((draggee.draggable) ? draggee.draggable(draggee, dragger) : true); } float Drag_MayChangeAngles(entity draggee) @@ -1016,7 +1003,7 @@ float Drag_IsDragging(entity dragger) dragger.dragentity = NULL; return false; } - if(!Drag_CanDrag(dragger) || !Drag_IsDraggable(dragger.dragentity)) + if(!Drag_CanDrag(dragger) || !Drag_IsDraggable(dragger.dragentity, dragger)) { Drag_Finish(dragger); return false;