Wc3C.net (http://www.wc3c.net/forums.php)
-   Samples (http://www.wc3c.net/forumdisplay.php?f=649)
-   -   Hero Selection System 1.10 (http://www.wc3c.net/showthread.php?t=100042)

emjlr3 04-19-2008 05:40 PM

Hero Selection System 1.30
2 Attachment(s)
Hero Selection System 1.30

A dynamic, completely customizable Hero Selection System!

Had originally been using Vex's system for a map I have been playing around with, and finally got fed up with players not being able to view the same hero simultaneously. So, with a little inspiration and minor coding help from Vexs system, and after some discussion with Fulla, this system was born.

Credits to Vexorian for his original system and the GetPlayerNameColored function, and to Fulla for our hero selection discussions. Credits also to Acehart for the original demo map he made, of which its terrain I used as a template for this map.

Read Me - Basic:
Hidden information:
Hero Selection System 1.30 - By: emjlr3

The basic steps to setup the system in your map
*Copy the Select Hero and Random Hero units to your map
*Copy the HSS and GetPlayerNameColored(if not already there) triggers to your map
*Configure he options you can(everything but Choose/RandomHeroOrder)
*Save, if that works, then everything is good, if not, start over and try again from the beginning

*Type -HSSGetOrders while in single player to determine the order ids for selling your selection units
This will create a hero at Player 1s start location. You can select choose hero or random hero on this hero, and it will display the correct order id for that selection. Write these two order ids down, and move to the next step
*Configure the order id options in HSS (ChooseHeroOrder and RandomHeroOrder)
*Add heroes to your map, owned by neutral passive, set their level and abilities learned to whatever you want, add a rect around your hero gallery
*Copy HSSSetup to yor map
*Look through HSSSetup, this is the trigger that will start and setup the system for you. You can have this run after X seconds, as I do, You can execute the trigger later, among many other things. Read through this and configure it to match your maps needs
*Save, if that works, yo are good to go, if not, look through HSSSetup again and see where your syntax went wrong

Read Me - Advanced
Hidden information:
Hero Selection System 1.30 - By: emjlr3

The more advanced configuration required for the system to function, or to be further customized
*All system used global arrays are stored as the id of the player they are for, ex. HSS_HeroSelection = GetPlayerId(unit)
*As seen in HSSSetup in this map, you must store the Hero Selection Gallery Rect and Hero Creation Loc for every player in your map, else the system does not know where they are
HSS_HeroSelection in a rect array used for the hero gallery
HSS_HeroCreation is a location array use for the creation of heroes
*The global trigger HSS_CreatedHeroTrigger will run once a hero is created, if set as a trigger. The created hero can be retrieved as "bj_lastCreatedUnit"
*The global unit array HSS_Heroes refers to heroes selected using the system
*The global group HSS_SelectableHeroes contains to all those heroes initialy selectable using the system
*Since players are given control of Player 15s units, the bong sound is played(unavoidable), and a message is displayed(also unavoidable)
However, in the gameplay constants you can edit this displayed message, as seen in this map
*Selecting the random hero flag before the map is loaded creates random heroes for all players
*You can edit the fields in HSSSetup to load the system when you want, or even completely scratch that trigger and do it yourself some place else, though this is not recommended

Systems Code:
Expand JASS:

Setup Code:
Expand JASS:

Version History:
  • 1.30 - Several new config. options
    Added a function to GetPlayerNameColored Library, to allow for colored hero names
    Minor coding updates/optimizations
    Errors messages now display in red
    Now reports an error if your max computer hero selection time is greater then your total selection time
    Improved the way hero selection messages were displayed
    Minor test map updates
  • 1.20 - Setup and readme completely redone
    HSS is now a library that contains the GetSelectionOrders system
    HSSSetup now sets up the systems variables and starts the HSS
    A few minor coding enhancements per Vexorians advice
    New option for max computer hero selection time
  • 1.10 - Users no longer need to manually input the number of players
    Added error messages in case the map runs out of heroes
    Slight updates/additions to readme
    Slight code updates and optimizations
    A few minor bug fixes(nothing related to system functionality)
  • 1.00 - Initial Release

Please report any and all bugs, and please leave comments and thoughts. Thanks and enjoy!!

Vexorian 04-19-2008 09:40 PM

It's a scope with no initializer?

How are people supposed to use it?

Edit: I see, that's lame.

This is a vJass map so I demand vJass to be exploited.

1. Use this, instead of your custom script section, have it in some trigger.

Collapse JASS:
library GetPlayerNameColored

function GetPlayerNameColored takes player id returns string
 local playercolor col=GetPlayerColor(id)
 local string r=GetPlayerName(id)
    if col == PLAYER_COLOR_RED then
        set r="|cffff0000"+r+"|r"
    elseif col == PLAYER_COLOR_BLUE then
        set r="|cff0000ff"+r+"|r"
    elseif col == PLAYER_COLOR_CYAN then
        set r="|cff93ffc9"+r+"|r"
    elseif col == PLAYER_COLOR_PURPLE then
        set r="|cff400080"+r+"|r"
    elseif col == PLAYER_COLOR_YELLOW then
        set r="|cffffff00"+r+"|r"
    elseif col == PLAYER_COLOR_ORANGE then
        set r="|cffff8000"+r+"|r"
    elseif col == PLAYER_COLOR_GREEN then
        set r="|cff00c400"+r+"|r"
    elseif col == PLAYER_COLOR_PINK then
        set r="|cffff80c0"+r+"|r"
    elseif col == PLAYER_COLOR_LIGHT_GRAY then
        set r="|cff808080"+r+"|r"
    elseif col == PLAYER_COLOR_LIGHT_BLUE then
        set r="|cffc1c1ff"+r+"|r"
    elseif col == PLAYER_COLOR_AQUA then
        set r="|cff5e5e2f"+r+"|r"
    elseif col == PLAYER_COLOR_BROWN then
        set r="|cff004000"+r+"|r"
        set r="|cff000000"+r+"|r"
 return r


1. Make HSS a library that requires it and also a library called HSS_setup, also make start begin automatically (an initializer)

2. Is the trigger that begins with GetSelectionOrders_Effects part of your HSS? Then include that in the library or make a library required by it.

3. Regarding the contents of HSS_setup, it should replace this:

Collapse JASS:
    local integer i = 0
    // Loop through players in map, setting up their hero selection rects and hero creation locs
        exitwhen i > 3
        set HSS_HeroSelection[i] = gg_rct_HeroSelection
        set HSS_HeroCreation[i] = GetStartLocationLoc(GetPlayerStartLocation(Player(i)))
        set i = i + 1
    // Store the trigger to be ran when a hero is created
    set HSS_CreatedHeroTrigger = gg_trg_PostHeroCreation
With what? you may ask, I dunno, you can use a function that returns that stuff, you can also use an initializer, be creative there.

So, in other words your users will just need to modify the setup library and just include your HSS instead of messing with when and how to call ExecuteFunc("Start_HSS") , btw, I should advice against ever ExecuteFunc, if necessary use .execute() this time it was not necessary.

The reasoning is that jasshelper will some day integrate the map optimizer's capabilities but taking advantage of the higher level syntax, so if we just use alternatives to ExecuteFunc the optimization will be much better than with the optimizer, .execute() is faster anyways.

4. Oh yes, if you make a function public, make sure to document what it does.

I don't like this, don't worry, the reason I don't like it is that my old hero system code has a lot of messy stuff, and yours has inherited most of the bad things old hss had. Can you try fixing them? Will save me the time of having to update it, for example it is way too liberal about dynamic triggers.

emjlr3 04-20-2008 02:23 PM


if there is anything you don't agree with or still have problems accepting, let me know and I will happily explain the reasoning behind my madness

Rising_Dusk 04-20-2008 04:24 PM

Collapse JASS:
private function SinglePlayer takes nothing returns boolean
    return bj_isSinglePlayer
That's totally unnecessary, just stick that BJ in the system wherever it's needed.

Vexorian 04-20-2008 05:18 PM

Anyways, it needs big cleanup specially the part that's from my system, why did you base it from my system anyways? I think the final result is too different from mine so I doubt you really needed my code if it isn't for just making the system messier.

If you are blocking orders like I did in the old system using DisableTrigger, etc. Change it to a 0. seconds timeout timer to order stop ASAP.

Soki 04-20-2008 06:38 PM

As both are different approaches, your HSS should be updated anyway Vexorian. Especially fixing that damn bug that desyncs Mac users.

emjlr3 04-20-2008 06:54 PM

@Dusk - was going to do that, but ended up adding a condition function, dont remember why
*now i remember - did not feeling like having to declare all my locals, then check if single player, then set them all up, that was it

@Vex - I based it on yours because it worked like I wanted this one to, minus the multi-player-selecting 1 unit part
I dont really see how it is "messy", or needs all this "cleanup"
I do disable the trigger, if it is a huge performance gain by using a timer as opposed to disabling and enabling the trigger, I would change it, but as it is now, i cant really justify doing so

@Soki - this really is not much different then Vexs (the approach is exactly the same), other then the fact that I think its cleaner, more optimized, and allows multiple players to select and view the same hero (which is why the install/setup requires an extra step)
then down part is you do not get the selection arrow when viewing a hero, but then that is a product of the system

Rising_Dusk 04-20-2008 07:16 PM

This makes me want to package the system I've had in DoE and AotZ for years and release it, it's shorter, easier to read, and does all of the same stuff as this one. (Just without the config, hence the need to package)

Actually, looking at your code mine does some stuff yours does not. Hrm.

emjlr3 04-20-2008 07:25 PM

whats stopping you?

the fact there were no real good updated ones out is what made me make this for myself, and eventually release it

Rising_Dusk 04-20-2008 07:31 PM


Originally Posted by emjlr3
whats stopping you?

Well, you did all of this work, I'd feel bad just storming in and taking over. I never released it before because I wasn't sure that there was even a need for a new one, people seemed content with Vex's.

emjlr3 04-20-2008 08:12 PM


Originally Posted by Rising_Dusk
Well, you did all of this work, I'd feel bad just storming in and taking over. I never released it before because I wasn't sure that there was even a need for a new one, people seemed content with Vex's.

i needed to do the work anyhow, because Vexs was not quite what I wanted anymore, the work was already done, uploading it here and adding a readme was simply all the extra work needed

how you would render this obsolete i cannot guess, if i remember correctly, you dont even let players view skills. Other then perhaps flamboyant effects, which i dont remember in DoE or AotZ, im at a loss for all these featuers yours contains that I seem to have overlooked, and the fact that you may save a few line somewhere I don't see as being anything special

other then the fact that your name is Rising_Dusk, i can't say people would like it any better, but who am I too judge, I'm not the one with two succesful maps at WC3C ;)

Rising_Dusk 04-20-2008 08:15 PM


Originally Posted by emjlr3
how you would render this obsolete i cannot guess, if i remember correctly, you dont even let players view skills, other then perhps flamboyant effects, which i dont remember on DoE or AotZ, im at a loss for all these featuers yours contains that I seem to have overlooked

All of those options are just a boolean away, though. I removed them from DoE because of a problem with auras and stuff. Otherwise, it's mostly the same thing just written to be shorter and easier to understand.

emjlr3 04-20-2008 08:21 PM

o well, can't say I'd lament people deciding against the use of my system

all the usage I care about I'm getting, the rest is merely superfluous

obsolete away all mighty sun setting one :), just keep me updated, so I can avoid catering to Vexs needs :)

Malf 04-21-2008 11:30 AM

Dusk has his own selection system?? I thought you were using Vex's system, with little modifications by adding the stories :emote_wtf:

Belphegor666 04-21-2008 12:01 PM

Interesting. Does this system supports remaking maps? Also completely hiding units is way better than making them transparent. I sometimes try to click on the transparent unit (don't ask why).

All times are GMT. The time now is 08:54 PM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services