Project X Forums



It is currently Thu Mar 28, 2024 10:50 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Help needed!
PostPosted: Sun Mar 28, 2010 11:51 am 
Offline
Betatester

Joined: Tue Mar 16, 2010 12:39 pm
Posts: 15
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Help needed!
PostPosted: Tue Mar 30, 2010 11:44 am 
Offline
Site Admin
User avatar

Joined: Mon Aug 17, 2009 12:29 pm
Posts: 91
Huuh that should work fine.


Top
 Profile  
Reply with quote  
 Post subject: No, it doesn't! =)
PostPosted: Tue Mar 30, 2010 2:16 pm 
Offline
Betatester

Joined: Tue Mar 16, 2010 12:39 pm
Posts: 15
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Help needed!
PostPosted: Wed Mar 31, 2010 1:36 pm 
Offline
Site Admin
User avatar

Joined: Mon Aug 17, 2009 12:29 pm
Posts: 91
Then do not hold space pressed.
There was something about map bounds on the documentation, look for it.
Check PASCAL's syntax.


Top
 Profile  
Reply with quote  
 Post subject: Re: Help needed!
PostPosted: Wed Mar 31, 2010 2:00 pm 
Offline
PX Developer

Joined: Mon Aug 17, 2009 12:01 pm
Posts: 91
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.


Top
 Profile  
Reply with quote  
 Post subject: Finally!
PostPosted: Thu Apr 01, 2010 9:56 pm 
Offline
Betatester

Joined: Tue Mar 16, 2010 12:39 pm
Posts: 15
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!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Skin by Lucas Kane