Project X Forums http://px.worms2d.info/forum/ |
|
Count amount of worms left in team http://px.worms2d.info/forum/viewtopic.php?f=13&t=2010 |
Page 1 of 1 |
Author: | -raffie- [ Sun Aug 17, 2014 6:28 pm ] |
Post subject: | Count amount of worms left in team |
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? |
Author: | DebugErr [ Tue Aug 19, 2014 8:01 am ] |
Post subject: | Re: Count amount of worms left in team |
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? |
Author: | -raffie- [ Wed Aug 20, 2014 1:20 pm ] |
Post subject: | Re: Count amount of worms left in team |
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 ![]() |
Author: | DebugErr [ Fri Aug 22, 2014 1:09 pm ] |
Post subject: | Re: Count amount of worms left in team |
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. |
Author: | Danylo [ Mon Aug 25, 2014 9:40 am ] |
Post subject: | Re: Count amount of worms left in team |
hi, raffie! yes, it is possible to get the number of worms in team.
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? |
Author: | -raffie- [ Mon Aug 25, 2014 8:03 pm ] |
Post subject: | Re: Count amount of worms left in team |
THANK YOU Danylo ![]() ![]() ![]() Awesome thank you thank you thank you ![]() |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |