Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Damaging All Players in a Sector
Damaging All Players in a Sector
2004-12-13, 10:22 PM #1
I'm trying to damage all players in a sector in a multiplayer game. I'm using this code, but it isn't working. Is there a better way? Did I make a simple mistake? Thanks for any help.

Code:
pulse:
	print("pulsing");
	thingToDamage = firstThingInSector(doctorSector);
	damageThing(thingToDamage, damageAmount, 0x2, doctor);
	for (i=0; i<getSectorThingCount(doctorSector)-1; i=i+1) {
		thingToDamage = nextThingInSector(doctorSector);
		damageThing(thingToDamage, damageAmount, 0x2, doctor);
	}

	return;
KOP_blujay
Just dancin'...and singin'...in the Force.
2004-12-13, 11:06 PM #2
I'm not sure what's wrong with your code, but server code (sync'd, not run on all machines) as follows may work:
Code:
   for(i=FirstThingInSector(doctorSector), j=0; j<GetSectorThingCount(doctorSector); i=NextThingInSector(i), j=j+1)
   {
      if(GetThingType(i) == 10)
      {
         DamageThing(i, damageAmount, 0x2, doctor);
      }
   }


I think your code fails because of
thingToDamage = nextThingInSector(doctorSector);
It needs to be
thingToDamage = NextThingInSector(thingToDamage);
if my understanding of the NextThingInSector verb is correct.

See if any of that info helps.

QM
2004-12-14, 12:05 AM #3
Thanks, QM. I will try that. :)
KOP_blujay
Just dancin'...and singin'...in the Force.
2004-12-14, 3:58 AM #4
Personally, I'd go with this:

Code:
For(X=0; X<GetNumPlayers(); X=X+1)
{
   if(GetThingSector(GetPlayerThing(X)) == DamageSector)
   {
      DamageThing(GetPlayerThing(X)....);
   }
}


Quick and simple. :D
-Hell Raiser
2004-12-14, 10:57 AM #5
Doh, that makes even more sense. I didn't think to look for a GetPlayerThing(). :) Thanks.
KOP_blujay
Just dancin'...and singin'...in the Force.
2004-12-14, 11:21 AM #6
Hell Raiser's code made me want to ask...does this work in COG? Just curious.

Code:
For(X=0; X<GetNumPlayers(); X=X+1)
    if(GetThingSector(GetPlayerThing(X)) == DamageSector)
        DamageThing(GetPlayerThing(X)....);
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2004-12-14, 11:38 AM #7
Well, it seems to follow the correct syntax without {}'s, but that just looks sloppy. :p
-Hell Raiser
2004-12-14, 11:56 AM #8
What? They're one line ifs and fors, it's correct! :p
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2004-12-14, 12:00 PM #9
I said the syntax looks correct :P It looks sloppy IMHO ;P
-Hell Raiser
2004-12-14, 12:30 PM #10
Actually I did mean acceptable coding standards-wise.

Heh, you know what's funny? The Java sourcecode violates the Java coding standard published by Sun.
Bassoon, n. A brazen instrument into which a fool blows out his brains.

↑ Up to the top!