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

Mouse On Trackable

Level 17
Joined
Nov 13, 2006
Messages
1,814
JASS:
//create tooltip for shop tooltip box (right bottom corner)
function CreateToolTip takes integer pl, string txt, real size, real x, real y, integer hkey returns nothing
    local texttag tt = null
    local real px = LoadReal(udg_FSS, 0, 1) + x
    local real py = LoadReal(udg_FSS, 0, 2) + y
    if GetLocalPlayer() == Player(pl - 1) then
        set tt = CreateTextTag( )
        call SetTextTagText( tt, txt, size * 0.023 )
        call SetTextTagPos( tt, px, py, 100.00 )
        call SetTextTagPermanent( tt, true )
    endif
    call SaveTextTagHandle(udg_FSS, 2402, hkey, tt)
    set tt = null
endfunction

function UpdateToolTip takes integer pl, integer t, integer slot returns nothing
    local integer id
    local integer price = 0
    local integer ilv = 0
    local integer mc = 0
    local integer sc = 0
    local integer ls = 0
    local string s = ""
    local integer i = 0
    local integer i1 = 0
    local integer i2 = 0
    local integer i3 = 0
    local string c = "|cffffff00"
    local string r = "|cffff0000"
    local string rc = r
    local real m = 0
    local real m2 = 0
    local string array de
    local integer d1 = 0
    local integer lv
    local integer rlv = 0
    local integer pgold
    local integer ui = 0
    local integer cv = udg_Inv_Unit[pl]
    local unit u = udg_UDexUnits[cv]
    local string craftlvr
    call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 180 + pl))
    call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 200 + pl))
    call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 220 + pl))
    call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 240 + pl))
    call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 260 + pl))
    call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 280 + pl))
    call SaveTextTagHandle(udg_FSS, 2402, 180 + pl, null)
    call SaveTextTagHandle(udg_FSS, 2402, 200 + pl, null)
    call SaveTextTagHandle(udg_FSS, 2402, 220 + pl, null)
    call SaveTextTagHandle(udg_FSS, 2402, 240 + pl, null)
    call SaveTextTagHandle(udg_FSS, 2402, 260 + pl, null)
    call SaveTextTagHandle(udg_FSS, 2402, 280 + pl, null)
  
    if udg_Camera_Lock[pl] == 2 then
        set craftlvr = ""
        if slot < 2000 then
           set slot = 0
        endif

        set mc = LoadInteger(udg_FSS, 2402, pl) - 2000
        if t == 1 then
            set sc = slot-2100
        elseif t == 2 then
            set sc = LoadInteger(udg_FSS, 2402, 20 + pl) - 2100
            set ls = slot - 2200
        endif

        if t == 0 then
            set id = 0
        elseif t == 1 and mc > 0 and sc > 0 then
            set id = LoadInteger(udg_Shop_Table, mc, sc)
        elseif t == 2 then
            set id = GetItemIdFromShop (pl, mc, sc, ls)
        endif
        if id != 0 then
            set ilv = LoadInteger(udg_FSS, 603, id)
            if ls > 0 then
                set pgold = GetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD)
                set ui = GetShopUniqueId (mc, sc, ls)
                set price = LoadInteger(udg_FSS, 602, id)
                if (ilv < 100 or ilv > 200) and ui > 0 then
                  set price = price * ui
                endif
                if pgold >= price then
                    set rc = c
                else
                    set rc = r
                endif
            endif
            if LoadInteger(udg_FSS, 606, id) != 0 and LoadInteger(udg_FSS, 607, id) > 0 then
  
              if ilv > 100 and ilv < 109 then
                set i = R2I(ls/2.00+0.5)
              elseif ilv == 109 or ilv == 110 then
                set i = 3
              else
               if ilv == 1902 or ilv == 1903 then
                set i = R2I(ls/2.00+0.5)
               elseif ilv == 1903 or ilv == 1904 then
                set i = 5
               else
                set i = 1
               endif
              endif

              if ilv > 100 and ilv < 106 and ilv != 103 then
                 set craftlvr = " - Tailor: "+I2S(i)
              elseif ilv == 103 then
                 set craftlvr = " - Blacksmith: "+I2S(i)
              elseif ilv > 105 and ilv < 111 then
                 set craftlvr = " - Jeweller: "+I2S(i)
              elseif ilv >= 1900 and ilv < 1910 then
                 set craftlvr = " - Pharmacist: "+I2S(i)
              else
                 set craftlvr = ""
              endif              
            set i = 0
            endif
 
            if ilv >= 100 and ilv < 112 then
                if ilv == 109 or ilv == 110 then
                  set price = LoadInteger(udg_FSS, 602, id)
                else
                  set price = price * ls * 5
                endif
                if ilv == 101 or ilv == 102 or ilv == 104 then
                    if sc < 10 then
                        if sc < 4 then
                            set m = 0.7
                        elseif sc < 7 then
                            set m = 1
                        else
                            set m = 0.55
                        endif
                        set i = sc - ((sc / 3) * 3)
                        if i == 1 then
                            set s = "Heavy "
                            set m2 = 1.5
                            set i2 = R2I(10 * 3.33 * ls * 5 * m) + 30
                            set i3 = R2I(3 * 3.33 * ls * 5 * m) + 10
                        elseif i == 2 then
                            set s = "Light "
                            set m2 = 1.25
                            set i2 = R2I(5 * 3.33 * ls * 5 * m) + 15
                            set i3 = R2I(5 * 3.33 * ls * 5 * m) + 15
                            set m = 1
                        elseif i == 0 then
                            set s = "Mage "
                            set m2 = 1.0
                            set i2 = R2I(3.00 * 3.33 * ls * 5 * m) + 10
                            set i3 = R2I(10 * 3.33 * ls * 5 * m) + 30
                        endif

                        set d1 = d1 + 1
                        set de[d1] = StringColoring("HP: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(m2 * m * 10.00 * ls * 5)) + "|r"
                        set d1 = d1 + 1
                        set de[d1] = StringColoring("Physical Defence: ", 85, 55, 255, 180, 180, 255) + c + I2S(i2) + "|r"
                        set d1 = d1 + 1
                        set de[d1] = StringColoring("Five El. Defence: ", 85, 55, 255, 180, 180, 255) + c + I2S(i3) + "|r"
                    endif
                elseif ilv == 103 then
                    set i = WeaponDamageModifier(LoadInteger(udg_FSS, 605, id))
                    set i1 = ls * 5 * WeaponDamageModifier(LoadInteger(udg_FSS, 605, id))
                    set d1 = d1 + 1
                    if i < 8 then
                        set de[d1] = StringColoring("Physical Attack: ", 85, 85, 255, 180, 180, 255) + c + I2S(i1) + "|r"
                    else
                        set de[d1] = StringColoring("Magical Attack: ", 85, 85, 255, 180, 180, 255) + c + I2S(i1) + "|r"
                    endif
                elseif ilv == 109 then
                    if ls == 1 then
                        set i1 = 30
                        set i2 = 30
                    elseif ls == 2 then
                        set i1 = 45
                        set i2 = 15
                    elseif ls == 3 then
                        set i1 = 10
                        set i2 = 45
                    endif
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Attack level: ", 85, 85, 255, 180, 180, 255) + c + I2S(i1) + "|r"
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Defence level: ", 85, 85, 255, 180, 180, 255) + c + I2S(i2) + "|r"
                elseif ilv == 106 then
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Physical Attack: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I((ls * 5 * 10 * 0.135) + 1)) + "|r"
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Magical Attack: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I((ls * 5 * 10 * 0.135) + 1)) + "|r"
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Critical chance: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I((ls * 5 * 10 / 250.00) + 1)) + "%|r"
                elseif ilv == 108 then
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Physical Defence: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 * 8.75 + 30)) + "|r"
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Accurancy: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 * 1.5 + 10)) + "|r"
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Evasion: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 * 1 + 10)) + "|r"
                elseif ilv == 105 then
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Physical Defence: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 * 3 + 30)) + "|r"
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Block chance: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 / 10 + 5)) + "%|r"
                elseif ilv == 110 then
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Exp/Discount:", 85, 85, 255, 180, 180, 255) + c + I2S(50) + "%|r"
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Gold drop rate: ", 85, 85, 255, 180, 180, 255) + c + I2S(50) + "%|r"
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Item drop luck: ", 85, 85, 255, 180, 180, 255) + c + I2S(50) + "%|r"
                elseif ilv == 111 then
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("A small but very old stone", 200, 200, 150, 255, 255, 255)
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("filled with magical power.", 200, 200, 150, 255, 255, 255)
                    set d1 = d1 + 1
                    set de[d1] = StringColoring("Do you want try your luck? ", 200, 200, 150, 255, 255, 255)
                endif
                if ilv >= 100 and ilv < 112 and ls > 0 and ls < 21 then
                    if ilv == 109 then
                        set rlv = 30
                    elseif ilv == 111 then
                        set rlv = 1
                    else
                        set rlv = ls * 5
                    endif
                    set lv = GetHeroLevel(u)
                endif
            else
               if ilv > 1901 and ilv < 1906 then
                  if ilv == 1902 or ilv == 1904 then
                     set s = "hit point"
                  else
                     set s = "mana point"
                  endif
                  set lv = GetHeroLevel(u)
                 if ilv < 1904 then
                  set rlv = ls * 5
                  set price = LoadInteger(udg_FSS, 602, id) * ls

                     set d1 = d1 + 2
                     set de[d1] = StringColoring("Restore "+I2S(ls*25+250)+" "+s, 200, 200, 150, 255, 255, 255)
                 else
                  set rlv = 0
                  set price = LoadInteger(udg_FSS, 602, id) 
                     set d1 = d1 + 2
                     set de[d1] = StringColoring("Regenerate 2000 " +s, 200, 200, 150, 255, 255, 255)
                     set d1 = d1 + 1
                     set de[d1] = StringColoring("In last 30 second.", 200, 200, 150, 255, 255, 255)
                 endif
                set s = ""
               else
                 if LoadStr(udg_FSS, 647, id) != null then
                    set d1 = d1 + 1
                    set de[d1] = StringColoring(LoadStr(udg_FSS, 647, id), 200, 200, 150, 255, 255, 255)
                  if LoadStr(udg_FSS, 648, id) != null then
                    set d1 = d1 + 1
                    set de[d1] = StringColoring(LoadStr(udg_FSS, 648, id), 200, 200, 150, 255, 255, 255)
                   if LoadStr(udg_FSS, 649, id) != null then
                     set d1 = d1 + 1
                     set de[d1] = StringColoring(LoadStr(udg_FSS, 649, id), 200, 200, 150, 255, 255, 255)
                   endif
                  endif
                 endif
               endif
            endif

            set m = 144
            if t == 1 then
              set s = StringColoring("Item Type: ", 85, 85, 255, 180, 180, 255) + StringColoring(s + LoadStr(udg_FSS, 604, id), 255, 255, 55, 255, 255, 200)
            else
              set s = StringColoring("Item Type: ", 85, 85, 255, 180, 180, 255) + StringColoring(s + GetObjectName(id), 255, 255, 55, 255, 255, 200)
            endif
            call CreateToolTip (pl, s, 1.1, 830, 192, 180 + pl)
            if price > 0 and ls > 0 then
                set s = "|cffffffffPrice:|r " + rc + I2S(R2I(price*(100-udg_Global_Discount[cv])/100.00)) + "|r |cffffff77gold|r|cffff7777"+craftlvr+"|r"
                call CreateToolTip (pl, s, 1, 850, 0, 200 + pl)
            elseif ls > 0 and price == -1 then
                set s = StringColoring(" - Not buyable - ", 150, 150, 150, 75, 75, 75)+craftlvr
                call CreateToolTip (pl, s, 1, 850, 0, 200 + pl)
            endif

            if rlv > 0 and ls > 0 then
                set m = 144 - 30
                if rlv > lv then
                    set rc = r
                else
                    set rc = c
                endif
                set s = StringColoring("Required level: ", 55, 55, 255, 150, 150, 255) + rc + I2S(rlv) + " level|r"
                call CreateToolTip (pl, s, 1, 850, 144, 220 + pl)
            endif
            if ls > 0 then
                set i = 1
                loop
                    exitwhen i > d1
                   if de[i] != null then
                    call CreateToolTip (pl, de[i], 1, 850, m, 220 + (i * 20) + pl)
                    set de[i] = null
                   endif
                    set m = m - 30
                    set i = i + 1
                endloop
            endif
        else
              set i = LoadInteger(udg_Stat_Table, 27000+cv, 1)
              set i1 = LoadInteger(udg_Stat_Table, 27000+cv, 2)
              set i2 = LoadInteger(udg_Stat_Table, 27000+cv, 3)
              set i3 = LoadInteger(udg_Stat_Table, 27000+cv, 4)

              set s = StringColoring("Production Skills: ", 255, 85, 85, 200, 200, 255) 
              call CreateToolTip (pl, s, 1.2, 850, 170, 180 + pl)
              set s = StringColoring("Blacksmith: ", 85, 85, 255, 180, 180, 255) +"   "+ StringColoring("Level:  "+I2S(GetCraftLv(i,true))+" ("+I2S(GetCraftLv(i, false))+" %)", 255, 255, 55, 255, 255, 250)
              call CreateToolTip (pl, s, 1.1, 850, 144-35, 200 + pl)
              set s = StringColoring("Tailor: ", 85, 85, 255, 180, 180, 255) +"   "+ StringColoring("Level:  "+I2S(GetCraftLv(i1,true))+" ("+I2S(GetCraftLv(i1, false))+" %)", 255, 255, 55, 255, 255, 250)
              call CreateToolTip (pl, s, 1.1, 850, 144-65, 220 + pl)
              set s = StringColoring("Jeweller: ", 85, 85, 255, 180, 180, 255) +"   "+ StringColoring("Level:  "+I2S(GetCraftLv(i2, true))+" ("+I2S(GetCraftLv(i2, false))+" %)", 255, 255, 55, 255, 255, 250)
              call CreateToolTip (pl, s, 1.1, 850, 144-100, 240 + pl)
              set s = StringColoring("Pharmacist: ", 85, 85, 255, 180, 180, 255) +"   "+ StringColoring("Level:  "+I2S(GetCraftLv(i3, true))+" ("+I2S(GetCraftLv(i3, false))+" %)", 255, 255, 55, 255, 255, 250)
              call CreateToolTip (pl, s, 1.1, 850, 144-130, 260 + pl)

        endif
     set craftlvr = null
    endif
    set s = null
    set r = null
    set c = null
    set rc = null
    set u = null
endfunction

function On_Trackable takes nothing returns nothing
    local integer id = GetHandleId(GetTriggeringTrackable())
    local integer pl = LoadInteger(udg_FSS, - id, 1) + 1
    local integer slot = LoadInteger(udg_FSS, - id, 1 + udg_Camera_Lock[pl])
    local integer cv = udg_Inv_Unit[pl]
    local integer i
    if udg_Camera_Lock[pl] > 0 then
     //call DisplayTimedTextToForce( GetPlayersAll(), 30,"slot "+I2S(slot))
        if udg_Camera_Lock[pl] == 1 then
            if slot < 1100 then
                if slot >= 100 and slot < 200 and udg_Trader[pl] == 0 then
                    set i = LoadInteger(udg_Stat_Table, cv, - slot)
                    if i >= 100 and i < 111 then
                        if LoadInteger(udg_Stat_Table, cv, - i + 100) == 0 then
                            call BumpSlot (pl, i - 100, 5)
                        elseif LoadInteger(udg_Stat_Table, cv, - 6) > 0 and LoadInteger(udg_Stat_Table, cv, - 7) == 0 then
                            call BumpSlot (pl, 7, 5)
                        endif
                    endif
                endif

                call Mb_ToolTip(pl, pl, slot)
            elseif udg_Trader[pl] > 0 then
                if slot < 1206 then
                    set i = LoadInteger(udg_FSS, 1249 + pl, slot)
                    if i > 0 then
                        call Mb_ToolTip(pl, pl, i)
                    endif
                elseif slot < 1212 then
                    set i = LoadInteger(udg_FSS, 1249 + udg_Trader[pl], slot - 6)
                    if LoadItemHandle(udg_Stat_Table, udg_Inv_Unit[udg_Trader[pl]], i) != null then
                        call Mb_Item_ToolTip (LoadItemHandle(udg_Stat_Table, udg_Inv_Unit[udg_Trader[pl]], i), cv, 0, 0)
                    endif
                else
                    call Mb_ToolTip(pl, pl, slot)
                endif
            endif
        elseif udg_Camera_Lock[pl] == 2 then
            if LoadInteger(udg_FSS, 2405, 20 + pl) == 0 then
                if slot != 0 then
                    if slot < 200 then
                        call Mb_ToolTip(pl, pl, slot)
                    else
                        if udg_Mb_Type[pl] == 1 then
                            set udg_Mb_Type[pl] = 0
                            call DestroyMultiboard(udg_Mb_Table[pl])
                        endif
                        if slot >= 2000 then
                            if slot < 2100 then
              //call UpdateToolTip(pl, 0, slot)
                            elseif slot < 2200 then
                                call UpdateToolTip(pl, 1, slot)
                            elseif slot < 2300 then
                                call UpdateToolTip(pl, 2, slot)
                            elseif slot > 2302 and slot < 2306 then
                                if LoadInteger(udg_FSS, 2405, pl) == 1 then
                                    set i = LoadInteger(udg_FSS, 2405, 160 + pl) //craft target item
                                    if LoadInteger(udg_FSS, 606 + ((slot - 2303) * 2), i) != 0 and LoadInteger(udg_FSS, 607 + ((slot - 2303) * 2), i) > 0 then
                                        call MultiboardClear(udg_Mb_Table[pl])
                                        call DestroyMultiboard(udg_Mb_Table[pl])
                                        set udg_Mb_Table[pl] = CreateMultiboard()
                                        set udg_Mb_Type[pl] = 1
                                        call MultiboardSetRowCount(udg_Mb_Table[pl], 0)
                                        call MultiboardSetColumnCount(udg_Mb_Table[pl], 0)
                                        call MultiboardSetTitleText(udg_Mb_Table[pl], (StringColoring(GetObjectName(LoadInteger(udg_FSS, 606 + ((slot - 2303) * 2), i)), 125, 125, 255, 200, 200, 255) + " |cffbbbbffx " + I2S(GetCraftMatAmount (pl, LoadInteger(udg_FSS, 2402, pl) - 2000, LoadInteger(udg_FSS, 2402, 20 + pl) - 2100, LoadInteger(udg_FSS, 2402, 40 + pl) - 2200, slot - 2302))) + "|r")
                                        call MultiboardSetTitleTextColor(udg_Mb_Table[pl], 255, 200, 200, 255)
                                        call MultiboardDisplay(udg_Mb_Table[pl], false)
                                        call MultiboardMinimize(udg_Mb_Table[pl], true)
                                        if ( GetLocalPlayer() == Player(pl - 1) ) then
                                            call MultiboardDisplay(udg_Mb_Table[pl], true)
                                        endif
                                    endif
                                endif
                            endif
                        endif
                    endif
                endif

            endif
        elseif udg_Camera_Lock[pl] == 3 then
            if (slot >= 100 and slot < 119) or (slot >= 2200 and slot < 2225) then
                call Mb_ToolTip(pl, pl, slot)
            endif
        endif
    endif
endfunction


//===========================================================================
function InitTrig_OnTrackable takes nothing returns nothing
    set gg_trg_OnTrackable = CreateTrigger()
    call TriggerAddAction( gg_trg_OnTrackable, function On_Trackable )
endfunction
Last edited:
Top