Page 1 of 2

Count number of axis players

Posted: Sat Nov 27, 2004 7:45 pm
by strafer
How can I make a script to count the number of axis players that are alive? Also, how can I disable the spawn for a certain team if a certain objective has been completed. This is all for AA.

Posted: Sun Nov 28, 2004 2:34 am
by Phil {sfx}
Off the top of my head.

Code: Select all

main:

thread body_counter
end

//*****************

body_counter:

while(1)
{
level.allies = 0
level.axis = 0
for(local.i=1;local.i<=$player.size;local.i++)
{
   if($player[local.i].dmteam=="allies")
{
   level.allies++
}
   else if($player[local.i].dmteam=="axis")
{
   level.axis++
                       }
                         }
                           iprintln ("Axis: " + (level.axis))
                           iprintln ("Allied: " + (level.allies))
                           wait 5
                         }
                         end           
That will print the team numbers on the left were game messages are shown every 5 seconds.

EDIT:

oops, forgot about your spawn q,

targetname means your spawns targetname.

$targetname enablespawn & $targetname disablespawn turns them on and off.

I could explain the part about triggering them after a obj, but it will be easier for you to look in obj_team3.scr (Omaha) and see how it is done.

Posted: Sun Nov 28, 2004 2:41 am
by Grassy
Something like this will do the job,

Code: Select all

level.axis_in_game =0
level.allies_in_game =0

thread get_player_info

//-----------------
get_player_info:
//-----------------

while(1) // or make a call from a trigger instead of looping
{
 for ( local.i=1 ; local.i <= $player.size ; local.i++ )
  {
    waitthread scan_players $player[local.i]
    waitframe
  }
 waitframe
}
end

//------------------------
scan_players local.player:
//------------------------
  
  local.trigger = spawn trigger_multiple 
  local.trigger.origin = local.player.origin
  waitframe
  waitframe
  waitframe
  local.trigger delete
  
  if(isAlive local.player)
  {
    if ( local.player.dmteam == "axis" )
    {
      level.axis_in_game++
      println "Z------ Axis in game = " level.axis_in_game
     }
    else if ( local.player.dmteam == "allies" )
     {
      level.allies_in_game++
      println "Z------ Allies in game = " level.allies_in_game
     }
   }
end
[/size]

Posted: Sun Nov 28, 2004 3:17 am
by strafer
Phil {sfx} wrote:Off the top of my head.

Code: Select all

main:

thread body_counter
end

//*****************

body_counter:

while(1)
{
level.allies = 0
level.axis = 0
for(local.i=1;local.i<=$player.size;local.i++)
{
   if($player[local.i].dmteam=="allies")
{
   level.allies++
}
   else if($player[local.i].dmteam=="axis")
{
   level.axis++
                       }
                         }
                           iprintln ("Axis: " + (level.axis))
                           iprintln ("Allied: " + (level.allies))
                           wait 5
                         }
                         end           
That will print the team numbers on the left were game messages are shown every 5 seconds.

EDIT:

oops, forgot about your spawn q,

targetname means your spawns targetname.

$targetname enablespawn & $targetname disablespawn turns them on and off.

I could explain the part about triggering them after a obj, but it will be easier for you to look in obj_team3.scr (Omaha) and see how it is done.
Ok so how do I figure out the targetnames for the spawns? I need to figure this out for a stock map.

Posted: Sun Nov 28, 2004 4:57 am
by Phil {sfx}
Decompile it with a bsp 2 map prog, and look at them in radiant. (N - brings down the entity menu in rad to check the values, if they have any)

Your be lucky tho if all spawns have targetnames set in stock maps, the ones on omaha have them set cos there used.

Posted: Sun Nov 28, 2004 5:22 pm
by strafer
Phil {sfx} wrote:Decompile it with a bsp 2 map prog, and look at them in radiant. (N - brings down the entity menu in rad to check the values, if they have any)

Your be lucky tho if all spawns have targetnames set in stock maps, the ones on omaha have them set cos there used.
Do you know where I can find a bsp to map converter? I searched at mohfiles.com and groundforce1.com and I couldn't find one. I know I have seen one before, but I can't remember where I found it at.

Posted: Sun Nov 28, 2004 5:34 pm
by At0miC
Search for MohBSPToMohMAP on google :wink:

Posted: Sun Nov 28, 2004 5:44 pm
by strafer
Ok I have it converted and opened in MOHRadiant. I pressed N and a little menu popped up with a list of different objects, but it seems to list everything that you find in .pk3 files. It doesn't show the entities.

Posted: Sun Nov 28, 2004 7:27 pm
by strafer
OK. This is what I have done so far:

I made a script that is enabled once a certain amount of objectives have been accomplished. It then takes away the players weapons and gives him noclip. So basically it is like he is in spectator. It then does not count him as being alive. That part works just fine. All I need now is a way to do this to axis players that are dead ONLY. I only know the way to find out if a player is alive. How do I find out if they are dead?

Posted: Mon Nov 29, 2004 2:46 pm
by Phil {sfx}
Just a quick edit of the above script to this should do it for you, I dont know how exactly you want it to work but that should give you the idea of how to do it.

Code: Select all

main:

level.allies_dead = 0 
level.axis_dead = 0 
end


while(1) 
{ 
for(local.i=1;local.i<=$player.size;local.i++) 
{ 
   if($player[local.i].dmteam=="allies") 
{ 
  $player[local.i] waittill death 
  level.allies_dead++ 
} 
   else if($player[local.i].dmteam=="axis") 
{ 
  $player[local.i] waittill death
   level.axis_dead++ 
} 
} 
} 
end     

Posted: Mon Nov 29, 2004 7:55 pm
by strafer
Sorry. I forgot to post an update. :oops:

I figured out how to figure out if they are dead. 8-)

What another guy and I are trying to figure out is how to disable the spawn for the axis only on an objective map. Like on SH TOW if the spawn was destroyed, they can no longer respawn. Yes, I looked at the script on SH, but couldn't find the script to not allow the players to respawn. :(

Posted: Tue Nov 30, 2004 3:30 am
by agentmad007
lol strafer i did too .

thats really weird there

if objective1 Takeover

iprintln " allies cant respanw" or somethink like that.

something similar.......


But i did not find how to disable the spawn even in tow_dm.scr!

Posted: Tue Nov 30, 2004 3:43 am
by strafer
agentmad007 wrote:lol strafer i did too .

thats really weird there

if objective1 Takeover

iprintln " allies cant respanw" or somethink like that.

something similar.......


But i did not find how to disable the spawn even in tow_dm.scr!
It may just be a SH map script...no idea. :oops:

Posted: Tue Nov 30, 2004 7:17 am
by Grassy
Takeover, setcurrent etc are set in the map bsp in SH.
TOW maps have control nodes and targets for triggers etc, ie; if a trigger is set it will update the setcurrent id to =1 or =0 depending on the team. Look in the SH sdk docs, there is a tute for TOW maps.
To enable - disable specific spawns then those spawns need to have a targetname so they can be controlled from script.
The other way I know of is to add right at the very top of your scr above main: new info_player_allied or axis spawn locations of the same number of original ones. Some players might still spawn in the old locations but most will spawn at the new ones. These new spawns can have targetnames that can be enabled/disabled in your scr..

Posted: Tue Nov 30, 2004 11:40 am
by bdbodger
They didn't give the spawnpoints targetnames in all of the stock maps so that won't help you . Also instead of decompileing the maps just open the bsp in notepad or wordpad and do a find for info_player_allied or info_player_axis it will be in the bsp in text form so you can tell if they have targetnames or not .