Author Topic: God mode (climb) v.1.1  (Read 4862 times)

0 Members and 1 Guest are viewing this topic.

Offline deguix

  • Major
  • *
  • Posts: 79
God mode (climb) v.1.1
« on: June 21, 2007, 12:16:13 pm »
Script Name: God mode (climb) v.1.1
Script Description:
I based this script on Flippeh's Admin God Mode script, except that I've adapted it for climb servers, and made this to be usable by any player.

Players with god mode active are:
- immune to death polys.
- killed whenever they touch any flag that can be grabbed.
- harmed whenever they hit other players. Damage they do to other players is redirected back to them. If Friendly Fire is on, then that also happens when they hit players in their own teams.

Because the god mode makes players invincible, I also changed the /kill command (from admin and players) to actually kill the player in this case.

There's also an option to allow you to be killed by enemies (constant GodMode_EnemyKill), which is by default turned off (False). Rarely climb servers admins like enemies killing other players.

How to use by players in servers with this enabled:
Type "/godmode 1" to enable it, "/godmode 0" to disable it, without pressing the talk button.

NOTES:
- Players are not immune to hurt polys (server version 2.6.1 bug with OnPlayerDamage not being called in this case).
- Whenever an admin uses "/recompile", all players have their god modes status set to 0 (deactivated). If you believe this is a problem, kill any player that has it active, create an add-on command to kill them and deactivate their god modes, or create add-on code that will store that data in a file and retrieve after the script is recompiled.

Version 1.1 fixes the god mode message that appeared when players who are spectators try to activate it.
Version 1.0.1 adds the handling of the command "/brutalkill", which is exactly the same as the currently coded "/kill" as DoDamage does the kill like the Soldat's "/brutalkill" command.

Original Author(s): deguix, based on code from Flippeh.
Core Version: 2.6.1
Code:

Code: [Select]
const
  GodMode_EnemyKill = False;

type
  trPlayer = record
    //Add more methods here if you use array/object style storage.
    GodMode : Boolean;
    GodMode_JustHitPlayer : Boolean;
    GodMode_JustGotKilled : Boolean;
  end;

var
  aPlayers: array[1..32] of trPlayer;

function GodMode_OnCommand(ID: byte; Text: string): boolean;
begin
  if (MaskCheck(Text,'/kill *') and (GetPlayerStat(strtoint(Copy(Text,7,Length(Text))),'Active') = True) and (GetPlayerStat(strtoint(Copy(Text,7,Length(Text))),'Alive') = True) and (GetPlayerStat(strtoint(Copy(Text,7,Length(Text))),'Team') <> 5)) then begin
    aPlayers[ID].GodMode_JustGotKilled := True;
    DoDamage(strtoint(Copy(Text,7,Length(Text))), 200);
    Command('/say '+GetPlayerStat(strtoint(Copy(Text,7,Length(Text))), 'Name')+' killed by admin');
    Result:=True;
  end;
end;

function GodMode_OnPlayerCommand(ID: byte; Text: string): boolean;
begin
  if (Text = '/kill') or (Text = '/brutalkill') and (GetPlayerStat(ID, 'Active') = True) and (GetPlayerStat(ID, 'Alive') = True) and (GetPlayerStat(ID, 'Team') <> 5) then begin
    aPlayers[ID].GodMode_JustGotKilled := True;
    DoDamage(ID,200);
    Result:=True;
  end;

  if (MaskCheck(Text,'/godmode *')) and (GetPlayerStat(ID, 'Active') = True) then begin
    if (GetPlayerStat(ID, 'Team') <> 5) then begin
      if (strtoint(Copy(Text,10,Length(Text))) = 1) and (aPlayers[ID].GodMode = False) then begin
        if GetPlayerStat(ID, 'Flagger') then
          DoDamage(ID,200);
        aPlayers[ID].GodMode := True;
        Command('/say "'+GetPlayerStat(ID, 'Name')+'" activated god mode (/godmode 1).');
      end else if (strtoint(Copy(Text,10,Length(Text))) = 0) and (aPlayers[ID].GodMode) then begin
        aPlayers[ID].GodMode := False;
        Command('/say "'+GetPlayerStat(ID, 'Name')+'" deactivated god mode (/godmode 0).');
        DoDamage(ID,200);
      end else begin
        if aPlayers[ID].GodMode then begin
          SayToPlayer(ID, GetPlayerStat(ID, 'Name')+', your god mode is activated at the moment. Use /godmode 0 to deactivate it.');
        end else
          SayToPlayer(ID, GetPlayerStat(ID, 'Name')+', your god mode is deactivated at the moment. Use /godmode 1 to activate it.');
      end;
    end else
      SayToPlayer(ID, GetPlayerStat(ID, 'Name')+', you can''t activate/deactivate the god mode when you are a spectator.');
  end;
end;

procedure GodMode_OnLeaveGame(ID,Team: byte;Kicked: boolean);
begin
  aPlayers[ID].GodMode := False;
  aPlayers[ID].GodMode_JustHitPlayer := False;
  aPlayers[ID].GodMode_JustGotKilled := False;
end;

procedure GodMode_OnFlagGrab(nPlayerID, nTeamIndex: byte; bGrabbedInBase: boolean);
begin 
  if ((GetPlayerStat(nPlayerID, 'Alive') = True) and aPlayers[nPlayerID].GodMode) then begin
    aPlayers[nPlayerID].GodMode_JustGotKilled := True;
    DoDamage(nPlayerID, 200);
  end;
end;

//BUG: Whenever a player is damaged by map (not killing), this is not called. :O
function GodMode_OnPlayerDamage(nVictimPlayerID, nShooterPlayerID: byte; nDamage: integer): integer;
begin
  // Victim = Player Damaged // Shooter = Player doing the damage
  // Victim = Shooter when:
    // Suicide.
    // Map/Server kill of a player.
  if ((GetPlayerStat(nVictimPlayerID, 'Active') and GetPlayerStat(nShooterPlayerID, 'Active')) and (GetPlayerStat(nVictimPlayerID, 'Alive') and GetPlayerStat(nShooterPlayerID, 'Alive'))) then begin
    if (nShooterPlayerID <> nVictimPlayerID) then begin
      Result := 0;
      if aPlayers[nShooterPlayerID].GodMode then begin //hit him with the same strength but opposite direction :D
        aPlayers[nShooterPlayerID].GodMode_JustHitPlayer:=True;
        DoDamage(nShooterPlayerID, nDamage);
      end else if GodMode_EnemyKill then begin
        Result := nDamage;
      end;
    end else if aPlayers[nVictimPlayerID].GodMode then begin
      if aPlayers[nVictimPlayerID].GodMode_JustGotKilled then begin
        Result := nDamage;
        aPlayers[nVictimPlayerID].GodMode_JustGotKilled := False;
      end else if aPlayers[nVictimPlayerID].GodMode_JustHitPlayer then begin
        Result := nDamage;
        aPlayers[nVictimPlayerID].GodMode_JustHitPlayer := False;
      end else
        Result := 0;
    end else
      Result := nDamage;
  end;
end;

function OnCommand(ID: byte; Text: string):Boolean;
begin
  Result:=False;

  //Put other OnCommand codes in here.

  if GodMode_OnCommand(ID, Text) then
    Result:=True;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  Result:=False;

  //Put other OnPlayerCommand codes in here.

  if GodMode_OnPlayerCommand(ID, Text) then
    Result:=True;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  GodMode_OnLeaveGame(ID, Team, Kicked);
 
  //Put other OnLeaveGame codes in here.
end;

procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean);
begin
  GodMode_OnFlagGrab(ID, TeamFlag, GrabbedInBase);
 
  //Put other OnFlagGrab codes in here.
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  // Victim = Player Damaged // Shooter = Player doing the damage
  result := GodMode_OnPlayerDamage(Victim, Shooter, Damage);
 
  //Put other OnPlayerDamage codes in here and make sure the result value
  //is the one wanted, as the "Result" variable now holds the damage from
  //GodMode.
end;
« Last Edit: June 21, 2007, 03:12:22 pm by deguix »

Offline Detector

  • Major
  • *
  • Posts: 55
Re: God mode (climb) v.1.0.1
« Reply #1 on: June 21, 2007, 02:43:56 pm »
Wow, it's realy useful scrip, but could you creat the simple scrip like, when i type command like "/god" than i will be invinsible,
without 
Quote
killed whenever they touch any flag that can be grabbed, harmed whenever they hit other players. Damage they do to other players is redirected back to them. If Friendly Fire is on, then that also happens when they hit players in their own teams

Just invincible after /***** secret comand.

Your "super god" is not interesting, nobody will play in this server
« Last Edit: June 21, 2007, 02:45:53 pm by Detector »
Read.Only.

Offline deguix

  • Major
  • *
  • Posts: 79
Re: God mode (climb) v.1.0.1
« Reply #2 on: June 21, 2007, 03:00:53 pm »
Your "super god" is not interesting, nobody will play in this server
That's to promote fairness in climbing... the script is not supposed to make everyone use it. Only the people who need to know how to jump some parts that will ever need this.

Updated to version 1.1 (see first post).

Offline Detector

  • Major
  • *
  • Posts: 55
Re: God mode (climb) v.1.0.1
« Reply #3 on: June 21, 2007, 03:06:20 pm »
hm, yes you are right, but nobody can use this secret command if i don't tell them.
command like some password /JR7b3PC

Please, if this is not dificult, create simple god script, activated by command, becouse i don't know how to do it.
I don't understand Admin god script.
Read.Only.

Offline deguix

  • Major
  • *
  • Posts: 79
Re: God mode (climb) v.1.1
« Reply #4 on: June 21, 2007, 03:26:53 pm »
I guess this part will be moved to another forum, but the following code just
enables/disables invincibility (doesn't have any messages with it at all).

Look at the OnPlayerDamage to see the effect of having no damage. If Result := 0, then no damage is ever dealt, except for hurt polys (bug). If Result is positive, then that will hurt. If negative, it will heal. Max health = 200 (= 133% health). Normal heath = 150 (= 100% health).

Code: [Select]
type
  trPlayer = record
    //Add more methods here if you use array/object style storage.
    GodMode : Boolean;
  end;

var
  aPlayers: array[1..32] of trPlayer;

function GodMode_OnPlayerCommand(ID: byte; Text: string): boolean;
begin
  if MaskCheck(Text,'/godmode *') then begin
    if (strtoint(Copy(Text,10,Length(Text))) = 1) then begin
      aPlayers[ID].GodMode := True;
    end else
      aPlayers[ID].GodMode := False;
  end;
end;

procedure GodMode_OnLeaveGame(ID,Team: byte;Kicked: boolean);
begin
  aPlayers[ID].GodMode := False;
end;

//BUG: Whenever a player is damaged by map (not killing), this is not called. :O
function GodMode_OnPlayerDamage(nVictimPlayerID, nShooterPlayerID: byte; nDamage: integer): integer;
begin
  // Victim = Player Damaged // Shooter = Player doing the damage
  // Victim = Shooter when:
    // Suicide.
    // Map/Server kill of a player.
  if aPlayers[nVictimPlayerID].GodMode then begin
    Result := 0;
  end else
    Result := nDamage;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  Result:=False;

  //Put other OnPlayerCommand codes in here.

  if GodMode_OnPlayerCommand(ID, Text) then
    Result:=True;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  GodMode_OnLeaveGame(ID, Team, Kicked);
 
  //Put other OnLeaveGame codes in here.
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  // Victim = Player Damaged // Shooter = Player doing the damage
  result := GodMode_OnPlayerDamage(Victim, Shooter, Damage);
 
  //Put other OnPlayerDamage codes in here and make sure the result value
  //is the one wanted, as the "Result" variable now holds the damage from
  //GodMode.
end;
« Last Edit: June 21, 2007, 03:29:45 pm by deguix »

Offline Flippeh

  • Major
  • *
  • Posts: 58
  • Fish go moo :>
    • My Homepage
Re: God mode (climb) v.1.1
« Reply #5 on: July 06, 2007, 03:51:31 pm »
If Result := 0, then no damage is ever dealt

Also M79 and Law will rip you D:
Thats why i did like -9999999 to be completly sure nothing can ever kill you :P

Nice work on the script ;D

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: God mode (climb) v.1.1
« Reply #6 on: July 09, 2007, 10:46:13 am »
So does this protect you against deadly polygons?  Cuz I see more potential in this than just this (hopefully I'll have some time to code what I'm thinking)
Can't think of anything original to put here...

Offline mxyzptlk

  • Veteran
  • *****
  • Posts: 1493
  • The Panda Ninja
Re: God mode (climb) v.1.1
« Reply #7 on: July 09, 2007, 01:33:24 pm »
If I read what he said right, it protects against everything but hurting polys.

"While preceding your entrance with a grenade is a good tactic in
Quake, it can lead to problems if attempted at work." -- C Hacking

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: God mode (climb) v.1.1
« Reply #8 on: July 09, 2007, 02:39:25 pm »
well that's hurting polygons - what about DEADLY polygons?
(and for that matter bloody ones (make you do brutal kill) and lava)
Can't think of anything original to put here...

Offline mxyzptlk

  • Veteran
  • *****
  • Posts: 1493
  • The Panda Ninja
Re: God mode (climb) v.1.1
« Reply #9 on: July 09, 2007, 03:44:48 pm »
It protects againt kill, brutal kill, and lava polys, I believe.

"While preceding your entrance with a grenade is a good tactic in
Quake, it can lead to problems if attempted at work." -- C Hacking

Offline Scorpian

  • Camper
  • ***
  • Posts: 272
  • Republican
Re: God mode (climb) v.1.1
« Reply #10 on: July 10, 2007, 10:36:32 pm »
Very nice script. I had alot of fun playing around with it.