Project X Forums



It is currently Thu Apr 18, 2024 5:55 pm

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Limit to 1 shot per turn, without ending turn
PostPosted: Sun Dec 08, 2013 8:59 pm 
Offline

Joined: Mon Jul 30, 2012 9:45 am
Posts: 194
Not possible with the editor, but it should be easy with script... Maybe someone could help me with this?
I would like to update the Holy War scheme, the HHG is the only weapon that doesn't end the turn, but it should be limited to 1 (or x) shot(s) per turn :) Pretty much like with Highlander where the worm gets dealt 1 shot of a weapon every turn.

_________________
http://twitch.tv/wormsdotam | http://worms.am/hl | http://worms.am/zombieshopper | http://worms.am/golf | http://worms.am/holywar


Top
 Profile  
Reply with quote  
 Post subject: Re: Limit to 1 shot per turn, without ending turn
PostPosted: Tue Dec 10, 2013 8:41 am 
Offline
User avatar

Joined: Sun Apr 08, 2012 1:09 pm
Posts: 425
Location: Ukraine, Kyiv
-raffie- wrote:
Not possible with the editor, but it should be easy with script... Maybe someone could help me with this?
I would like to update the Holy War scheme, the HHG is the only weapon that doesn't end the turn, but it should be limited to 1 (or x) shot(s) per turn :) Pretty much like with Highlander where the worm gets dealt 1 shot of a weapon every turn.

Hi raffie :)
Yeah its pretty easy task.
here is a code you`re looking for:
Code:
override void CWorm::Message(CObject* sender,EMType Type,int MSize,CMessageData* MData)
{
 super;
 if (Type == M_TURNBEGIN)
 {
         local Weap = GetWeaponByName("Holy Hand Grenade");
         GS->Info.AddWeaponEx(WormTeam, Weap->GetWeaponIndex(), Weap->GetPageIndex(), 1);
 }
}

I did not test it, but it should definitely work.
What it should do: add to ANY of existing worms 1 holy hand grenade when turn starts. Doesn`t stick to current worm, coz in case of select worm that would be a tragedy))
You can put this code anywhere but not inside of existing functions and overrides :)
You can put into existing script of existing lib. Or make separate script in existing lib. Or make new lib and make there new script and attach to scheme. Or even put it into new scheme script (without libs). All of those methods will work.
But i would recommend to choose one that doesnt affect original library to avoid reloading all unnecessary data from that library for everyone in a lobby. You can also ignore this if original library is very small in size :)

Cheers.

_________________
Things to impress.


Top
 Profile  
Reply with quote  
 Post subject: Re: Limit to 1 shot per turn, without ending turn
PostPosted: Tue Dec 10, 2013 8:58 am 
Offline
User avatar

Joined: Sun Apr 08, 2012 1:09 pm
Posts: 425
Location: Ukraine, Kyiv
hmmm i just thinked about.
What do you think about the idea, that when game starts - everyone get 1 HHG. But when some particular worm is active - he got +1 HHG every turn.
So you can choose: use HHG now or hold it for next turn (of this particular worm) in case of fail or tactical meanings.
Or.. everyone got 0 HHG when game starts. And worm get +one HHG only when his turn begins. This should expand tactical thinking under this scheme.

Anyway, script is very simple and if you like, you could try it. I`ll write the code:
Code:
override void CWorm::Message(CObject* sender,EMType Type,int MSize,CMessageData* MData)
{
 super;
 // Set HHG amout = 0 for all worms AT FIRST FRAME of the game.
 if (Type == M_FRAME && gframe == 1) // require stepsutils to be loaded;
 {
         local Weap = GetWeaponByName("Holy Hand Grenade");
         GS->Info.AddWeaponEx(WormTeam, Weap->GetWeaponIndex(), Weap->GetPageIndex(), 0);
 }
 // Add +1 HHG for current worm only when his turn starts.
 if (Type == M_TURNBEGIN && CurrentWorm == this) // require p_utils to be loaded;
 {
         local Weap = GetWeaponByName("Holy Hand Grenade");
         GS->Info.AddWeaponEx(WormTeam, Weap->GetWeaponIndex(), Weap->GetPageIndex(), +1);
 }
}


This code doesnt care of what settings you will have in weapon editor. It will just set amount to 0 and then add +1.
But if you want to control from weap editor what amount of weap you want at start of the game - just comment out or delete part of the code that set HHG amount to 0. In that case it will load values from weap editor. But you will need to set those ammo value there :)

And again, i did not test it. If you got any problems with this - let me know.

_________________
Things to impress.


Top
 Profile  
Reply with quote  
 Post subject: Re: Limit to 1 shot per turn, without ending turn
PostPosted: Tue Dec 10, 2013 10:15 am 
Offline

Joined: Mon Jul 30, 2012 9:45 am
Posts: 194
Hey Pyro, you come to the rescue again :) Thanks so much for your help, I'm gonna try this code out tonight, would be so nice to bring this classic scheme into the PX era ;)

And yes you're right, great idea to make it possible to save up Holy's, I definitely wanna use that in the scheme!

_________________
http://twitch.tv/wormsdotam | http://worms.am/hl | http://worms.am/zombieshopper | http://worms.am/golf | http://worms.am/holywar


Top
 Profile  
Reply with quote  
 Post subject: Re: Limit to 1 shot per turn, without ending turn
PostPosted: Tue Dec 10, 2013 10:48 am 
Offline
User avatar

Joined: Sun Apr 08, 2012 1:09 pm
Posts: 425
Location: Ukraine, Kyiv
Glad to help :)
wish you a good tests! Further ideas acceptible ;)

_________________
Things to impress.


Top
 Profile  
Reply with quote  
 Post subject: Re: Limit to 1 shot per turn, without ending turn
PostPosted: Wed Dec 11, 2013 8:59 pm 
Offline

Joined: Mon Jul 30, 2012 9:45 am
Posts: 194
Hey Pyro, I'm getting following error when loading teh script:


Code:
PXS : CError : TES:MakeOperandSt error : Operator is not supported yet
at Scheme:holy_war:16



this is line 16:

Code:
GS->Info.AddWeaponEx(WormTeam, Weap->GetWeaponIndex(), Weap->GetPageIndex(), +1);


I guess it has to do with the +1 ;)

_________________
http://twitch.tv/wormsdotam | http://worms.am/hl | http://worms.am/zombieshopper | http://worms.am/golf | http://worms.am/holywar


Top
 Profile  
Reply with quote  
 Post subject: Re: Limit to 1 shot per turn, without ending turn
PostPosted: Wed Dec 11, 2013 10:24 pm 
Offline
User avatar

Joined: Sun Apr 08, 2012 1:09 pm
Posts: 425
Location: Ukraine, Kyiv
hmmm lol, i forgot about those things. And now i see that i made huge mistake - choosed wrong function to SET ammo and to ADD ammo) I used one for both operations. But there are seperate functions there :)

here is tweaked code versions:
SET HHG to 1 at start of each round for everyone:
Code:
override void CWorm::Message(CObject* sender,EMType Type,int MSize,CMessageData* MData)
{
 super;
 if (Type == M_TURNBEGIN)
 {
         local Weap = GetWeaponByName("Holy Hand Grenade");
         GS->Info.SetWeaponEx(WormTeam, Weap->GetWeaponIndex(), Weap->GetPageIndex(), 1);
 }
}


SET 0 when game starts. ADD +1 to current worm:
Code:
override void CWorm::Message(CObject* sender,EMType Type,int MSize,CMessageData* MData)
{
 super;
 // Set HHG amout = 0 for all worms AT FIRST FRAME of the game.
 if (Type == M_FRAME && gframe == 1) // require stepsutils to be loaded;
 {
         local Weap = GetWeaponByName("Holy Hand Grenade");
         GS->Info.SetWeaponEx(WormTeam, Weap->GetWeaponIndex(), Weap->GetPageIndex(), 0);
 }
 // Add +1 HHG for current worm only when his turn starts.
 if (Type == M_TURNBEGIN && CurrentWorm == this) // require p_utils to be loaded;
 {
         local Weap = GetWeaponByName("Holy Hand Grenade");
         GS->Info.AddWeaponEx(WormTeam, Weap->GetWeaponIndex(), Weap->GetPageIndex(), 1);
 }
}


At first time i`ve wrote code here, on forum) so it has those miskates))) i should`ve create it into PXLedit first.
Now i`ve checked it there and no errors appears. So this one should work now :)
Cheers

_________________
Things to impress.


Top
 Profile  
Reply with quote  
 Post subject: Re: Limit to 1 shot per turn, without ending turn
PostPosted: Wed Dec 11, 2013 10:34 pm 
Offline
User avatar

Joined: Sun Apr 08, 2012 1:09 pm
Posts: 425
Location: Ukraine, Kyiv
i`ve noticed that you named your script "holy_war" which is bad name and can be redeclared.
And error on line 16 says that you`ve made that script as empty one. Or just placed code at top of existing script.
In case of separate script, better rename it to something like "holy_war_extension"
just like i did here:
Attachment:
p_holy_war_extension.rar [519 Bytes]
Downloaded 445 times

_________________
Things to impress.


Top
 Profile  
Reply with quote  
 Post subject: Re: Limit to 1 shot per turn, without ending turn
PostPosted: Thu Dec 12, 2013 5:32 pm 
Offline

Joined: Mon Jul 30, 2012 9:45 am
Posts: 194
Hey Pyro :)

Thanks again for the help, now we're almost getting there :lol:

- Holy Hand-Grenade needs dash or doesn't work xD
- when using "CurrentWorm = this" the Holy's don't get added up, when removing that part, it works :mrgreen:
but off course as you predicted, when using Select, it's all messed up couse for every time you change a worm, a Holy gets added xD

thanks again for yr help man I appreciate it :)

_________________
http://twitch.tv/wormsdotam | http://worms.am/hl | http://worms.am/zombieshopper | http://worms.am/golf | http://worms.am/holywar


Top
 Profile  
Reply with quote  
 Post subject: Re: Limit to 1 shot per turn, without ending turn
PostPosted: Thu Dec 12, 2013 6:11 pm 
Offline
User avatar

Joined: Sun Apr 08, 2012 1:09 pm
Posts: 425
Location: Ukraine, Kyiv
-raffie- wrote:
Hey Pyro :)

Thanks again for the help, now we're almost getting there :lol:

- Holy Hand-Grenade needs dash or doesn't work xD
- when using "CurrentWorm = this" the Holy's don't get added up, when removing that part, it works :mrgreen:
but off course as you predicted, when using Select, it's all messed up couse for every time you change a worm, a Holy gets added xD

thanks again for yr help man I appreciate it :)

-raffie- wrote:
- Holy Hand-Grenade needs dash or doesn't work xD

lolololo :D I`ve been writing this weap name by memory)) probably its bad :D
-raffie- wrote:
- when using "CurrentWorm = this" the Holy's don't get added up, when removing that part, it works :mrgreen:
but off course as you predicted, when using Select, it's all messed up couse for every time you change a worm, a Holy gets added xD

Lolz ))
well "CurrentWorm = this" is wrong. should be "CurrentWorm == this". Also this global variable works only if p_utils is loaded.
But.. maybe when "TurnBegin" current worm is not active yet? hm. If so, we will need change the way it works.

I`ll be online today on wormnet. We could test it out :)

_________________
Things to impress.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 42 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