X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcheats.qc;h=3270a9077fbcb1c7b640303553026221836ec7f3;hb=48a9eb74e54b8e703797522a2591c65d19596915;hp=a75537907d7560e43e833221663c6659f20cd47c;hpb=9fa4c0d887cfe9f1165c2407639f4cca2f62a2e1;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index a75537907..e7154b7f5 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -14,7 +14,7 @@ void Drag_MoveDrag(entity from, entity to) { } #else .float maycheat; -float sv_cheats; +float gamestart_sv_cheats; #define CHIMPULSE_SPEEDRUN_INIT 30 #define CHIMPULSE_GIVE_ALL 99 @@ -28,7 +28,7 @@ float sv_cheats; void CheatInit() { - sv_cheats = cvar("sv_cheats"); + gamestart_sv_cheats = autocvar_sv_cheats; } void CheatShutdown() @@ -61,7 +61,7 @@ float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as a return 1; // sv_cheats - if(sv_cheats && autocvar_sv_cheats) + if(gamestart_sv_cheats && autocvar_sv_cheats) return 1; // if we get here, player is not allowed to cheat. Log it. @@ -89,10 +89,14 @@ float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as a ADD_CHEATS(self,cheating); \ return attempting #define IS_CHEAT(i,argc,fr) \ - ++attempting; \ - if(!CheatsAllowed(i,argc,fr)) \ + if((++attempting, !CheatsAllowed(i,argc,fr))) \ break +void spawnfunc_info_autoscreenshot() +{ + // empty spawnfunc just so this entity can exist +} + float CheatImpulse(float i) { BEGIN_CHEAT_FUNCTION(); @@ -180,10 +184,10 @@ float CheatImpulse(float i) self.health = start_health; self.armorvalue = start_armorvalue; self.weapons |= weaponsInMap; - self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn"); - self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn"); - self.pauserotfuel_finished = time + cvar("g_balance_pause_fuel_rot_spawn"); - self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn"); + self.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot_spawn; + self.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot_spawn; + self.pauserotfuel_finished = time + autocvar_g_balance_pause_fuel_rot_spawn; + self.pauseregen_finished = time + autocvar_g_balance_pause_health_regen_spawn; self.strength_finished = 0; self.invincible_finished = 0; } @@ -215,8 +219,25 @@ float CheatImpulse(float i) break; case CHIMPULSE_TELEPORT: IS_CHEAT(i, 0, 0); - if(MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((sv_cheats >= 2) ? 100000 : 100), 1024, 256)) + if(self.movetype == MOVETYPE_NOCLIP) + { + e = find(world, classname, "info_autoscreenshot"); + if(e) + { + sprint(self, "Emergency teleport used info_autoscreenshot location\n"); + setorigin(self, e.origin); + self.angles = e.angles; + remove(e); + // should we? self.angles_x = -self.angles_x; + self.fixangle = TRUE; + self.velocity = '0 0 0'; + DID_CHEAT(); + break; + } + } + if(MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((gamestart_sv_cheats >= 2) ? 100000 : 100), 1024, 256)) { + sprint(self, "Emergency teleport used random location\n"); self.angles_x = -self.angles_x; self.fixangle = TRUE; self.velocity = '0 0 0'; @@ -229,7 +250,7 @@ float CheatImpulse(float i) IS_CHEAT(i, 0, 0); FOR_EACH_PLAYER(e) { - get_model_parameters(e.playermodel, e.skinindex); + get_model_parameters(e.playermodel, e.skin); if(get_model_parameters_sex == "Female") { makevectors(e.angles); @@ -249,7 +270,7 @@ float CheatImpulse(float i) e2 = spawn(); setorigin(e2, org); pointparticles(particleeffectnum("rocket_explode"), org, '0 0 0', 1); - sound(e2, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM); + sound(e2, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM); RadiusDamage(e2, e, 1000, 0, 128, e, 500, DEATH_CHEAT, world); remove(e2); } @@ -303,7 +324,7 @@ float CheatCommand(float argc) // arguments: // effectname effectnum = particleeffectnum(argv(1)); - W_SetupShot(self, FALSE, FALSE, "",0); + W_SetupShot(self, FALSE, FALSE, "", CH_WEAPON_A, 0); traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self); trailparticles(self, effectnum, w_shotorg, trace_endpos); DID_CHEAT(); @@ -318,7 +339,7 @@ float CheatCommand(float argc) // arguments: // modelname mode f = stof(argv(2)); - W_SetupShot(self, FALSE, FALSE, "", 0); + W_SetupShot(self, FALSE, FALSE, "", CH_WEAPON_A, 0); traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, self); if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) || trace_fraction == 1) { @@ -604,14 +625,6 @@ float CheatCommand(float argc) remove(e); DID_CHEAT(); break; - case "warp": - IS_CHEAT(0, argc, 0); - if(argc == 2) if(cvar("g_campaign")) - { - CampaignLevelWarp(stof(argv(1))); - DID_CHEAT(); - } - break; case "god": IS_CHEAT(0, argc, 0); BITXOR_ASSIGN(self.flags, FL_GODMODE); @@ -672,6 +685,7 @@ float CheatCommand(float argc) END_CHEAT_FUNCTION(); } +float Drag(entity e, float grab, float ischeat); void Drag_Begin(entity dragger, entity draggee, vector touchpoint); void Drag_Finish(entity dragger); float Drag_IsDraggable(entity draggee); @@ -689,58 +703,53 @@ float CheatFrame() { BEGIN_CHEAT_FUNCTION(); - if(Drag_IsDragging(self)) + // Dragging can be used as either a cheat, or a function for some objects. If sv_cheats is active, + // the cheat dragging is used (unlimited pickup range and any entity can be carried). If sv_cheats + // is disabled, normal dragging is used (limited pickup range and only dragable objects can be carried), + // grabbing itself no longer being accounted as cheating. + + switch(0) { - if(self.BUTTON_DRAG) - { - if(self.impulse == 10 || self.impulse == 15 || self.impulse == 18) - { - Drag_MoveForward(self); - self.impulse = 0; - } - else if(self.impulse == 12 || self.impulse == 16 || self.impulse == 19) - { - Drag_MoveBackward(self); - self.impulse = 0; - } - else if(self.impulse >= 1 && self.impulse <= 9) - { - Drag_SetSpeed(self, self.impulse - 1); - } - else if(self.impulse == 14) + default: + if(self.maycheat || (gamestart_sv_cheats && autocvar_sv_cheats)) { - Drag_SetSpeed(self, 9); + // use cheat dragging if cheats are enabled + crosshair_trace_plusvisibletriggers(self); + Drag(trace_ent, TRUE, TRUE); } - - if(frametime) - Drag_Update(self); - } - else - { - Drag_Finish(self); - } - } - else - { - if(Drag_CanDrag(self)) - if(self.BUTTON_DRAG) + else { - crosshair_trace(self); - if(trace_ent) - if(Drag_IsDraggable(trace_ent)) - switch(0) - { - default: - IS_CHEAT(0, 0, CHRAME_DRAG); - if(trace_ent.draggedby) - Drag_Finish(trace_ent.draggedby); - if(trace_ent.tag_entity) - detach_sameorigin(trace_ent); - Drag_Begin(self, trace_ent, trace_endpos); - DID_CHEAT(); - break; - } + // drag 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. + + float drag; + crosshair_trace_plusvisibletriggers(self); + if(vlen(self.origin - trace_ent.origin) <= autocvar_g_grab_range) + { + switch(trace_ent.grab) + { + case 0: // can't grab + break; + case 1: // owner can grab + if(trace_ent.owner == self || trace_ent.realowner == self) + drag = TRUE; + break; + case 2: // owner and team mates can grab + if(!IsDifferentTeam(trace_ent.owner, self) || !IsDifferentTeam(trace_ent.realowner, self) || trace_ent.team == self.team) + drag = TRUE; + break; + case 3: // anyone can grab + drag = TRUE; + break; + default: + break; + } + } + Drag(trace_ent, drag, FALSE); // execute dragging } + break; } END_CHEAT_FUNCTION(); @@ -752,6 +761,74 @@ float CheatFrame() // ENTITY DRAGGING +float Drag(entity e, float pick, float ischeat) +{ + BEGIN_CHEAT_FUNCTION(); + + // returns TRUE when an entity has been picked up + // If pick is TRUE, the object can also be picked up if it's not being held already + // If pick is FALSE, only keep dragging the object if it's already being held + + switch(0) + { + default: + if(Drag_IsDragging(self)) + { + if(self.BUTTON_DRAG) + { + if(self.impulse == 10 || self.impulse == 15 || self.impulse == 18) + { + Drag_MoveForward(self); + self.impulse = 0; + } + else if(self.impulse == 12 || self.impulse == 16 || self.impulse == 19) + { + Drag_MoveBackward(self); + self.impulse = 0; + } + else if(self.impulse >= 1 && self.impulse <= 9) + { + Drag_SetSpeed(self, self.impulse - 1); + } + else if(self.impulse == 14) + { + Drag_SetSpeed(self, 9); + } + + if(frametime) + Drag_Update(self); + } + else + { + Drag_Finish(self); + } + } + else + { + if(Drag_CanDrag(self)) + if(self.BUTTON_DRAG && pick) + { + if(e) + if(Drag_IsDraggable(e)) + { + if(ischeat) + IS_CHEAT(0, 0, CHRAME_DRAG); + if(e.draggedby) + Drag_Finish(e.draggedby); + if(e.tag_entity) + detach_sameorigin(e); + Drag_Begin(self, e, trace_endpos); + if(ischeat) + DID_CHEAT(); + return TRUE; + } + } + } + break; + } + return FALSE; +} + // on dragger: .float draggravity; .float dragspeed; // speed of mouse wheel action @@ -820,6 +897,8 @@ void Drag_Finish(entity dragger) float Drag_IsDraggable(entity draggee) { // TODO add more checks for bad stuff here + if(draggee == world) + 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) @@ -828,14 +907,16 @@ float Drag_IsDraggable(entity draggee) return FALSE; if(draggee.classname == "func_button") return FALSE; - if(draggee.model == "") - return FALSE; +// if(draggee.model == "") +// return FALSE; if(draggee.classname == "spectator") return FALSE; if(draggee.classname == "observer") return FALSE; if(draggee.classname == "exteriorweaponentity") return FALSE; + if(draggee.classname == "weaponentity") + return FALSE; return TRUE; } @@ -926,11 +1007,6 @@ void Drag_MoveDrag(entity from, entity to) } } - - - - - void DragBox_Think() { if(self.aiment && self.enemy)