HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

jass question?

03-24-2006, 08:31 PM#1
Linera
I'm working on something and need to know about player numbers.

In this code, where Player(p) or Player(a) is used, would that be 0 = player 1?

Collapse JASS:
function Combat takes integer p, integer a, unit attacking, unit attacked returns nothing
   if GetPlayerController(Player(p)) == MAP_CONTROL_USER then
      set udg_InCombat[p] = true
      call ForGroupBJ( GetUnitsOfPlayerAndTypeId(Player(p), 'o001'), function Remove )
   endif
   if GetPlayerController(Player(a)) == MAP_CONTROL_USER then
      set udg_InCombat[a] = true
      call ForGroupBJ( GetUnitsOfPlayerAndTypeId(Player(a), 'o001'), function Remove )
   endif
endfunction
03-24-2006, 08:42 PM#2
emjlr3
they start at 0, if that is what you want to know
03-24-2006, 08:51 PM#3
Linera
Now this would return 1 if it was player 1 right?

Collapse JASS:
GetConvertedPlayerId(GetTriggerPlayer())
03-24-2006, 09:03 PM#4
Thunder_Eye
no it would return 0
03-24-2006, 09:12 PM#5
Blade.dk
No.

If you use GetConvertedPlayerId it returns GetPlayerId()+1, so yes it would return 1.

But better use GetPlayerId, and it will return 0.
03-24-2006, 09:16 PM#6
Thunder_Eye
Oh ok ;P
03-24-2006, 09:42 PM#7
Linera
Thanks
03-24-2006, 09:47 PM#8
Linera
Will this work right?
When I call the combat function I'll be calling the player number like for example player 1 = 1
Collapse JASS:
function Remove takes nothing returns nothing
    call RemoveUnit( GetEnumUnit() )
endfunction

function Combat takes integer p, integer a, unit attacking, unit attacked returns nothing
   if GetPlayerController(Player(p)) == MAP_CONTROL_USER then
      set udg_InCombat[p] = true
      call StartTimerBJ( udg_CombatCheckTimer[p], false, 10.00 )
      call ForGroupBJ( GetUnitsOfPlayerAndTypeId(Player(p-1), 'o001'), function Remove )
   endif
   if GetPlayerController(Player(a)) == MAP_CONTROL_USER then
      set udg_InCombat[a] = true
      call StartTimerBJ( udg_CombatCheckTimer[a], false, 10.00 )
      call ForGroupBJ( GetUnitsOfPlayerAndTypeId(Player(a-1), 'o001'), function Remove )
   endif
//Begin Combat

endfunction
03-24-2006, 10:09 PM#9
Anitarf
No, if you use the Player() function, then 0 = Player 1. We already went over this.
03-24-2006, 10:10 PM#10
Linera
This is what will call the function Combat:

Collapse JASS:
call Combat(GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit())), GetConvertedPlayerId(GetOwningPlayer(GetSpellTargetUnit())), GetSpellAbilityUnit(), GetSpellTargetUnit())
03-24-2006, 10:49 PM#11
Anitarf
Whatever, you use the function Player() inside the function Combat().

You have the functions Player(), GetPlayerId() and ConvertedPlayer(), GetConvertedPlayerId(). Use one pair or the other, don't mix them up.

And why use integers anyway, just change the Combat function to take the player as an argument, rather than his ID. Better yet, since you pass the units to the function as well, why pass the players at all, you define them as the owners of the two units, might as well define them this way in the Combat() function.