HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Gametype selection.

05-08-2006, 08:44 PM#1
HalfSlothNCamel
I am in the process of making a hero based map and have plenty of gametypes I want available to the players. However I am presented with a dilemma. I want these gametypes to be selected through dialog boxes at the beginning of the game instead of the way DoTA handles it (typing in -ar, -ap, -sm, -dm, etc.).

However I want the game creator to have control of what gametypes are chosen, but this means that the game creator has to be in a certain player spot to have that control. This sucks for that player, especially if they want a different color or even to go to the other team.

Now a solution I thought of is having a voting dialogue box, but then the control is taken from the game host....

Any ideas to solve this problem?
05-08-2006, 08:47 PM#2
Tim.
GetHost()

Check it out at www.wc3jass.com
05-08-2006, 09:21 PM#3
Captain Griffen
Alternatively you can use the options like 'Random Heroes' that do nothing in random melee, and the host can select before creating the game.
05-08-2006, 11:53 PM#4
HalfSlothNCamel
Oh no.....the dreaded JASS. I have no idea what to do with it. Where to even put it, or if I use that GetHost() code how to implement that into my dialog boxes....
05-09-2006, 02:05 AM#5
TaintedReality
Heh. GetHost() just returns the host player. So, make a player variable using the variable editor. Name the variable host. Then, use a custom script action inside a trigger that runs at map init that is:
Collapse JASS:
Custom Script: set udg_host = GetHost()
Now whenever you need the host player, use that player variable named host.

Edit: Forgot something. You need to copy that GetHost() function into your Map Script area. That's the area in the Trigger Editor that shows your map name.w3x, at the very top of the trigger selection tree. If you already have stuff in there, just attach this onto the bottom.
05-09-2006, 03:04 AM#6
HalfSlothNCamel
I copied that script into my map script area and now I have an error coming up with almost all of my previous scripts when I try to save. Why is this?
05-09-2006, 03:33 AM#7
Vuen
This would be easier if you actually told us the error you're getting.

You're probably missing a GameCache() function. Here:

Collapse JASS:
function GameCache takes nothing returns gamecache
    if GetLastCreatedGameCacheBJ() == null then
        call InitGameCacheBJ( "junk.w3v" )
    endif
    return GetLastCreatedGameCacheBJ()
endfunction

//This function takes nothing and returns the host of the game.
function GetHost takes nothing returns player
    //This stores the Id + 1 for each player.
    call StoreInteger(GameCache(), "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1)
    //Setup the TriggerSyncReady call.
    call TriggerSyncStart()
    //Sync the value of the entry for each player.
    //Each value will sync to the value of the host.
    call SyncStoredInteger(GameCache(), "missionKey", "key")
    //Wait until the Game Cache syncs the key for everyone.
    call TriggerSyncReady()
    //Return the synced value as a player.
    return Player(GetStoredInteger(GameCache(), "missionKey", "key") - 1)
endfunction

Then make a player variable called 'host', and use this in your map:

Trigger:
Actions
Custom Script: set udg_host = GetHost()
05-09-2006, 04:19 AM#8
HalfSlothNCamel
Ok the error I am getting is..."Expected a Variable Name".

I created the player variable Host.

When I get the error it highlights this part in the dialog box with the error:
Trigger: GetHost
//===========================================================================
function Trig_GetHost_Actions takes nothing returns nothing
set udg_host = GetHost()
endfunction

This seems to be the only error right now.

Sorry if I seem to be dumb, but JASS is really over my head.
05-09-2006, 05:31 AM#9
Blade.dk
Even though WE claims that the error is there, it might be that it actually is in a whole other place. So if you have the variable, then I guess the error is in the GetHost function not modified like Vuen said.
05-09-2006, 05:52 AM#10
Tim.
Please use [jass] tags around JASS code so it is easier to read.

Alright follow these steps:

1 Find the GetHost section of your Map Script.
2 Scroll just above it.
3 Paste this above the current GetHost function.
Collapse JASS:
function GameCache takes nothing returns gamecache
    if GetLastCreatedGameCacheBJ() == null then
        call InitGameCacheBJ( "GameCacheTest.w3v" )
    endif
    return GetLastCreatedGameCacheBJ()
endfunction
4 Try to test now.

If it gives you an error tell us the line the first error is on, and one line above as well as below that line.
05-09-2006, 06:19 AM#11
Anitarf
Also note that JASS is case sensitive, make sure you capitalize the name of the Host variable the same in all places.
05-09-2006, 07:19 AM#12
Vuen
Also, make sure you call the variable 'host', not 'udg_host'. The World Editor adds the udg_ part to your variable, and hides it from you in the GUI, which is why you need to use udg_ when you use Custom Script.
05-09-2006, 01:31 PM#13
HalfSlothNCamel
Ok here is my whole map script.

Collapse JASS:
function GameCache takes nothing returns gamecache
    if GetLastCreatedGameCacheBJ() == null then
        call InitGameCacheBJ( "GameCacheTest.w3v" )
    endif
    return GetLastCreatedGameCacheBJ()
endfunction

//This function takes nothing and returns the host of the game.
function GetHost takes nothing returns player
    //This stores the Id + 1 for each player.
    call StoreInteger(GameCache(), "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1)
    //Setup the TriggerSyncReady call.
    call TriggerSyncStart()
    //Sync the value of the entry for each player.
    //Each value will sync to the value of the host.
    call SyncStoredInteger(GameCache(), "missionKey", "key")
    //Wait until the Game Cache syncs the key for everyone.
    call TriggerSyncReady()
    //Return the synced value as a player.
    return Player(GetStoredInteger(GameCache(), "missionKey", "key") - 1)
endfunction

The Error is still expected a Variable name.

//===========================================================================
// Trigger: Untitled Trigger 001
//===========================================================================
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
set udg_host = GetHost()
endfunction

So it looks like the trigger I have made that runs the custom script is the problem. For it made a trigger in my Initialization category with just the action posted above
Trigger:
custom script = set udg_host = GetHost()

Also I have a player variable Host, that is initially empty.
If needs be I can upload my map and y'all can check out the triggers and find out exactly whats wrong.
05-09-2006, 01:46 PM#14
blu_da_noob
Capitilisation matters. If your global player variable is called Host, then you need to use udg_Host in the custom script.
05-09-2006, 03:41 PM#15
Tim.
Yep, must be your capitalization.

Make sure Host is a player-type variable, too.