Author Topic: OverShields  (Read 1046 times)

0 Members and 2 Guests are viewing this topic.

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
OverShields
« on: December 07, 2007, 09:47:54 pm »
does anyone want to help me make an overshields script?

here is the current version (it compiles, but doesn't work...)

Code: [Select]
const
//-----Default-----
  Default_Enabled=true;
  Default_Command='/toggle';
  Default_Name='OverShields';
  Default_On=$FF20FF20;
  Default_Off=$FFFF8020;
  Default_Error=$FFFF2020;

//-----Shield-----
  Shield_Echo=true;
  Shield_Time=5;
  Shield_Rate=5;
  Shield_Chance=75;
  Shield_Vamp=true;

type
  PlayerType = record
    Name: string;
    Health: integer;
    Time: integer;
    Dmg: integer;
    Flip: integer;
//    Skip: integer;
  end;

var
  Enabled: boolean;
  Player: array[1..32] of PlayerType;
  MHealth: integer;
  i: integer;

procedure PVarReset(ID: byte);
begin
  if Player[ID].Time > -1 then Player[ID].Time:=-1;
  if Player[ID].Dmg > 0 then Player[ID].Dmg:=0;
  if Player[ID].Flip > 0 then Player[ID].Flip:=0;
//  if Player[ID].Skip > 0 then Player[ID].Skip:=0;
end;

procedure ActivateServer();
var
  RMode: string;
begin
//-----Initialization-----
  Enabled:=Default_Enabled;
  RMode:=ReadINI('Soldat.ini','GAME','Realistic_Mode','0');
  MHealth:=iif(RMode='1',65,150);
  for i:=1 to 32 do begin
    Player[i].Time:=-1;
//    Player[i].Skip:=0;
    Player[i].Dmg:=0;
  end;
end;

function OnCommand(ID: Byte; Text: string):boolean;
var
  Temp0, Temp1: string;
begin
  Result:=false;
//-----Toggle-----
  Temp0:=GetPiece(LowerCase(Text), ' ', 0); //command
  Temp1:=GetPiece(LowerCase(Text), ' ', 1); //value
  if Temp0 = Default_Command then begin
    Case Temp1 of
      'enable','true','on','1': begin
        if Enabled <> true then begin
          Enabled:=true;
          WriteConsole(0,Default_Name+' script enabled by '+Player[ID].Name+'.',Default_On);
        end else WriteConsole(ID,Default_Name+' script is already enabled.',Default_Error);
      end;
      'disable','false','off','0': begin
        if Enabled <> false then begin
          Enabled:=false;
          WriteConsole(0,Default_Name+' script disabled by '+Player[ID].Name+'.',Default_Off);
        end else WriteConsole(ID,Default_Name+' script is already disabled.',Default_Error);
      end;
    end;
  end;
  if Temp0 = '/bon' then begin
    GiveBonus(ID,strtoint(Temp1));
  end;
end;

procedure OnJoinGame(ID, Team: byte);
begin
//-----Join Stuff-----
  if Enabled then begin
    for i:=1 to 32 do begin
      Player[i].Name:=GetPlayerStat(i,'Name');
    end;
  end;
end;

procedure OnJoinTeam(ID, Team: byte);
begin
//-----Switch Stuff-----
  if Enabled then begin
    PVarReset(ID);
  end else exit;
end;

procedure AppOnIdle(Ticks: integer);
begin
//-----Time Stuff-----
  if Enabled then begin
    for i:=1 to 32 do begin
      if Player[i].Time > 0 then begin
        Player[i].Time:=Player[i].Time-1;
      end else if Player[i].Time = 0 then begin
        if Player[i].Health < MHealth then begin
//          Player[i].Skip:=1;
          DoDamage(i,Player[i].Dmg);
          Player[i].Time:=1;
        end else if Player[i].Health = MHealth then begin
          Player[i].Time:=-1;
          Player[i].Dmg:=0;
        end else if Player[i].Health < MHealth then begin
          DoDamage(i,Player[i].Health-MHealth);
        end;
      end else if Player[i].Time < 0 then exit;
    end;
  end else exit;
end;

function OnPlayerDamage(Victim, Shooter: Byte; Damage: integer):integer;
begin
//-----Damage Stuff-----
  if Enabled then begin
//    if Player[Victim].Skip = 0 then begin
      if Player[Victim].Health < 10 then begin
        WriteConsole(Victim,'Your shields are down, Get to cover!',$FFFF2020);
        Player[Victim].Flip:=Random(1,100);
        if Player[Victim].Flip > Shield_Chance then Result:=0 else Result:=Damage;
      end else Result:=Damage;
      if Shield_Echo then WriteLn(inttostr(Damage));
      Player[Victim].Time:=Shield_Time;
      Player[Victim].Health:=GetPlayerStat(Victim,'Health');
      if Player[Victim].Dmg = 0 then Player[Victim].Dmg:=(MHealth/Player[Victim].Health)/Shield_Rate;
//    end else if Player[Victim].Skip > 0 then Player[Victim].Skip:=Player[Victim].Skip-1;
  end else exit;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
//-----Death Stuff-----
  if Enabled then begin
    PVarReset(Victim);
    if Shield_Vamp then begin
      if Player[Killer].Health <> MHealth then begin
        WriteConsole(Killer,'Healed for killing an enemy.',$FF20FF20);
        DoDamage(Killer,Player[Killer].Health-MHealth);
        PVarReset(Killer);
      end else exit;
    end else exit;
  end else exit;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
//-----Leave Stuff-----
  if Enabled then begin
    PVarReset(ID);
  end else exit;
end;

all I need at the moment is someone to get it working properly (so that I can understand how it would work) so I can re-write it
« Last Edit: December 08, 2007, 05:29:38 pm by Kavukamari »
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Chuck

  • Soldier
  • **
  • Posts: 121
  • Chuck P.
Re: OverShields
« Reply #1 on: December 07, 2007, 10:08:35 pm »
Hey Kavu, Its Chuck. I see you finally posted the script. Its been a while, hasnt it? Well, I cant wait for it to work.
Are you 9 years old? Or is that just your mental age.
Favorite Wepons:
Ruger, Spas, M79, Barret, Steyr, Chainsaw, LAW, and Knife.

Offline Ride

  • Soldier
  • **
  • Posts: 199
    • NA Soldat Clan Website
Re: OverShields
« Reply #2 on: December 07, 2007, 10:29:51 pm »
If you get this to work, I'd like to use it in a sub-gamemode my friend and I are making. if thats ok with you ofcourse :)
Ingame Name: TC ~ Ryde.Lf ~
Past Clans: ^Re/ ~ -eO:

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: OverShields
« Reply #3 on: December 07, 2007, 10:33:26 pm »
anyone who wants can use it, I just gotta make it work :P
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: OverShields
« Reply #4 on: December 07, 2007, 11:05:21 pm »
What the fuck is an OverShield

Offline Spacewing

  • Soldier
  • **
  • Posts: 184
Re: OverShields
« Reply #5 on: December 08, 2007, 06:29:37 am »
A shield armor in Halo?

Offline Chuck

  • Soldier
  • **
  • Posts: 121
  • Chuck P.
Re: OverShields
« Reply #6 on: December 08, 2007, 08:03:38 am »
Yeah, it is this shield from halo that lets you either get less damage, or totally avoid it (depending on how Kavu's making it).
Are you 9 years old? Or is that just your mental age.
Favorite Wepons:
Ruger, Spas, M79, Barret, Steyr, Chainsaw, LAW, and Knife.

Offline poutch

  • Major(1)
  • Posts: 34
Re: OverShields
« Reply #7 on: December 08, 2007, 03:06:26 pm »
don t use i as a global var.
also at first look ur flip array is useless (u just need : if Random(1,100) > 75 ... etc...)

And about the overshield, can you explain how it s supposed to work ?
www.pleez.fr .... coming soon

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: OverShields
« Reply #8 on: December 08, 2007, 05:29:09 pm »
I put the current code up, it still doesn't work btw

and it is sposed to:

1: when you get damaged, start counting down
2: when countdown is fin'd, start healing you and reset the countdown timer
3: if your health is under 10, tell you to get to cover, and script tries to block damage
4: when you are healed, reset the variables
5: if you die or leave game or change team, reset your var's
6: if you kill an enemy and health is down, heal you

pretty much: heal you gradually after a few seconds and if your health is low, try to protect you
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."