Shared Hero Icons

Cohadar

master of fugue
Reaction score
209
Have you ever wanted to see hero icons of your allied players?
(without being able to control them)

JASS:

scope ShowAllyIcons initializer Init 

//===========================================================================
// The trick is to give advanced control but not shared control
// That way you see allied hero icons, but cannot control them
//===========================================================================
private function SetAlliance takes player sourcePlayer, player otherPlayer returns nothing
    call SetPlayerAllianceStateAllyBJ(        sourcePlayer, otherPlayer, true  )
    call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_VISION, true)
    //call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_CONTROL, true)
    call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_ADVANCED_CONTROL, true)
endfunction

//===========================================================================
private function Conditions takes nothing returns boolean
    return true
endfunction

//===========================================================================
//  Sets same alliances between 7 starting players
//===========================================================================
private function Actions takes nothing returns nothing
    local integer i = 0
    local integer j
    loop
        exitwhen i>=6
        set j = i + 1
        loop
            exitwhen j>=7
            call SetAlliance(Player(i), Player(j))
            call SetAlliance(Player(j), Player(i))
            set j = j + 1
        endloop
        set i = i + 1
    endloop
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( trig, 0.00 )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope


Now I have a problem with this, it works but for up to 5 players in one team.
(One hero icon and 4 allied icons are always shown)
So it is great idea for 5vs5 AoS maps

But if you want to make 7 player map (7 samurai, 7 illidans ...)
It does not work because wc3 reserves 3 hero slots for player's heroes,
so only 4 can be used for allies.
(see the attached map)

Can anyone find a solution for this to work for 7 players?
 

Attachments

  • Allied Hero Icons.w3x
    10.5 KB · Views: 129

Tom Jones

N/A
Reaction score
437
JASS:
native SetReservedLocalHeroButtons takes integer reserved returns nothing

function ...
    call SetReservedLocalHeroButtons(1)
endfunction


screeniea.jpg
 

wraithseeker

Tired.
Reaction score
122
JASS:
scope ShowAllyIcons initializer Init 

//===========================================================================
// The trick is to give advanced control but not shared control
// That way you see allied hero icons, but cannot control them
//===========================================================================
private function SetAlliance takes player sourcePlayer, player otherPlayer returns nothing
    call SetPlayerAllianceStateAllyBJ(        sourcePlayer, otherPlayer, true  )
    call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_VISION, true)
    //call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_CONTROL, true)
    call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_ADVANCED_CONTROL, true)
endfunction

//===========================================================================
private function Conditions takes nothing returns boolean
    return true
endfunction

//===========================================================================
//  Sets same alliances between 7 starting players
//===========================================================================
private function Actions takes nothing returns nothing
    local integer i = 0
    local integer j
    local multiboard mb = CreateMultiboard()
    call MultiboardDisplay(mb,true)
    call MultiboardSuppressDisplay(true)
    call SetReservedLocalHeroButtons(1)
    loop
        exitwhen i>=6
        set j = i + 1
        loop
            exitwhen j>=11
            call SetAlliance(Player(i), Player(j))
            call SetAlliance(Player(j), Player(i))
            set j = j + 1
        endloop
        set i = i + 1
    endloop
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( trig, 0.00 )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope


Here's a better verison of this one, I claim no credit, just editing some parts.
 

emjlr3

Change can be a good thing
Reaction score
395
how do you supress the shared resources mutiboard?
 

UndeadDragon

Super Moderator
Reaction score
448
That's pretty awesome :thup:
 

Cohadar

master of fugue
Reaction score
209
Can someone make this into a proper resource?
Someone was sending me a pm asking for it because he/she could not find a link.

This is useful, no need for it to be lost in the crowd and reinvented over and over.
 

wraithseeker

Tired.
Reaction score
122
You should do it although I amended it. If I submitted this as a proper resource I'll be killed for stealing.

I would do it but I don't like getting flamed for stealing resources unless you permit it :D
 

Cohadar

master of fugue
Reaction score
209
@wraithseeker

This is not "mine", it has been around for some time and a lot of people contributed ideas.

So feel free to do it and add some credits if you feel necessary (no need as far as I am concerned)

Oh and make sure you put some nice structured comments.

PS: you will get rep for saving my time.
 

Cohadar

master of fugue
Reaction score
209
Just a thought:

This should not be a standalone system but a function
JASS:

function ShareAllyIcons takes force x returns nothing

That way it is more custom, for example if you have 2 teams you call:
JASS:

call ShareAllyIcons(GoodForce)
call ShareAllyIcons(EvilForce)


also you should add a constant:
JASS:

// distance between your hero icon and that of friendly heroes
private constant integer IconSpacing = 1

//.. implementation
call SetReservedLocalHeroButtons(IconSpacing+1)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top