DarkPlacesEngine / DarkPlaces

The DarkPlaces Quake engine, created by LadyHavoc. Official Git repository (replaces SVN).
https://icculus.org/twilight/darkplaces/
GNU General Public License v2.0
286 stars 41 forks source link

I want new "GIVE A" cheat command #132

Closed ghost closed 6 months ago

ghost commented 8 months ago

As how the "GIVE H" cheat command is used to set player's health to any number the cheater wants, the "GIVE A" cheat command is used to set player's armor to any number the cheater wants.

hemebond commented 8 months ago

I believe this is usually controlled by the mod/game code (QuakeC), not the engine.

Baker7 commented 8 months ago

Actually, "give" is entirely an engine command. Zircon has give "a" for armor and has for over a year. Quakespasm and other engines all support give "a".

It is just a few lines of code in the give function.

SV_Give_f ...

int v = atoi (Cmd_Argv(cmd, 2)); ....

    case 'a':
        int flagsz = PRVM_serveredictfloat(host_client->edict, items);
        PRVM_serveredictfloat(host_client->edict, armorvalue) = v;
        if (gamemode == GAME_ROGUE) {   Flag_Remove_From    (flagsz, RIT_ARMOR1 | RIT_ARMOR2 | RIT_ARMOR3 ); }
        else                        {   Flag_Remove_From    (flagsz, IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3 );   }

        if (v > 150) {
            PRVM_serveredictfloat(host_client->edict, armortype) = 0.8;
            if (gamemode == GAME_ROGUE) {   Flag_Add_To         (flagsz, IT_ARMOR3); }
            else                        {Flag_Add_To            (flagsz, IT_ARMOR3); }
        } else if (v > 100) {
            PRVM_serveredictfloat(host_client->edict, armortype) = 0.6;
            if (gamemode == GAME_ROGUE) {   Flag_Add_To         (flagsz, IT_ARMOR2); }
            else                        {Flag_Add_To            (flagsz, IT_ARMOR2); }
        } else if (v >= 0) {
            PRVM_serveredictfloat(host_client->edict, armortype) = 0.3;
            if (gamemode == GAME_ROGUE) {   Flag_Add_To         (flagsz, IT_ARMOR1); }
            else                        {Flag_Add_To            (flagsz, IT_ARMOR1); }
        }
        PRVM_serveredictfloat(host_client->edict, items) = flagsz;
        break;
ghost commented 8 months ago

Actually, "give" is entirely an engine command. Zircon has give "a" for armor and has for over a year. Quakespasm and other engines all support give "a".

It is just a few lines of code in the give function.

SV_Give_f ...

int v = atoi (Cmd_Argv(cmd, 2)); ....

    case 'a':
      int flagsz = PRVM_serveredictfloat(host_client->edict, items);
      PRVM_serveredictfloat(host_client->edict, armorvalue) = v;
      if (gamemode == GAME_ROGUE) {   Flag_Remove_From    (flagsz, RIT_ARMOR1 | RIT_ARMOR2 | RIT_ARMOR3 ); }
      else                        {   Flag_Remove_From    (flagsz, IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3 );   }

      if (v > 150) {
          PRVM_serveredictfloat(host_client->edict, armortype) = 0.8;
          if (gamemode == GAME_ROGUE) {   Flag_Add_To         (flagsz, IT_ARMOR3); }
          else                        {Flag_Add_To            (flagsz, IT_ARMOR3); }
      } else if (v > 100) {
          PRVM_serveredictfloat(host_client->edict, armortype) = 0.6;
          if (gamemode == GAME_ROGUE) {   Flag_Add_To         (flagsz, IT_ARMOR2); }
          else                        {Flag_Add_To            (flagsz, IT_ARMOR2); }
      } else if (v >= 0) {
          PRVM_serveredictfloat(host_client->edict, armortype) = 0.3;
          if (gamemode == GAME_ROGUE) {   Flag_Add_To         (flagsz, IT_ARMOR1); }
          else                        {Flag_Add_To            (flagsz, IT_ARMOR1); }
      }
      PRVM_serveredictfloat(host_client->edict, items) = flagsz;
      break;

You are correct and I like Zircon very much. I asked this "GIVE A" cheat command also for fteqw but nobody wanted to do it and I always wondered why if the task is just a few lines of code as you say.

Baker7 commented 8 months ago

Giving yourself armor is nice, but probably not really necessary. I am kind of defending fteqw a little because fteqw Spike/Shoipke is one of the most helpful people on the face of the planet. He helped me tons of times in earlier days.

ghost commented 8 months ago

Giving yourself armor is nice, but probably not really necessary. I am kind of defending fteqw a little because fteqw Spike/Shoipke is one of the most helpful people on the face of the planet. He helped me tons of times in earlier days.

Nobody bothered even to tell me this but you are right, Spike indeed did excellent work.

If giving yourself armor is not really necessary then why did you implement the "GIVE A" cheat command then?

hemebond commented 8 months ago

I asked this "GIVE A" cheat command also for fteqw but nobody wanted to do it and I always wondered why if the task is just a few lines of code as you say.

What if the game doesn't have armour? What if the armour behaviour is different to Quake?

bones-was-here commented 8 months ago

I always wondered why if the task is just a few lines of code as you say

Because none of the people who want it bothered even to open a PR

Edit: and because the above patch is an unsafe hack

ghost commented 8 months ago

I asked this "GIVE A" cheat command also for fteqw but nobody wanted to do it and I always wondered why if the task is just a few lines of code as you say.

What if the game doesn't have armour? What if the armour behaviour is different to Quake?

I expect the "GIVE A" cheat command to be recognized on quake games, not on games are not quake but now that I am thinking on it this feature request is really redundant.

ghost commented 8 months ago

I believe this is usually controlled by the mod/game code (QuakeC), not the engine.

Is the "GIVE H" cheat command also controlled by the mod/game code (QuakeC) too?

I tried to find the implementation of the "GIVE H" cheat command anywhere in the QuakeC source code of the game and didn't find it anywhere.

I did find there the implementation of the "impulse" commands though but not "GIVE H".

hemebond commented 8 months ago

I believe this is usually controlled by the mod/game code (QuakeC), not the engine.

Is the "GIVE H" cheat command also controlled by the mod/game code (QuakeC) too?

No, in this case it is actually implemented in the engine. I had forgotten about it, and it works on ammo and weapons too. If you use give health by itself the game doesn't realise you're dead so you can actually still look around and shoot.