Author Topic: Name Read Problems  (Read 698 times)

0 Members and 1 Guest are viewing this topic.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Name Read Problems
« on: November 10, 2008, 12:37:16 pm »
Im sorry for making so many threads, but atleast it shows im trying. But anyway I keep getting Out Of Range errors that make no sense (i defined the variables).

1) Specialbots.pas (edited by me made by Gizd) {I changed it like this so that it would be using the acual Health and not a Var}

SpecialBots.pas \/
SOLVED

Code: [Select]
const
  CLASSES = 5;   //how many bot classes you want

  //for dmgammount ********************************
  Type Player = Record
  Active:     Boolean;
  Countdown:  Integer;
  Caps:       Byte;
  Damage:     Integer;
  TakenDamage:Integer;
End;

var
Players: Array[1 .. 32] Of Player;
s, t, kaz, totalcaps: Byte;
  //for dmgammount ******************************
 
type
  SBot = Record
    BName   : string;
    BHealth : integer;
    BHPReg  : integer;
    BRegLim : boolean;
    BShowHP : boolean;
    BHColor : longint;
    BWeapon : byte;
    BBonus  : byte;
    BBonT   : integer;
    BDamage : integer;

    BWaveVal: byte;
    BWaveStl: byte;
    BWaveSpd: integer;
  end;

var
  TheBot: array[0..CLASSES] of SBot;
  IGB: array[1..32] of SBot;
  BotHpLeft: array[1..32] of integer;
  UnAssign: array[1..32] of boolean;

//********************************************************************

procedure ActivateServer();
begin
for t := 1 to 32 do begin
Players[t].Active := false;
Players[t].Countdown := 0;
Players[t].Caps := 0;
Players[t].Damage := 0;
Players[t].TakenDamage := 0;
end;
  begin
    TheBot[1].BName   := 'Vortex';
    TheBot[1].BHealth := 40;
    TheBot[1].BHPReg  := 20;
    TheBot[1].BRegLim := true;
    TheBot[1].BShowHP := true;
    TheBot[1].BHColor := $666666;
    TheBot[1].BWeapon := 10;
    TheBot[1].BBonus  := 1;
    TheBot[1].BBonT   := 300;
    TheBot[1].BDamage := 99500;

    TheBot[1].BWaveVal:= 20;
    TheBot[1].BWaveStl:= 7;
    TheBot[1].BWaveSpd:= 5;
  end;

  begin
    TheBot[2].BName   := 'Zombie';
    TheBot[2].BHealth := 125;
    TheBot[2].BHPReg  := 25;
    TheBot[2].BRegLim := true;
    TheBot[2].BShowHP := false;
    TheBot[2].BHColor := $FF0000;
    TheBot[2].BWeapon := 15;
    TheBot[2].BBonus  := 255;
    TheBot[2].BBonT   := 0;
    TheBot[2].BDamage := 3;

    TheBot[2].BWaveVal:= 0;
    TheBot[2].BWaveStl:= 1;
    TheBot[2].BWaveSpd:= 0;
  end;

  begin
    TheBot[3].BName   := 'Elite Zombie';
    TheBot[3].BHealth := 500;
    TheBot[3].BHPReg  := 2;
    TheBot[3].BRegLim := true;
    TheBot[3].BShowHP := true;
    TheBot[3].BHColor := $FF0000;
    TheBot[3].BWeapon := 15;
    TheBot[3].BBonus  := 255;
    TheBot[3].BBonT   := 0;
    TheBot[3].BDamage := 30;

    TheBot[3].BWaveVal:= 5;
    TheBot[3].BWaveStl:= 3;
    TheBot[3].BWaveSpd:= 5;
  end;

  begin
    TheBot[4].BName   := 'Slicer Zombie';
    TheBot[4].BHealth := 250;
    TheBot[4].BHPReg  := 5;
    TheBot[4].BRegLim := true;
    TheBot[4].BShowHP := true;
    TheBot[4].BHColor := $00ff00;
    TheBot[4].BWeapon := 14;
    TheBot[4].BBonus  := 255;
    TheBot[4].BBonT   := 0;
    TheBot[4].BDamage := 5;

    TheBot[4].BWaveVal:= 10;
    TheBot[4].BWaveStl:= 13;
    TheBot[4].BWaveSpd:= 5;
  end;

  begin
    TheBot[5].BName   := 'Kamakazi';
    TheBot[5].BHealth := 3;
    TheBot[5].BHPReg  := 0;
    TheBot[5].BRegLim := true;
    TheBot[5].BShowHP := false;
    TheBot[5].BHColor := $FF0000;
    TheBot[5].BWeapon := 15;
    TheBot[5].BBonus  := 1;
    TheBot[5].BBonT   := 300;
    TheBot[5].BDamage := 1;

    TheBot[5].BWaveVal:= 150;
    TheBot[5].BWaveStl:= 3;
    TheBot[5].BWaveSpd:= 5;
  end;

//THIS SET WILL BE GIVEN TO ANY OTHER BOT & TO ALL PLAYERS
  begin
    TheBot[0].BName   := 'THIS TEXT SHOULD''T BE A BOT NAME(OR HUMAN NAME)';
    TheBot[0].BHealth := 150;
    TheBot[0].BHPReg  := 1;
    TheBot[0].BRegLim := true;
    TheBot[0].BShowHP := false;
    TheBot[0].BHColor := $000000;
    TheBot[0].BWeapon := 255;
    TheBot[0].BBonus  := 255;
    TheBot[0].BBonT   := 0;
    TheBot[0].BDamage := 1;

    TheBot[0].BWaveVal:= 0;
    TheBot[0].BWaveStl:= 0;
    TheBot[0].BWaveSpd:= 0;
  end;

{ begin
    TheBot[10].BName   := 'Kamikaze';       D
    TheBot[10].BHealth := 200;              D
    TheBot[10].BHPReg  := 0;                D
    TheBot[10].BRegLim := false;            D
    TheBot[10].BShowHP := false;            D
    TheBot[10].BHColor := $FFFF00;          D
    TheBot[10].BWeapon := 16;               D
    TheBot[10].BBonus  := 255;              D
    TheBot[10].BBonT   := 0;                D
    TheBot[10].BDamage := 1;                D

    TheBot[10].BWaveVal:= 25;               D
    TheBot[10].BWaveStl:= 4;                D
    TheBot[10].BWaveSpd:= 20;               D
  end; }
end;

//********************************************************************

procedure Explode(Target: byte);
var i: byte;
begin
  for i:= 1 to IGB[Target].BWaveVal do CreateBullet(GetPlayerStat(Target,'X'),GetPlayerStat(Target,'Y'),Random(IGB[Target].BWaveSpd, -(IGB[Target].BWaveSpd)),Random(IGB[Target].BWaveSpd, -(IGB[Target].BWaveSpd)), 100, IGB[Target].BWaveStl, Target);
end;

procedure ShowHP(Target,Shooter: byte);
begin
  DrawText(Shooter, IntToStr(GetPlayerStat(Target,'Helath')), 180, IGB[Target].BHColor, 0.1, 260, 350);
end;

procedure Assign(ID: Byte);
var i: byte;
begin
  for i:= 1 to CLASSES do if IDToName(ID) = TheBot[i].BName then begin
    IGB[ID] := TheBot[i];
    DoDamage(ID,200);
  end;
  if IGB[ID].BName = '' then begin
    IGB[ID]:= TheBot[0];
    UnAssign[ID]:= true;
  end;
end;

procedure Regenerate(ID: byte);
begin
  if IGB[ID].BRegLim then begin
    if (IGB[ID].BHealth - GetPlayerStat(ID,'Helath')) < IGB[ID].BHPReg then DoDamage(ID,(IGB[ID].BHealth-GetPlayerStat(ID,'Helath')));
    if (IGB[ID].BHealth - GetPlayerStat(ID,'Helath')) >= IGB[ID].BHPReg then DoDamage(ID,(IGB[ID].BHPReg-IGB[ID].BHPReg-IGB[ID].BHPReg));
  end else if GetPlayerStat(ID,'Helath') < 65000 then DoDamage(ID,(IGB[ID].BHPReg-IGB[ID].BHPReg-IGB[ID].BHPReg));
end;

{procedure AllHealth;
var
  HP: string;
  i: byte;
begin
  HP:= '';
  for i:= 1 to 32 do if GetPlayerStat(i,'Active') then if GetPlayerStat(i,'Team') = 1 then begin
    if UnAssign[i] then HP:= HP + IDToName(i) + ' : ' + IntToStr(GetPlayerStat(i,'Health')) + chr(10) + chr(13);
    if not UnAssign[i] then HP:= HP + IDToName(i) + ' : ' + IntToStr(BotHpLeft[i]) + chr(10) + chr(13);
  end;
  DrawText(0, HP, 240, $66FFFF00, 0.08, 10, 60);
end;
}

//********************************************************************

var
n: Byte;
kamdist: Single;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
  if not UnAssign[Victim] then if IGB[Victim].BWaveVal > 0 then Explode(Victim);
end;

procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
//  AllHealth;
  for i:= 1 to 32 do if not UnAssign[i] then begin
    if IDToName(i) <> IGB[i].BName then Assign(i);
    if (IGB[i].BBonT >= 60) and (IGB[i].BBonus <> 255) then if Ticks mod IGB[i].BBonT = 0 then GiveBonus(i, IGB[i].BBonus);
    if IGB[i].BWeapon <> 255 then if (GetPlayerStat(i, 'Primary') <> IGB[i].BWeapon) or (GetPlayerStat(i, 'Secondary') <> 255) then ForceWeapon(i, IGB[i].BWeapon, 255, 0);
   // if (IGB[i].BHPReg <> 0) and (GetPlayerStat(i,'Alive')= true) then Regenerate(i);
  end;
end;

procedure OnPlayerRespawn(ID: Byte);
begin
if GetPlayerStat(ID,'Human') then begin
  if not UnAssign[ID] then begin
  DoDamage(ID,(GetPlayerStat(ID,'Helath')-TheBot[0].BHealth));
    if IGB[0].BBonus <> 255 then GiveBonus(ID, IGB[0].BBonus);
    if IGB[0].BWeapon <> 255 then ForceWeapon(ID, IGB[0].BWeapon, 255, 0);
  end;
  end;
 if not GetPlayerStat(ID,'Human') then begin
   if not UnAssign[ID] then begin
  DoDamage(ID,(GetPlayerStat(ID,'Helath')-TheBot[ID].BHealth));
    if IGB[ID].BBonus <> 255 then GiveBonus(ID, IGB[ID].BBonus);
    if IGB[ID].BWeapon <> 255 then ForceWeapon(ID, IGB[ID].BWeapon, 255, 0);
  end;
  end;
end;

function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer) : integer;
begin
  Result:= Damage;
  if not UnAssign[Victim] then if IGB[Victim].BShowHP then ShowHP(Victim, Shooter);
  if not UnAssign[Shooter] then if IGB[Shooter].BDamage <> 1 then Result:= Damage*IGB[Shooter].BDamage;
Players[Shooter].Damage := Players[Shooter].Damage + Damage;
Players[Victim].TakenDamage := Players[Victim].TakenDamage + Damage;
end;

//for dmgammunt***************************************** \/

procedure OnMapChange(NewMap: String);
begin
For s := 1 To 32 Do Begin
WriteConsole(s,'*******************************************',$66330000);
WriteConsole(s,'You did ' + inttostr(Players[s].Damage) + ' damage.',$ffff3399);
WriteConsole(s,'You took ' + inttostr(Players[s].TakenDamage) + ' damage.',$ffff3399);
WriteConsole(s,'*******************************************',$66330000);
Players[s].Active := false;
Players[s].Caps := 0;
Players[s].Countdown := 0;
Players[s].Damage := 0;
Players[s].TakenDamage := 0;
end;
end;

//********************************************************************

procedure OnJoinGame(ID, Team: Byte);
begin
  if GetPlayerStat(ID,'Human') then UnAssign[ID]:= true;
  Players[ID].Active := false;
Players[ID].Caps := 0;
Players[ID].Countdown := 0;
Players[ID].Damage := 0;
Players[ID].TakenDamage := 0;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  UnAssign[ID]:= false;
  Players[ID].Active := false;
Players[ID].Caps := 0;
Players[ID].Countdown := 0;
Players[ID].Damage := 0;
Players[ID].TakenDamage := 0;
end;

//********************************************************************

In this one I get an Out Of Range error for OnJoinGame and OnPlayerRespawn

I get similar errors in another script but I will probably be able to fix it myself once I know what is wrong with the one above.


THANK YOU

EDIT: side problem EDIT-EDIT Main Problem

Why is this block of code not working if the victim's name is Kamakazi or Vortex?! Thank you.

Code: [Select]
function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer) : integer;
begin
tmod:=0
Result:= Damage;
//WriteConsole(Shooter,inttostr(Damage),$ffff3399);
//if TheBot[Victim].BShowHP then ShowHP(Victim, Shooter);
if IDToName(Victim) = 'Kamakazi' then tmod:=(GetPlayerStat(Victim,'health')-(GetPlayerStat(Victim,'health')-2));
if IDToName(Victim) = 'Vortex' then tmod:=(GetPlayerStat(Victim,'health')-(GetPlayerStat(Victim,'health')-20));
if not UnAssign[Shooter] then if IGB[Shooter].BDamage <> 1 then Result:= Damage*IGB[Shooter].BDamage+tmod;
Players[Shooter].Damage := Players[Shooter].Damage + Damage;
Players[Victim].TakenDamage := Players[Victim].TakenDamage + Damage;
end;
« Last Edit: November 11, 2008, 06:31:40 pm by Hacktank »


Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Name Read Problems
« Reply #1 on: November 11, 2008, 06:44:49 pm »
Try moving "Result := Damage;" to after your code.