• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

player select a destructible event ?

Status
Not open for further replies.
They construct the UI with destructibles. Because of this, they can use a flat plane along with modifiable texture ID's or something like that to easily change the skin it uses.

They just kind of make it at a specific point on the map. Then they use trackables to detect if you select the icon/potion/whatever. It is impossible to do this fully in GUI, or at least it is impossible to make a good one in full GUI.

Since the trackable API wasn't finished, we had to resort to placing it on one specific area of the map, since we can't move/destroy trackables. That's why we don't have on-screen inventory, it has to be full-screen so that we can make a minimal amount of trackables, or else the map can lag/lose quite a bit of fps after a while.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
-Use DUMMY UNIT (dummy must have Rally ability,model file - something invisible and selectable like effect used on unit with no color)
-Make destructible unselectable
-Make trigger
EVENT
player selects unit
CONDITION
unit type of triggering unit equal to DUMMY UNIT
---------to detect destructible-------
destructible - rally of triggering unit




pick destructibles you want
create DUMMY UNIT at picked destructible
order DUMMY UNIT to set rally on picked destructible

(full GUI :D)
OR

use buildings as destructibles
 
Level 9
Joined
Jan 3, 2010
Messages
359
-Use DUMMY UNIT (dummy must have Rally ability,model file - something invisible and selectable like effect used on unit with no color)
-Make destructible unselectable
-Make trigger
EVENT
player selects unit
CONDITION
unit type of triggering unit equal to DUMMY UNIT
---------to detect destructible-------
destructible - rally of triggering unit




pick destructibles you want
create DUMMY UNIT at picked destructible
order DUMMY UNIT to set rally on picked destructible

(full GUI :D)
OR

use buildings as destructibles

Yea, a good one :)
but the dummy unit will shows it's HP BAR !
and it's ugly :(
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
oh crap ...
I can't make it then ...
So sad ... :'(

you can learn it
I think this is a very good tutorial
http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=38300
but since you don't know a lot about JASS I made a testmap for you (it also includes the required models)
Here is the code:
it might contain mistakes because I am new to JASS
but most of the time there are some smart people around who will tell me how to do it right
JASS:
//You better start by reading the 3rd/last function first

//Create a special effect for a single player
function AddSpecialEffectPlayer takes string s, real x, real y, integer i returns effect
    if GetLocalPlayer() != Player(i) then
        set s = null
    endif
    return AddSpecialEffect( s, x, y)
endfunction

//Display data associated with the selected trackable
function DisplayData takes nothing returns nothing
    local integer id = GetHandleId(GetTriggeringTrackable())             //Get handle id of triggering trackable
    local real x = LoadReal(udg_Track_Hashtable, id, 0)                  //Load icon x position
    local real y = LoadReal(udg_Track_Hashtable, id, 1)                  //Load icon y position
    local integer iconnumber = LoadInteger(udg_Track_Hashtable, id, 0)   //Load icon number
    local integer playernumber = LoadInteger(udg_Track_Hashtable, id, 1) //Load playernumber of icon owner

    call BJDebugMsg("Icon "+I2S(iconnumber))     //Display icon number (I2S converts integers to strings)
    call BJDebugMsg("Player "+I2S(playernumber)) //Display playernumber 

    call DestroyEffect(udg_SelectionEffect[playernumber])  //Destroy selection effect
    set udg_SelectionEffect[playernumber] = AddSpecialEffectPlayer("BTNselection.mdx", x, y, playernumber)
endfunction

//Create a trigger which will run if a icon gets selected
function InitTrig_TrackableTest takes nothing returns nothing  //function must have the same name as the trigger (InitTrig_"TrackableTest")
    local real x = 0                             //Icon x position
    local real y = 0                             //Icon y position
    local integer i  = 0                         //Counter
    local integer id = 0                         //Unit handle id
    local integer playernumber = 0               //Number of player (Note: Player(0) = Red, Player(1) = Blue, etc.)
    local integer max  = 10                      //Number of selectable icons
    local string s = ""                          //String (text) variable
    local string trackmodel = "BTNalpha.mdx"     //Trackable model (you may use a peon or any other model as well)
    local trackable track                        //Trackable variable (used to detect if it is clicked or if the mouse is over it)
    local trigger tracktrigger = CreateTrigger() //Create trigger
    set udg_Track_Hashtable = InitHashtable()    //Create hashtable

    call TriggerAddAction(tracktrigger , function DisplayData) //Add actions to trigger (Show data)

    loop                                                        //Star a loop
        exitwhen i == max                                       //Loop will run until i beomces max (10 times, once for every icon)
        set playernumber = 0                                    //First player who gets icons is player red
        set x = i*64+32                                         //Icon x position (depending on i)
        set y = 32                                              //Icon y position
        loop                                                    //Star the second loop
            exitwhen playernumber == 12                         //This loop will run once for every player
            set s = ""                                          //Clear temporary model file path

            //Local player is the plaer in front of the pc
            //It will disconnect everyone if you use any functions causing net traffic
            //Because with the "if" you can set data which is different for every player
            //Unfortunately we can't detect if a trackable was clicked by a special player
            //And we can't create a trackable for a special player only cause it causes net traffic
            //But we can remove the model of a trackable for a special player

            if GetLocalPlayer() == Player(playernumber) then              //Check if current player is local player
                set s = trackmodel                                        //Set model path for current player
            endif                                                         //Ends the if
            set track = CreateTrackable(s, x, y, 0)                       //Create trackable for all players but with different model path
            call CreateDestructable( 'B000', x, y, 180, 1, 0 )            //Create icon (go to object editor and press "Ctrl + D" to see the destructable ids)
            set id = GetHandleId(track)                                   //Get a handle's id (each handle has its own id which is different from every other id
                                                                          //A handle is a variable type which is neither real or integer
                                                                          //Knowing this we can use that id to associate data with a handle
            call SaveInteger(udg_Track_Hashtable, id , 0, i )             //Save the icon number for 
            call SaveInteger(udg_Track_Hashtable, id , 1, playernumber)   //Save the player number and as
            call SaveReal(udg_Track_Hashtable, id , 0, x)                 //Save icon x position
            call SaveReal(udg_Track_Hashtable, id , 1, y)                 //Save icon y position
            call TriggerRegisterTrackableTrackEvent(tracktrigger , track)   //Add event to trigger (trigger runs if the mouse is over a trackable
                                                                          //You may change "Track" to "Hit" which will make the trigger run if a trackable is clicked
            set playernumber = playernumber + 1                           //Do stuff for next player
        endloop                                                           //Ends the second loop
        set i = i + 1                                                     //Do stuff for next icon
    endloop                                                               //Ends the first loop

    //handles leak if they are not nulled
    //parameters don't leak (Example: "takes player p" or "takes unit u" are parameters)
    set tracktrigger = null //null trigger
    set track = null        //null trackable
    set s = null            //I'm not sure about strings but it won't hurt
endfunction

Note:
I tested this online with another player and it worked for me and the dude who tested it with me said it would work fine for him, too
He also did not disconnect :grin:
 

Attachments

  • TrackTest.w3x
    17.9 KB · Views: 92
Status
Not open for further replies.
Top