• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] How to detect when a player checks allied victory?

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2010
Messages
950
I want to make a custom melee type map but with triggers that control victory and not the melee victory conditions. One issue i have is the event of a player checking the allied victory button without changing anything else in F11. Its a game where players can change from enemies to allies and reverse.

Once that event is detected i would check if there is any enemies of that player or if any player has an enemy left and if not are all remaining players allies and all have the allied victory check box checked? then do action etc
 
You can use this native to grant a trigger the capability to detect such stuff:

JASS:
native TriggerRegisterPlayerAllianceChange(trigger trig, player p, alliancetype a)

The alliance types are as follows:

JASS:
ALLIANCE_HELP_REQUEST
ALLIANCE_HELP_RESPONSE
ALLIANCE_PASSIVE
ALLIANCE_RESCUABLE
ALLIANCE_SHARED_ADVANCED_CONTROL
ALLIANCE_SHARED_CONTROL
ALLIANCE_SHARED_SPELLS
ALLIANCE_SHARED_VISION
ALLIANCE_SHARED_VISION_FORCED
ALLIANCE_SHARED_XP
 
Last edited:
Can you give me an example in gui please :)
Its been quite a few years since i map edited at all, too rusty to mess with vjass for this kind of map. thanks!
Luckily that is JASS however here. [trigger=]
Actions
Trigger - Add to (This trigger) the event (Player - Player 1 (Red) changes alliance settings)
[/trigger]
 
Level 13
Joined
May 10, 2009
Messages
868
Unfortunately, allied victory is not really part of alliance data type, but rather a player state. It's also hidden from GUI events.


ConvertPlayerState(8)
JASS:
    constant playerstate PLAYER_STATE_GAME_RESULT               = ConvertPlayerState(0)

    // current resource levels
    //
    constant playerstate PLAYER_STATE_RESOURCE_GOLD             = ConvertPlayerState(1)
    constant playerstate PLAYER_STATE_RESOURCE_LUMBER           = ConvertPlayerState(2)
    constant playerstate PLAYER_STATE_RESOURCE_HERO_TOKENS      = ConvertPlayerState(3)
    constant playerstate PLAYER_STATE_RESOURCE_FOOD_CAP         = ConvertPlayerState(4)
    constant playerstate PLAYER_STATE_RESOURCE_FOOD_USED        = ConvertPlayerState(5)
    constant playerstate PLAYER_STATE_FOOD_CAP_CEILING          = ConvertPlayerState(6)

    constant playerstate PLAYER_STATE_GIVES_BOUNTY              = ConvertPlayerState(7)
    constant playerstate PLAYER_STATE_ALLIED_VICTORY            = ConvertPlayerState(8)
    constant playerstate PLAYER_STATE_PLACED                    = ConvertPlayerState(9)
    constant playerstate PLAYER_STATE_OBSERVER_ON_DEATH         = ConvertPlayerState(10)
    constant playerstate PLAYER_STATE_OBSERVER                  = ConvertPlayerState(11)
    constant playerstate PLAYER_STATE_UNFOLLOWABLE              = ConvertPlayerState(12)

    // taxation rate for each resource
    //
    constant playerstate PLAYER_STATE_GOLD_UPKEEP_RATE          = ConvertPlayerState(13)
    constant playerstate PLAYER_STATE_LUMBER_UPKEEP_RATE        = ConvertPlayerState(14)

    // cumulative resources collected by the player during the mission
    //
    constant playerstate PLAYER_STATE_GOLD_GATHERED             = ConvertPlayerState(15)
    constant playerstate PLAYER_STATE_LUMBER_GATHERED           = ConvertPlayerState(16)

upload_2018-4-29_4-11-9.png

Fortunately, you can simply use a custom script in order to add that event to your triggers.
JASS:
call TriggerRegisterPlayerStateEvent(whichTrigger, whichPlayer, PLAYER_STATE_ALLIED_VICTORY, NOT_EQUAL, -1) // It detects when the state is set to on or off

JASS:
function AlliedVictoryChanges takes nothing returns boolean
    if GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_ALLIED_VICTORY) == 0 then
        // OFF
    else
        // ON
    endif
    return false
endfunction

//===========================================================================
function InitTrig_AlliedVictory_State takes nothing returns nothing
    local integer i = 0
 
    set gg_trg_AlliedVictory_State = CreateTrigger()
    call TriggerAddCondition(gg_trg_AlliedVictory_State, Condition(function AlliedVictoryChanges))
    loop
        exitwhen i == bj_MAX_PLAYERS
        call TriggerRegisterPlayerStateEvent(gg_trg_AlliedVictory_State, Player(i), PLAYER_STATE_ALLIED_VICTORY, NOT_EQUAL, -1)
        set i = i + 1
    endloop
endfunction

The good thing about player group (all players) is that it only enumerates player slots that aren't empty.
  • Initialize GUI Example
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: call TriggerRegisterPlayerStateEvent(gg_trg_GUI_Example, GetEnumPlayer(), PLAYER_STATE_ALLIED_VICTORY, NOT_EQUAL, -1)
  • GUI Example
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Allied victory is on for (Triggering player)) Equal to True
        • Then - Actions
          • -------- ON --------
        • Else - Actions
          • -------- OFF --------
 

Attachments

  • Allied Victory.w3x
    16.7 KB · Views: 29
Last edited:
Status
Not open for further replies.
Top