HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Creating an additional PlayerForce?

07-01-2006, 03:59 PM#1
Sharingan
Now, there are 12 Players Slots, and what do I have to do if I want all the slots to be filled with Players, and still be able to create creeps belonging to the specific ally force? (Sharing Vision etc....)
Until now, the only Game I saw this implemented was Age of Myths by vile.
vile, if you see this, would you tell me how you did that?
07-01-2006, 04:16 PM#2
Rising_Dusk
*It was also seen in ToB :P*

You'll want to use the Neutral Victim and Enemy players (Player13 and Player14) for the creeps.
There again, this only works if you only need two computers.

You'll want to loop through all players of a force and set them allied or enemies of their corresponding computer.
Say Player(13) is going to be the creeps for team 1, you need to ally and set the player alliance flags for shared vision, allied, allied victory all on from those players to the computer and vice versa.

This is the code taken straight from the new AotZ that does the main setup.
Collapse JASS:
    loop
        exitwhen index > 5
        if GetPlayerSlotState(Player(index)) == PLAYER_SLOT_STATE_PLAYING then
            call ForceAddPlayer(udg_HallowedOrder, Player(index))
        endif
        call SetPlayersAsEnemies(index, 12)
        call SetPlayersAsAllies(index, 13)
        call SetPlayersAsEnemies(index, 14)
        set index = index + 1
    endloop
    set index = 6
    loop
        exitwhen index > 11
        if GetPlayerSlotState(Player(index)) == PLAYER_SLOT_STATE_PLAYING then
            call ForceAddPlayer(udg_BaneOfEternity, Player(index))
        endif
        call SetPlayersAsEnemies(index, 12)
        call SetPlayersAsAllies(index, 14)
        call SetPlayersAsEnemies(index, 13)
        set index = index + 1
    endloop
    //****************************************************
    //*The Creep Players Setup
    call SetPlayersAsEnemies(12, 13)
    call SetPlayersAsEnemies(12, 14)
    call SetPlayersAsEnemies(13, 14)
    call EnableOcclusion(true)
    call SetPlayerName(Player(12), "N/A")
    call SetPlayerName(Player(13), "|cff2f4f4fHallowed Order|r")
    call SetPlayerColor(Player(13), PLAYER_COLOR_AQUA)
    call SetPlayerColor(Player(14), PLAYER_COLOR_BROWN)
    call SetPlayerRacePreference(Player(13), RACE_PREF_HUMAN)
    call SetPlayerController(Player(13), MAP_CONTROL_COMPUTER)
    call SetPlayerTeam(Player(13), 0)
    call ForceAddPlayer(udg_HallowedOrder, Player(13))
    call SetPlayerState(Player(13), PLAYER_STATE_ALLIED_VICTORY, 1)
    call SetPlayerName(Player(14), "|cff8b4513Bane of Eternity|r")
    call SetPlayerRacePreference(Player(14), RACE_PREF_UNDEAD)
    call SetPlayerController(Player(14), MAP_CONTROL_COMPUTER)
    call SetPlayerTeam(Player(14), 1)
    call ForceAddPlayer(udg_BaneOfEternity, Player(14))
    call SetPlayerState(Player(14), PLAYER_STATE_ALLIED_VICTORY, 1)

SetPlayersAsEnemies and SetPlayersAsAllies are also functions I added to the custom script section of the map.
They appear like this.

Collapse JASS:
//***************************************************************************************************************
//*Sets two players as enemies based on their integer indicies.
//*
function SetPlayersAsEnemies takes integer p1, integer p2 returns nothing
    local integer i
    set i = 0
    loop
        exitwhen i > 7
        call SetPlayerAlliance(Player(p1), Player(p2), ConvertAllianceType(i), false)
        set i=i+1
    endloop
    set i = 0
    loop
        exitwhen i > 7
        call SetPlayerAlliance(Player(p2), Player(p1), ConvertAllianceType(i), false)
        set i=i+1
    endloop
endfunction

//***************************************************************************************************************
//*Sets two players as allies in all regards based on their integer indicies.
//*
function SetPlayersAsAllies takes integer p1, integer p2 returns nothing
    call SetPlayerAlliance(Player(p1), Player(p2), ConvertAllianceType(0), true)
    call SetPlayerAlliance(Player(p1), Player(p2), ConvertAllianceType(1), true)
    call SetPlayerAlliance(Player(p1), Player(p2), ConvertAllianceType(2), true)
    call SetPlayerAlliance(Player(p1), Player(p2), ConvertAllianceType(3), true) 
    call SetPlayerAlliance(Player(p1), Player(p2), ConvertAllianceType(4), true)
    call SetPlayerAlliance(Player(p1), Player(p2), ConvertAllianceType(5), true)
    call SetPlayerAlliance(Player(p1), Player(p2), ConvertAllianceType(6), false)
    call SetPlayerAlliance(Player(p1), Player(p2), ConvertAllianceType(7), false)
    call SetPlayerAlliance(Player(p2), Player(p1), ConvertAllianceType(0), true)
    call SetPlayerAlliance(Player(p2), Player(p1), ConvertAllianceType(1), true)
    call SetPlayerAlliance(Player(p2), Player(p1), ConvertAllianceType(2), true)
    call SetPlayerAlliance(Player(p2), Player(p1), ConvertAllianceType(3), true) 
    call SetPlayerAlliance(Player(p2), Player(p1), ConvertAllianceType(4), true)
    call SetPlayerAlliance(Player(p2), Player(p1), ConvertAllianceType(5), true)
    call SetPlayerAlliance(Player(p2), Player(p1), ConvertAllianceType(6), false)
    call SetPlayerAlliance(Player(p2), Player(p1), ConvertAllianceType(7), false)
endfunction

Hope this has helped any. :P
07-01-2006, 06:10 PM#3
Sharingan
Hmm, would
Collapse JASS:
call ForceEnumEnemies(force whichForce, player whichPlayer, boolexpr filter)
also work?
Also, who is Player12?(Hostile?)
Is Player13 Victim, 14, Extra and 15 Passive?
If Player12 is Neutral Hostile, why would you set them as enemies?I think hostile Neutrals are enemies to begin with ...
Collapse JASS:
call SetPlayersAsEnemies(12, 13)
    call SetPlayersAsEnemies(12, 14)
And...uh
Collapse JASS:
set index = 6
This one is not neccessary btw :>
07-01-2006, 06:16 PM#4
Rising_Dusk
Of course it would work.
You can do any derivation of what I posted.
Also, if you ForceEnumEnemies()'d after the stuff was set, you would get the neutral player on that team too.

My way is only one method to the end.
The point being, you need to set enemies and allies accordingly.
07-01-2006, 06:42 PM#5
Sharingan
Oh!
And uh..what about my other questions?._.
Hmm, oups, I seem to have edited too late ...
07-01-2006, 07:01 PM#6
Rising_Dusk
Collapse JASS:
set index = 6
May not be necessary, but I like to just be certain on some things.
It wont ruin the map resetting a variable to a number. :P

I set Neutral Hostile to enemies with Victim and Enemy as a buffer.
It's like insurance, because Hostile has weird AI associated with it, may as well be certain about it.

And yes --
Player(12) == Hostile
Player(13) == Victim
Player(14) == Extra
Player(15) == Passive
07-02-2006, 11:23 AM#7
Sharingan
...
Now I lost the mind....
What exactly is a force?
Why would you need to create a global force variable for this if there already is a force setting in the editor?
And, the BJ function GetPlayersAllies also baffles me:
Collapse JASS:
function GetPlayersAllies takes player whichPlayer returns force
    local force f = CreateForce()
    call ForceEnumAllies(f, whichPlayer, null)
    return f
endfunction
...Did I missunderstand the function forceenumallies?
What exactly does it do?
07-02-2006, 11:26 AM#8
The)TideHunter(
Collapse JASS:
function GetPlayersAllies takes player whichPlayer returns force
    local force f = CreateForce()
    call ForceEnumAllies(f, whichPlayer, null)
    return f
endfunction

A force is player group, a team or whatever you want to call it

Firstly, the function is creating a brand new force, then its Enum'ing the force to get allies of whichPlayer (enum means like a filter, imagine everything the criteria says passes through the filter, and what dosent stays out of the force). Then it returns the force.
GetPlayersAllies leaks a force if you dont destroy f
07-02-2006, 08:29 PM#9
Rising_Dusk
I made a global for my forces so they'd be easier to manipulate.
Makes it easier to count and so on and so forth without Enuming the allies of the player everytime.

GetPlayersAllies() sucks.
Just make a local force and ForceEnumAllied(...) on your own, faster and less leaky.

And yeah, forces are player groups basically.
It's like a unit group for players. They're handy.