• 🏆 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!

Detect Host System

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
This system can use as make dialog to the "Host" .I cant find out any uses of this system already.
Here is the trigger.
[trigger=Detect Host System]Events
Player - Player 1 (Red) types a chat message containing -Host as An exact match
Player - Player 2 (Blue) types a chat message containing -Host as An exact match
Player - Player 3 (Teal) types a chat message containing -Host as An exact match
Player - Player 4 (Purple) types a chat message containing -Host as An exact match
Player - Player 5 (Yellow) types a chat message containing -Host as An exact match
Player - Player 6 (Orange) types a chat message containing -Host as An exact match
Player - Player 7 (Green) types a chat message containing -Host as An exact match
Player - Player 8 (Pink) types a chat message containing -Host as An exact match
Player - Player 9 (Gray) types a chat message containing -Host as An exact match
Player - Player 10 (Light Blue) types a chat message containing -Host as An exact match
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 1 (Red) slot status) Not equal to Is playing
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 2 (Blue) slot status) Not equal to Is playing
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 3 (Teal) slot status) Not equal to Is playing
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 4 (Purple) slot status) Not equal to Is playing
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 5 (Yellow) slot status) Not equal to Is playing
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 6 (Orange) slot status) Not equal to Is playing
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 7 (Green) slot status) Not equal to Is playing
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 8 (Pink) slot status) Not equal to Is playing
Then - Actions
Set Host = Player 9 (Gray)
Else - Actions
Set Host = Player 8 (Pink)
Else - Actions
Set Host = Player 7 (Green)
Else - Actions
Set Host = Player 6 (Orange)
Else - Actions
Set Host = Player 5 (Yellow)
Else - Actions
Set Host = Player 4 (Purple)
Else - Actions
Set Host = Player 3 (Teal)
Else - Actions
Set Host = Player 2 (Blue)
Else - Actions
Set Host = Player 1 (Red)
Game - Display to (All players) the text: Detecting.
Wait 0.50 seconds
Cinematic - Clear the screen of text messages for (All players)
Game - Display to (All players) the text: Detecting..
Wait 0.50 seconds
Cinematic - Clear the screen of text messages for (All players)
Game - Display to (All players) the text: Detecting...
Wait 0.50 seconds
Cinematic - Clear the screen of text messages for (All players)
Game - Display to (All players) the text: Detecting.
Wait 0.50 seconds
Cinematic - Clear the screen of text messages for (All players)
Game - Display to (All players) the text: Detecting..
Wait 0.50 seconds
Cinematic - Clear the screen of text messages for (All players)
Game - Display to (All players) the text: Detecting...
Wait 1.00 seconds
Cinematic - Clear the screen of text messages for (All players)
Game - Display to (All players) the text: (Host Detected : + (Name of Host))

[/trigger]

[jass=Jass]function Trig_Detect_Host_Func001Func001Func001Func001Func001Func001Func001Func001C takes nothing returns boolean
if ( not ( GetPlayerSlotState(Player(7)) != PLAYER_SLOT_STATE_PLAYING ) ) then
return false
endif
return true
endfunction

function Trig_Detect_Host_Func001Func001Func001Func001Func001Func001Func001C takes nothing returns boolean
if ( not ( GetPlayerSlotState(Player(6)) != PLAYER_SLOT_STATE_PLAYING ) ) then
return false
endif
return true
endfunction

function Trig_Detect_Host_Func001Func001Func001Func001Func001Func001C takes nothing returns boolean
if ( not ( GetPlayerSlotState(Player(5)) != PLAYER_SLOT_STATE_PLAYING ) ) then
return false
endif
return true
endfunction

function Trig_Detect_Host_Func001Func001Func001Func001Func001C takes nothing returns boolean
if ( not ( GetPlayerSlotState(Player(4)) != PLAYER_SLOT_STATE_PLAYING ) ) then
return false
endif
return true
endfunction

function Trig_Detect_Host_Func001Func001Func001Func001C takes nothing returns boolean
if ( not ( GetPlayerSlotState(Player(3)) != PLAYER_SLOT_STATE_PLAYING ) ) then
return false
endif
return true
endfunction

function Trig_Detect_Host_Func001Func001Func001C takes nothing returns boolean
if ( not ( GetPlayerSlotState(Player(2)) != PLAYER_SLOT_STATE_PLAYING ) ) then
return false
endif
return true
endfunction

function Trig_Detect_Host_Func001Func001C takes nothing returns boolean
if ( not ( GetPlayerSlotState(Player(1)) != PLAYER_SLOT_STATE_PLAYING ) ) then
return false
endif
return true
endfunction

function Trig_Detect_Host_Func001C takes nothing returns boolean
if ( not ( GetPlayerSlotState(Player(0)) != PLAYER_SLOT_STATE_PLAYING ) ) then
return false
endif
return true
endfunction

function Trig_Detect_Host_Actions takes nothing returns nothing
if ( Trig_Detect_Host_Func001C() ) then
if ( Trig_Detect_Host_Func001Func001C() ) then
if ( Trig_Detect_Host_Func001Func001Func001C() ) then
if ( Trig_Detect_Host_Func001Func001Func001Func001C() ) then
if ( Trig_Detect_Host_Func001Func001Func001Func001Func001C() ) then
if ( Trig_Detect_Host_Func001Func001Func001Func001Func001Func001C() ) then
if ( Trig_Detect_Host_Func001Func001Func001Func001Func001Func001Func001C() ) then
if ( Trig_Detect_Host_Func001Func001Func001Func001Func001Func001Func001Func001C() ) then
set udg_Host = Player(8)
else
set udg_Host = Player(7)
endif
else
set udg_Host = Player(6)
endif
else
set udg_Host = Player(5)
endif
else
set udg_Host = Player(4)
endif
else
set udg_Host = Player(3)
endif
else
set udg_Host = Player(2)
endif
else
set udg_Host = Player(1)
endif
else
set udg_Host = Player(0)
endif
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_003" )
call TriggerSleepAction( 0.50 )
call ClearTextMessagesBJ( GetPlayersAll() )
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_004" )
call TriggerSleepAction( 0.50 )
call ClearTextMessagesBJ( GetPlayersAll() )
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_005" )
call TriggerSleepAction( 0.50 )
call ClearTextMessagesBJ( GetPlayersAll() )
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_007" )
call TriggerSleepAction( 0.50 )
call ClearTextMessagesBJ( GetPlayersAll() )
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_008" )
call TriggerSleepAction( 0.50 )
call ClearTextMessagesBJ( GetPlayersAll() )
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_009" )
call TriggerSleepAction( 1.00 )
call ClearTextMessagesBJ( GetPlayersAll() )
call DisplayTextToForce( GetPlayersAll(), ( "Host Detected : " + GetPlayerName(udg_Host) ) )
endfunction

//===========================================================================
function InitTrig_Detect_Host takes nothing returns nothing
set gg_trg_Detect_Host = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(0), "-Host", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(1), "-Host", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(2), "-Host", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(3), "-Host", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(4), "-Host", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(5), "-Host", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(6), "-Host", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(7), "-Host", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(8), "-Host", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Detect_Host, Player(9), "-Host", true )
call TriggerAddAction( gg_trg_Detect_Host, function Trig_Detect_Host_Actions )
endfunction

[/code]
Pls give credit to me if u r using my system :) (Credit for :Garylau / 0oRendyo0)

Keywords:
Detect
Contents

Just another Warcraft III map (Map)

Reviews
08:42, 8th Jul 2014 BPower: Rejected.
Level 21
Joined
Mar 27, 2012
Messages
3,232
Well, the JASS code is this:
JASS:
call FlushGameCache(InitGameCache("gamehost.w3v"))
set udg_gamehost = InitGameCache("gamehost.w3v")
call StoreInteger ( udg_gamehost, "host", "host", GetPlayerId ( GetLocalPlayer () ) )
call TriggerSyncStart ()
call SyncStoredInteger ( udg_gamehost, "host", "host" )
call TriggerSyncReady ()
set udg_Host = GetStoredInteger ( udg_gamehost, "host", "host" )
call FlushStoredMission(udg_gamehost,"host")

I don't think it can be done in GUI though, due to the lack of sync natives.
 

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,864
No, you don't get it. Suppose that a player named "jean" hosts a game with a bot named "anybot", the player joins the game, some other players join too, and he starts the game. Obviously the bot isn't a player, just a means to host a game, so when you use this method to detect the host ANY player ("jean" or any other players) will be host (the player who is more synchronized).
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
My point still stands though. Bots still have one player that they consider the owner. Yes, using a bot means that detecting host should be done in some other way, but there are ways that bots can transfer information to the game.
 

EdgeOfChaos

E

EdgeOfChaos

Don't convert GUI to JASS, just leave it.

Btw, a Player Group loop can eliminate the need for any If statement.

Why do you need the "Detecting" cinematic? It just wastes time.
-----

Here's how to improve it (something like this).
  • AddEvents
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Trigger - Add to DetectHost <gen> the event (Player - (Picked player) types a chat message containing -host as An exact match)
  • DetectHost
    • Events
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing))) and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Host detected: + (Name of (Picked player)))
          • Skip remaining actions
Takes way fewer lines, same functionality.

(Also remove player group leaks)
 
Last edited by a moderator:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Facts:
#1 this is bad.
I.e this does not detect host no matter if it's hosted via bot or not.

#2 Xonok is right about his example, and his solution is closest to approach we actually would want to use.

#3Wrda is right. There is no convenient way of detecting bot-host I can think of.

Considering facts: if we have to decide between cake and empty plate I'd go for cake, even if its pie that I'd like to eat.
Cake - sync solution.
 

EdgeOfChaos

E

EdgeOfChaos

Yeah, I think it leaks, I just wrote it in 1 min as a demo of what can remove every If statement.

Not on a computer with WE right now, but:
Set TempForce = All Players Matching Condition...
For (TempForce)
...
DestroyForce(udg_TempForce)
 
Top