Author Topic: Access violations in AppOnIdle  (Read 741 times)

0 Members and 1 Guest are viewing this topic.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Access violations in AppOnIdle
« on: December 28, 2008, 02:59:43 am »
Im sorry for making so many threads but my RPG script is almost ready for its beta and im encountering lots of little problems :-\ . But anyway one of the enemy zombies throws back any bullet that hits it at half the damage, but what is the ratio for the power variable to the actual damage?  SOLVED
Thank You

Please look at my last post for the new problem
« Last Edit: December 28, 2008, 06:00:11 pm by Hacktank »


Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: CreateBullet() power:damage?
« Reply #1 on: December 28, 2008, 03:20:27 am »
HitM (Single): Hit Multiplier (Usually 100 works good)

i.e. 100 = 100% damage.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: CreateBullet() power:damage?
« Reply #2 on: December 28, 2008, 03:51:41 am »
Thanks Toumaz! Lol i kinda figured that :). But i have a new problem, as the total level of all the players on the server gets higher the bots on the server change, but for some reason it adds the correct 16 plain Zombies (for a maxlvl of 0-3) but when someone joins (me) and logs in it starts to wig out and constantly kicks and adds bots and the log says it cannot find some of the bot files when I know for a fact that they are there. Here is my code:

my test account is set to be lvl 20

Code: [Select]
procedure SwitchBots(lvl: integer);
var bots: byte; blvl: string;
begin
if lvl >= 0 then if lvl <= 3 then blvl := '1';
if lvl >= 4 then if lvl <= 7 then blvl := '2';
if lvl >= 8 then if lvl <= 11 then blvl := '3';
if lvl >= 12 then if lvl <= 15 then blvl := '4';
if lvl >= 16 then if lvl <= 19 then blvl := '5';
if lvl >= 20 then if lvl <= 25 then blvl := '6';
if lvl >= 26 then if lvl <= 30 then blvl := '7';
if lvl >= 31 then if lvl <= 34 then blvl := '8';
if lvl >= 35 then if lvl <= 39 then blvl := '9';
if lvl >= 40 then if lvl <= 900 then blvl := '10';
for bots := 1 to 16 do begin
if botslot[bots] <> inigetvalue(botsini,blvl,inttostr(bots),'0') then begin
Command('/kick ' + inttostr(bots));
Command('/addbot2 ' + inigetvalue(botsini,blvl,inttostr(bots),'0'));
end;
end;
end;

And here is a section of the botini:
[6]
1=Zombie
2=Zombie
3=Zombie
4=Zombie
5=Zombie
6=Zombie
7=Vortex
8=Mummy
9=Turncoat
10=Elite Zombie
11=Elite Zombie
12=Elite Zombie
13=Elite Zombie
14=Elite Zombie
15=Elite Zombie
16=Elite Zombie

What is the problem? This is the best system for bot choosing that I could think of, if there is a better one please tell me :)

Thank you Toumaz and whoever answers this!
« Last Edit: December 28, 2008, 04:12:38 am by Hacktank »


Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: CreateBullet() power:damage? -- -<}New problem{>-
« Reply #3 on: December 28, 2008, 04:32:47 am »
Haven't tested this, but it should hopefully work. And you better elaborate a tad on the last bit, where you add and kick bots... I'm not all too certain what exactly it is that you're trying to accomplish there.

Code: [Select]
procedure SwitchBots(lvl: integer);
var
bots: byte;
bot_level: integer;
i: integer;
bot_level_data: array[1..9] of integer;
begin
// Populate an array - the key is the bot level we'll read from the .ini, and the value is the maximum level allowed to set this bot level.
bot_level_data[1] := 3;
bot_level_data[2] := 7;
bot_level_data[3] := 11;
bot_level_data[4] := 15;
bot_level_data[5] := 19;
bot_level_data[6] := 25;
bot_level_data[7] := 30;
bot_level_data[8] := 34;
bot_level_data[9] := 39;
// Note that the maximum level is NOT included in this array.

// By default, set the bot level to the maximum, which is number of entries in the array + 1 (i.e. 10).
bot_level := ArrayHigh(bot_level_data)+1;

// Iterate through the array, and check which level of bots we should use.
for i := 1 to ArrayHigh(bot_level_data) do begin
if lvl <= bot_level_data[i] then begin
bot_level = i;
break; // Exit the for loop
end;
end;
// If we didn't find a suitable level inside the array, then the old assignment to bot_level would assure that the bot level is now 10.

// Loop through the bots... at this point I'm not certain what you're trying to do., so sorry, without any more information, I can't do much.
for bots := 1 to 16 do begin
if botslot[bots] <> inigetvalue(botsini, inttostr(bot_level), inttostr(bots), '0') then begin
Command('/kick ' + inttostr(bots));
Command('/addbot2 ' + inigetvalue(botsini, inttostr(bot_level), inttostr(bots),'0'));
end;
end;
end;

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Access violations in AppOnIdle
« Reply #4 on: December 30, 2008, 04:31:33 am »
Ok I just realized that I accidently made a couple of typos in my ini... lol but now I have it working with my code, except every time a bot is kicked and another joins i get an out of range error in AppOnIdle, here it is: (near the bottom is the bot controls and what is definently the problem)
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var i: byte; buffer: integer;
begin
buffer := 0;
  for i:= 1 to 32 do begin
  if getplayerstat(i,'human') then if not players[i].logged then begin
  if players[i].kt > 0 then dec(players[i].kt,1);
  DrawText(i,'You have ' + IntToStr(players[i].kt) + ' seconds',60,$FFFF0000,0.18,10,150);
  if players[i].kt = 0 then Command('/kick '+inttostr(i));
  end;
  if getplayerstat(i,'active') then if players[i].logged then begin
  if players[i].mana > players[i].maxmana then players[i].mana := players[i].maxmana;
  if players[i].xp >= round(100 * (nextlvlm * strtofloat(inttostr(players[i].lvl)))) then begin
players[i].xp := players[i].xp - round(100 * (nextlvlm * strtofloat(inttostr(players[i].lvl))));
LVLUP(i);
end;
if players[i].turrettime > 0 then begin
dec(players[i].turrettime,1);
DrawText(i,inttostr(players[i].turrettime),60,$FF555555,0.2,240,300);
end;
if players[i].turrettime = 0 then if players[i].turretout then begin
KillObject(players[i].turretid);
players[i].turretout := false;
end;
    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') then Regenerate(i);
  end;
  if IDToName(i) <> IGB[i].BName then Assign(i);
  if getplayerstat(i,'active') then if players[i].logged then begin
  buffer := buffer + players[i].lvl;
  end;
  if i <= 16 then begin
botslot[i] := getplayerstat(i,'name');
end;
end;
SwitchBots(buffer);
end;

Your code looks like a much more complicated version of what i already have but if it will fix the AppOnIdle error ill use it.

The point of SwitchBots is to kick low lvl bots and add high lvl ones when a high lvl player loggs in and vice versa, simalar to the INC bots. (I was unable to get a copy of there Zombie RPG script so i just made my own :p) { it is NOT copying all of INC's fetures, many are of my own creativity, but some are modled after their's }

Also why wont my heal code work when i have a vest? (it only heals part of the health each time) Am i wrong that a vest is + 100 pts of health essentially? Here is my code: (only relevent parts are shown)

if GetPlayerStat(ID,'vest') > 0 then pts := (GetPlayerStat(ID,'Health') + GetPlayerStat(ID,'vest')) - 250;
if GetPlayerStat(ID,'vest') = 0 then pts := GetPlayerStat(ID,'Health') - 150;

DoDamage(ID,pts);

Thank you Toumaz


EDIT and what is wrong with this onjointeam?
Code: [Select]
procedure OnJoinTeam(ID, Team: byte);
begin
if ID > 16 then begin
if not players[ID].logged then if not Team = 5 then begin
Command('/setteam5 ' + inttostr(ID));
ShowInfo(ID,false);
end;
if Team = 2 then Command('/setteam1 ' + inttostr(ID));
end;
end;