wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Samples
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 08-24-2008, 12:05 PM   #1
Vestras
User


Project Member: LoC
 
Join Date: Dec 2007
Posts: 756

Submissions (4)

Vestras will become famous soon enough (40)Vestras will become famous soon enough (40)

Default Hero Selection System

Well, here is a HSS I made for my Single Player RPG.
It isn't very funny on the screenshot, so I recommend you to check it out :)

MUI: Should it? :P
vJASS: Couldn't live without..
JASS/GUI: I think it's GUI... :)
Systems used: None! (Only a texttag library, not anything fancy)

Code:
Collapse JASS:
library HSS requires TextTag

// Configurable globals
globals
    private constant real Interval        = 0.01
    // The timer interval.
    private constant real Turn            = 5
    // The real the current hero is turned every Interval seconds.
    private constant rect ChooseRect      = gg_rct_Hero_Selection
    // The region where the hero selection takes place.
    private constant rect CreateRect      = gg_rct_Hero_Selection
    // The region where the hero is created.
    private constant integer Rows         = 10
    // The number of rows in the multiboard.
    // I'm sorry, but you can't edit the columns. :(
    private constant real HeroWidth       = 16
    // The width of the hero name spot.
    private constant real DescWidth       = 60
    // The width of the hero description spot.
    private constant string Title         = "Hero Selection"
    // The title of the multiboard.
    constant real Height                  = 10
    // The height of floating text.
    constant integer PlayerID             = 0
    // The player you want this to work for. (Remember, in JASS the players are minus one, eg.: Player 0 == Player 1, Player 2 == Player 3 etc.)
    private constant string CreateFX      = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl"
    // The creation fx.
    private constant string Attach        = "origin"
    // Where CreateFX is attached to the unit.
endglobals

// Necessary globals
globals
     unit        current
     real           HSSX
     real           HSSY
     real          CHSSX
     real          CHSSY
     real         facing
     integer array    id
     string array   name
     string array   desc
     string array  fdesc
     integer        size
     integer          CS
     integer         max
     texttag        Text
     private trigger  T0
     private trigger  T1
     private trigger  T2
     private trigger  T3
     private trigger  T4
     
       // Multiboard stuff...
        private multiboard    Multiboard
        private multiboarditem  HeroText
        private multiboarditem  DescText
endglobals

private function TurnActs takes nothing returns nothing
    set facing=GetUnitFacing(current)+Turn
    call SetUnitFacing(current,facing)
    call PanCameraTo(HSSX,HSSY)
endfunction

private function Pick takes nothing returns nothing
    local integer id=GetUnitTypeId(current)
    local unit d
    call RemoveUnit(current)
        call PanCameraTo(CHSSX,CHSSY)
        set d=CreateUnit(Player(PlayerID),id,CHSSX,CHSSY,facing)
        call SelectUnit(d,true)
        call DestroyEffect(AddSpecialEffectTarget(CreateFX,d,Attach))
            // And now, leak cleaning;
            call DestroyTrigger(T0)
            call DestroyTrigger(T1)
            call DestroyTrigger(T2)
            call DestroyTrigger(T3)
            call DestroyTrigger(T4)
            call DestroyTextTag(Text)
            call DestroyMultiboard(Multiboard)
            set T0=null
            set T1=null
            set T2=null
            set T3=null
            set T4=null
            set Text=null
            set Multiboard=null
            set HeroText=null
            set DescText=null
            // And last, but not least, our love;
            set current=null
    set d=null
endfunction

private function Down takes nothing returns nothing
   if CS!=0 then
    set CS=CS-1
    call MultiboardSetItemValue(HeroText,name[CS])
    call MultiboardSetItemValue(DescText,desc[CS])
        call RemoveUnit(current)
        call DestroyTextTag(Text)
          set Text=FadingTextSingle(Player(PlayerID),fdesc[CS],255,255,255,HSSX,HSSY,0,9999999,9999999)
            set current=CreateUnit(Player(PlayerID),id[CS],HSSX,HSSY,facing)
                call SetCameraTargetController(current,0,0,true)
            call PanCameraTo(HSSX,HSSY)
        call UnitAddAbility(current,'Aloc')
        call PauseUnit(current,true)
   endif
endfunction

private function Up takes nothing returns nothing
   if CS!=(max-1) then
    set CS=CS+1
    call MultiboardSetItemValue(HeroText,name[CS])
    call MultiboardSetItemValue(DescText,desc[CS])
        call RemoveUnit(current)
        call DestroyTextTag(Text)
          set Text=FadingTextSingle(Player(PlayerID),fdesc[CS],255,255,255,HSSX,HSSY,0,9999999,9999999)
            set current=CreateUnit(Player(PlayerID),id[CS],HSSX,HSSY,facing)
                call SetCameraTargetController(current,0,0,true)
            call PanCameraTo(HSSX,HSSY)
        call UnitAddAbility(current,'Aloc')
        call PauseUnit(current,true)
   endif
endfunction

private function Setup takes nothing returns nothing
    local integer i=0
    set Multiboard=CreateMultiboard()
    call MultiboardSetColumnCount(Multiboard,5)
    call MultiboardSetRowCount(Multiboard,Rows)
    call MultiboardSetTitleText(Multiboard,Title)
    set HeroText=MultiboardGetItem(Multiboard,1,0)
    set DescText=MultiboardGetItem(Multiboard,4,0)
            call MultiboardSetItemWidth(HeroText,HeroWidth)
            call MultiboardSetItemWidth(DescText,DescWidth)
            loop
                exitwhen i>Rows
                    call MultiboardSetItemStyle(MultiboardGetItem(Multiboard,i,0),true,false)
                    call MultiboardSetItemStyle(MultiboardGetItem(Multiboard,i,1),true,false)
                    call MultiboardSetItemStyle(MultiboardGetItem(Multiboard,i,2),true,false)
                    call MultiboardSetItemStyle(MultiboardGetItem(Multiboard,i,3),true,false)
                    call MultiboardSetItemStyle(MultiboardGetItem(Multiboard,i,4),true,false)
                    call MultiboardSetItemStyle(MultiboardGetItem(Multiboard,i,5),true,false)
                set i=i+1
            endloop
            set i=0
        call MultiboardSetItemValue(HeroText,name[0])
        call MultiboardSetItemValue(DescText,desc[0])
        call MultiboardDisplay(Multiboard,true)
endfunction

function AddHero takes integer ID, string NAME, string DESCRIPTION, string FLOATDESC, boolean SETCURR returns unit
    set id[size]=ID
    set name[size]=NAME
    set desc[size]=DESCRIPTION
    set fdesc[size]=FLOATDESC
        if SETCURR==true then
            if current!=null then
                call RemoveUnit(current)
            endif
            set current=CreateUnit(Player(PlayerID),id[size],HSSX,HSSY,0)
            call SetCameraTargetController(current,0,0,true)
            call PanCameraTo(HSSX,HSSY)
            call UnitAddAbility(current,'Aloc')
            call PauseUnit(current,true)
              set Text=FadingTextSingle(Player(PlayerID),FLOATDESC,255,255,255,HSSX,HSSY,0,9999999,9999999)
        endif
        set size=size+1
        set max=max+1
        return current
endfunction

//===========================================================================
function InitTrig_HeroSelectionSystem takes nothing returns nothing
    set T0=CreateTrigger()
    set T1=CreateTrigger()
    set T2=CreateTrigger()
    set T3=CreateTrigger()
    set T4=CreateTrigger()
    call TriggerRegisterTimerEvent(T1,Interval,true)
    call TriggerAddAction(T1,function TurnActs)
    set HSSX=GetRectCenterX(ChooseRect)
    set HSSY=GetRectCenterY(ChooseRect)
    set CHSSX=GetRectCenterX(CreateRect)
    set CHSSY=GetRectCenterY(CreateRect)
    call CreateFogModifierRect(Player(0),FOG_OF_WAR_VISIBLE,ChooseRect,false,false)
    set size=0
    set CS=0
    set max=0
    set current=null

        call TriggerRegisterTimerEvent(T0,0,false)
        call TriggerAddAction(T0,function Setup)
        call TriggerRegisterPlayerKeyEventBJ(T2,Player(0),bj_KEYEVENTTYPE_DEPRESS,bj_KEYEVENTKEY_DOWN)
        call TriggerAddAction(T2,function Down)
        call TriggerRegisterPlayerKeyEventBJ(T3,Player(0),bj_KEYEVENTTYPE_DEPRESS,bj_KEYEVENTKEY_UP)
        call TriggerAddAction(T3,function Up)
        call TriggerRegisterPlayerEventEndCinematic(T4,Player(0))
        call TriggerAddAction(T4,function Pick)
endfunction

endlibrary

Documentation:
Collapse JASS:
    1) Copy the trigger "TextTag" into your map.
    2) Copy the trigger "HeroSelectionSystem" into your map.
    3) Done!
    
        Note: requires vJASS.
        
            ~Vestras.

        Pros:
            - A new type of hero selection system.
            - Simple, yet effective.
            
        Cons:
            - Can only work for one player. (Not necessarily player red, just only one player.)
            - No leaks or bugs detected so far, if you find some, please report.
    
    Notes:
    
        - This system can only work for one player.
        - This system is ideal for any single player RPG which wants to add a characteristic feeling.
        - This system is used in my single player RPG.
        
            ~Vestras.

    1) To switch between Heroes, press the up and down arrow keys.
    2) To select a Hero, press the ESC/Escape key.
    3) Info, name and a short description is found at the Hero's position and in the Multiboard.
    
            ~Vestras.

Screenshot:
Click image for larger version

Name:	wc3scrnshot082408135351xs9.jpg
Views:	169
Size:	81.7 KB
ID:	46042

Enjoy, and credit me if you use it :)
Oh yeah, it isn't really "ultimate", it's just a name :)
EDIT: You can now check it out!
Attached Files
File Type: w3x Ultimate Hero Selection System.w3x (22.6 KB, 83 views)

Last edited by Rising_Dusk : 10-12-2009 at 08:07 PM.
Vestras is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 08-24-2008, 10:12 PM   #2
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

You need to upload that screenshot as attachment.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 10-15-2008, 12:12 AM   #3
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,269

Submissions (17)

moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

I don't like the fact that this only works for singleplayer maps... therefore it's not a system due to that limitation.
moyack is offline   Reply With Quote
Old 10-15-2008, 01:15 PM   #4
emjlr3
Rehabbing
 
emjlr3's Avatar
 
Join Date: Jun 2005
Posts: 1,386

Submissions (14)

emjlr3 is a jewel in the rough (151)emjlr3 is a jewel in the rough (151)

Mapping Contest First Place

Send a message via AIM to emjlr3 Send a message via MSN to emjlr3
Default

where I don't agree with you assessment that its not a system (it clearly is) - having this only work for 1 player reduces its usage to basically zero
__________________
emjlr3 is offline   Reply With Quote
Old 11-14-2008, 10:17 PM   #5
Kwah
Christmassy.
 
Kwah's Avatar
 
Join Date: Jun 2008
Posts: 644

Submissions (4)

Kwah will become famous soon enough (43)Kwah will become famous soon enough (43)

Default

Single Player selection systems are so easy to brute code that creating a system seems rather extravagant.
Kwah is offline   Reply With Quote
Old 11-19-2008, 01:10 AM   #6
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,514

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

As this works only in SP, this is definitely not a system. If you update it to make it work for all players, then this could be acceptable, but until then no. This could be a sample if you don't want to make it for all players.

Following the new rules, if you don't update or respond to this thread within 7 days, this will be graveyarded.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 11-19-2008, 05:33 AM   #7
Vestras
User


Project Member: LoC
 
Join Date: Dec 2007
Posts: 756

Submissions (4)

Vestras will become famous soon enough (40)Vestras will become famous soon enough (40)

Default

Quote:
Originally Posted by Pyrogasm
As this works only in SP, this is definitely not a system. If you update it to make it work for all players, then this could be acceptable, but until then no. This could be a sample if you don't want to make it for all players.

Following the new rules, if you don't update or respond to this thread within 7 days, this will be graveyarded.

Then go sample.
Vestras is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 06:57 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

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