Project X Forums
http://px.worms2d.info/forum/

Help needed!
http://px.worms2d.info/forum/viewtopic.php?f=5&t=64
Page 1 of 1

Author:  ravander [ Sun Mar 28, 2010 11:51 am ]
Post subject:  Help needed!

I have made a script like this:

Code:
procedure InitHooks;
begin
RegisterHook('OnFire',On_Fire);
end;

procedure OnFire;
var
  a,b : integer;
  WormObj : TWorm;
begin
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  WormObj := GetTekWormObj;
  if (WormObj.SelWeapon.WT = 2) and (WormObj.SelWeapon.WN = 22) then begin
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  a:=GetSyncRandom(1920,1);
  b:=GetSyncRandom(696,1);
  MakeMine(a,b);
  end;
end;


When I use it, it makes so many mines that round never ends. How can I make it to do only as many mines as the script says?
And is it possible to make the script check maps size?

Author:  Gran PC [ Tue Mar 30, 2010 11:44 am ]
Post subject:  Re: Help needed!

Huuh that should work fine.

Author:  ravander [ Tue Mar 30, 2010 2:16 pm ]
Post subject:  No, it doesn't! =)

Maybe it should, but it does not!
When using this script I can keep space pressed when using mine and it makes so many mines into the same place
that round never ends and the mines just shake as a tower or something like that.

And again: Is it possible to make a script that checks maps size?

Edit: And just one more question! How to code loops with SchemeEd ?

-Tuomas

Author:  Gran PC [ Wed Mar 31, 2010 1:36 pm ]
Post subject:  Re: Help needed!

Then do not hold space pressed.
There was something about map bounds on the documentation, look for it.
Check PASCAL's syntax.

Author:  Entuser [ Wed Mar 31, 2010 2:00 pm ]
Post subject:  Re: Help needed!

In 0.6.5, GetSyncRandom returns same value during frame. For preventing this, use GetSyncRandom(1920, 1) first time, GetSyncRandom(1920,2) (or something) next time etc.

Author:  ravander [ Thu Apr 01, 2010 9:56 pm ]
Post subject:  Finally!

So, finally got time for project x and repaired the script like this:

Code:
procedure InitHooks;
begin
RegisterHook('OnFire',On_Fire);
end;

procedure OnFire;
var
  a,b,c,d,e,MapSizeX,MapSizeY : integer;
  WormObj : TWorm;
begin
  c := 0;
  d := 1;
  e := 1;
  MapSizeX := MapX;  // Checks map's size
  MapSizeY := MapY;
  WormObj := GetTekWormObj;
  if (WormObj.SelWeapon.WT = 1) and (WormObj.SelWeapon.WN = 22) then begin //Looks if mine is selected
  repeat
  a:=GetSyncRandom(MapSizex,d);  //Randomizes locations of mines
  b:=GetSyncRandom(MapSizeY,e);
  MakeMine(a,b);
  c:=c+1;
  d:=d+1;
  e:=e+1;
  until c=10;  // Loops until 10 mines are created
  end;
end;


Thanks for help!

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/