Author Topic: FireWall Spell  (Read 2404 times)

0 Members and 1 Guest are viewing this topic.

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
FireWall Spell
« on: August 04, 2010, 12:29:52 pm »
Hi. I want to write FireWall spell but i dont know how to save position of wall and how to save it for certain of time... something like mine but with column of flames that hurts zombies, can someone do it for me? ill be so grateful if yes :) [ just ask for more info ]
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline freestyler

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 326
Re: FireWall Spell
« Reply #1 on: August 04, 2010, 01:23:01 pm »
I don't quite understand what's the problem, because I checked your profile and you seem to know how to script.

Code: [Select]
YourVariableX, YourVariableY: single;

YourVariableX := <x position>;
YourVariableY := <y position>;

You can also use arrays if you have to store these coordinates for each player, for example.
« Last Edit: August 04, 2010, 01:24:43 pm by freestyler »

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: FireWall Spell
« Reply #2 on: August 05, 2010, 09:40:41 am »
ya, maybe i know how to script some things but im not experienced so much and i have problem with that xD
just help me, pls :/

Edit:
i tried to make something... all looks fine but im getting OutOfRange error in AppOnIdle... here is code:
Code: [Select]
const
MAXFLAMETIME= 300;

type tFire = record
Active: boolean;
Owner: integer;
X,Y: single;
Duration: integer;
end;

var
flames: array[1..32] of tFire;

procedure CreateFireWall(ID:byte;PX,PY:single);
var
   i:byte;
begin
for i := 1 to HighestID do begin
if flames[i].Active = false then begin
flames[i].Active := true;
flames[i].Owner := ID;       
flames[i].X := PX;
flames[i].Y := PY;
flames[i].Duration := MAXFLAMETIME;
end;
end;
end;

function OnPlayerCommand(ID: integer; Text: string): boolean;
var
X,Y: single;
begin
X:= GetPlayerStat(ID,'X');
Y:= GetPlayerStat(ID,'Y');
if Text = '/firewall' then
CreateFireWall(ID,X,Y);
Result := false;
end;

procedure AppOnIdle(Ticks: longint);
var
FlameCount: integer;
begin
if flames[FlameCount].Active = true then begin
if flames[FlameCount].Duration > 0 then begin
flames[FlameCount].Duration := flames[FlameCount].Duration - 1;
CreateBullet(flames[FlameCount].X,flames[FlameCount].Y,0,0,0,5, flames[FlameCount].Owner); // 1 createbullet for test
if flames[FlameCount].Duration = 0 then begin   
flames[FlameCount].Active := false;
end;
end;
end;
end;
« Last Edit: August 05, 2010, 10:00:18 am by kosik231 »
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: FireWall Spell
« Reply #3 on: August 05, 2010, 10:15:29 am »
probably because FlameCount is always 0 in your script, and flames[] starts from 1 |:

Loop through the whole array in apponidle...

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: FireWall Spell
« Reply #4 on: August 05, 2010, 04:41:11 pm »
ugh, yes, i forgot about loop ^^
i made something similar but that creates 1 flame (because of laggs), when zombie is near this flame (distance = 50px) he die but every 1 second im getting biggg laggs... can any1 help me to debug this? if its possible... here is code
Code: [Select]
const
MAXFLAMETIME = 300;

type tFire = record
Active: boolean;
Owner: integer;
X,Y: single;
Duration: integer;
end;

var
flames: array[1..32] of tFire;

procedure CreateFireWall(ID:byte;PX,PY:single);
var
   i:byte;
begin
for i := 1 to 32 do begin
if flames[i].Active = false then begin
flames[i].Active := true;
flames[i].Owner := ID;   
flames[i].X := PX;
flames[i].Y := PY;
flames[i].Duration := MAXFLAMETIME;
end;
end;
end;

function OnPlayerCommand(ID: integer; Text: string): boolean;
var
X,Y: single;
begin
X:= GetPlayerStat(ID,'X');
Y:= GetPlayerStat(ID,'Y');
if Text = '/firewall' then begin
CreateFireWall(ID,X,Y);
end;
Result := false;
end;



procedure AppOnIdle(Ticks: longint);
var
i,j,Target: integer;
begin
for i:= 1 to 32 do begin
if (flames[i].Active = true) then begin
if (flames[i].Duration > 0) then begin
flames[i].Duration := flames[i].Duration - 1;
CreateBullet(flames[i].X,flames[i].Y,0,0,0,5, flames[i].Owner);
for j := 1 to 32 do begin
if GetPlayerStat(j,'Active') = true then begin
if (GetPlayerStat(j,'Alive') = true) and (GetPlayerStat(j,'Team') <> GetPlayerStat(flames[i].Owner,'Team')) then begin
if Distance(flames[i].X,flames[i].Y,GetPlayerstat(j,'X'),Getplayerstat(j,'Y')) <= 50 then begin
DoDamageBy(j,flames[i].Owner,200);
end;
end;
end;
end;
end;

if (flames[i].Duration = 0) then begin   
flames[i].Active := false;
end;
end;
end;
end;
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: FireWall Spell
« Reply #5 on: August 05, 2010, 05:10:29 pm »
There are lots of loops. I merged somes togethers, script should work as usual. You also had
Code: [Select]
GetPlayerStat(j,'Active') = true 2 times.

Always try to avoid making lots of loops, if possible merge them together!

Code: [Select]
const
MAXFLAMETIME = 300;

type tFire = record
Active: boolean;
Owner: integer;
X,Y: single;
Duration: integer;
end;

var
flames: array[1..32] of tFire;

procedure CreateFireWall(ID:byte;PX,PY:single);
var
   i:byte;
begin
for i := 1 to 32 do begin
if flames[i].Active = false then begin
flames[i].Active := true;
flames[i].Owner := ID;   
flames[i].X := PX;
flames[i].Y := PY;
flames[i].Duration := MAXFLAMETIME;
end;
end;
end;

function OnPlayerCommand(ID: integer; Text: string): boolean;
var
X,Y: single;
begin
X:= GetPlayerStat(ID,'X');
Y:= GetPlayerStat(ID,'Y');
if Text = '/firewall' then begin
CreateFireWall(ID,X,Y);
end;
Result := false;
end;



procedure AppOnIdle(Ticks: longint);
var
i,j,Target: integer;
begin
for i:= 1 to 32 do begin
if (flames[i].Active = true) and (flames[i].Duration > 0) then begin
flames[i].Duration := flames[i].Duration - 1;
CreateBullet(flames[i].X,flames[i].Y,0,0,0,5, flames[i].Owner);
for j := 1 to 32 do begin
if (GetPlayerStat(j,'Alive') = true) and (GetPlayerStat(j,'Team') <> GetPlayerStat(flames[i].Owner,'Team')) and (Distance(flames[i].X,flames[i].Y,GetPlayerstat(j,'X'),Getplayerstat(j,'Y')) <= 50) then begin
DoDamageBy(j,flames[i].Owner,200);
end;
end;
end;
end;
end;

It compiles, it SHOULD be less laggy.

Edit: Tried and no lags :3
« Last Edit: August 05, 2010, 05:14:15 pm by VinceBros »

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: FireWall Spell
« Reply #6 on: August 05, 2010, 05:38:11 pm »
ya, i tried too but with bots and without... without bots all works fine, but when i add 13 zombies... laggs come back, maybe can it be caused by FLAME? if yes, how can i mark position of it..?
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: FireWall Spell
« Reply #7 on: August 05, 2010, 06:31:21 pm »
Well i tried the script i gave you with 15 bots, i had more than multikillsx2, and my ping didn't spike or anything.

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: FireWall Spell
« Reply #8 on: August 05, 2010, 10:16:52 pm »
maybe your computer just can't handle that many bots?

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: FireWall Spell
« Reply #9 on: August 06, 2010, 04:07:38 am »
hmm... i testing all my scripts on laptop... when i run soldat, CPU temp can be above 80*C... maybe thats why? ill try on PC, flame on my server can do laggs too because i have high quality image for flames...  btw, laptop sux

Edit:

Same thing on PC... laggs, laggs and laggs, attached demo, just look how zombies are pulled back every 1 second, flame on middle of map is that used spell (reinstalled soldat with basic flame bmp) i think that my sister's pc is not weak... 4x PCU, 3GB ram so this can handle this spell, something is wrong in script... everything was fine with 14 bots before, something is wrong in this spell ;]
« Last Edit: August 06, 2010, 05:42:34 am by kosik231 »
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: FireWall Spell
« Reply #10 on: August 06, 2010, 08:43:25 am »
Try with 2 or 3 bot  ;D

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: FireWall Spell
« Reply #11 on: August 06, 2010, 08:47:12 am »
Jesus... PK you wanna play on my server with JUST 3 ZOMBIES? you are really crazy...
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: FireWall Spell
« Reply #12 on: August 06, 2010, 08:59:46 am »
No i mean try with 3 zombie maybe it willn't lagg

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: FireWall Spell
« Reply #13 on: August 06, 2010, 01:17:28 pm »
ehm, i tried to find a mistake... createbullet is that what making laggs... how can i fix it? i need some reason to mark position of spell but without createbullet its impossible i think x.X
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

DarkCrusade

  • Guest
Re: FireWall Spell
« Reply #14 on: August 06, 2010, 01:26:09 pm »
I barely find words to explain this difficult situation to you, PK, but it comes down to "read or die" if that's okay with you ;)

The code is pretty ridiculous, because you create one firewall for every player on the server for the ID using the command.. or is that meant to be like that? I only had a quick glance on the script, so if I misunderstood what you want to achieve I'm sorry.

@Above post: There is only one function creating bullets and that is CreateBullet. Unless you want it to be invisible you'll need to stick with it. But how'd you find out it's CreateBullet causing the issue? Did you comment those lines out? I suggest using loops only if they are really necessary and keep them at low. If you loop through 32 IDs and then - in this one loop - again through all 32 IDs you'll cause a big lag that wouldn't be caused by CreateBullet.

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: FireWall Spell
« Reply #15 on: August 06, 2010, 05:16:38 pm »
yes, i commented line with createbullet and it works, but how to fix second loop if i need it to check "j,'team' and i,'team'" for example...?
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: FireWall Spell
« Reply #16 on: August 06, 2010, 05:35:38 pm »
I tried it and there is no lagg ... :)
but if i put a firewall i cant put another one ...  >:(

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: FireWall Spell
« Reply #17 on: August 06, 2010, 05:52:26 pm »
Quote
I tried it and there is no lagg ... :)
1. You tried with bots? If yes, how many of them?
2. With / Without createbullet?
Quote
but if i put a firewall i cant put another one ...  >:(
1. Because Active is boolean...
2. Change it to integer and edit AppOnIdle...
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: FireWall Spell
« Reply #18 on: August 06, 2010, 05:55:09 pm »
16 bot named ZoMbIe   ;)
with createbullet  ;D

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: FireWall Spell
« Reply #19 on: August 07, 2010, 07:11:29 am »
finally i made it :D i forgot about 'active' in loop, with this all working beautiful :) if someone want to use that, here is code ^^
Code: [Select]
const
MAXFLAMETIME = 120;

type tFire = record
Active: boolean;
Owner: integer;
X,Y: single;
Duration: integer;
end;

var
flames: array[1..32] of tFire;

procedure CreateFireWall(ID:byte;PX,PY:single);
var
   i:byte;
begin
for i := 1 to 32 do begin
if flames[i].Active = false then begin
flames[i].Active := true;
flames[i].Owner := ID;   
flames[i].X := PX;
flames[i].Y := PY;
flames[i].Duration := MAXFLAMETIME;
end;
end;
end;

function OnPlayerCommand(ID: integer; Text: string): boolean;
var
X,Y: single;
begin
X:= GetPlayerStat(ID,'X');
Y:= GetPlayerStat(ID,'Y');
if Text = '/firewall' then begin
CreateFireWall(ID,X,Y);
end;
Result := false;
end;



procedure AppOnIdle(Ticks: longint);
var
i,j: integer;
begin
for i:= 1 to 32 do begin
if getplayerstat(i,'active')= true then begin
if getplayerstat(i,'human')= true then begin
if (flames[i].Active = true) then begin
if (flames[i].Duration > 0) then begin
flames[i].Duration := flames[i].Duration - 1;
CreateBullet(flames[i].X+50,flames[i].Y,0,0,2000,5, flames[i].Owner);
CreateBullet(flames[i].X,flames[i].Y-50,0,0,2000,5, flames[i].Owner);
CreateBullet(flames[i].X-50,flames[i].Y,0,0,2000,5, flames[i].Owner);
for j := 1 to 32 do begin
if getplayerstat(j,'active') = true then begin
if getplayerstat(j,'human') = false then begin
if (Distance(flames[i].X,flames[i].Y,GetPlayerstat(j,'X'),Getplayerstat(j,'Y')) <= 50) then begin
if (GetPlayerStat(j,'Alive') = true) then begin
if (GetPlayerStat(j,'Team') <> GetPlayerStat(flames[i].Owner,'Team')) then begin
DoDamageBy(j,flames[i].Owner,2000);
end;
end;
end;
end;
end;
end;
if (flames[i].Duration = 0) then begin   
flames[i].Active := false;
end;
end;
end;
end;
end;
end;
end;
its not FireWall, but i test it as FireWall (8 create bullets with flames, 2 columns with 4 CB each, without second loop), that was nice but lagging for me, try yourself ^^
Title of this spell will be: Black Hole xD
if you have suggestions to rebuild it, write a post about it ^^
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.