Project X Forums



It is currently Thu Dec 13, 2018 5:59 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Infinite in scripts
PostPosted: Sun Dec 06, 2009 1:11 am 
Offline
Betatester

Joined: Sun Dec 06, 2009 12:11 am
Posts: 21
Hi, I stumbled upon PX a few days ago and so far I'm loving it. I'm trying to script a custom "mission" and so far so good, I've managed to position mines, barrels and worms to my liking on the map, to give different amounts of initial health for different worms and so far so good. I also tried to use the SetWeaponNum function to set weaponry individually for each team. My only problem with it is that I couldn't find a way to add infinite weapons using that function. I tried setting the value to 255, 10 and a few others, to no avail. For example, if I try to set the bazooka stock to infinite by calling SetWeaponNum(1,1,1,255,false); , the weapon menu doesn't show x255, but when you select the weapon itself it shows on the top of the screen: "Bazooka (255)", and the number decreases as I use the weapon. Is there a way to set it to infinite?

Also, functions to spawn targets (like the blue one, the red one or the old woman shaped one) and crates of all kinds would be great for custom missions too, just like the WWP Mission Editor is able to do.

Thanks ! :D


Top
 Profile  
Reply with quote  
 Post subject: Re: Infinite in scripts
PostPosted: Sun Dec 06, 2009 5:38 am 
Offline
PX Developer

Joined: Mon Aug 17, 2009 12:01 pm
Posts: 91
Hi! ;) Use -1 for infinite amount.

Quote:
Also, functions to spawn targets (like the blue one, the red one or the old woman shaped one) and crates of all kinds would be great for custom missions too, just like the WWP Mission Editor is able to do.


Yeah, it would be great, but I'm not developing old scripting engine anymore. If you have basic knowledge of C/Lua, or simply want to develop missions or schemes for new version, you can contact me or GranPC


Top
 Profile  
Reply with quote  
 Post subject: Re: Infinite in scripts
PostPosted: Sun Dec 06, 2009 11:10 am 
Offline
Site Admin
User avatar

Joined: Mon Aug 17, 2009 12:29 pm
Posts: 91
Hey, nice job. As Entuser said, infinite is -1. Maybe you should release your script here, since it seems to be quite interesting.

Also, you could become a betatester for PX 0.8.0. It has a much nicer scripting language that makes everything easier.
You can contact me with ICQ (553138752), Steam (granpc, [IoS] Gran PC) or Messenger (granpc [hurr] gaminggalaxy [thingy] net).


Top
 Profile  
Reply with quote  
 Post subject: Re: Infinite in scripts
PostPosted: Sun Dec 06, 2009 3:44 pm 
Offline
Betatester

Joined: Sun Dec 06, 2009 12:11 am
Posts: 21
Thanks a bunch for the quick answers! The script I made was intentionally coded for this map I built with WormMM. Two players with different weapons team up to stop the enemy team who's trying to break into the tower. I'll be trying to find what's wrong with my turn tracking code to show different messages at the beginning of each turn. Oh, and I also got an "access violation" exception when trying to spawn mines with a W.A. scheme with no random objects enabled. If I set it to have 1 random mine on the map only, the MakeMine functions do work. The barrel ones work no matter the scheme settings.

Here's what I ended up with:

Code:
var
t1w1,t1w2,t1w3,t1w4,t1w5,t1w6,t1w7,t1w8,t2w1,t2w2,t2w3,t2w4,t2w5,t2w6,t2w7,t2w8,t3w1,t3w2,t3w3,t3w4,t3w5,t3w6,t3w7,t3w8 : TWorm;
current_turn : Integer;

procedure InitHooks();
begin
    begin
     RegisterHook('Init', ON_INIT);
     RegisterHook('OnFire', ON_BEGIN_FIRE); 
     RegisterHook('OnTurn', ON_TURN_BEGIN); 
     RegisterHook('Frame', ON_FRAME); 
     RegisterHook('OnCrate', ON_CRATE_PICK); //Don't know if all of these are really necessary 
    end;
end;           

procedure Init;
begin
current_turn := 0
t1w1 := getWormObj(1,1);
t1w2 := getWormObj(1,2);
t1w3 := getWormObj(1,3);
t1w4 := getWormObj(1,4);
t1w5 := getWormObj(1,5);
t1w6 := getWormObj(1,6);
t1w7 := getWormObj(1,7);
t1w8 := getWormObj(1,8);
t2w1 := getWormObj(2,1);
t2w2 := getWormObj(2,2);
t2w3 := getWormObj(2,3);
t2w4 := getWormObj(2,4);
t2w5 := getWormObj(2,5);
t2w6 := getWormObj(2,6);
t2w7 := getWormObj(2,7);
t2w8 := getWormObj(2,8);
t3w1 := getWormObj(3,1);
t3w2 := getWormObj(3,2);
t3w3 := getWormObj(3,3);
t3w4 := getWormObj(3,4);
t3w5 := getWormObj(3,5);
t3w6 := getWormObj(3,6);
t3w7 := getWormObj(3,7);
t3w8 := getWormObj(3,8);

t1w1.PosX := 115 ;
t1w1.PosY := 7940 ;
t1w2.PosX := 155 ;
t1w2.PosY := 7940 ;
t1w3.PosX := 205 ;
t1w3.PosY := 7940 ;
t1w4.PosX := 255 ;
t1w4.PosY := 7940 ;
t1w5.PosX := 2525 ;
t1w5.PosY := 7940 ;
t1w6.PosX := 2575 ;
t1w6.PosY := 7940 ;
t1w7.PosX := 2625 ;
t1w7.PosY := 7940 ;
t1w8.PosX := 2675 ;
t1w8.PosY := 7940 ;
t1w1.Health := 250 ;
t1w2.Health := 500 ;
t1w3.Health := 750 ;
t1w4.Health := 1000 ;
t1w5.Health := 250 ;
t1w6.Health := 500 ;
t1w7.Health := 750 ;
t1w8.Health := 1000 ;

t2w1.PosX := 1768 ;
t2w1.PosY := 1935 ;
t2w2.PosX := 1648 ;
t2w2.PosY := 1888 ;
t2w3.PosX := 1410 ;
t2w3.PosY := 1930 ;
t2w4.PosX := 1243 ;
t2w4.PosY := 1771 ;
t2w5.PosX := 1493 ;
t2w5.PosY := 1666 ;
t2w6.PosX := 1770 ;
t2w6.PosY := 1700 ;
t2w7.PosX := 1230 ;
t2w7.PosY := 1930 ;
t2w8.PosX := 1560 ;
t2w8.PosY := 1770 ;
t2w1.Health := 250 ;
t2w2.Health := 500 ;
t2w3.Health := 750 ;
t2w4.Health := 1000 ;
t2w5.Health := 250 ;
t2w6.Health := 500 ;
t2w7.Health := 750 ;
t2w8.Health := 1000 ;

t3w1.PosX := 1510 ;
t3w1.PosY := 1355 ;
t3w2.PosX := 1650 ;
t3w2.PosY := 1350 ;
t3w3.PosX := 1820 ;
t3w3.PosY := 1315 ;
t3w4.PosX := 1880 ;
t3w4.PosY := 1315 ;
t3w5.PosX := 2030 ;
t3w5.PosY := 1350 ;
t3w6.PosX := 2030 ;
t3w6.PosY := 1130 ;
t3w7.PosX := 1560 ;
t3w7.PosY := 1130 ;
t3w8.PosX := 1500 ;
t3w8.PosY := 1130 ;

t3w1.Health := 250 ;
t3w2.Health := 500 ;
t3w3.Health := 750 ;
t3w4.Health := 1000 ;
t3w5.Health := 250 ;
t3w6.Health := 500 ;
t3w7.Health := 750 ;
t3w8.Health := 1000 ;

end;

procedure OnTurn;
begin
  if current_turn = 0 then
     begin
MakeMine(1263,6680);
MakeMine(1263,6555);
MakeMine(1423,6680);
MakeMine(1423,6555);
MakeMine(1394,3968);
MakeMine(1460,3968);
MakeMine(1425,3935);
MakeMine(1587,2660);
MakeMine(1618,2660);
MakeMine(1652,2660);
MakeMine(1683,2660);
MakeMine(1714,2660);


MakeBarrel(1790,7440);
MakeBarrel(1790,7480);
MakeBarrel(1790,7520);
MakeBarrel(1790,7560);
MakeBarrel(1790,7600);
MakeBarrel(1470,2705);
MakeBarrel(1821,2721);
MakeBarrel(1376,2368);
MakeBarrel(1506,2368);
MakeBarrel(1634,2368);
MakeBarrel(1762,2368);
MakeBarrel(1631,368);

     
     SetWeaponNum(1,1,1,-1,false);
     SetWeaponNum(1,3,1,30,false);
     SetWeaponNum(1,6,1,-1,false);
     SetWeaponNum(1,7,1,30,false);
     SetWeaponNum(1,11,1,-1,false);
     SetWeaponNum(1,12,1,-1,false);
     SetWeaponNum(1,13,1,27,false);
     SetWeaponNum(1,14,1,10,false);
     SetWeaponNum(1,15,1,25,false);
     SetWeaponNum(1,16,1,-1,false);
     SetWeaponNum(1,17,1,-1,false);
     SetWeaponNum(1,21,1,15,false);
     SetWeaponNum(1,22,1,20,false);
     SetWeaponNum(1,23,1,12,false);
     SetWeaponNum(1,24,1,12,false);
     SetWeaponNum(1,35,1,10,false);
     SetWeaponNum(1,37,1,-1,false);
     SetWeaponNum(1,38,1,-1,false);
     SetWeaponNum(1,39,1,-1,false);
     SetWeaponNum(1,47,1,20,false);
     SetWeaponNum(1,52,1,25,false);

     SetWeaponNum(2,1,1,-1,false);
     SetWeaponNum(2,7,1,30,false);
     SetWeaponNum(2,12,1,-1,false);
     SetWeaponNum(2,15,1,25,false);
     SetWeaponNum(2,16,1,-1,false);
     SetWeaponNum(2,22,1,20,false);
     SetWeaponNum(2,38,1,-1,false);
     SetWeaponNum(2,62,1,-1,false);

     SetWeaponNum(3,6,1,-1,false);
     SetWeaponNum(3,3,1,30,false);
     SetWeaponNum(3,11,1,-1,false);
     SetWeaponNum(3,13,1,27,false);
     SetWeaponNum(3,17,1,-1,false);
     SetWeaponNum(3,21,1,15,false);
     SetWeaponNum(3,39,1,-1,false);
     SetWeaponNum(3,62,1,-1,false);
     current_turn := 1;
     end;
  case current_turn of
     1:  ShowMessageOnTop(23,'Possible threat spotted!'); //doesn't seem to be working
     2:  ShowMessageOnTop(23,'Unidentified worms approaching!');
     3:  ShowMessageOnTop(23,'Their weaponry is bigger than ours.');
     4:  ShowMessageOnTop(23,'Be careful!');
     5:  ShowMessageOnTop(23,'End of transmission.');
  end;
  if current_turn < 6 then
       current_turn := current_turn+1
end;

procedure Frame;
begin

end;

function OnFire : boolean;
begin
  Result := True;
end;

procedure OnCrate;
begin

end;


Thanks!

I do have really basic knowledge of Lua, but I don't think I have enough knowledge of C to be useful for anything. I mean, I would probably understand the overall structure of the code since it bears some resemblance to 'Game Maker Language', which I'm quite fluent at and have used for years. I didn't really have any experience of Pascal beforehand, though I managed to come up with this script just by taking a look at the ones that come with PX.


Top
 Profile  
Reply with quote  
 Post subject: Re: Infinite in scripts
PostPosted: Sun Dec 06, 2009 5:49 pm 
Offline
Site Admin
User avatar

Joined: Mon Aug 17, 2009 12:29 pm
Posts: 91
Hello, the script looks very nice! And the map is quite good. On scripting, refer to this thread. The script most likely won't work anymore, but it serves as a quick reference of what it looks like.

If you think you can code something similar, feel free to ask us for PX 0.8.0. It's a bit hard to get started on this, but you'll be given commented and working examples, documentation and you'll be able to ask us anything.
The reason you may be interested on the new scripting language is because you can easily do basically anything, from a SMG that shoots mines that don't explode unless an ENEMY activates it (by Entuser) to magnets that repel everything (by _Kilburn) and even to stones that push worms and then return when you press space (by _Kilburn).

Also, nice to know another person who has ever used Game Maker ;)


Top
 Profile  
Reply with quote  
 Post subject: Re: Infinite in scripts
PostPosted: Sun Dec 06, 2009 7:10 pm 
Offline
Betatester

Joined: Sun Dec 06, 2009 12:11 am
Posts: 21
I don't think I would be able to code such a thing from scratch, but by looking at examples I would probably experiment a lot with the coding, just like I did with Pascal. Then again, I would love to contribute to the project, and even though I can't guarantee I'll be coming up with productive stuff, I would certainly try to do my best. It's up to the team. ;)

By the way, any advice on why ShowMessageOnTop isn't working? Is there a built-in way to track the turn number?


Top
 Profile  
Reply with quote  
 Post subject: Re: Infinite in scripts
PostPosted: Mon Dec 07, 2009 8:52 am 
Offline
Site Admin
User avatar

Joined: Mon Aug 17, 2009 12:29 pm
Posts: 91
No, coding anything from scratch on this language is almost impossible, unless you are able to perfectly remember the syntax. I did the same exact thing with Pascal, just fucked around with the code until it either broke or started working.
I'll ask Entuser and if everything goes well, you'll soon have a PM.

I think ShowMessageOnTop has been broken since it was made, but I haven't ever used it. And no, you'll have to track the numbers yourself.


Top
 Profile  
Reply with quote  
 Post subject: Re: Infinite in scripts
PostPosted: Wed Dec 09, 2009 7:56 pm 
Offline
Betatester

Joined: Mon Nov 09, 2009 1:53 pm
Posts: 11
Location: Russia, Tuapse
Cant add anything but that i used GameMaker too =)
By the way, ShowMessageOnTop works, i remember i used it. But i packed all the old schemes into the archive and now they "collect dust on themselves" in PXSchemes folder) I may try to search for the scheme i used this in.
Haha rules list for my unfinished RPG scheme. I was too noob to use CASE then.
Code:
procedure RULES;
begin
tick:=tick+1;
if tick=100 then ShowMessageOnTop(23, ' !! LOOK UP HERE !!');
if tick=200 then ShowMessageOnTop(23, 'WEAPS FOR CASTLE SIEGE F1');
if tick=300 then ShowMessageOnTop(23, 'WEAPS FOR WARRIORS F2');
if tick=400 then ShowMessageOnTop(23, 'WEAPS FOR ROGUES F3');
if tick=500 then ShowMessageOnTop(23, 'WEAPS FOR MAGES F4');
if tick=600 then ShowMessageOnTop(23, ' !! REWARDS FOR MOBS !!');
if tick=700 then ShowMessageOnTop(23, 'Beasts-10 gold');
if tick=800 then ShowMessageOnTop(23, 'Monsters-20 gold');
if tick=900 then ShowMessageOnTop(23, 'Bosses(Label B)-30 gold');
if tick=1000 then ShowMessageOnTop(23, ' !! WAYS TO WIN !!');
if tick=1100 then ShowMessageOnTop(23, '1)Destroy enemy castle');
if tick=1200 then ShowMessageOnTop(23, '2)Kill all enemy heroes');
if tick=1300 then ShowMessageOnTop(23, ' !! HOW TO EARN MONEY !!');
if tick=1400 then ShowMessageOnTop(23, '1)Press "="');
if tick=1500 then ShowMessageOnTop(23, '2)Select weapon named same as...');
if tick=1600 then ShowMessageOnTop(23, '...the class of monster u killed');
if tick=1700 then ShowMessageOnTop(23, '3)Use that weapon');
if tick=1800 then ShowMessageOnTop(23, ' !!!DONT CHEAT WITH THIS!!!');
end;

Idk. Used this and it worked xD

_________________
Image
Image


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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