Project X Forums



It is currently Sun Apr 28, 2024 12:14 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Count amount of worms left in team
PostPosted: Sun Aug 17, 2014 6:28 pm 
Offline

Joined: Mon Jul 30, 2012 9:45 am
Posts: 194
I would like to have events happen in the case that each team has only 1 worm left, so I would like to be able to count the worms left in any given team (so, not just the active one).

Is there a way to do this?

_________________
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: Count amount of worms left in team
PostPosted: Tue Aug 19, 2014 8:01 am 
Offline

Joined: Mon Aug 18, 2014 6:49 pm
Posts: 15
Hey Raffie, I think I played with you some days ago.

I'm not really into all the API functions provided by PX but can't you just iterate over all worms of any team and get the team color of each one?


Top
 Profile  
Reply with quote  
 Post subject: Re: Count amount of worms left in team
PostPosted: Wed Aug 20, 2014 1:20 pm 
Offline

Joined: Mon Jul 30, 2012 9:45 am
Posts: 194
Hi DebugErr, good to see you here, PX needs some active developers :p

So I read in your intrduction post that you're a software developer, me, I'm a webdeveloper, writing PHP is a big part of my job. But I don't know any C, C++, C#,.... so EAX is a bit of a stretch for me. I do understand basic principles of programming obviously from what I know in PHP, and I've learned a thing or two from studying existing PX libs' code.

In any event, I'm gonna see if I can figure out how to convert your suggestion into a EAX script :P

_________________
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: Count amount of worms left in team
PostPosted: Fri Aug 22, 2014 1:09 pm 
Offline

Joined: Mon Aug 18, 2014 6:49 pm
Posts: 15
Will be a nice share! Didn't have the time to check the idea myself yet sadly.

Lol, for me, PHP and other web development doesn't tickle my balls, but strongly typed, "traditional" languages (can you even call non-web-languages like this already?) for app development will do.


Top
 Profile  
Reply with quote  
 Post subject: Re: Count amount of worms left in team
PostPosted: Mon Aug 25, 2014 9:40 am 
Offline

Joined: Wed Jul 31, 2013 4:03 pm
Posts: 35
Location: Ukraine
hi, raffie!
yes, it is possible to get the number of worms in team.
  • GS->Info.Teams[team].NWorms - starting number of worms (as set in the lobby); note: worms resurrecting may increment this variable
  • GS->Info.Teams[team].Worms[worm].State - state of worm; value 135 (more memorizable: WS_DEAD) means that worm is dead
so the following script is counting non-dead worms. the simplest solution that i can write:
Code:
require utils;

override void CTurnGame::Message(CObject* sender,EMType Type,int MSize,CMessageData* MData) {
  super;
  if (Type == M_TURNEND) {
 
    for (local team = 0; team < 6; team++) {
   
      local wormCount = 0;
      for (local worm = 0; worm < GS->Info.Teams[team].NWorms; worm++)
        if (GS->Info.Teams[team].Worms[worm].State != 135) // if not dead
          wormCount++;
         
      if (wormCount == 1)
        GG->WriteToChat(9+team, StrCon(StrCon("poor lonely ", IToC(team)), " worm... :{"), false);
       
    }
   
  }
}         
       
string IToC(int n) {
  if (n == 0) return "Red";
  if (n == 1) return "Blue";
  if (n == 2) return "Green";
  if (n == 3) return "Yellow";
  if (n == 4) return "Purple";
  if (n == 5) return "Cyan";
  return "Null";

is my answer helpful?


Top
 Profile  
Reply with quote  
 Post subject: Re: Count amount of worms left in team
PostPosted: Mon Aug 25, 2014 8:03 pm 
Offline

Joined: Mon Jul 30, 2012 9:45 am
Posts: 194
THANK YOU Danylo :mrgreen: :mrgreen: :mrgreen:

Awesome thank you thank you thank you :)

_________________
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  
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 38 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