function Debug takes string s returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0,0, s)
endfunction
function DebugExist takes string s, integer index returns nothing
call BJDebugMsg(s+"."+I2S(index)+" Handle: "+I2S(GetHandleId(BlzGetFrameByName(s,index))))
endfunction
function DebugFrameValue takes string s, integer index returns nothing
call BJDebugMsg(s+"."+I2S(index)+" Value: "+R2S(BlzFrameGetValue(BlzGetFrameByName(s,index))))
endfunction
function DebugFrameVisible takes string s, integer index returns nothing
if BlzFrameIsVisible(BlzGetFrameByName(s,index)) then
call BJDebugMsg(s+"."+I2S(index)+" is Visible")
else
call BJDebugMsg(s+"."+I2S(index)+" is Hidden")
endif
endfunction
function DebugFrameText takes string s, integer index returns nothing
call BJDebugMsg(s+"."+I2S(index)+" Text: "+BlzFrameGetText(BlzGetFrameByName(s,index)))
endfunction
function LoadToc takes string s returns nothing
if BlzLoadTOCFile(s) then
call BJDebugMsg("Loaded: "+s)
else
call BJDebugMsg("Failed to Load: "+s)
endif
endfunction
Name | Type | is_array | initial_value |
BlutMagierTier5 | integer | Yes | |
LastSelected | unit | No | |
StatPower | integer | Yes | |
StatType | integer | Yes | |
Talent__Button | integer | No | |
Talent__Choice | integer | No | |
Talent__Event | real | No | |
Talent__Level | integer | No | |
Talent__ResetAmount | integer | No | |
Talent__Tier | integer | No | |
Talent__Unit | unit | No | |
Talent__UnitCode | unitcode | No | |
TalentChoiceHead | string | Yes | |
TalentChoiceIcon | imagefile | Yes | |
TalentChoiceInt1 | integer | Yes | |
TalentChoiceInt2 | integer | Yes | |
TalentChoiceInt3 | integer | Yes | |
TalentChoiceLast | integer | No | |
TalentChoiceOnLearn | trigger | Yes | |
TalentChoiceOnReset | trigger | Yes | |
TalentChoiceReal1 | real | Yes | |
TalentChoiceReal2 | real | Yes | |
TalentChoiceText | string | Yes | |
TalentControlGroup | group | No | |
TalentControlLevels | integer | Yes | |
TalentControlLevelsCurrent | integer | Yes | |
TalentControlLevelsMax | integer | Yes | |
TalentControlPreventReset | boolean | Yes | |
TalentControlSingleMode | boolean | Yes | |
TalentControlTarget | unit | Yes | |
TalentGUI_ChoiceHead | string | No | |
TalentGUI_ChoiceIcon | imagefile | No | |
TalentGUI_ChoiceText | string | No | |
TalentGUI_Level | integer | No | |
TalentGUI_OnLearn | trigger | No | |
TalentGUI_OnReset | trigger | No | |
TalentGUI_ReplacedSpell | abilcode | No | |
TalentGUI_Spell | abilcode | No | |
TalentGUI_UnitType | unitcode | No | |
TalentGUI_UnitTypeCopied | unitcode | No | |
TalentGUIAddSpell | trigger | No | |
TalentGUICopyUnit | trigger | No | |
TalentGUICreateChoice | trigger | No | |
TalentGUIReplaceSpell | trigger | No | |
TalentHash | hashtable | No | |
TalentPreMadeChoiceTrigger | trigger | Yes | |
TalentReset | trigger | No | |
TalentSpellsPrefix | string | Yes | |
TalentSpellsSufix | string | Yes | |
TalentStrings | string | Yes | |
TalentTasStatAgi | integer | Yes | |
TalentTasStatArmor | real | Yes | |
TalentTasStatAttackSpeed | real | Yes | |
TalentTasStatCastBackswing | real | Yes | |
TalentTasStatCastPoint | real | Yes | |
TalentTasStatDamage | integer | Yes | |
TalentTasStatInt | integer | Yes | |
TalentTasStatLife | integer | Yes | |
TalentTasStatLifeReg | real | Yes | |
TalentTasStatMana | integer | Yes | |
TalentTasStatManaReg | real | Yes | |
TalentTasStatStr | integer | Yes | |
TalentTierLast | integer | No | |
TalentTrigger | trigger | Yes | |
TalentUser | group | No |
library Ascii /* v1.1.0.0 Nestharus/Bribe
************************************************************************************
*
* function Char2Ascii takes string s returns integer
* integer ascii = Char2Ascii("F")
*
* function Ascii2Char takes integer a returns string
* string char = Ascii2Char('F')
*
* function A2S takes integer a returns string
* string rawcode = A2S('CODE')
*
* function S2A takes string s returns integer
* integer rawcode = S2A("CODE")
*
************************************************************************************/
globals
private integer array i //hash
private integer array h //hash2
private integer array y //hash3
private string array c //char
endglobals
function Char2Ascii takes string p returns integer
local integer z = i[StringHash(p)/0x1F0748+0x40D]
if (c[z] != p) then
if (c[z - 32] != p) then
if (c[h[z]] != p) then
if (c[y[z]] != p) then
if (c[83] != p) then
debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"ASCII ERROR: INVALID CHARACTER: " + p)
return 0
endif
return 83
endif
return y[z]
endif
return h[z]
endif
return z - 32
endif
return z
endfunction
function Ascii2Char takes integer a returns string
return c[a]
endfunction
function A2S takes integer a returns string
local string s=""
loop
set s=c[a-a/256*256]+s
set a=a/256
exitwhen 0==a
endloop
return s
endfunction
function S2A takes string s returns integer
local integer a=0
local integer l=StringLength(s)
local integer j=0
local string m
local integer h
loop
exitwhen j==l
set a = a*256 + Char2Ascii(SubString(s,j,j+1))
set j=j+1
endloop
return a
endfunction
private module Init
private static method onInit takes nothing returns nothing
set i[966] = 8
set i[1110] = 9
set i[1621] = 10
set i[1375] = 12
set i[447] = 13
set i[233] = 32
set i[2014] = 33
set i[1348] = 34
set i[1038] = 35
set i[1299] = 36
set i[1018] = 37
set i[1312] = 38
set i[341] = 39
set i[939] = 40
set i[969] = 41
set i[952] = 42
set i[2007] = 43
set i[1415] = 44
set i[2020] = 45
set i[904] = 46
set i[1941] = 47
set i[918] = 48
set i[1593] = 49
set i[719] = 50
set i[617] = 51
set i[703] = 52
set i[573] = 53
set i[707] = 54
set i[1208] = 55
set i[106] = 56
set i[312] = 57
set i[124] = 58
set i[1176] = 59
set i[74] = 60
set i[1206] = 61
set i[86] = 62
set i[340] = 63
set i[35] = 64
set i[257] = 65
set i[213] = 66
set i[271] = 67
set i[219] = 68
set i[1330] = 69
set i[1425] = 70
set i[1311] = 71
set i[238] = 72
set i[1349] = 73
set i[244] = 74
set i[1350] = 75
set i[205] = 76
set i[1392] = 77
set i[1378] = 78
set i[1432] = 79
set i[1455] = 80
set i[1454] = 81
set i[1431] = 82
set i[1409] = 83
set i[1442] = 84
set i[534] = 85
set i[1500] = 86
set i[771] = 87
set i[324] = 88
set i[1021] = 89
set i[73] = 90
set i[1265] = 91
set i[1941] = 92
set i[1671] = 93
set i[1451] = 94
set i[1952] = 95
set i[252] = 96
set i[257] = 97
set i[213] = 98
set i[271] = 99
set i[219] = 100
set i[1330] = 101
set i[1425] = 102
set i[1311] = 103
set i[238] = 104
set i[1349] = 105
set i[244] = 106
set i[1350] = 107
set i[205] = 108
set i[1392] = 109
set i[1378] = 110
set i[1432] = 111
set i[1455] = 112
set i[1454] = 113
set i[1431] = 114
set i[1409] = 115
set i[1442] = 116
set i[534] = 117
set i[1500] = 118
set i[771] = 119
set i[324] = 120
set i[1021] = 121
set i[73] = 122
set i[868] = 123
set i[1254] = 124
set i[588] = 125
set i[93] = 126
set i[316] = 161
set i[779] = 162
set i[725] = 163
set i[287] = 164
set i[212] = 165
set i[7] = 166
set i[29] = 167
set i[1958] = 168
set i[1009] = 169
set i[1580] = 170
set i[1778] = 171
set i[103] = 172
set i[400] = 174
set i[1904] = 175
set i[135] = 176
set i[1283] = 177
set i[469] = 178
set i[363] = 179
set i[550] = 180
set i[1831] = 181
set i[1308] = 182
set i[1234] = 183
set i[1017] = 184
set i[1093] = 185
set i[1577] = 186
set i[606] = 187
set i[1585] = 188
set i[1318] = 189
set i[980] = 190
set i[1699] = 191
set i[1292] = 192
set i[477] = 193
set i[709] = 194
set i[1600] = 195
set i[2092] = 196
set i[50] = 197
set i[546] = 198
set i[408] = 199
set i[853] = 200
set i[205] = 201
set i[411] = 202
set i[1311] = 203
set i[1422] = 204
set i[1808] = 205
set i[457] = 206
set i[1280] = 207
set i[614] = 208
set i[1037] = 209
set i[237] = 210
set i[1409] = 211
set i[1023] = 212
set i[1361] = 213
set i[695] = 214
set i[161] = 215
set i[1645] = 216
set i[1822] = 217
set i[644] = 218
set i[1395] = 219
set i[677] = 220
set i[1677] = 221
set i[881] = 222
set i[861] = 223
set i[1408] = 224
set i[1864] = 225
set i[1467] = 226
set i[1819] = 227
set i[1971] = 228
set i[949] = 229
set i[774] = 230
set i[1828] = 231
set i[865] = 232
set i[699] = 233
set i[786] = 234
set i[1806] = 235
set i[1286] = 236
set i[1128] = 237
set i[1490] = 238
set i[1720] = 239
set i[1817] = 240
set i[729] = 241
set i[1191] = 242
set i[1164] = 243
set i[413] = 244
set i[349] = 245
set i[1409] = 246
set i[660] = 247
set i[2016] = 248
set i[1087] = 249
set i[1497] = 250
set i[753] = 251
set i[1579] = 252
set i[1456] = 253
set i[606] = 254
set i[1625] = 255
set h[92] = 47
set h[201] = 108
set h[201] = 76
set h[203] = 103
set h[203] = 71
set h[246] = 115
set h[246] = 83
set h[246] = 211
set h[254] = 187
set y[201] = 108
set y[203] = 103
set y[246] = 115
set c[8]="\b"
set c[9]="\t"
set c[10]="\n"
set c[12]="\f"
set c[13]="\r"
set c[32]=" "
set c[33]="!"
set c[34]="\""
set c[35]="#"
set c[36]="$"
set c[37]="%"
set c[38]="&"
set c[39]="'"
set c[40]="("
set c[41]=")"
set c[42]="*"
set c[43]="+"
set c[44]=","
set c[45]="-"
set c[46]="."
set c[47]="/"
set c[48]="0"
set c[49]="1"
set c[50]="2"
set c[51]="3"
set c[52]="4"
set c[53]="5"
set c[54]="6"
set c[55]="7"
set c[56]="8"
set c[57]="9"
set c[58]=":"
set c[59]=";"
set c[60]="<"
set c[61]="="
set c[62]=">"
set c[63]="?"
set c[64]="@"
set c[65]="A"
set c[66]="B"
set c[67]="C"
set c[68]="D"
set c[69]="E"
set c[70]="F"
set c[71]="G"
set c[72]="H"
set c[73]="I"
set c[74]="J"
set c[75]="K"
set c[76]="L"
set c[77]="M"
set c[78]="N"
set c[79]="O"
set c[80]="P"
set c[81]="Q"
set c[82]="R"
set c[83]="S"
set c[84]="T"
set c[85]="U"
set c[86]="V"
set c[87]="W"
set c[88]="X"
set c[89]="Y"
set c[90]="Z"
set c[91]="["
set c[92]="\\"
set c[93]="]"
set c[94]="^"
set c[95]="_"
set c[96]="`"
set c[97]="a"
set c[98]="b"
set c[99]="c"
set c[100]="d"
set c[101]="e"
set c[102]="f"
set c[103]="g"
set c[104]="h"
set c[105]="i"
set c[106]="j"
set c[107]="k"
set c[108]="l"
set c[109]="m"
set c[110]="n"
set c[111]="o"
set c[112]="p"
set c[113]="q"
set c[114]="r"
set c[115]="s"
set c[116]="t"
set c[117]="u"
set c[118]="v"
set c[119]="w"
set c[120]="x"
set c[121]="y"
set c[122]="z"
set c[123]="{"
set c[124]="|"
set c[125]="}"
set c[126]="~"
set c[128] = "€"
set c[130] = "‚"
set c[131] = "ƒ"
set c[132] = "„"
set c[133] = "…"
set c[134] = "†"
set c[135] = "‡"
set c[136] = "ˆ"
set c[137] = "‰"
set c[138] = "Š"
set c[139] = "‹"
set c[140] = "Œ"
set c[142] = "Ž"
set c[145] = "‘"
set c[146] = "’"
set c[147] = "“"
set c[148] = "”"
set c[149] = "•"
set c[150] = "–"
set c[151] = "—"
set c[152] = "˜"
set c[153] = "™"
set c[154] = "š"
set c[155] = "›"
set c[156] = "œ"
set c[158] = "ž"
set c[159] = "Ÿ"
set c[160] = " "
set c[161] = "¡"
set c[162] = "¢"
set c[163] = "£"
set c[164] = "¤"
set c[165] = "¥"
set c[166] = "¦"
set c[167] = "§"
set c[168] = "¨"
set c[169] = "©"
set c[170] = "ª"
set c[171] = "«"
set c[172] = "¬"
set c[174] = "®"
set c[175] = "¯"
set c[176] = "°"
set c[177] = "±"
set c[178] = "²"
set c[179] = "³"
set c[180] = "´"
set c[181] = "µ"
set c[182] = "¶"
set c[183] = "·"
set c[184] = "¸"
set c[185] = "¹"
set c[186] = "º"
set c[187] = "»"
set c[188] = "¼"
set c[189] = "½"
set c[190] = "¾"
set c[191] = "¿"
set c[192] = "À"
set c[193] = "Á"
set c[194] = "Â"
set c[195] = "Ã"
set c[196] = "Ä"
set c[197] = "Å"
set c[198] = "Æ"
set c[199] = "Ç"
set c[200] = "È"
set c[201] = "É"
set c[202] = "Ê"
set c[203] = "Ë"
set c[204] = "Ì"
set c[205] = "Í"
set c[206] = "Î"
set c[207] = "Ï"
set c[208] = "Ð"
set c[209] = "Ñ"
set c[210] = "Ò"
set c[211] = "Ó"
set c[212] = "Ô"
set c[213] = "Õ"
set c[214] = "Ö"
set c[215] = "×"
set c[216] = "Ø"
set c[217] = "Ù"
set c[218] = "Ú"
set c[219] = "Û"
set c[220] = "Ü"
set c[221] = "Ý"
set c[222] = "Þ"
set c[223] = "ß"
set c[224] = "à"
set c[225] = "á"
set c[226] = "â"
set c[227] = "ã"
set c[228] = "ä"
set c[229] = "å"
set c[230] = "æ"
set c[231] = "ç"
set c[232] = "è"
set c[233] = "é"
set c[234] = "ê"
set c[235] = "ë"
set c[236] = "ì"
set c[237] = "í"
set c[238] = "î"
set c[239] = "ï"
set c[240] = "ð"
set c[241] = "ñ"
set c[242] = "ò"
set c[243] = "ó"
set c[244] = "ô"
set c[245] = "õ"
set c[246] = "ö"
set c[247] = "÷"
set c[248] = "ø"
set c[249] = "ù"
set c[250] = "ú"
set c[251] = "û"
set c[252] = "ü"
set c[253] = "ý"
set c[254] = "þ"
set c[255] = "ÿ"
endmethod
endmodule
private struct Inits extends array
implement Init
endstruct
endlibrary
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 4.1.0.1.
One map, one hashtable. Welcome to NewTable 4.1.0.1
This newest iteration of Table introduces the new HashTable struct.
You can now instantiate HashTables which enables the use of large
parent and large child keys, just like a standard hashtable. Previously,
the user would have to instantiate a Table to do this on their own which -
while doable - is something the user should not have to do if I can add it
to this resource myself (especially if they are inexperienced).
This library was originally called NewTable so it didn't conflict with
the API of Table by Vexorian. However, the damage is done and it's too
late to change the library name now. To help with damage control, I
have provided an extension library called TableBC, which bridges all
the functionality of Vexorian's Table except for 2-D string arrays &
the ".flush(integer)" method. I use ".flush()" to flush a child hash-
table, because I wanted the API in NewTable to reflect the API of real
hashtables (I thought this would be more intuitive).
API
------------
struct Table
| static method create takes nothing returns Table
| create a new Table
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush all stored values inside of it
|
| method remove takes integer key returns nothing
| remove the value at index "key"
|
| method operator []= takes integer key, $TYPE$ value returns nothing
| assign "value" to index "key"
|
| method operator [] takes integer key returns $TYPE$
| load the value at index "key"
|
| method has takes integer key returns boolean
| whether or not the key was assigned
|
----------------
struct TableArray
| static method operator [] takes integer array_size returns TableArray
| create a new array of Tables of size "array_size"
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush and destroy it
|
| method operator size takes nothing returns integer
| returns the size of the TableArray
|
| method operator [] takes integer key returns Table
| returns a Table accessible exclusively to index "key"
*/
globals
private integer less = 0 //Index generation for TableArrays (below 0).
private integer more = 8190 //Index generation for Tables.
//Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
private hashtable ht = InitHashtable()
private key sizeK
private key listK
endglobals
private struct dex extends array
static method operator size takes nothing returns Table
return sizeK
endmethod
static method operator list takes nothing returns Table
return listK
endmethod
endstruct
private struct handles extends array
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private struct agents extends array
method operator []= takes integer key, agent value returns nothing
call SaveAgentHandle(ht, this, key, value)
endmethod
endstruct
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSaved$SUPER$(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSaved$SUPER$(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$Handle(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$Handle(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
//New textmacro to allow table.integer[] syntax for compatibility with textmacros that might desire it.
//! runtextmacro NEW_ARRAY_BASIC("Integer", "Integer", "integer")
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
//! runtextmacro NEW_ARRAY("Frame", "framehandle")
struct Table extends array
// Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
implement realm
implement integerm
implement booleanm
implement stringm
implement playerm
implement widgetm
implement destructablem
implement itemm
implement unitm
implement abilitym
implement timerm
implement triggerm
implement triggerconditionm
implement triggeractionm
implement eventm
implement forcem
implement groupm
implement locationm
implement rectm
implement boolexprm
implement soundm
implement effectm
implement unitpoolm
implement itempoolm
implement questm
implement questitemm
implement defeatconditionm
implement timerdialogm
implement leaderboardm
implement multiboardm
implement multiboarditemm
implement trackablem
implement dialogm
implement buttonm
implement texttagm
implement lightningm
implement imagem
implement ubersplatm
implement regionm
implement fogstatem
implement fogmodifierm
implement hashtablem
implement framehandlem
method operator handle takes nothing returns handles
return this
endmethod
method operator agent takes nothing returns agents
return this
endmethod
//set this = tb[GetSpellAbilityId()]
method operator [] takes integer key returns Table
return LoadInteger(ht, this, key) //return this.integer[key]
endmethod
//set tb[389034] = 8192
method operator []= takes integer key, Table tb returns nothing
call SaveInteger(ht, this, key, tb) //set this.integer[key] = tb
endmethod
//set b = tb.has(2493223)
method has takes integer key returns boolean
return HaveSavedInteger(ht, this, key) //return this.integer.has(key)
endmethod
//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key) //call this.integer.remove(key)
endmethod
//Remove all data from a Table instance
method flush takes nothing returns nothing
call FlushChildHashtable(ht, this)
endmethod
//local Table tb = Table.create()
static method create takes nothing returns Table
local Table this = dex.list[0]
if this == 0 then
set this = more + 1
set more = this
else
set dex.list[0] = dex.list[this]
call dex.list.remove(this) //Clear hashed memory
endif
debug set dex.list[this] = -1
return this
endmethod
// Removes all data from a Table instance and recycles its index.
//
// call tb.destroy()
//
method destroy takes nothing returns nothing
debug if dex.list[this] != -1 then
debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
debug return
debug endif
call this.flush()
set dex.list[this] = dex.list[0]
set dex.list[0] = this
endmethod
//! runtextmacro optional TABLE_BC_METHODS()
endstruct
//! runtextmacro optional TABLE_BC_STRUCTS()
struct TableArray extends array
//Returns a new TableArray to do your bidding. Simply use:
//
// local TableArray ta = TableArray[array_size]
//
static method operator [] takes integer array_size returns TableArray
local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
local TableArray this = tb[0] //The last-destroyed TableArray that had this array size
debug if array_size <= 0 then
debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
debug return 0
debug endif
if this == 0 then
set this = less - array_size
set less = this
else
set tb[0] = tb[this] //Set the last destroyed to the last-last destroyed
call tb.remove(this) //Clear hashed memory
endif
set dex.size[this] = array_size //This remembers the array size
return this
endmethod
//Returns the size of the TableArray
method operator size takes nothing returns integer
return dex.size[this]
endmethod
//This magic method enables two-dimensional[array][syntax] for Tables,
//similar to the two-dimensional utility provided by hashtables them-
//selves.
//
//ta[integer a].unit[integer b] = unit u
//ta[integer a][integer c] = integer d
//
//Inline-friendly when not running in debug mode
//
method operator [] takes integer key returns Table
static if DEBUG_MODE then
local integer i = this.size
if i == 0 then
call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
return 0
elseif key < 0 or key >= i then
call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
return 0
endif
endif
return this + key
endmethod
//Destroys a TableArray without flushing it; I assume you call .flush()
//if you want it flushed too. This is a public method so that you don't
//have to loop through all TableArray indices to flush them if you don't
//need to (ie. if you were flushing all child-keys as you used them).
//
method destroy takes nothing returns nothing
local Table tb = dex.size[this.size]
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
debug return
debug endif
if tb == 0 then
//Create a Table to index recycled instances with their array size
set tb = Table.create()
set dex.size[this.size] = tb
endif
call dex.size.remove(this) //Clear the array size from hash memory
set tb[this] = tb[0]
set tb[0] = this
endmethod
private static Table tempTable
private static integer tempEnd
//Avoids hitting the op limit
private static method clean takes nothing returns nothing
local Table tb = .tempTable
local integer end = tb + 0x1000
if end < .tempEnd then
set .tempTable = end
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
else
set end = .tempEnd
endif
loop
call tb.flush()
set tb = tb + 1
exitwhen tb == end
endloop
endmethod
//Flushes the TableArray and also destroys it. Doesn't get any more
//similar to the FlushParentHashtable native than this.
//
method flush takes nothing returns nothing
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
debug return
debug endif
set .tempTable = this
set .tempEnd = this + this.size
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
call this.destroy()
endmethod
endstruct
//NEW: Added in Table 4.0. A fairly simple struct but allows you to do more
//than that which was previously possible.
struct HashTable extends array
//Enables myHash[parentKey][childKey] syntax.
//Basically, it creates a Table in the place of the parent key if
//it didn't already get created earlier.
method operator [] takes integer index returns Table
local Table t = Table(this)[index]
if t == 0 then
set t = Table.create()
set Table(this)[index] = t //whoops! Forgot that line. I'm out of practice!
endif
return t
endmethod
//You need to call this on each parent key that you used if you
//intend to destroy the HashTable or simply no longer need that key.
method remove takes integer index returns nothing
local Table t = Table(this)[index]
if t != 0 then
call t.destroy()
call Table(this).remove(index)
endif
endmethod
//Added in version 4.1
method has takes integer index returns boolean
return Table(this).has(index)
endmethod
//HashTables are just fancy Table indices.
method destroy takes nothing returns nothing
call Table(this).destroy()
endmethod
//Like I said above...
static method create takes nothing returns thistype
return Table.create()
endmethod
endstruct
endlibrary
// TalentTasStats
// addon for Talent JUI V1.35b+ by Tasyen
// TalentTasStat variables for a choice index provides basis stats.
// This includes changing ability fields.
// Having TalentTasStats installed makes picking/reseting choices a little bit heavier
// , but it reduces the need of OnLearn/OnReset callbacks/Triggers.
// Unlike the Lua version this can not change Ability Field values
library TalentTasStats
// when increasing MaxLife gain current Life?
function TalentTasStatsGainLife takes nothing returns boolean
return true
endfunction
// when increasing MaxMana gain current Mana?
function TalentTasStatsGainMana takes nothing returns boolean
return true
endfunction
function TalentTasStatsAdd takes unit u, integer choice returns nothing
if udg_TalentTasStatStr[choice] != 0 then
call SetHeroStr(u, GetHeroStr(u, false) + udg_TalentTasStatStr[choice], true)
endif
if udg_TalentTasStatAgi[choice] != 0 then
call SetHeroAgi(u, GetHeroAgi(u, false) + udg_TalentTasStatAgi[choice], true)
endif
if udg_TalentTasStatInt[choice] != 0 then
call SetHeroInt(u, GetHeroInt(u, false) + udg_TalentTasStatInt[choice], true)
endif
if udg_TalentTasStatLife[choice] != 0 then
call BlzSetUnitMaxHP(u, BlzGetUnitMaxHP(u) + udg_TalentTasStatLife[choice])
if TalentTasStatsGainLife() then
call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE) + udg_TalentTasStatLife[choice])
endif
endif
if udg_TalentTasStatLifeReg[choice] != 0 then
call BlzSetUnitRealField(u, UNIT_RF_HIT_POINTS_REGENERATION_RATE, BlzGetUnitRealField(u, UNIT_RF_HIT_POINTS_REGENERATION_RATE) + udg_TalentTasStatLifeReg[choice])
endif
if udg_TalentTasStatMana[choice] != 0 then
call BlzSetUnitMaxMana(u, BlzGetUnitMaxMana(u) + udg_TalentTasStatMana[choice])
if TalentTasStatsGainMana() then
call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA) + udg_TalentTasStatMana[choice])
endif
endif
if udg_TalentTasStatManaReg[choice] != 0 then
call BlzSetUnitRealField(u, UNIT_RF_MANA_REGENERATION, BlzGetUnitRealField(u, UNIT_RF_MANA_REGENERATION) + udg_TalentTasStatManaReg[choice])
endif
if udg_TalentTasStatArmor[choice] != 0 then
call BlzSetUnitArmor(u, BlzGetUnitArmor(u) + udg_TalentTasStatArmor[choice])
endif
if udg_TalentTasStatDamage[choice] != 0 then
call BlzSetUnitBaseDamage(u, BlzGetUnitBaseDamage(u, 0) + udg_TalentTasStatDamage[choice], 0)
call BlzSetUnitBaseDamage(u, BlzGetUnitBaseDamage(u, 1) + udg_TalentTasStatDamage[choice], 1)
endif
if udg_TalentTasStatAttackSpeed[choice] != 0 then
call BlzSetUnitAttackCooldown(u, BlzGetUnitAttackCooldown(u, 0) + udg_TalentTasStatAttackSpeed[choice], 0)
call BlzSetUnitAttackCooldown(u, BlzGetUnitAttackCooldown(u, 1) + udg_TalentTasStatAttackSpeed[choice], 1)
endif
if udg_TalentTasStatCastPoint[choice] != 0 then
call BlzSetUnitRealField(u, UNIT_RF_CAST_POINT, BlzGetUnitRealField(u, UNIT_RF_CAST_POINT) + udg_TalentTasStatCastPoint[choice])
endif
if udg_TalentTasStatCastBackswing[choice] != 0 then
call BlzSetUnitRealField(u, UNIT_RF_CAST_BACK_SWING, BlzGetUnitRealField(u, UNIT_RF_CAST_BACK_SWING) + udg_TalentTasStatCastBackswing[choice])
endif
endfunction
function TalentTasStatsRemove takes unit u, integer choice returns nothing
if udg_TalentTasStatStr[choice] != 0 then
call SetHeroStr(u, GetHeroStr(u, false) - udg_TalentTasStatStr[choice], true)
endif
if udg_TalentTasStatAgi[choice] != 0 then
call SetHeroAgi(u, GetHeroAgi(u, false) - udg_TalentTasStatAgi[choice], true)
endif
if udg_TalentTasStatInt[choice] != 0 then
call SetHeroInt(u, GetHeroInt(u, false) - udg_TalentTasStatInt[choice], true)
endif
if udg_TalentTasStatLife[choice] != 0 then
call BlzSetUnitMaxHP(u, BlzGetUnitMaxHP(u) - udg_TalentTasStatLife[choice])
endif
if udg_TalentTasStatLifeReg[choice] != 0 then
call BlzSetUnitRealField(u, UNIT_RF_HIT_POINTS_REGENERATION_RATE, BlzGetUnitRealField(u, UNIT_RF_HIT_POINTS_REGENERATION_RATE) - udg_TalentTasStatLifeReg[choice])
endif
if udg_TalentTasStatMana[choice] != 0 then
call BlzSetUnitMaxMana(u, BlzGetUnitMaxMana(u) - udg_TalentTasStatMana[choice])
endif
if udg_TalentTasStatManaReg[choice] != 0 then
call BlzSetUnitRealField(u, UNIT_RF_MANA_REGENERATION, BlzGetUnitRealField(u, UNIT_RF_MANA_REGENERATION) - udg_TalentTasStatManaReg[choice])
endif
if udg_TalentTasStatArmor[choice] != 0 then
call BlzSetUnitArmor(u, BlzGetUnitArmor(u) - udg_TalentTasStatArmor[choice])
endif
if udg_TalentTasStatDamage[choice] != 0 then
call BlzSetUnitBaseDamage(u, BlzGetUnitBaseDamage(u, 0) - udg_TalentTasStatDamage[choice], 0)
call BlzSetUnitBaseDamage(u, BlzGetUnitBaseDamage(u, 1) - udg_TalentTasStatDamage[choice], 1)
endif
if udg_TalentTasStatAttackSpeed[choice] != 0 then
call BlzSetUnitAttackCooldown(u, BlzGetUnitAttackCooldown(u, 0) - udg_TalentTasStatAttackSpeed[choice], 0)
call BlzSetUnitAttackCooldown(u, BlzGetUnitAttackCooldown(u, 1) - udg_TalentTasStatAttackSpeed[choice], 1)
endif
if udg_TalentTasStatCastPoint[choice] != 0 then
call BlzSetUnitRealField(u, UNIT_RF_CAST_POINT, BlzGetUnitRealField(u, UNIT_RF_CAST_POINT) - udg_TalentTasStatCastPoint[choice])
endif
if udg_TalentTasStatCastBackswing[choice] != 0 then
call BlzSetUnitRealField(u, UNIT_RF_CAST_BACK_SWING, BlzGetUnitRealField(u, UNIT_RF_CAST_BACK_SWING) - udg_TalentTasStatCastBackswing[choice])
endif
endfunction
endlibrary
Make sure World Editor generates unknown variables in Preferences is set.
Copy the Talent Folder.
update values inside Talent Init
export
war3mapImported\TalentBox.fdf
war3mapImported\TalentBox.toc
also import them into your map
Installed
Allows choosen UnitTypes to select 1 choice out of many at specific Levels, you might know that out of Heroes of the Storm.
can replace the default skill choicing or work seperate.
Choices in 1 Tier should not have the same OrderString, something strange might happen if they share the same orderstring.
All Choice-Containers used by 1 Hero must use the same OrderString, to be showin by the UI-Book.
A Hero is only added to the Talent_Triggers, if he has the default UI or the Hero Speciifc one, when starting this system or he enters the map. (can use this overall)
If you already have an enters map event, it might be good to remove the event from udg_TalentTrigger[1] (bottom of talent-script) and let yours call udg_TalentTrigger[1] with ConditionalTriggerExecute.
library FrameLoader initializer init_function
// in 1.31 and upto 1.32.9 PTR (when I wrote this). Frames are not correctly saved and loaded, breaking the game.
// This library runs all functions added to it with a 0s delay after the game was loaded.
// function FrameLoaderAdd takes code func returns nothing
// func runs when the game is loaded.
globals
private trigger eventTrigger = CreateTrigger()
private trigger actionTrigger = CreateTrigger()
private timer t = CreateTimer()
endglobals
function FrameLoaderAdd takes code func returns nothing
call TriggerAddAction(actionTrigger, func)
endfunction
private function timerAction takes nothing returns nothing
call TriggerExecute(actionTrigger)
endfunction
private function eventAction takes nothing returns nothing
call TimerStart(t, 0, false, function timerAction)
endfunction
private function init_function takes nothing returns nothing
call TriggerRegisterGameEvent(eventTrigger, EVENT_GAME_LOADED)
call TriggerAddAction(eventTrigger, function eventAction)
endfunction
endlibrary
library TalentJUI initializer init_function uses optional TalentTasStats, optional Ascii
//Talent Jui 1.36f
//by Tasyen
// Talent provides at wanted Levels a choice from a collection (Tier), from which the user picks one.
// Tiers are unitType specific (a paladin has different Choices then a demon hunter), This also includes the Levels obtaining them.
// One can handle choices by Events or one can bind Code beeing executed when picking a choice.
// Regardless using Events or binded code, creating a reset (revert picking a choice) is quite easy.
// Talent is mui.
// Choices and Tiers have a stable arrayIndex.
// Only UnitTypId having used TalentHeroSetFinalTier can use Talent.
// It is also recommented using "function TalentHeroSetCopy", if multiple unitTypes share the same Talent Setup, morphing units for example.
// Before an TalentUser is removed from them game, one should use "call FlushChildHashtable(udg_TalentHash, GetHandleId(unit))"
// Also it is recommented to do "call GroupRemoveUnit(udg_TalentUser, unit)"
//Known Erros: Choosen options overglow sometimes (most frequently the lowest button).
//===========================================================================
//Definitions:
//===========================================================================
globals
//TalentAutoDetectNewUser (true) will create an "unit enters map" event for udg_TalentTrigger[TT_AutoDetectUnits()]
boolean TalentAutoDetectNewUser = true
//Increases the Level of abilities gained by choices, if the ability is already owned.
boolean TalentImproveAbilities = true
//(true) only add the new ability if the unit has the to replaced Ability
boolean TalentReplacedAbilityRequiered = true
//Throw an Event when an unit picks a choiceTalent
boolean TalentThrowEventPick = true
//Throw an Event when an unit gains a choice to pick a talent
boolean TalentThrowEventAvailable = true
//Throw an Event when an unit resets a choice
boolean TalentThrowEventReset = true
//Throw an Event when an unit resets a choice
boolean TalentThrowEventFinish = true
endglobals
function TalentUseCondition takes unit u returns boolean
local boolean allowed = true
set udg_Talent__Unit = u
set allowed = TriggerEvaluate(gg_trg_TasTalent_UseCondition)
if not allowed then
call DisplayTimedTextToPlayer(GetOwningPlayer(u), 0, 0, 20, GetUnitName(u)+" can currently not use Talent.")
endif
return allowed
endfunction
function TalentStringsInit takes nothing returns nothing
//Customiceable Strings of Talent
//Customiceable Strings of TalentPreMadeChoice
set udg_TalentStrings[1] = "Learn:" //TalentChoiceCreateAddSpells First Word.
set udg_TalentStrings[2] = "\n" //TalentChoiceCreateAddSpells First Seperator.
set udg_TalentStrings[3] = ", " //TalentChoiceCreateAddSpells Further Seperator.
set udg_TalentStrings[9] = "" //TalentChoiceCreateImproveSpell Prefix
set udg_TalentStrings[10] = ", Manacost-Change" //TalentChoiceCreateImproveSpell ManaCost-Change
set udg_TalentStrings[11] = ", Cooldown-Change" //TalentChoiceCreateImproveSpell Cooldown-Change
set udg_TalentStrings[15] = "Weapon: " //TalentChoiceCreateImproveWeapon PreFix
set udg_TalentStrings[16] = ", Damage-Bonus " //TalentChoiceCreateImproveWeapon Damage-Bonus
set udg_TalentStrings[17] = ", AttackSpeedCooldown-Bonus " //TalentChoiceCreateImproveWeapon AttackSpeedCooldown-Bonus
set udg_TalentStrings[20] = "" //TalentChoiceCreateSustain Prefix
set udg_TalentStrings[21] = "Life-Bonus " //TalentChoiceCreateSustain Life-Bonus
set udg_TalentStrings[22] = ", Mana-Bonus " //TalentChoiceCreateSustain Mana-Bonus
set udg_TalentStrings[23] = ", Armor-Bonus " //TalentChoiceCreateSustain Armor-Bonus
set udg_TalentStrings[28] = "" //TalentChoiceCreateStats Prefix
set udg_TalentStrings[29] = "Str-Bonus" //TalentChoiceCreateStats Str-Bonus
set udg_TalentStrings[30] = ", Agi-Bonus" //TalentChoiceCreateStats Agi-Bonus
set udg_TalentStrings[31] = ", Int-Bonus" //TalentChoiceCreateStats Agi-Bonus
set udg_TalentStrings[100] = "Unlearn choosen Talents from this Level and higher Levels.|nCan also be used to relearn Talents from this level upwards." //Tooltip of Unlearn Button
set udg_TalentStrings[101] = "(Un)Learn" //Text of Reset-Button
set udg_TalentStrings[102] = "Talent Level: " //TalentBox Titel Prefix
set udg_TalentStrings[103] = "Show Talent" //Text of ShowTalentButton
set udg_TalentStrings[104] = "No Talent User" //No Talent User
set udg_TalentStrings[105] = "Group Mode" //TooltipGroupModeHead
set udg_TalentStrings[106] = "During GroupMode all selected Units using the same Talent and with the same amount of selections done, will do picks/Unlearn/Relearn together.|n|nClick to disable Group Mode." //TooltipGroupModeText
set udg_TalentStrings[107] = "ui/widgets/battlenet/bnet-mainmenu-customteam-up" //TooltipGroupModeIcon
set udg_TalentStrings[108] = "Single Mode" //TooltipSingleModeHead
set udg_TalentStrings[109] = "Only the selected Unit will do picks, unlearns.|n|nClick to enable Group Mode" //TooltipSingleModeText
set udg_TalentStrings[110] = "ui/widgets/battlenet/bnet-mainmenu-customteam-disabled" //TooltipSingleModeIcon
endfunction
//===========================================================================
//API:
//===========================================================================
// function TalentMacroDo takes unit u, string s returns nothing
//executes a bunch of Picks for Unit u.
//"-U123" ->Unlearn all, Pick 1, Pick 2, Pick 3
//"-112" -> Pick 1, Pick 1, Pick 2, s has to start with "-"
//Each done action will evoke events/triggers.
// function TalentGetMacro takes unit u returns nothing
// returns the text to be used inside TalentMacroDo to pick the current Picks.
// the use of this function is to save Talentpicks in files.
// function TalentAddSelection takes unit u returns nothing
//Test if u gets a new Tier to pick from, done automatically in: udg_TalentTrigger[TT_LevelUp()] (LevelUp).
// function TalentAdd2Hero takes unit u returns nothing
// can be used to force talentDetetcion
//do not use it more than once for one unit.
// function TalentResetDo takes unit u, integer amountOfResets returns nothing
//This will undo the last amountOfResets done choices of unit u. Each Time calling the needed "udg_TalentChoiceOnReset" and throwing an event.
//An OnLearn Requiers an onReset doing the opposite, if one wants to use this feature.
//call it with 1 to remove the last done choice.
//To undo all done Choices of an unit, call it with an absurd high number.
// function TalentPickDo takes unit u, integer buttonNr returns nothing
//unit u learns choice buttonNr of currentSelection Tier.
//will only work if the hasSelection flag is set.
//buttonNr is expected to be 1 to TalentBoxOptionMaxCount() including both
//buttonNr also should not exceed TalentTierGetChoiceCount of the current Tier.
// function TalentGetUnitTypeId takes unit u returns integer
//wrapper for TalentGetUsedHeroTypeId
// function TalentGetUsedHeroTypeId takes integer heroTypeId returns integer
//Returns the unitTypeId used in Talent by that unit.
//use it, if you used TalentHeroSetCopy in your map. If you did not use copy you can simple use GetUnitTypeId when using TalentHero-API
//===========================================================================
//TalentHero API
//===========================================================================
// TalentHero makes reading/writing HeroSheets(TalentTrees) more simple. This is not for data of existing units its the plan.
// function TalentHeroSetCopy takes integer result, integer copyOrigin returns nothing
//units from type result will use the setup from copyOrigin
//also supports copy copy...
//TalentHeroSetCopy is quite important, if an hero can morph
//reading further data from result is disabled
// function TalentHeroTierCreate takes integer heroTypeId, integer level returns integer
//Create a new Tier for that hero at level.
//level should be 0 or bigger.
//returns udg_TalentTierLast
// function TalentHeroGetTier takes integer heroTypeId, integer level returns integer
//get the tier at that level for heroTypeId
//0 = no tier
// function TalentHeroSetTier takes integer heroTypeId, integer level, integer tier returns nothing
//heroTypeId will use at level given tier.
// function TalentHeroGetFinalTier takes integer heroTypeId returns integer
// function TalentHeroSetFinalTier takes integer heroTypeId, integer level returns nothing
//Units picking a choice of the tier added at level will be considered as Finished with their Talents.
//this one has to be used to make a heroTypeId useable for talent.
// function TalentHeroLevel2SelectionIndex takes integer heroTypeId, integer level returns integer
//Tells you which selectionIndex that level would be selected as.
//Valid is 0 to x
//Returns -1 if the level does not have a tier for that heroTypeId and therefore wouldn't be a valid selectionindex
//===========================================================================
//TalentUnit API
//===========================================================================
//Access Hashtable Data for active units
//function TalentUnitGetSelectionsDoneCount takes integer unitHandle returns integer
// How many selections this unit has done?
//function TalentUnitGetSelectionButtonUsed takes integer unitHandle, integer selectionIndex returns integer
// ButtonNr used, 1 to TalentBoxOptionMaxCount() (included)
//function TalentUnitGetSelectionLevel takes integer unitHandle, integer selectionIndex returns integer
// level of that selectionDone (1 to TalentUnitGetSelectionsDoneCount)
//function TalentUnitGetChoiceDone takes integer unitHandle, integer selectionIndex returns integer
// arrayIndex of the choice of that selectionDone
//function TalentUnitGetCurrentTier takes integer unitHandle returns integer
// the tier from which unit can pick from
//function TalentUnitGetCurrentTierLevel takes integer unitHandle returns integer
// from which level the tier the unit picks currently is from?
//function TalentUnitGetTalentProgressLevel takes integer unitHandle returns integer
//function TalentUnitHasChoice takes integer unitHandle returns boolean
//===========================================================================
//TalentTier API
//===========================================================================
// function TalentTierCreate takes nothing returns integer
//creates a new Tier
//a Tier is an collection of choices from which the user can pick one.
//returns udg_TalentTierLast the ArrayIndex of the tier
// function TalentTierAddChoice takes integer tier, integer choice returns nothing
//Adds a Choice to the tier, tier is the ArrayIndex of the tier choice the ArrayIndex of Choice.
// function TalentTierGetChoiceCount takes integer tier returns integer
//returns the amount of choices added to this tier
// function TalentTierGetChoice takes integer tier, integer index returns integer
//returns the choice index (0 means no choice was added yet)
//will return the to this tier last added choice if index is to high
//expects index > 0
//===========================================================================
//TalentChoice API
//===========================================================================
// function TalentChoiceCreate takes code onLearn, code onReset returns integer
//if you do not need the function binding for this choice, you could use "set udg_TalentChoiceLast = udg_TalentChoiceLast + 1" instead.
//Creates a choice and 1 Trigger for each OnLearn/OnReset, if they are not null.
//returns the ArrayIndex of the Choice
//afterwards one should set udg_TalentChoiceText[returnedValue], udg_TalentChoiceHead[returnedValue], udg_TalentChoiceIcon[returnedValue]
// function TalentChoiceCreateEx takes code onLearn, code onReset returns integer
//Wrapper creating a choice and adding it to the last Created Tier
//use this over TalentChoiceCreate and TalentTierAddChoice in most cases.
//returns the choice ArrayIndex.
// function TalentChoiceCreateAddSpells takes code onLearn, code onReset, string abilityCodes returns integer
// creates a new choice, add it to the last created Tier. This choice will give all abilities mentioned
// This will also set Text to: GetLocalizedString("COLON_SPELLS") spellA, spellB, ...
// Expected Format TalentChoiceCreateAddSpells(function XLearn, function XReset, "AHbz,AHwe,AHab,AHmt")
// returns the new choice
// function TalentChoiceCreateAddSpellsSimple takes string abilityCodes returns integer
// TalentChoiceCreateAddSpells with null for callBacks
// function TalentChoiceCreateReplaceSpell takes integer oldSpell, integer newSpell returns integer
// function TalentChoiceCreateTrigger takes trigger onLearn, trigger onReset returns integer
// function TalentChoiceCreateTriggerEx takes trigger onLearn, trigger onReset returns integer
//like TalentChoiceCreateEx
// function TalentChoiceCreateAll takes string head, string text, string icon, code onLearn, code onReset returns integer
//creates the Choice with the wanted data
// function TalentChoiceCreateAllTrigger takes string head, string text, string icon, trigger onLearn, trigger onReset returns integer
// function TalentChoiceCreateAllEx takes string head, string text, string icon, code onLearn, code onReset returns integer
//Create and Add
// function TalentChoiceCreateAllTriggerEx takes string head, string text, string icon, trigger onLearn, trigger onReset returns integer
// function TalentChoiceAddAbility takes integer choice, integer abilityId returns nothing
//Add abilityId to choiceIndex
//one can attach multiple abilities to one choice.
//one can attach the same ability multiple times to the same choice to increase its level.
// ^^ needs function TalentImproveAbilities to return true
// function TalentChoiceAddAbilityEx takes integer abilityId returns nothing
//Add to last created Choice
// function TalentChoiceAddSpells takes integer choice, string abilityCodes returns nothing
//Add many abilities to this choice in one String
//call TalentChoiceAddSpells(choice, "AHbz,AHwe,AHab,AHmt")
// function TalentChoiceAddSpellsEx takes string abilityCodes returns nothing
//Add to last created Choice
// function TalentChoiceReplaceAbility takes integer choice, integer oldAbility, integer newAbility returns nothing
//TalentImproveAbilities(true)oldAbility - 1 Level and newAbility + 1 Level
//TalentImproveAbilities(false) removed oldAbility, add newAbility set level of newAbility to level of oldAbility
// function TalentChoiceGetAbilityCount takes integer choice returns integer
//===========================================================================
//Variables inside Events and Code Binding:
//===========================================================================
// udg_Talent__Unit = the unit doing the choice
// udg_Talent__UnitCode = the unitCode the unit is using
// udg_Talent__Choice = the arrayIndex of the selected choice.
// udg_Talent__Level = the level from which this choice/Tier is.
// udg_Talent__Tier = the arrayIndex of the tier from which the choice is.
// udg_Talent__Button = the Index of the Button used, 1 to TalentBoxOptionMaxCount().
// , this variable is needed for event based Talent usage.
//===========================================================================
//Event:
//===========================================================================
// To identyfy a choice in an Event use HeroType, udg_Talent__Level and udg_Talent__Button.
// Inside trigger condition check for heroType, to use the correct talent tree for this unit.
// UnitType of udg_Talent__Unit equal (==) "wanted Type"
// Now create ifs one for each udg_Talent__Level (it is the level of the tier picked from).
// Inside this ifs now do a check: udg_Talent__Button equal (==) 1 -> yes, do actions of Level x Button 1
// Create another one with udg_Talent__Button equal (==) 2 -> yes, do actions of Level x, Button 2.
// You can skip Button Ifs not beeing used for that hero-Class on that Level.
// udg_Talent__Event
// = 1 => on Choice.
// after the Auotskills are added
// = 2 => Tier aviable, does only call when there is no choice for this hero yet.
// = 3 => Finished all choices of its hero Type.
// = -1 => on Reset for each choice reseted.
// before the autoskills are removed
// Events can be indivudal (de)aktivaded inside "Definitions"
//===========================================================================
//Code Binding
//===========================================================================
// One can directly bind functions/triggers to an choice, 1 for picking the choice, 1 for reseting the choice.
// Talent allways uses triggers, but one can let the triggers be generated by only giving the functions.
// udg_TalentChoiceOnLearn - Executes when Picked
// udg_TalentChoiceOnReset - Executes when Reset, should do the opposite of OnLearn, if one wants to use the reset feature.
// - if there is no reset in your project, just skip reset.
//===========================================================================
//Tier and Choice variables
//===========================================================================
// TalentChoice is a simple rising Array, each index represents a new choice.
// udg_TalentChoiceLast - last Index used from TalentChoice
// udg_TalentChoiceHead - the headLine shown
// udg_TalentChoiceText - the mainTooltip shown
// udg_TalentChoiceIcon - the image shown
// udg_TalentChoiceOnLearn - trigger
// udg_TalentChoiceOnReset - trigger
// TalentChoice Abilities are Saved in the hash.
// With the used ArrayIndex as main Key.
// rising Positive sec Keys are the abilities gained
// falling negative sec Keys are the abilities replaced.
//=====
// Tier is managed inside the hash.
// used tiers are from 1 to udg_TalentTierLast. (therefore you could also use arrayIndexes)
// Tiers use negative main Keys, (Background Info).
//===========================================================================
//TalentSpells
//===========================================================================
// udg_TalentSpellsPrefix - text displayed before the choicesHead, if a choice uses this Button.
// udg_TalentSpellsSufix - text displayed after choicesHead
// The displayed HeadLine is ButtonPrefix + choiceHead + ButtonSufix
//===========================================================================
//udg_TalentTrigger is an array of Triggers controlling this system.
// udg_TalentTrigger[TT_LevelUp()] = On Levelup| It checks for new Talent Tiers.
// udg_TalentTrigger[TT_AutoDetectUnits()] = EnterPlayable Map Event
// , if you alreay have a EnterPlayable Map trigger you should let "constant function TalentAutoDetectNewUser" return false
// , also you then have to manualy inser talent users by:
// , if TalentHas(unit) then
// call TalentAdd2Hero(unit)
// endif
// udg_TalentTrigger[TT_SelectUnit()] = Make Talent UI (In)Visbile; Event On Unit Selection.
// you could disable all TalentTriggers[0 to 4], if you do not use reset and all Choices are done.
// udg_TalentReset = when called resets udg_Talent__Unit and calls for each choice undone the reset event(-1).
// Reset uses following values
// udg_Talent__ResetAmount = amount of talents undone starting from last selected. (use an absurd high number to undo all talents of a hero)
// udg_Talent__Unit = the hero losing talents.
//===========================================================================
//udg_TalentStrings contain all builtIn Strings which can/should be localiced used by This System.
//===========================================================================
//TT = TalentTrigger, ArrayIndexes
constant function TT_LevelUp takes nothing returns integer
return 1
endfunction
constant function TT_AutoDetectUnits takes nothing returns integer
return 2
endfunction
constant function TT_SelectUnit takes nothing returns integer
return 3
endfunction
constant function TT_DeathTrigger takes nothing returns integer
return 4
endfunction
//Hashtable
//unit handleId
constant function TalentHashIndex_LastLevel takes nothing returns integer
return -1
endfunction
constant function TalentHashIndex_LevelOfLastChoice takes nothing returns integer
return -2
endfunction
constant function TalentHashIndex_CurrentChoice takes nothing returns integer
return -3
endfunction
constant function TalentHashIndex_CurrentChoiceLevel takes nothing returns integer
return -4
endfunction
constant function TalentHashIndex_SelectionsDone takes nothing returns integer
return -5
endfunction
constant function TalentHashIndex_HasChoice takes nothing returns integer
return 0
endfunction
//UnitTypeId
// 0 to x choice containers
// x = last talent(true)
constant function TalentHashIndex_DataCopyData takes nothing returns integer
return -6 // this needs to be not colide with the unit HandleId constants
endfunction
constant function TalentHashIndex_FinalTierLevel takes nothing returns integer
return -3
endfunction
//TalentSpells
// at 0 they save its array index.
//===========================================================================
function TalentGetUsedHeroTypeId takes integer heroTypeId returns integer
local integer copyId = LoadInteger(udg_TalentHash, heroTypeId, TalentHashIndex_DataCopyData())
if copyId != 0 then
return TalentGetUsedHeroTypeId(copyId)
else
return heroTypeId
endif
endfunction
function TalentGetUnitTypeId takes unit u returns integer
if HaveSavedInteger(udg_TalentHash, GetHandleId(u), TalentHashIndex_DataCopyData()) then
return TalentGetUsedHeroTypeId(GetHandleId(u))
endif
return TalentGetUsedHeroTypeId(GetUnitTypeId(u))
endfunction
//TalentJ
//Handleing Choice / Tier Creations
function TalentChoiceCreateTrigger takes trigger onLearn, trigger onReset returns integer
set udg_TalentChoiceLast = udg_TalentChoiceLast + 1
set udg_TalentChoiceOnLearn[udg_TalentChoiceLast] = onLearn
set udg_TalentChoiceOnReset[udg_TalentChoiceLast] = onReset
return udg_TalentChoiceLast
endfunction
function TalentChoiceCreate takes code onLearn, code onReset returns integer
set udg_TalentChoiceLast = udg_TalentChoiceLast + 1
if onLearn != null then
set udg_TalentChoiceOnLearn[udg_TalentChoiceLast] = CreateTrigger()
call TriggerAddAction(udg_TalentChoiceOnLearn[udg_TalentChoiceLast], onLearn)
endif
if onReset != null then
set udg_TalentChoiceOnReset[udg_TalentChoiceLast] = CreateTrigger()
call TriggerAddAction(udg_TalentChoiceOnReset[udg_TalentChoiceLast], onReset)
endif
return udg_TalentChoiceLast
endfunction
function TalentChoiceCreateAll takes string head, string text, string icon, code onLearn, code onReset returns integer
call TalentChoiceCreate(onLearn, onReset)
set udg_TalentChoiceHead[udg_TalentChoiceLast] = head
set udg_TalentChoiceText[udg_TalentChoiceLast] = text
set udg_TalentChoiceIcon[udg_TalentChoiceLast] = icon
return udg_TalentChoiceLast
endfunction
function TalentChoiceCreateAllTrigger takes string head, string text, string icon, trigger onLearn, trigger onReset returns integer
call TalentChoiceCreateTrigger(onLearn, onReset)
set udg_TalentChoiceHead[udg_TalentChoiceLast] = head
set udg_TalentChoiceText[udg_TalentChoiceLast] = text
set udg_TalentChoiceIcon[udg_TalentChoiceLast] = icon
return udg_TalentChoiceLast
endfunction
function TalentTierCreate takes nothing returns integer
set udg_TalentTierLast = udg_TalentTierLast + 1
return udg_TalentTierLast
endfunction
function TalentTierAddChoice takes integer tier, integer choice returns nothing
local integer count = LoadInteger(udg_TalentHash, -tier, 0) + 1
call SaveInteger(udg_TalentHash, -tier, count, choice)
call SaveInteger(udg_TalentHash, -tier, 0, count)
endfunction
function TalentTierGetChoiceCount takes integer tier returns integer
if tier > 0 then //tiers are saved in the negative side, convert positive calls in negative ones
return LoadInteger(udg_TalentHash, -tier, 0)
else
return LoadInteger(udg_TalentHash, tier, 0)
endif
endfunction
function TalentTierGetChoice takes integer tier, integer index returns integer
if tier > 0 then //tiers are saved in the negative side, convert positive calls in negative ones
return LoadInteger(udg_TalentHash, -tier, index)
else
return LoadInteger(udg_TalentHash, tier, index)
endif
endfunction
function TalentChoiceCreateEx takes code onLearn, code onReset returns integer
local integer choice = TalentChoiceCreate(onLearn, onReset)
call TalentTierAddChoice(udg_TalentTierLast, choice)
return choice
endfunction
function TalentChoiceCreateTriggerEx takes trigger onLearn, trigger onReset returns integer
local integer choice = TalentChoiceCreateTrigger(onLearn, onReset)
call TalentTierAddChoice(udg_TalentTierLast, choice)
return choice
endfunction
function TalentChoiceCreateAllEx takes string head, string text, string icon, code onLearn, code onReset returns integer
local integer choice = TalentChoiceCreateAll(head, text, icon, onLearn, onReset)
call TalentTierAddChoice(udg_TalentTierLast, choice)
return choice
endfunction
function TalentChoiceCreateAllTriggerEx takes string head, string text, string icon, trigger onLearn, trigger onReset returns integer
local integer choice = TalentChoiceCreateAllTrigger(head, text, icon, onLearn, onReset)
call TalentTierAddChoice(udg_TalentTierLast, choice)
return choice
endfunction
function TalentChoiceGetAbilityCount takes integer choice returns integer
return LoadInteger(udg_TalentHash, choice, 0)
endfunction
function TalentChoiceAddAbility takes integer choice, integer abilityId returns nothing
local integer count = LoadInteger(udg_TalentHash, choice, 0) + 1
call SaveInteger(udg_TalentHash, choice, count, abilityId)
call SaveInteger(udg_TalentHash, choice, 0, count)
endfunction
function TalentChoiceAddAbilityEx takes integer abilityId returns nothing
call TalentChoiceAddAbility(udg_TalentChoiceLast, abilityId)
endfunction
function TalentChoiceReplaceAbility takes integer choice, integer oldAbility, integer newAbility returns nothing
local integer count = LoadInteger(udg_TalentHash, choice, 0) + 1
call SaveInteger(udg_TalentHash, choice, count, newAbility)
call SaveInteger(udg_TalentHash, choice, -count, oldAbility)
call SaveInteger(udg_TalentHash, choice, 0, count)
endfunction
function TalentChoiceReplaceAbilityEx takes integer oldAbility, integer newAbility returns nothing
call TalentChoiceReplaceAbility(udg_TalentChoiceLast, oldAbility, newAbility)
endfunction
function TalentChoiceAddSpells takes integer choice, string abilityCodes returns nothing
static if LIBRARY_Ascii then
local integer startIndex = 0
local integer skillCode = 1
loop
exitwhen startIndex + 3 >= StringLength(abilityCodes)
set skillCode = S2A(SubString(abilityCodes, startIndex, startIndex + 4))
call TalentChoiceAddAbility(choice, skillCode)
set startIndex = startIndex + 5
endloop
else
call BJDebugMsg("TalentChoiceAddSpells requires LIBRARY Ascii")
endif
endfunction
function TalentChoiceAddSpellsEx takes string abilityCodes returns nothing
call TalentChoiceAddSpells(udg_TalentChoiceLast, abilityCodes)
endfunction
function TalentChoiceCreateAddSpells takes code onLearn, code onReset, string abilityCodes returns integer
local integer choice = TalentChoiceCreateEx(onLearn, onReset)
local integer index = 0
local integer abiCode = 0
call TalentChoiceAddSpells(choice, abilityCodes)
set udg_TalentChoiceText[choice] = GetLocalizedString("COLON_SPELLS")
loop
set index = index + 1
exitwhen index > TalentChoiceGetAbilityCount(choice)
set abiCode = LoadInteger(udg_TalentHash, choice, index)
if index == 1 then
set udg_TalentChoiceText[choice] = udg_TalentChoiceText[choice] + " " + GetObjectName(abiCode) + "|r"
else
set udg_TalentChoiceText[choice] = udg_TalentChoiceText[choice] + ", " + GetObjectName(abiCode) + "|r"
endif
endloop
return choice
endfunction
function TalentChoiceCreateAddSpellsSimple takes string abilityCodes returns integer
return TalentChoiceCreateAddSpells(null, null, abilityCodes)
endfunction
function TalentChoiceCreateReplaceSpell takes integer oldSpell, integer newSpell returns integer
call TalentChoiceCreateEx(null,null)
call TalentChoiceReplaceAbility(udg_TalentChoiceLast, oldSpell, newSpell)
return udg_TalentChoiceLast
endfunction
//TalentHero
//Access data by UnitTypeId
function TalentHeroTierCreate takes integer heroTypeId, integer level returns integer
call SaveInteger(udg_TalentHash, heroTypeId, level, TalentTierCreate())
return udg_TalentTierLast
endfunction
function TalentHeroGetTier takes integer heroTypeId, integer level returns integer
return LoadInteger(udg_TalentHash, heroTypeId, level)
endfunction
function TalentHeroSetTier takes integer heroTypeId, integer level, integer tier returns nothing
call SaveInteger(udg_TalentHash, heroTypeId, level, tier)
endfunction
function TalentHeroGetFinalTier takes integer heroTypeId returns integer
return LoadInteger(udg_TalentHash, heroTypeId, TalentHashIndex_FinalTierLevel())
endfunction
function TalentHeroSetFinalTier takes integer heroTypeId, integer level returns nothing
call SaveInteger(udg_TalentHash, heroTypeId, TalentHashIndex_FinalTierLevel(), level)
endfunction
function TalentHeroSetCopy takes integer result, integer copyOrigin returns nothing
call SaveInteger(udg_TalentHash, result, TalentHashIndex_DataCopyData(), copyOrigin)
endfunction
function TalentHeroLevel2SelectionIndex takes integer heroTypeId, integer level returns integer
local integer i = 0
local integer count = 0
if TalentHeroGetTier(heroTypeId, level) == 0 then //The level has no tier?
return -1
endif
loop
exitwhen i > level
if TalentHeroGetTier(heroTypeId, i) != 0 then
set count = count + 1
endif
set i = i + 1
endloop
return count
endfunction
//TalentUnit
//Talent-Data of an existing unit
function TalentUnitGetSelectionsDoneCount takes integer unitHandle returns integer
return LoadInteger(udg_TalentHash, unitHandle, TalentHashIndex_SelectionsDone())
endfunction
function TalentUnitGetSelectionButtonUsed takes integer unitHandle, integer selectionIndex returns integer
return LoadInteger(udg_TalentHash, unitHandle, selectionIndex)
endfunction
function TalentUnitGetSelectionLevel takes integer unitHandle, integer selectionIndex returns integer
return LoadInteger(udg_TalentHash, unitHandle, StringHash("SelectionLevel"+I2S(selectionIndex)))
endfunction
function TalentUnitGetChoiceDone takes unit u, integer selectionIndex returns integer
local integer uId = GetHandleId(u)
return TalentTierGetChoice(TalentHeroGetTier(TalentGetUnitTypeId(u), TalentUnitGetSelectionLevel(uId, selectionIndex)), TalentUnitGetSelectionButtonUsed(uId, selectionIndex))
endfunction
function TalentUnitGetCurrentTier takes integer unitHandle returns integer
return LoadInteger(udg_TalentHash, unitHandle, TalentHashIndex_CurrentChoice())
endfunction
function TalentUnitGetCurrentTierLevel takes integer unitHandle returns integer
return LoadInteger(udg_TalentHash, unitHandle, TalentHashIndex_CurrentChoiceLevel())
endfunction
function TalentUnitGetTalentProgressLevel takes integer unitHandle returns integer
return LoadInteger(udg_TalentHash, unitHandle, TalentHashIndex_LevelOfLastChoice())
endfunction
function TalentUnitHasChoice takes integer unitHandle returns boolean
return LoadBoolean(udg_TalentHash, unitHandle, TalentHashIndex_HasChoice())
endfunction
//Talent
//=========
function TalentHas takes unit u returns boolean
return HaveSavedInteger(udg_TalentHash, TalentGetUnitTypeId(u), TalentHashIndex_FinalTierLevel())
endfunction
//has the general Choice UI or hero specific Choice UI.
function TalentHasCondition takes nothing returns boolean
return TalentHas(GetTriggerUnit())
endfunction
function TalentAddSelection takes unit u returns nothing
local integer tierGained
local integer heroTypeId = TalentGetUnitTypeId(u)
local integer currentLevel = IMaxBJ(GetHeroLevel(u), GetUnitLevel(u))
local integer uId = GetHandleId(u)
local player owner
//Start from the last skill selection added.
local integer loopA = TalentUnitGetTalentProgressLevel(uId)
// Only show 1 SelectionContainer at the same time.
if TalentUnitHasChoice(uId) then
return
endif
set owner = GetOwningPlayer(u)
loop
exitwhen loopA > currentLevel
set tierGained = TalentHeroGetTier(heroTypeId, loopA)
if tierGained != 0 then
//Remember the container gained
call SaveInteger(udg_TalentHash, uId, TalentHashIndex_CurrentChoice(), tierGained)
//Remember the level of the container gained
call SaveInteger(udg_TalentHash, uId, TalentHashIndex_CurrentChoiceLevel(), loopA)
//Mark unit to have a selection.
call SaveBoolean(udg_TalentHash, uId, TalentHashIndex_HasChoice(), true)
//Remember this Level to leave lower levels out for further selections checks.
call SaveInteger(udg_TalentHash, uId,TalentHashIndex_LevelOfLastChoice(),loopA +1)
if TalentThrowEventAvailable then //Throw Selection Event
set udg_Talent__Choice = 0
set udg_Talent__Unit = u
set udg_Talent__UnitCode = heroTypeId
set udg_Talent__Level = loopA
set udg_Talent__Tier = tierGained
set udg_Talent__Event = 0
set udg_Talent__Event = 2
set udg_Talent__Event = 0
endif
// call TalentBoxSetTier(loopA, tierGained, owner)
set owner = null
return
endif
set loopA = loopA + 1
endloop
//if this part of code is reached there is no choice avaible
//Remember this Level to leave lower levels out for further selections checks.
call SaveInteger(udg_TalentHash, uId,TalentHashIndex_LevelOfLastChoice(),currentLevel + 1)
set owner = null
endfunction
function TalentAddSkill takes unit u, integer skillGained, integer newLevel returns nothing
local integer skillGainedLevel = GetUnitAbilityLevel(u, skillGained)
if skillGainedLevel == 0 then //Already got skillGained?
call UnitAddAbility(u, skillGained)
call UnitMakeAbilityPermanent(u, true, skillGained)
call SetUnitAbilityLevel(u, skillGained, newLevel)
elseif TalentImproveAbilities then//Can upgrade Levels?
call SetUnitAbilityLevel(u, skillGained, skillGainedLevel + 1)
endif
endfunction
function TalentRemoveSkill takes unit u, integer skillLost returns nothing
local integer skillLostLevel = GetUnitAbilityLevel(u, skillLost)
if TalentImproveAbilities and skillLostLevel > 1 then //Can Decrease Level?
set skillLostLevel = skillLostLevel - 1
call SetUnitAbilityLevel(u, skillLost, skillLostLevel)
else
call UnitRemoveAbility(u, skillLost)
endif
endfunction
function TalentReplaceSkill takes unit u, integer skillReplaced, integer skillGained returns nothing
local integer skillReplacedLevel = GetUnitAbilityLevel(u, skillReplaced)
if not TalentReplacedAbilityRequiered or skillReplacedLevel != 0 then
call TalentRemoveSkill(u, skillReplaced)
if skillGained != 0 then
call TalentAddSkill(u, skillGained, skillReplacedLevel)
endif
endif
endfunction
function TalentPickDo takes unit u, integer buttonNr returns nothing
local integer uId = GetHandleId(u)
local integer heroTypeId = TalentGetUnitTypeId(u)
local integer tier = TalentUnitGetCurrentTier(uId)
local integer tierLevel = TalentUnitGetCurrentTierLevel(uId)
local integer selectionsDone = TalentUnitGetSelectionsDoneCount(uId) + 1
local integer choiceIndex = TalentTierGetChoice(tier, buttonNr)
local integer skillGained
local integer skillReplaced
local integer loopB = TalentChoiceGetAbilityCount(choiceIndex)
if not TalentUseCondition(u) then
return
endif
if not TalentUnitHasChoice(uId) or choiceIndex == 0 then //Requiers to have a Choice
return
endif
loop //Load all saved Abilities and add/improve them to the unit
exitwhen loopB == 0
set skillGained = LoadInteger(udg_TalentHash, choiceIndex, loopB)
set skillReplaced = LoadInteger(udg_TalentHash, choiceIndex, -loopB)
if skillReplaced != 0 then //Replaces?
call TalentReplaceSkill(u, skillReplaced, skillGained)
else
call TalentAddSkill(u, skillGained,1)
endif
set loopB = loopB - 1
endloop
//Execute OnLearn
set udg_Talent__Unit = u
set udg_Talent__UnitCode = heroTypeId
set udg_Talent__Button = buttonNr
set udg_Talent__Choice = choiceIndex
set udg_Talent__Tier = tier
set udg_Talent__Level = tierLevel
static if LIBRARY_TalentTasStats then
call TalentTasStatsAdd(u, choiceIndex)
endif
call TriggerExecute(udg_TalentChoiceOnLearn[choiceIndex])
if TalentThrowEventPick then
//Throw Selection Event
set udg_Talent__Event = 0
set udg_Talent__Event = 1
set udg_Talent__Event = 0
endif
//Save Choices
//call SaveInteger(udg_TalentHash, uId, selectionsDone, choiceIndex) //Save the picked ChoiceIndex
call SaveInteger(udg_TalentHash, uId, selectionsDone, buttonNr) //Save the picked ButtonIndex
call SaveInteger(udg_TalentHash, uId, TalentHashIndex_SelectionsDone(), selectionsDone)
call SaveInteger(udg_TalentHash, uId, StringHash("SelectionLevel"+I2S(selectionsDone)), tierLevel)
//Unmark having a selection.
call SaveBoolean(udg_TalentHash, uId, TalentHashIndex_HasChoice(), false)
//Last choice for this heroType?
if TalentHeroGetFinalTier(heroTypeId) == tierLevel then
//Throw Finish Choices Event.
if TalentThrowEventFinish then
set udg_Talent__Event = 0
set udg_Talent__Event = 3
set udg_Talent__Event = 0
endif
else
//Check for further choices.
call TalentAddSelection(u)
endif
set u = null
endfunction
function TalentLevelUpSimple takes nothing returns nothing
call TalentAddSelection(GetTriggerUnit())
endfunction
function TalentAdd2Hero takes unit u returns nothing
local integer uId = GetHandleId(u)
if not IsUnitInGroup(u, udg_TalentUser) then
call GroupAddUnit(udg_TalentUser, u)
endif
call TalentAddSelection(u)
endfunction
function TalentAutoOnEnterMap takes nothing returns nothing
call TalentAdd2Hero(GetTriggerUnit())
endfunction
function TalentResetDo takes unit u, integer amountOfResets returns nothing
local integer uId
local integer heroTypeId
local integer selectionsDone
local integer skillGained
local integer skillReplaced
local integer choice
local integer level
local integer loopB = 0
local integer customUI
local integer tier
local integer spellNr
local boolean isUsingBook
//stop nullpointer.
if u == null then
return
endif
if not TalentUseCondition(u) then
return
endif
// reset less then 1 does not make sense.
if amountOfResets < 1 then
return
endif
set uId = GetHandleId(u)
set heroTypeId = TalentGetUnitTypeId(u)
set selectionsDone = TalentUnitGetSelectionsDoneCount(uId)
//No selections done -> skip the rest.
if selectionsDone == 0 then
return
endif
set udg_Talent__Unit = u
set udg_Talent__UnitCode = heroTypeId
//Remove Autoadded Skills
loop
set level = TalentUnitGetSelectionLevel(uId, selectionsDone)
set tier = TalentHeroGetTier(heroTypeId, level)
set spellNr = TalentUnitGetSelectionButtonUsed(uId, selectionsDone)
set choice = TalentTierGetChoice(tier, spellNr)
set udg_Talent__Choice = choice
set udg_Talent__Tier = tier
set udg_Talent__Level = level
set udg_Talent__Button = spellNr
static if LIBRARY_TalentTasStats then
call TalentTasStatsRemove(u, choice)
endif
if TalentThrowEventReset then //Throw a event that this choice is going to be lost.
set udg_Talent__Event = 0
set udg_Talent__Event = -1
set udg_Talent__Event = 0
endif
set loopB = TalentChoiceGetAbilityCount(choice)
loop //Load all saved Abilities and add/improve them to the unit
exitwhen loopB == 0
set skillGained = LoadInteger(udg_TalentHash, choice, loopB)
set skillReplaced = LoadInteger(udg_TalentHash, choice, -loopB)
if skillReplaced != 0 then //Replaces?
call TalentReplaceSkill(u, skillGained, skillReplaced)
else
call TalentRemoveSkill(u, skillGained)
endif
set loopB = loopB - 1
endloop
call TriggerExecute(udg_TalentChoiceOnReset[choice])
set selectionsDone = selectionsDone - 1
set amountOfResets = amountOfResets - 1
exitwhen selectionsDone <= 0 or amountOfResets <= 0
endloop
//Forget this unit?
if selectionsDone <= 0 then
//Save Level Progress of talents to the choice Level.
call SaveInteger(udg_TalentHash, uId, TalentHashIndex_LevelOfLastChoice(), 0)
//Choices Done
call SaveInteger(udg_TalentHash, uId,TalentHashIndex_SelectionsDone(), 0)
call SaveBoolean(udg_TalentHash, uId,TalentHashIndex_HasChoice(), false)
//Full Reset
// call FlushChildHashtable(udg_TalentHash, uId)
else
//Partly Reset.
//Has no Choice,dat is needed to run the addChoice function.
call SaveBoolean(udg_TalentHash, uId,TalentHashIndex_HasChoice(), false)
//Save Level Progress of talents to the choice Level.
call SaveInteger(udg_TalentHash, uId, TalentHashIndex_LevelOfLastChoice(), level)
//Choices Done
call SaveInteger(udg_TalentHash, uId,TalentHashIndex_SelectionsDone(), selectionsDone)
endif
call TalentAddSelection(u)
endfunction
function TalentReset takes nothing returns nothing
call TalentResetDo(udg_Talent__Unit, udg_Talent__ResetAmount)
set udg_Talent__Unit = null
endfunction
//runs when executing the Talent <gen> trigger.
function TalentInit takes nothing returns nothing
local group g = CreateGroup()
local unit fog
local integer fogId
set udg_TalentTrigger[TT_LevelUp()] = CreateTrigger()
set udg_TalentTrigger[TT_AutoDetectUnits()] = CreateTrigger()
set udg_TalentReset = CreateTrigger()
call TriggerAddAction( udg_TalentReset, function TalentReset)
call TriggerAddAction( udg_TalentTrigger[TT_LevelUp()], function TalentLevelUpSimple)
//Get Choices on Entering Map for lvl 0/1.
if TalentAutoDetectNewUser then
call TriggerRegisterEnterRectSimple( udg_TalentTrigger[TT_AutoDetectUnits()], GetPlayableMapRect() )
endif
call TriggerAddAction( udg_TalentTrigger[TT_AutoDetectUnits()], function TalentAutoOnEnterMap)
call TriggerAddCondition( udg_TalentTrigger[TT_AutoDetectUnits()], Condition( function TalentHasCondition ))
call TriggerRegisterAnyUnitEventBJ(udg_TalentTrigger[TT_LevelUp()], EVENT_PLAYER_HERO_LEVEL)
//Add possible choices to all Units having the Talent book.
call GroupEnumUnitsInRect (g, GetPlayableMapRect(), null)
loop
set fog = FirstOfGroup(g)
exitwhen fog == null
call GroupRemoveUnit(g,fog)
if TalentHas(fog) then
call TalentAdd2Hero(fog)
endif
endloop
//cleanup
call DestroyGroup(g)
set g = null
set fog = null
call ExecuteFunc("TalentBoxInit")
call ExecuteFunc("TalentGridInit")
endfunction
function TalentMacroDo takes unit u, string s returns nothing
local string char
local integer i = 0
local integer sLength = StringLength(s)
local integer charAsInt
if not TalentUseCondition(u) then
return
endif
set char = SubString(s, 0, 1)
if char != "-" then //Invalid macro, macro has to start with "-"
return
endif
loop
exitwhen i > sLength
set char = SubString(s, i, i + 1)
if char == "U" or char == "u" then
call TalentResetDo(u, 999999)
endif
set charAsInt = S2I(char)
if charAsInt > 0 then
call TalentPickDo(u, charAsInt)
endif
set i = i + 1
endloop
endfunction
function TalentGetMacro takes unit u returns string
local string text = "-U"
local integer uId = GetHandleId(u)
local integer selectionsDone = TalentUnitGetSelectionsDoneCount(uId)
local integer i = 1
loop
exitwhen i > selectionsDone
set text = text + I2S(TalentUnitGetSelectionButtonUsed(uId, i))
set i = i + 1
endloop
return text
endfunction
private function init_function takes nothing returns nothing
set udg_TalentHash = InitHashtable( )
call ExecuteFunc("TalentStringsInit") //TalentStringsInit should run before any TalentHeroSheet was generated
call TimerStart(CreateTimer(),0,false, function TalentInit)
endfunction
endlibrary
library TalentBoxJUI uses TalentJUI
//TalentBox for Talent Jui 1.36c
//by Tasyen
globals
// public globlas can be changed during the runtime to change behaviour
//(true) When having no Choice close Talents. Happens on Levelup and picking a choice.
public boolean CloseWhenNoChoice = true
//With false the unlearn Button won't exist
//udg_TalentControlPreventReset[GetConvertedPlayerId(player)] = true will disable the reset/Relearn Button for that player
private boolean UseUnlearnButton = true
// FixedTarget (true) Talent will not change udg_TalentControlTarget[playerId]
public boolean FixedTarget = false
// OnlyOwnUnit (true) can not pick Talents for Shared Control of other player's Units.
public boolean OnlyOwnUnit = false
//MaxAmount of Options shown in the UI of one tier.
//The Buttons start with 1 and include OptionMaxCount
//One could still learn the Choice when a chat command would be provided.
private integer OptionMaxCount = 6
//Amount of LevelBoxes, if an unit got more tiers there will be a page control.
//if you want lest more boxes you might change LevelBoxSizeX & LevelBoxSizeY
private integer LevelBoxAmount = 7
//sane values are below 0.05
private real LevelBoxSizeX = 0.02
private real LevelBoxSizeY = 0.02
//Bigger Options allow bigger texts, but also take more space of the screen, which reduces the possible amount of showing options in one tier.
//XSize of an option in the TalentBox
private real OptionSizeX = 0.25
//YSize of an option in the TalentBox, shouldn't be smaller than 0.04, when using Font 0.0085
private real OptionSizeY = 0.045
//YSpace between 2 options, + values increases the space between, - values reduces they can also overlap.
private real Option2OptionGap = -0.005
//YSpace between Title and option at the top.
private real Option2TitleGap = 0.05
//YSpace between LevelBoxes and option at the bottom
private real Option2BottomGap = 0.00
private real ResetSizeX = 0.07
private real ResetSizeY = 0.025
//IconSize, should be smaller than OptionSizeY
private real OptionIconSize = 0.028
//Show the Text inside the option, excludes the Head.
public boolean OptionShowText = true
//Default Position of the TalentBox
private real PosX = 0.005
private real PosY = 0.2
private framepointtype PosType = FRAMEPOINT_BOTTOMLEFT
//The total y size varies with amount of shown options.
private real BaseSizeY = 0.02
//Default Position for the ShowTalentBoxButton
private real ShowButtonPosX = 0.0
private real ShowButtonPosY = 0.18
private real ShowButtonSizeX = 0.03
private real ShowButtonSizeY = 0.03
private framepointtype ShowButtonPosType = FRAMEPOINT_BOTTOMLEFT
private string ShowButtonIcon = "ReplaceableTextures/PassiveButtons/PASBTNStatUp.tga" // when not "" or not null then an IconButton is created.
// Display the choice in a big Tooltip
private boolean OptionHaveTooltip = true
// Tooltip Pos
private boolean OptionTooltipFixedPos = true
// Fixed
private real OptionTooltipPosX = 0.79
private real OptionTooltipPosY = 0.165
private framepointtype OptionTooltipPos = FRAMEPOINT_BOTTOMRIGHT
// Relative to TalentBox
private real OptionTooltipRelaPosX = 0.001
private real OptionTooltipRelaPosY = -0.052
private framepointtype OptionTooltipRelaPosA = FRAMEPOINT_TOPLEFT
private framepointtype OptionTooltipRelaPosB = FRAMEPOINT_TOPRIGHT
// XSize of the Tooltip
private real OptionTooltipSizeX = 0.28
// Sprite on the showButton
public boolean ShowButtonSprite = true
private real ShowButtonSpriteSize = 0.039
private string ShowButtonSpritePath = "ui/feedback/autocast/ui-modalbuttonon.mdx"
endglobals
//===========================================================================
//API:
//===========================================================================
// function TalentBoxShow takes unit target, player activePlayer returns nothing
//Shows the TalentBox for activePlayer with target as unit.
function TalentBoxHasControl takes player p, unit u returns boolean
return IsUnitOwnedByPlayer(u, p) or (not OnlyOwnUnit and GetPlayerAlliance(GetOwningPlayer(u), p, ALLIANCE_SHARED_CONTROL))
endfunction
function TalentBoxSetTier takes integer level, integer tier, player p returns nothing
local integer i = OptionMaxCount
local integer choice
local integer playerId = GetPlayerId(p)
local integer unitHandle = GetHandleId(udg_TalentControlTarget[playerId] )
local integer levelSelectionIndex = TalentHeroLevel2SelectionIndex(TalentGetUnitTypeId(udg_TalentControlTarget[playerId]), level)
local integer buttonused = TalentUnitGetSelectionButtonUsed(unitHandle, levelSelectionIndex)
local boolean enable = TalentBoxHasControl(p, udg_TalentControlTarget[playerId]) and TalentUnitGetCurrentTierLevel(unitHandle) == level and TalentUnitHasChoice(unitHandle)
local real frameSizeY = BaseSizeY + Option2TitleGap + Option2BottomGap + RMaxBJ(ResetSizeY, LevelBoxSizeY)
local real frameSizeX = OptionSizeX + 0.05
local real optionSizeY = OptionSizeY
local integer selectionDone = TalentUnitGetSelectionsDoneCount(unitHandle)
set udg_TalentControlLevelsCurrent[playerId] = level
if GetLocalPlayer() == p then
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxItemParent",0), true)
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxShowButtonSprite", 0), TalentBoxHasControl(p, udg_TalentControlTarget[playerId] ) and ShowButtonSprite and TalentUnitHasChoice(unitHandle))
loop
set choice = TalentTierGetChoice(tier, i) //Choices start with 1, buttons with 0
if choice > 0 then
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxItem", i), true)
call BlzFrameSetText(BlzGetFrameByName("TalentBoxItemTextText", i), GetLocalizedString(udg_TalentChoiceText[choice]))
call BlzFrameSetTexture(BlzGetFrameByName("TalentBoxItemIcon", i), GetLocalizedString(udg_TalentChoiceIcon[choice]), 0, true)
call BlzFrameSetText(BlzGetFrameByName("TalentBoxItemTitle", i), udg_TalentSpellsPrefix[i] + GetLocalizedString(udg_TalentChoiceHead[choice]) + udg_TalentSpellsSufix[i] )
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxItemText", i), OptionShowText)
if OptionHaveTooltip then
call BlzFrameSetText(BlzGetFrameByName("TalentBoxTooltipText", i), GetLocalizedString(udg_TalentChoiceText[choice]))
call BlzFrameSetTexture(BlzGetFrameByName("TalentBoxTooltipIcon", i), GetLocalizedString(udg_TalentChoiceIcon[choice]), 0, true)
call BlzFrameSetText(BlzGetFrameByName("TalentBoxTooltipName", i), udg_TalentSpellsPrefix[i] + GetLocalizedString(udg_TalentChoiceHead[choice]) + udg_TalentSpellsSufix[i] )
endif
//set frameSizeY = frameSizeY + optionSizeY
if i < OptionMaxCount and i > 1 then
set frameSizeY = frameSizeY + optionSizeY + Option2OptionGap
else
set frameSizeY = frameSizeY + optionSizeY
endif
else
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxItem", i), false)
endif
call BlzFrameSetEnable(BlzGetFrameByName("TalentBoxItem", i), enable)
set i = i -1
exitwhen i == 0
endloop
if buttonused > 0 and TalentUnitGetSelectionsDoneCount(unitHandle) >= levelSelectionIndex then
if not BlzFrameIsVisible(BlzGetFrameByName("TalentHighlight", 0)) then
call BlzFrameSetVisible(BlzGetFrameByName("TalentHighlight", 0),true)
endif
call BlzFrameClearAllPoints(BlzGetFrameByName("TalentHighlight", 0))
//call BlzFrameSetParent(BlzGetFrameByName("TalentHighlight", 0), BlzGetFrameByName("TalentBoxItem", buttonused))
call BlzFrameSetAllPoints(BlzGetFrameByName("TalentHighlight", 0), BlzGetFrameByName("TalentBoxItem", buttonused)) //Buttons start with 0, talent with 1
else
call BlzFrameSetVisible(BlzGetFrameByName("TalentHighlight", 0),false)
endif
call BlzFrameSetSize(BlzGetFrameByName("TalentBox", 0), frameSizeX, frameSizeY)
call BlzFrameSetText(BlzGetFrameByName("TalentBoxTitle", 0), GetLocalizedString(udg_TalentStrings[102]) +I2S(level))
if UseUnlearnButton then
call BlzFrameSetEnable(BlzGetFrameByName("TalentResetButton",0), TalentUnitGetCurrentTierLevel(unitHandle) >= level and not udg_TalentControlPreventReset[GetConvertedPlayerId(p)])
endif
endif
endfunction
function TalentBoxUpdate takes player p returns nothing
local integer unitHandle = GetHandleId(udg_TalentControlTarget[GetPlayerId(p)])
call TalentBoxSetTier(TalentUnitGetCurrentTierLevel(unitHandle), TalentUnitGetCurrentTier(unitHandle), p)
endfunction
function TalentBoxLevelClick takes nothing returns nothing
local framehandle fh = BlzGetTriggerFrame()
local integer i = LevelBoxAmount
local integer playerFactor = LevelBoxAmount*GetPlayerId(GetTriggerPlayer())
loop
if fh == BlzGetFrameByName("TalentBoxLevelButton", i) then
call TalentBoxSetTier(udg_TalentControlLevels[playerFactor + i], TalentHeroGetTier(TalentGetUnitTypeId(udg_TalentControlTarget[GetPlayerId(GetTriggerPlayer())]), udg_TalentControlLevels[playerFactor + i]), GetTriggerPlayer())
exitwhen true
endif
exitwhen i == 0
set i = i - 1
endloop
set fh = null
endfunction
function FrameLoseFocus takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
call BlzFrameSetEnable(BlzGetTriggerFrame(), false)
call BlzFrameSetEnable(BlzGetTriggerFrame(), true)
endif
endfunction
function TalentBoxUpdateLevelBoxes takes player p, integer levelStart returns nothing
local integer count = -1
local integer level = levelStart
local integer playerId = GetPlayerId(p)
local integer heroTypeId = TalentGetUnitTypeId(udg_TalentControlTarget[playerId])
local integer finalLevel = TalentHeroGetFinalTier(heroTypeId)
local integer playerFactor = LevelBoxAmount*playerId
if level > finalLevel then
set level = 0
endif
if level < 1 then
set level = 0
endif
if heroTypeId != 0 then
loop
if TalentHeroGetTier(heroTypeId,level) != 0 then //Have tier on that Level?
set count = count + 1
set udg_TalentControlLevels[playerFactor + count] = level
set udg_TalentControlLevelsMax[playerId] = level
if GetLocalPlayer() == p then
call BlzFrameSetText(BlzGetFrameByName("TalentBoxLevelButton", count), I2S(level))
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxLevelButton", count), true)
endif
endif
exitwhen level >= finalLevel
set level = level + 1
exitwhen count >= LevelBoxAmount-1
endloop
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxLevelParent", 0), count > 1) //when there is only one level to choose from hide the levels
if GetLocalPlayer() == p and levelStart <= 1 then
call BlzFrameSetVisible(BlzGetFrameByName("TalentButtonDown", 0), udg_TalentControlLevelsMax[playerId] < finalLevel)
call BlzFrameSetVisible(BlzGetFrameByName("TalentButtonUp", 0), udg_TalentControlLevelsMax[playerId] < finalLevel)
endif
call TalentBoxSetTier(udg_TalentControlLevels[playerFactor], TalentHeroGetTier(heroTypeId, udg_TalentControlLevels[playerFactor]), p)
endif
loop
set count = count + 1
exitwhen count >= LevelBoxAmount
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxLevelButton", count), false)
endloop
endfunction
function TalentBoxUpdateLevelBoxesDown takes player p, integer levelStart returns nothing
local integer count = LevelBoxAmount
local integer level = levelStart
local integer playerId = GetPlayerId(p)
local integer heroTypeId = TalentGetUnitTypeId(udg_TalentControlTarget[playerId])
local integer finalLevel = TalentHeroGetFinalTier(heroTypeId)
local integer playerFactor = LevelBoxAmount*playerId
local boolean first = true
if level <= 0 then
set level = finalLevel
endif
if heroTypeId != 0 then
loop
if TalentHeroGetTier(heroTypeId,level) != 0 then //Have tier on that Level?
set count = count - 1
set udg_TalentControlLevels[playerFactor + count] = level
if first then
set udg_TalentControlLevelsMax[playerId] = level
set first = false
endif
if GetLocalPlayer() == p then
call BlzFrameSetText(BlzGetFrameByName("TalentBoxLevelButton", count), I2S(level))
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxLevelButton", count), true)
endif
endif
exitwhen level <= 0
set level = level - 1
exitwhen count == 0
endloop
call TalentBoxSetTier(udg_TalentControlLevelsMax[playerId], TalentHeroGetTier(heroTypeId, udg_TalentControlLevelsMax[playerId]), p)
endif
endfunction
function TalentBoxLevelUpButtonAction takes nothing returns nothing
local integer playerFactor = LevelBoxAmount*GetPlayerId(GetTriggerPlayer())
call TalentBoxUpdateLevelBoxes(GetTriggerPlayer(), udg_TalentControlLevelsMax[GetPlayerId(GetTriggerPlayer())] + 1)
endfunction
function TalentLevelBoxDownButtonAction takes nothing returns nothing
local integer playerFactor = LevelBoxAmount*GetPlayerId(GetTriggerPlayer())
call TalentBoxUpdateLevelBoxesDown(GetTriggerPlayer(), udg_TalentControlLevels[playerFactor] - 1)
endfunction
function TalentBoxShowEmpty takes player activePlayer returns nothing
local real frameSizeY = 0.08
local real frameSizeX = OptionSizeX + 0.05
local real optionSizeY = OptionSizeY
set udg_TalentControlLevelsCurrent[GetPlayerId(activePlayer)] = 0
if GetLocalPlayer() == activePlayer then
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxItemParent",0), false)
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxLevelParent",0), false)
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxShowButtonSprite", 0), false)
call BlzFrameSetSize(BlzGetFrameByName("TalentBox",0), frameSizeX, frameSizeY)
call BlzFrameSetText(BlzGetFrameByName("TalentBoxTitle",0), GetLocalizedString(udg_TalentStrings[104]))
endif
endfunction
//Shows the TalentBox and sets the target for activePlayer.
function TalentBoxShow takes unit target, player activePlayer returns nothing
local integer playerId = GetPlayerId(activePlayer)
local integer unitHandle = GetHandleId(target)
if not FixedTarget then
set udg_TalentControlTarget[playerId] = target
else
set target = udg_TalentControlTarget[playerId]
endif
if TalentHas(target) then
call TalentBoxUpdateLevelBoxes(activePlayer, 0)
call TalentBoxSetTier(TalentUnitGetCurrentTierLevel(unitHandle), TalentUnitGetCurrentTier(unitHandle), activePlayer)
if UseUnlearnButton then
call BlzFrameSetVisible(BlzGetFrameByName("TalentResetButton",0), TalentBoxHasControl(activePlayer, target))
endif
else
call TalentBoxShowEmpty(activePlayer)
if UseUnlearnButton then
call BlzFrameSetVisible(BlzGetFrameByName("TalentResetButton",0), false)
endif
endif
endfunction
function TalentOnDeath takes nothing returns nothing
if GetTriggerUnit() == udg_TalentControlTarget[GetPlayerId(GetLocalPlayer())] then
call BlzFrameSetVisible(BlzGetFrameByName("TalentBox", 0), false)
call BlzFrameSetVisible(BlzGetFrameByName("TalentShowButton", 0), true)
endif
endfunction
function TalentShowUI takes nothing returns nothing
call TalentBoxShow(GetTriggerUnit(), GetTriggerPlayer())
endfunction
function TalentBoxChoiceClick takes nothing returns nothing
local framehandle fh = BlzGetTriggerFrame()
local integer i = OptionMaxCount
local integer playerId = GetPlayerId(GetTriggerPlayer())
local integer unitCode
local integer selectionsDone
local unit u
local integer loopA
if GetLocalPlayer() == GetTriggerPlayer() then
call BlzFrameSetEnable(fh, false)
call BlzFrameSetEnable(fh, true)
endif
loop
if fh == BlzGetFrameByName("TalentBoxItem", i) then
if not FixedTarget and not udg_TalentControlSingleMode[playerId] then
set unitCode = TalentGetUnitTypeId(udg_TalentControlTarget[playerId])
set selectionsDone = TalentUnitGetSelectionsDoneCount(GetHandleId(udg_TalentControlTarget[playerId]))
call GroupEnumUnitsSelected(udg_TalentControlGroup, GetTriggerPlayer(), null)
set loopA = BlzGroupGetSize(udg_TalentControlGroup) - 1
loop
exitwhen loopA < 0
set u = BlzGroupUnitAt(udg_TalentControlGroup, loopA)
if TalentGetUnitTypeId(u) == unitCode and TalentBoxHasControl(GetTriggerPlayer(), u) and TalentUnitGetSelectionsDoneCount(GetHandleId(u)) == selectionsDone then
call TalentPickDo(u, i)
endif
set loopA = loopA - 1
endloop
set u = null
else
call TalentPickDo(udg_TalentControlTarget[GetPlayerId(GetTriggerPlayer())], i) //Choices start with 1, buttons with 0
endif
call TalentBoxUpdate(GetTriggerPlayer())
exitwhen true
endif
set i = i -1
exitwhen i == - 1
endloop
set fh = null
if not CloseWhenNoChoice then
call TalentBoxUpdate(GetTriggerPlayer())
elseif GetLocalPlayer() == GetTriggerPlayer() and not TalentUnitHasChoice(GetHandleId(udg_TalentControlTarget[GetPlayerId(GetTriggerPlayer())])) then
call BlzFrameSetVisible(BlzGetFrameByName("TalentBox", 0), false)
call BlzFrameSetVisible(BlzGetFrameByName("TalentShowButton", 0), true)
endif
endfunction
function TalentResetButtonActionDo takes unit u returns nothing
local integer playerId = GetPlayerId(GetTriggerPlayer())
local integer unitHandle = GetHandleId(u)
local integer shownLevel = TalentHeroLevel2SelectionIndex(TalentGetUnitTypeId(u), udg_TalentControlLevelsCurrent[playerId])
local integer selectedCount = TalentUnitGetSelectionsDoneCount(unitHandle)
local integer i
if selectedCount + 1 - shownLevel > 0 then //reset
call TalentResetDo(u, selectedCount + 1 - shownLevel)
else //learn all rested talents.
loop
set selectedCount = selectedCount + 1
set i = TalentUnitGetSelectionButtonUsed(unitHandle, selectedCount)
exitwhen i == 0
call TalentPickDo(u, i)
endloop
endif
endfunction
function TalentResetButtonAction takes nothing returns nothing
local integer unitCode
local integer selectionsDone
local unit u
local integer loopA
local integer playerId = GetPlayerId(GetTriggerPlayer())
if not FixedTarget and not udg_TalentControlSingleMode[playerId] then
set unitCode = TalentGetUnitTypeId(udg_TalentControlTarget[playerId])
set selectionsDone = TalentUnitGetSelectionsDoneCount(GetHandleId(udg_TalentControlTarget[playerId]))
call GroupEnumUnitsSelected(udg_TalentControlGroup, GetTriggerPlayer(), null)
set loopA = BlzGroupGetSize(udg_TalentControlGroup) - 1
loop
exitwhen loopA < 0
set u = BlzGroupUnitAt(udg_TalentControlGroup, loopA)
if TalentGetUnitTypeId(u) == unitCode and TalentBoxHasControl(GetTriggerPlayer(), u) and TalentUnitGetSelectionsDoneCount(GetHandleId(u)) == selectionsDone then
call TalentResetButtonActionDo(u)
endif
set loopA = loopA - 1
endloop
set u = null
else
call TalentResetButtonActionDo(udg_TalentControlTarget[GetPlayerId(GetTriggerPlayer())])
endif
call TalentBoxUpdate(GetTriggerPlayer())
endfunction
function TalentBoxCloseButtonAction takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
call BlzFrameSetVisible(BlzGetFrameByName("TalentBox", 0), false)
call BlzFrameSetVisible(BlzGetFrameByName("TalentShowButton", 0), true)
endif
endfunction
function TalentBoxShowButtonAction takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
call BlzFrameSetVisible(BlzGetFrameByName("TalentBox", 0), true)
call BlzFrameSetVisible(BlzGetFrameByName("TalentShowButton", 0), false)
call TalentBoxUpdate(GetTriggerPlayer())
endif
endfunction
function TalentBoxGroupModeButtonAction takes nothing returns nothing
// I mixed up the images so the mode is reversed
local integer playerId = GetPlayerId(GetTriggerPlayer())
set udg_TalentControlSingleMode[playerId] = true
if GetLocalPlayer() == GetTriggerPlayer() then
call BlzFrameSetVisible(BlzGetFrameByName("TalentButtonSingleMode",0), true)
call BlzFrameSetVisible(BlzGetFrameByName("TalentButtonGroupMode",0), false)
endif
// print(TalentBox.Control[player].SingleMode)
endfunction
function TalentBoxSingleModeButtonAction takes nothing returns nothing
// I mixed up the images so the mode is reversed
local integer playerId = GetPlayerId(GetTriggerPlayer())
set udg_TalentControlSingleMode[playerId] = false
if GetLocalPlayer() == GetTriggerPlayer() then
call BlzFrameSetVisible(BlzGetFrameByName("TalentButtonSingleMode",0), false)
call BlzFrameSetVisible(BlzGetFrameByName("TalentButtonGroupMode",0), true)
endif
// print(TalentBox.Control[player].SingleMode)
endfunction
function TalentBoxCreateFixedTooltip takes framehandle frame, string icon, string head, string text returns nothing
// create an empty FRAME parent for the box BACKDROP, otherwise it can happen that it gets limited to the 4:3 Screen.
local framehandle toolTipFrameParent = BlzCreateFrame("TalentBoxTooltipBoxFrame", frame, 0, 0)
local framehandle toolTipFrame = BlzGetFrameByName("TalentBoxTooltipBox", 0)
local framehandle toolTipFrameIcon = BlzGetFrameByName("TalentBoxTooltipIcon", 0)
// reserve HandleIds, to allow using them later in async manner
local framehandle toolTipFrameName = BlzGetFrameByName("TalentBoxTooltipName", 0)
local framehandle toolTipFrameText = BlzGetFrameByName("TalentBoxTooltipText", 0)
call BlzFrameSetSize(toolTipFrameText, OptionTooltipSizeX, 0)
call BlzFrameSetText(toolTipFrameText, GetLocalizedString(text))
call BlzFrameSetText(toolTipFrameName, GetLocalizedString(head))
call BlzFrameSetTexture(toolTipFrameIcon, GetLocalizedString(icon), 0, true)
if OptionTooltipFixedPos then
call BlzFrameSetAbsPoint(toolTipFrameText, OptionTooltipPos, OptionTooltipPosX, OptionTooltipPosY)
else
call BlzFrameSetPoint(toolTipFrameText, OptionTooltipRelaPosA, BlzGetFrameByName("TalentBox", 0), OptionTooltipRelaPosB, OptionTooltipRelaPosX, OptionTooltipRelaPosY)
endif
call BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_TOPLEFT, toolTipFrameIcon, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
call BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_BOTTOMRIGHT, toolTipFrameText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
call BlzFrameSetTooltip(frame, toolTipFrameParent)
endfunction
function TalentBoxCreate takes nothing returns nothing
local boolean loaded = BlzLoadTOCFile("war3mapimported\\talentbox.toc")
local framehandle talentBox = BlzCreateFrameByType("BACKDROP", "TalentBox", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "TalentBoxBackground", 0)
local framehandle talentBoxItemParent = BlzCreateFrameByType("FRAME", "TalentBoxItemParent", talentBox, "", 0)
local framehandle talentBoxLevelParent = BlzCreateFrameByType("FRAME", "TalentBoxLevelParent", talentBox, "", 0)
local framehandle talentBoxItem
local framehandle fh
local framehandle selected = BlzCreateFrame("TalentHighlight", talentBox, 0, 0)
local framehandle reset
local framehandle pageUp = BlzCreateFrame("TalentButtonUp", talentBoxLevelParent, 0, 0)
local framehandle pageDown = BlzCreateFrame("TalentButtonDown", talentBoxLevelParent, 0, 0)
local framehandle closeButton = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentCloseButton",talentBox, "ScriptDialogButton", 0)
local framehandle showButton
local framehandle showButtonIcon
local framehandle toolTipFrame
local framehandle toolTipFrameParent
local framehandle toolTipFrameText
local framehandle toolTipFrameIcon
local framehandle showButtonSprite
local integer i = 1
local trigger choiceHandler = CreateTrigger()
local trigger levelBoxHandler = CreateTrigger()
local trigger resetHandler
local trigger pageDownHandler = CreateTrigger()
local trigger pageUpHandler = CreateTrigger()
local trigger closeButtonHandler = CreateTrigger()
local trigger showButtonHandler = CreateTrigger()
local trigger GroupModeButtonHandler = CreateTrigger()
local trigger SingleModeButtonHandler = CreateTrigger()
if ShowButtonIcon != null and ShowButtonIcon != "" then
set showButton = BlzCreateFrameByType("GLUEBUTTON", "TalentShowButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "IconButtonTemplate", 0)
set showButtonIcon = BlzCreateFrameByType("BACKDROP", "TalentShowButtonIcon", showButton, "", 0)
call BlzFrameSetTexture(showButtonIcon, ShowButtonIcon, 0, true)
call BlzFrameSetAllPoints(showButtonIcon, showButton)
else
set showButton = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentShowButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "ScriptDialogButton", 0)
endif
call BlzCreateFrame("TalentButtonGroupMode", talentBoxItemParent, 0, 0)
call BlzCreateFrame("TalentButtonSingleMode", talentBoxItemParent, 0, 0)
call BlzFrameSetPoint(BlzGetFrameByName("TalentButtonGroupMode",0), FRAMEPOINT_BOTTOMRIGHT, talentBox, FRAMEPOINT_BOTTOMRIGHT, -0.027 - ResetSizeX , 0.02)
call BlzFrameSetPoint(BlzGetFrameByName("TalentButtonSingleMode",0), FRAMEPOINT_BOTTOMRIGHT, talentBox, FRAMEPOINT_BOTTOMRIGHT, -0.027 - ResetSizeX, 0.02)
call BlzFrameSetVisible(BlzGetFrameByName("TalentButtonGroupMode",0), false)
call TriggerAddAction(GroupModeButtonHandler, function TalentBoxGroupModeButtonAction)
call TriggerAddAction(GroupModeButtonHandler, function FrameLoseFocus)
call TriggerAddAction(SingleModeButtonHandler, function TalentBoxSingleModeButtonAction)
call TriggerAddAction(SingleModeButtonHandler, function FrameLoseFocus)
call BlzTriggerRegisterFrameEvent(GroupModeButtonHandler, BlzGetFrameByName("TalentButtonGroupMode",0), FRAMEEVENT_CONTROL_CLICK)
call BlzTriggerRegisterFrameEvent(SingleModeButtonHandler, BlzGetFrameByName("TalentButtonSingleMode",0), FRAMEEVENT_CONTROL_CLICK)
// call BlzFrameSetVisible(TalentBox.Frame.SingleMode, false)
call TalentBoxCreateFixedTooltip(BlzGetFrameByName("TalentButtonGroupMode",0), udg_TalentStrings[107], udg_TalentStrings[105], udg_TalentStrings[106])
call TalentBoxCreateFixedTooltip(BlzGetFrameByName("TalentButtonSingleMode",0), udg_TalentStrings[110], udg_TalentStrings[108], udg_TalentStrings[109])
call BlzFrameSetSize(showButton, ShowButtonSizeX, ShowButtonSizeY)
call BlzFrameSetText(showButton, GetLocalizedString(udg_TalentStrings[103]))
call BlzFrameSetPoint(BlzCreateFrameByType("TEXT", "TalentBoxTitle", talentBox, "TalentBoxTitle", 0), FRAMEPOINT_TOP, talentBox, FRAMEPOINT_TOP, 0.0, -0.03)
call BlzFrameSetAbsPoint(showButton, ShowButtonPosType, ShowButtonPosX, ShowButtonPosY)
call TriggerAddAction(choiceHandler, function TalentBoxChoiceClick)
call TriggerAddAction(levelBoxHandler, function TalentBoxLevelClick)
call TriggerAddAction(pageDownHandler, function TalentLevelBoxDownButtonAction)
call TriggerAddAction(pageUpHandler, function TalentBoxLevelUpButtonAction)
call TriggerAddAction(closeButtonHandler, function TalentBoxCloseButtonAction)
call TriggerAddAction(showButtonHandler, function TalentBoxShowButtonAction)
//call TriggerAddAction(choiceHandler, function FrameLoseFocus)
call TriggerAddAction(levelBoxHandler, function FrameLoseFocus)
call TriggerAddAction(pageDownHandler, function FrameLoseFocus)
call TriggerAddAction(pageUpHandler, function FrameLoseFocus)
call TriggerAddAction(closeButtonHandler, function FrameLoseFocus)
call BlzFrameSetText(closeButton, "X")
call BlzFrameSetSize(closeButton, 0.035, 0.035)
call BlzFrameSetVisible(selected, false)
call BlzTriggerRegisterFrameEvent(pageDownHandler, pageDown, FRAMEEVENT_CONTROL_CLICK)
call BlzTriggerRegisterFrameEvent(pageUpHandler, pageUp, FRAMEEVENT_CONTROL_CLICK)
call BlzTriggerRegisterFrameEvent(closeButtonHandler, closeButton, FRAMEEVENT_CONTROL_CLICK)
call BlzTriggerRegisterFrameEvent(showButtonHandler, showButton, FRAMEEVENT_CONTROL_CLICK)
call BlzFrameSetAbsPoint(talentBox, PosType, PosX, PosY)
call BlzFrameSetText(BlzGetFrameByName("TalentBoxTitle", 0), GetLocalizedString(udg_TalentStrings[102]))
loop
exitwhen i > OptionMaxCount
set talentBoxItem = BlzCreateFrame("TalentBoxItem", talentBoxItemParent, 0, i)
call BlzFrameSetPoint(talentBoxItem, FRAMEPOINT_BOTTOM, BlzGetFrameByName("TalentBoxItem", i - 1), FRAMEPOINT_TOP, 0, Option2OptionGap)
call BlzFrameSetSize(talentBoxItem, OptionSizeX, OptionSizeY)
call BlzFrameSetSize(BlzGetFrameByName("TalentBoxItemIcon", i), OptionIconSize, OptionIconSize)
call BlzTriggerRegisterFrameEvent(choiceHandler, talentBoxItem, FRAMEEVENT_CONTROL_CLICK)
call BlzFrameSetVisible(BlzGetFrameByName("TalentBoxItemTextText", i), OptionShowText)
// reserve HandleIds
call BlzGetFrameByName("TalentBoxItem", i)
call BlzGetFrameByName("TalentBoxItemTextText", i)
call BlzGetFrameByName("TalentBoxItemText", i)
call BlzGetFrameByName("TalentBoxItemIcon", i)
call BlzGetFrameByName("TalentBoxItemTitle", i)
if OptionHaveTooltip then
// create an empty FRAME parent for the box BACKDROP, otherwise it can happen that it gets limited to the 4:3 Screen.
set toolTipFrameParent = BlzCreateFrame("TalentBoxTooltipBoxFrame", talentBoxItem, 0, i)
set toolTipFrame = BlzGetFrameByName("TalentBoxTooltipBox", i)
set toolTipFrameIcon = BlzGetFrameByName("TalentBoxTooltipIcon", i)
// reserve HandleIds, to allow using them later in async manner
call BlzGetFrameByName("TalentBoxTooltipName", i)
call BlzGetFrameByName("TalentBoxTooltipSeperator", i)
set toolTipFrameText = BlzGetFrameByName("TalentBoxTooltipText", i)
call BlzFrameSetSize(toolTipFrameText, OptionTooltipSizeX, 0)
if OptionTooltipFixedPos then
call BlzFrameSetAbsPoint(toolTipFrameText, OptionTooltipPos, OptionTooltipPosX, OptionTooltipPosY)
else
call BlzFrameSetPoint(toolTipFrameText, OptionTooltipRelaPosA, talentBox, OptionTooltipRelaPosB, OptionTooltipRelaPosX, OptionTooltipRelaPosY)
endif
call BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_TOPLEFT, toolTipFrameIcon, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
call BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_BOTTOMRIGHT, toolTipFrameText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
call BlzFrameSetTooltip(talentBoxItem, toolTipFrameParent)
endif
set i = i + 1
endloop
call BlzFrameSetPoint(BlzGetFrameByName("TalentBoxItem", 1), FRAMEPOINT_BOTTOMLEFT, talentBox, FRAMEPOINT_BOTTOMLEFT, 0.025, 0.0235 + Option2BottomGap + RMaxBJ(ResetSizeY, LevelBoxSizeY))
//call BlzFrameSetVisible(BlzGetFrameByName("TalentHighlight", 1), false)
call BlzFrameSetPoint(closeButton, FRAMEPOINT_TOPRIGHT, talentBox, FRAMEPOINT_TOPRIGHT, 0.0, 0)
set i = 0
loop
set fh = BlzCreateFrame("TalentBoxLevelButton", talentBoxLevelParent, 0, i)
call BlzFrameSetPoint(fh, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName("TalentBoxLevelButton", i - 1), FRAMEPOINT_BOTTOMRIGHT, 0,0)
call BlzFrameSetSize(fh, LevelBoxSizeX, LevelBoxSizeY)
call BlzTriggerRegisterFrameEvent(levelBoxHandler, fh, FRAMEEVENT_CONTROL_CLICK)
set i = i + 1
exitwhen i == LevelBoxAmount
endloop
call BlzFrameSetPoint(BlzGetFrameByName("TalentBoxLevelButton",0), FRAMEPOINT_BOTTOMLEFT, talentBox, FRAMEPOINT_BOTTOMLEFT, 0.027,0.0235)
call BlzFrameSetVisible(talentBox, false)
call BlzFrameSetPoint(pageDown, FRAMEPOINT_BOTTOMLEFT, fh, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
call BlzFrameSetPoint(pageUp, FRAMEPOINT_BOTTOM, pageDown, FRAMEPOINT_TOP, 0, 0)
if UseUnlearnButton then
set resetHandler = CreateTrigger()
set reset = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentResetButton",talentBox, "ScriptDialogButton", 0)
call TalentBoxCreateFixedTooltip(reset, "UI/Widgets/EscMenu/Human/blank-background", udg_TalentStrings[101], udg_TalentStrings[100])
call BlzFrameSetText(reset, GetLocalizedString(udg_TalentStrings[101]))
call BlzFrameSetSize(reset, ResetSizeX, ResetSizeY)
call BlzTriggerRegisterFrameEvent(resetHandler, reset, FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(resetHandler, function TalentResetButtonAction)
call TriggerAddAction(resetHandler, function FrameLoseFocus)
call BlzFrameSetPoint(reset, FRAMEPOINT_BOTTOMRIGHT, talentBox, FRAMEPOINT_BOTTOMRIGHT, -0.027, 0.0235)
endif
set showButtonSprite = BlzCreateFrameByType("SPRITE", "TalentBoxShowButtonSprite", showButton, "", 0)
call BlzFrameSetModel(showButtonSprite, ShowButtonSpritePath, 0)
call BlzFrameSetAllPoints(showButtonSprite, showButton)
call BlzFrameSetScale(showButtonSprite, BlzFrameGetWidth(showButton)/ShowButtonSpriteSize)
call BlzFrameSetVisible(showButtonSprite, false)
set fh = null
endfunction
function TalentBoxInit takes nothing returns nothing
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function TalentBoxCreate)
endif
set udg_TalentTrigger[TT_SelectUnit()] = CreateTrigger()
set udg_TalentTrigger[TT_DeathTrigger()] = CreateTrigger()
call TriggerAddAction( udg_TalentTrigger[TT_SelectUnit()], function TalentShowUI)
call TriggerAddAction( udg_TalentTrigger[TT_DeathTrigger()], function TalentOnDeath)
call TriggerRegisterAnyUnitEventBJ(udg_TalentTrigger[TT_SelectUnit()], EVENT_PLAYER_UNIT_SELECTED)
call TriggerRegisterAnyUnitEventBJ(udg_TalentTrigger[TT_DeathTrigger()], EVENT_PLAYER_UNIT_DEATH)
call TalentBoxCreate()
endfunction
endlibrary
library TalentGridJUI uses TalentJUI
// TalentGrid for Talent Lui 1.36e
// By Tasyen
//===========================================================================
//TalentGrid displays Tiers in rows one can scroll up and down.
//===========================================================================
globals
//public globals support being changed during the runtime
//Pack = true, changes the Size of the UI so that the current displayed fits.
//t is recommented to use a cornerPoint for PosType with enabled Pack
public boolean Pack = true
// Closes the UI when no unit is selected
public boolean AutoCloseWithoutSelection = false
// Closes the UI after doing a choice without being able to pick again
public boolean AutoCloseWhenDone = true
//With false the unlearn Button won't exist
//TalentBox.Control[GetConvertedPlayerId(player)].PreventResetButton = true will prevent player to use reset/Relearn button.
public boolean HaveResetButton = true
// FixedTarget (true) Talent will not change udg_TalentControlTarget[playerId]
public boolean FixedTarget = false
// OnlyOwnUnit (true) can not pick Talents for Shared Control of other player's Units.
public boolean OnlyOwnUnit = false
//MaxAmount of Options shown in the UI of one tier.
//The Buttons start with 1 and include OptionMaxCount
//One could still learn the Choice when a chat command would be provided.
private integer OptionMaxCount = 6
//The Buttons of the Grid to Pick/display choices.
//ColsAmount should be equal or higher than the highest choice count in a tier
private integer RowsAmount = 5
private integer ColsAmount = 5
private real ResetSizeX = 0.07
private real ResetSizeY = 0.025
//Default Position of the TalentGrid
private real PosX = 0.05
private real PosY = 0.55
private framepointtype PosType = FRAMEPOINT_TOPLEFT
public boolean OptionHaveTooltip = true
// Tooltip Pos
private boolean OptionTooltipFixedPos = true
// Fixed
private real OptionTooltipPosX = 0.79
private real OptionTooltipPosY = 0.165
private framepointtype OptionTooltipPos = FRAMEPOINT_BOTTOMRIGHT
// Relative to TalentGrid
private real OptionTooltipRelaPosX = 0.001
private real OptionTooltipRelaPosY = -0.052
private framepointtype OptionTooltipRelaPosA = FRAMEPOINT_TOPLEFT
private framepointtype OptionTooltipRelaPosB = FRAMEPOINT_TOPRIGHT
// XSize of the Tooltip
private real OptionTooltipSizeX = 0.2
//Bigger Options allow bigger texts, but also take more space of the screen, which reduces the possible amount of showing options in one tier.
//XSize of an option in the TalentGrid
private real OptionSizeX = 0.11
//YSize of an option in the TalentGrid
private real OptionSizeY = 0.04
public boolean OptionShowText = true
//IconSize, should be smaller than OptionSizeY and OptionSizeX
private real OptionIconSize = 0.03
private real OptionLevelSizeX = 0.04
//YSize of an option in the TalentGrid
private real OptionLevelSizeY = 0.04
//Default Position for the ShowTalentGridButton
private real ShowButtonPosX = 0.00
private real ShowButtonPosY = 0.28
private real ShowButtonSizeX = 0.05
private real ShowButtonSizeY = 0.05
private framepointtype ShowButtonPosType = FRAMEPOINT_BOTTOMLEFT
private string ShowButtonIcon = "" // when not "" or not null then an IconButton is created.
// Display a Sprite on the Show Button when the current Unit can do a choice
public boolean ShowButtonSprite = true
private string ShowButtonSpritePath = "ui/feedback/autocast/ui-modalbuttonon.mdx"
private real ShowButtonSpriteSize = 0.039
private string StringButtonResetTooltip = "Unlearn all choosen Talents.|nIn GroupMode this applies to all selected using the same Talents"
private string StringButtonResetText = "UnLearn"
private string StringButtonShowText = "Show TalentGrid"
private string StringTitlePrefix = "Talent: "
private string StringNoTalentUser = "No Talent User"
private string StringTooltipGroupModeHead = "Group Mode"
private string StringTooltipGroupModeText = "During GroupMode all selected Units using the same Talent and with the same amount of selections done, will do picks/Unlearn/Relearn together.|n|nClick to disable Group Mode."
private string StringTooltipGroupModeIcon = "ui/widgets/battlenet/bnet-mainmenu-customteam-up"
private string StringTooltipSingleModeHead = "Single Mode"
private string StringTooltipSingleModeText = "Only the selected Unit will do picks, unlearns|n|nClick to enable Group Mode."
private string StringTooltipSingleModeIcon = "ui/widgets/battlenet/bnet-mainmenu-customteam-disabled"
public trigger SelectTrigger
public trigger WheelTrigger
public trigger CloseTrigger
public trigger ShowTrigger
public trigger SliderTrigger
public trigger MyResetTrigger
public trigger PickTrigger
public trigger GroupModeTrigger
public trigger SingleModeTrigger
public framehandle FrameSlider
public framehandle FrameParent
public framehandle FrameItemParent
public framehandle FrameShow
public framehandle FrameShowSprite
public framehandle FrameClose
public framehandle FrameTitle
public framehandle FrameGroupMode
public framehandle FrameSingleMode
public framehandle FrameReset
public framehandle array FrameLevel
public framehandle array FrameLevelText
public framehandle array FrameSelected
// the gridbuttons are a 2D array [rowIndex*rowMax + col]
public framehandle array FrameItem
public framehandle array FrameItemIcon
public framehandle array FrameItemText
public framehandle array FrameItemToolTip
public framehandle array FrameItemToolTipText
public framehandle array FrameItemToolTipIcon
public framehandle array FrameItemToolTipName
public integer array Offset
public string array OptionTitleSufix
public string array OptionTitlePrefix
private timer SelectionCheckTimer
private group SelectionCheckGroup
endglobals
function TalentGridHasControl takes player p, unit u returns boolean
return IsUnitOwnedByPlayer(u, p) or (not OnlyOwnUnit and GetPlayerAlliance(GetOwningPlayer(u), p, ALLIANCE_SHARED_CONTROL))
endfunction
function TalentGridUpdate takes player p returns nothing
local integer playerId = GetPlayerId(p)
local integer rows = RowsAmount
local integer cols = ColsAmount
local unit u = udg_TalentControlTarget[playerId]
local integer unitHandle = GetHandleId(u)
local integer unitCode = TalentGetUnitTypeId(u)
local integer offset = Offset[playerId]
local integer y = -1
local integer x
local integer tierCount = 0
local integer choice
local integer tier
local integer frameIndex
local integer colsMax = 0
local integer rowsMax = 0
local integer level = 0
local integer buttonUsed
local boolean hasControl = TalentGridHasControl(p, u)
if GetLocalPlayer() != p then
set u = null
return
endif
if not TalentHas(u) then
set u = null
return
endif
call BlzFrameSetVisible(FrameShowSprite, hasControl and ShowButtonSprite and TalentUnitHasChoice(unitHandle))
// walk the tiers of the current unit
// pairs sorts it bad so loop from 1 to Talent[unitCode].MaxLevel
//for level, tier in pairs(Talent[unitCode]["Tier"]) do
loop
exitwhen level > TalentHeroGetFinalTier(unitCode)
set tier = TalentHeroGetTier(unitCode, level)
if tier != 0 then
set tierCount = tierCount + 1
// skip tiers before offset
if tierCount > offset then
set y = y + 1
exitwhen y > rows
if y > rowsMax then
set rowsMax = y
endif
call BlzFrameSetVisible(FrameLevel[y], true)
call BlzFrameSetText(FrameLevelText[y], I2S(level))
set buttonUsed = TalentUnitGetSelectionButtonUsed(unitHandle, tierCount)
if buttonUsed > 0 and TalentUnitGetSelectionsDoneCount(unitHandle) >= tierCount then
call BlzFrameSetVisible(FrameSelected[y],true)
else
call BlzFrameSetVisible(FrameSelected[y],false)
endif
// walk the cols and update each button
set x = 1
loop
exitwhen x > cols
set choice = TalentTierGetChoice(tier, x)
set frameIndex = y*cols + x
if choice > 0 then
if x > colsMax then
set colsMax = x
endif
call BlzFrameSetVisible(FrameItem[frameIndex], true)
call BlzFrameSetEnable(FrameItem[frameIndex], hasControl and TalentUnitGetCurrentTierLevel(unitHandle) == level and TalentUnitHasChoice(unitHandle))
call BlzFrameSetTexture(FrameItemIcon[frameIndex], GetLocalizedString(udg_TalentChoiceIcon[choice]), 0, true)
call BlzFrameSetText(FrameItemText[frameIndex], GetLocalizedString(udg_TalentChoiceHead[choice]))
call BlzFrameSetVisible(FrameItemText[frameIndex], OptionShowText)
if OptionHaveTooltip then
call BlzFrameSetText(FrameItemToolTipText[frameIndex], GetLocalizedString(udg_TalentChoiceText[choice]))
call BlzFrameSetTexture(FrameItemToolTipIcon[frameIndex], GetLocalizedString(udg_TalentChoiceIcon[choice]), 0, true)
call BlzFrameSetText(FrameItemToolTipName[frameIndex], GetLocalizedString(udg_TalentChoiceHead[choice]))
endif
if x == buttonUsed then
call BlzFrameClearAllPoints(FrameSelected[y])
call BlzFrameSetAllPoints(FrameSelected[y], FrameItem[frameIndex])
endif
else
call BlzFrameSetVisible(FrameItem[frameIndex], false)
endif
set x = x + 1
endloop
endif
endif
set level = level + 1
endloop
// hide the rows not used
set y = y + 1
loop
exitwhen y >= RowsAmount
call BlzFrameSetVisible(FrameLevel[y], false)
call BlzFrameSetVisible(FrameSelected[y], false)
set x = 1
loop
exitwhen x > cols
call BlzFrameSetVisible(FrameItem[y*cols + x], false)
set x = x + 1
endloop
set y = y + 1
endloop
if Pack then
call BlzFrameSetSize(FrameParent, 0.033 + OptionLevelSizeX + IMaxBJ(colsMax, 1)*OptionSizeX, 0.09 + OptionSizeY* (rowsMax + 1))
endif
set u = null
endfunction
function TalentGridShowEmpty takes player p returns nothing
if GetLocalPlayer() == p then
call BlzFrameSetVisible(FrameItemParent, false)
call BlzFrameSetText(FrameTitle, GetLocalizedString(StringNoTalentUser))
endif
endfunction
function TalentGridShow takes unit target, player activePlayer returns nothing
local integer playerId = GetPlayerId(activePlayer)
local integer unitCode
local integer count
local integer loopA
if not FixedTarget then
set udg_TalentControlTarget[playerId] = target
else
set target = udg_TalentControlTarget[playerId]
endif
if TalentHas(target) then
set Offset[playerId] = 0
set unitCode = TalentGetUnitTypeId(target)
set count = 0
set loopA = 0
loop
exitwhen loopA > TalentHeroGetFinalTier(unitCode)
if TalentHeroGetTier(unitCode, loopA) != 0 then
set count = count + 1
endif
set loopA = loopA + 1
endloop
if GetLocalPlayer() == activePlayer then
call BlzFrameSetVisible(FrameSlider, count > RowsAmount)
call BlzFrameSetText(FrameTitle, GetLocalizedString(StringTitlePrefix) + GetObjectName(unitCode))
if IsUnitType(target, UNIT_TYPE_HERO) then
call BlzFrameSetText(FrameTitle, BlzFrameGetText(FrameTitle) + " ("+GetHeroProperName(target)+")" )
endif
endif
call BlzFrameSetMinMaxValue(FrameSlider, 0, IMaxBJ(0, count - RowsAmount))
call BlzFrameSetVisible(FrameItemParent, true)
call TalentGridUpdate(activePlayer)
if HaveResetButton then
call BlzFrameSetVisible(FrameReset, TalentGridHasControl(activePlayer, target))
endif
else
call TalentGridShowEmpty(activePlayer)
if HaveResetButton then
call BlzFrameSetVisible(FrameReset, false)
endif
endif
endfunction
// used for fixed Tooltips which don't change after the creation anymore
public function CreateTooltip takes framehandle frame, string icon, string head, string text returns nothing
// create an empty FRAME parent for the box BACKDROP, otherwise it can happen that it gets limited to the 4:3 Screen.
local framehandle toolTipFrameFrame = BlzCreateFrame("TalentBoxTooltipBoxFrame", frame, 0, 0)
local framehandle toolTipFrame = BlzGetFrameByName("TalentBoxTooltipBox", 0)
local framehandle toolTipFrameIcon = BlzGetFrameByName("TalentBoxTooltipIcon", 0)
local framehandle toolTipFrameName = BlzGetFrameByName("TalentBoxTooltipName", 0)
local framehandle toolTipFrameSeperator = BlzGetFrameByName("TalentBoxTooltipSeperator", 0)
local framehandle toolTipFrameText = BlzGetFrameByName("TalentBoxTooltipText", 0)
call BlzFrameSetSize(toolTipFrameText, OptionTooltipSizeX, 0)
call BlzFrameSetText(toolTipFrameText, GetLocalizedString(text))
call BlzFrameSetText(toolTipFrameName, GetLocalizedString(head))
call BlzFrameSetTexture(toolTipFrameIcon, GetLocalizedString(icon), 0, true)
if OptionTooltipFixedPos then
call BlzFrameSetAbsPoint(toolTipFrameText, OptionTooltipPos, OptionTooltipPosX, OptionTooltipPosY)
else
call BlzFrameSetPoint(toolTipFrameText, OptionTooltipRelaPosA, FrameParent, OptionTooltipRelaPosB, OptionTooltipRelaPosX, OptionTooltipRelaPosY)
endif
call BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_TOPLEFT, toolTipFrameIcon, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
call BlzFrameSetPoint(toolTipFrame, FRAMEPOINT_BOTTOMRIGHT, toolTipFrameText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
call BlzFrameSetTooltip(frame, toolTipFrameFrame)
endfunction
private function Reset takes unit u returns nothing
call TalentResetDo(u, 99999)
endfunction
private function ResetActionFuncDoA takes framehandle frame, player p returns nothing
local integer playerId = GetPlayerId(p)
local unit u
local integer unitCode
local integer selectionsDone
local integer i
if not FixedTarget and not udg_TalentControlSingleMode[playerId] then
set unitCode = TalentGetUnitTypeId(udg_TalentControlTarget[playerId])
set selectionsDone = TalentUnitGetSelectionsDoneCount(GetHandleId(udg_TalentControlTarget[playerId]))
call GroupEnumUnitsSelected(SelectionCheckGroup, p, null)
set i = 0
loop
exitwhen i >= BlzGroupGetSize(SelectionCheckGroup)
set u = BlzGroupUnitAt(SelectionCheckGroup, i)
if TalentGetUnitTypeId(u) == unitCode and TalentGridHasControl(p, u) then
//and TalentUnitGetSelectionsDoneCount(u) == selectionsDone
call Reset(u)
endif
set i = i + 1
endloop
else
call Reset(udg_TalentControlTarget[playerId])
endif
call TalentGridUpdate(p)
set u = null
endfunction
private function ResetActionFunc takes nothing returns nothing
call ResetActionFuncDoA(BlzGetTriggerFrame(), GetTriggerPlayer())
endfunction
private function PickActionFuncDo takes framehandle frame, player p returns nothing
local unit u
local integer playerId = GetPlayerId(p)
local integer unitCode
local integer selectionsDone
local integer index = LoadInteger(udg_TalentHash, GetHandleId(frame), 0)
local integer i
if not FixedTarget and not udg_TalentControlSingleMode[playerId] then
set unitCode = TalentGetUnitTypeId(udg_TalentControlTarget[playerId])
set selectionsDone = TalentUnitGetSelectionsDoneCount(GetHandleId(udg_TalentControlTarget[playerId]))
call GroupEnumUnitsSelected(SelectionCheckGroup, p, null)
set i = 0
loop
exitwhen i >= BlzGroupGetSize(SelectionCheckGroup)
set u = BlzGroupUnitAt(SelectionCheckGroup, i)
if TalentGetUnitTypeId(u) == unitCode and TalentGridHasControl(p, u) and TalentUnitGetSelectionsDoneCount(GetHandleId(u)) == selectionsDone then
call TalentPickDo(u, index)
endif
set i = i + 1
endloop
set u = null
else
call TalentPickDo(udg_TalentControlTarget[playerId], index)
endif
if AutoCloseWhenDone and not TalentUnitHasChoice(GetHandleId(udg_TalentControlTarget[playerId])) then
if GetLocalPlayer() == p then
call BlzFrameClick(FrameClose)
endif
else
call TalentGridUpdate(p)
endif
endfunction
private function PickActionFunc takes nothing returns nothing
call PickActionFuncDo(BlzGetTriggerFrame(), GetTriggerPlayer())
endfunction
private function SliderActionFunc takes nothing returns nothing
local framehandle frame = BlzGetTriggerFrame()
if BlzGetTriggerFrameEvent() == FRAMEEVENT_MOUSE_WHEEL then
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameValue() > 0 then
call BlzFrameSetValue(frame, BlzFrameGetValue(frame) + 1)
else
call BlzFrameSetValue(frame, BlzFrameGetValue(frame) - 1)
endif
endif
else
set Offset[GetPlayerId(GetTriggerPlayer())] = R2I(BlzGetTriggerFrameValue())
call TalentGridUpdate(GetTriggerPlayer())
endif
set frame = null
endfunction
// this functions runs when not the slider is mouse wheel rolled
private function WheelFunc takes framehandle frame, player p, real value returns nothing
if GetLocalPlayer() == p then
if value > 0 then
call BlzFrameSetValue(FrameSlider, BlzFrameGetValue(FrameSlider) + 1)
else
call BlzFrameSetValue(FrameSlider, BlzFrameGetValue(FrameSlider) - 1)
endif
endif
endfunction
private function WheelActionFunc takes nothing returns nothing
call WheelFunc(BlzGetTriggerFrame(), GetTriggerPlayer(), BlzGetTriggerFrameValue())
endfunction
private function CloseActionFunc takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
call BlzFrameSetVisible(FrameParent, false)
call BlzFrameSetVisible(FrameShow, true)
endif
endfunction
private function ShowActionFunc takes nothing returns nothing
local player p = GetTriggerPlayer()
if GetLocalPlayer() == p then
call BlzFrameSetVisible(FrameParent, true)
call BlzFrameSetVisible(FrameShow, false)
call TalentGridUpdate(p)
endif
set p = null
endfunction
private function SingleModeActionFunc takes nothing returns nothing
local player p = GetTriggerPlayer()
local integer playerId = GetPlayerId(p)
// I mixed up the images so the mode is reversed
set udg_TalentControlSingleMode[playerId] = false
if GetLocalPlayer() == p then
call BlzFrameSetVisible(FrameSingleMode, false)
call BlzFrameSetVisible(FrameGroupMode, true)
endif
set p = null
endfunction
private function GroupModeActionFunc takes nothing returns nothing
local player p = GetTriggerPlayer()
local integer playerId = GetPlayerId(p)
// I mixed up the images so the mode is reversed
set udg_TalentControlSingleMode[playerId] = true
if GetLocalPlayer() == p then
call BlzFrameSetVisible(FrameSingleMode, true)
call BlzFrameSetVisible(FrameGroupMode, false)
endif
set p = null
endfunction
function TalentGridCreate takes nothing returns nothing
local integer rows = RowsAmount
local integer cols = ColsAmount
local integer y
local integer x
local integer frameIndex
local framehandle parent
local framehandle tooltipFrame
local framehandle showButtonIcon
call BlzLoadTOCFile("war3mapImported/Talentbox.toc")
set parent = BlzCreateFrameByType("BUTTON", "TalentGridParent", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
call BlzFrameSetAllPoints(BlzCreateFrameByType("BACKDROP", "TalentGridBackground", parent, "TalentBoxBackground", 0), parent)
call BlzFrameSetSize(parent, 0.1, 0.1)
call BlzFrameSetAbsPoint(parent, PosType, PosX, PosY)
set FrameParent = parent
call BlzTriggerRegisterFrameEvent(WheelTrigger, parent, FRAMEEVENT_MOUSE_WHEEL)
set FrameTitle = BlzCreateFrame("TalentBoxTitle", parent, 0, 0)
call BlzFrameSetPoint(FrameTitle, FRAMEPOINT_TOP, parent, FRAMEPOINT_TOP, 0.0, -0.024)
call BlzFrameSetText(FrameTitle, GetLocalizedString(StringTitlePrefix))
set FrameItemParent = BlzCreateFrameByType("FRAME", "TalentBoxOptionParent", parent, "", 0)
set FrameClose = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentCloseButton", parent, "ScriptDialogButton", 0)
call BlzFrameSetText(FrameClose, "X")
call BlzFrameSetSize(FrameClose, 0.035, 0.035)
call BlzFrameSetPoint(FrameClose, FRAMEPOINT_TOPRIGHT, parent, FRAMEPOINT_TOPRIGHT, 0.0, 0)
call BlzTriggerRegisterFrameEvent(CloseTrigger, FrameClose, FRAMEEVENT_CONTROL_CLICK)
if ShowButtonIcon != null and ShowButtonIcon != "" then
set FrameShow = BlzCreateFrameByType("GLUEBUTTON", "TalentGridShowButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "IconButtonTemplate", 0)
set showButtonIcon = BlzCreateFrameByType("BACKDROP", "TalentGridShowButtonIcon", FrameShow, "", 0)
call BlzFrameSetTexture(showButtonIcon, ShowButtonIcon, 0, true)
call BlzFrameSetAllPoints(showButtonIcon, FrameShow)
else
set FrameShow = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentGridShowButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "ScriptDialogButton", 0)
endif
call BlzFrameSetSize(FrameShow, ShowButtonSizeX, ShowButtonSizeY)
call BlzFrameSetText(FrameShow, GetLocalizedString(StringButtonShowText))
call BlzFrameSetAbsPoint(FrameShow, ShowButtonPosType, ShowButtonPosX, ShowButtonPosY)
call BlzTriggerRegisterFrameEvent(ShowTrigger, FrameShow, FRAMEEVENT_CONTROL_CLICK)
set FrameShowSprite = BlzCreateFrameByType("SPRITE", "TalentGridShowButtonSprite", FrameShow, "", 0)
call BlzFrameSetModel(FrameShowSprite, ShowButtonSpritePath, 0)
call BlzFrameSetAllPoints(FrameShowSprite, FrameShow)
call BlzFrameSetScale(FrameShowSprite, BlzFrameGetWidth(FrameShow)/ShowButtonSpriteSize)
call BlzFrameSetVisible(FrameShowSprite, false)
set y = 0
loop
exitwhen y >= rows
set FrameLevel[y] = BlzCreateFrame("TalentBoxGridText", FrameItemParent, 0, 0)
set FrameLevelText[y] = BlzGetFrameByName("TalentBoxGridTextValue", 0)
call BlzFrameSetSize(FrameLevel[y], OptionLevelSizeX, OptionLevelSizeY)
call BlzTriggerRegisterFrameEvent(WheelTrigger, FrameLevel[y], FRAMEEVENT_MOUSE_WHEEL)
if y == 0 then
call BlzFrameSetPoint(FrameLevel[y], FRAMEPOINT_TOPLEFT, parent, FRAMEPOINT_TOPLEFT, 0.015, -0.045)
else
call BlzFrameSetPoint(FrameLevel[y], FRAMEPOINT_TOPLEFT, FrameLevel[y - 1], FRAMEPOINT_BOTTOMLEFT, 0, 0)
endif
set x = 1
loop
exitwhen x > cols
set frameIndex = y*cols + x
set FrameItem[frameIndex] = BlzCreateFrame("TalentBoxGridItem", FrameItemParent, 0, 0)
set FrameItemIcon[frameIndex] = BlzGetFrameByName("TalentBoxGridItemIcon", 0)
set FrameItemText[frameIndex] = BlzGetFrameByName("TalentBoxGridItemTitle", 0)
call BlzFrameSetSize(FrameItem[frameIndex], OptionSizeX, OptionSizeY)
call BlzFrameSetSize(FrameItemIcon[frameIndex], OptionIconSize, OptionIconSize)
call BlzFrameSetVisible(FrameItemText[frameIndex], OptionShowText)
call SaveInteger(udg_TalentHash, GetHandleId(FrameItem[frameIndex]), 0, x)
if x == 1 then
call BlzFrameSetPoint(FrameItem[frameIndex], FRAMEPOINT_BOTTOMLEFT, FrameLevel[y], FRAMEPOINT_BOTTOMRIGHT, 0, 0)
else
call BlzFrameSetPoint(FrameItem[frameIndex], FRAMEPOINT_BOTTOMLEFT, FrameItem[frameIndex - 1], FRAMEPOINT_BOTTOMRIGHT, 0, 0)
endif
call BlzTriggerRegisterFrameEvent(PickTrigger, FrameItem[frameIndex], FRAMEEVENT_CONTROL_CLICK)
if OptionHaveTooltip then
// create an empty FRAME parent for the box BACKDROP, otherwise it can happen that it gets limited to the 4:3 Screen.
set tooltipFrame = BlzCreateFrame("TalentBoxTooltipBoxFrame", FrameItem[frameIndex], 0, 0)
set FrameItemToolTip[frameIndex] = BlzGetFrameByName("TalentBoxTooltipBox", 0)
set FrameItemToolTipIcon[frameIndex] = BlzGetFrameByName("TalentBoxTooltipIcon", 0)
set FrameItemToolTipName[frameIndex] = BlzGetFrameByName("TalentBoxTooltipName", 0)
set FrameItemToolTipText[frameIndex] = BlzGetFrameByName("TalentBoxTooltipText", 0)
call BlzFrameSetSize(FrameItemToolTipText[frameIndex], OptionTooltipSizeX, 0)
if OptionTooltipFixedPos then
call BlzFrameSetAbsPoint(FrameItemToolTipText[frameIndex], OptionTooltipPos, OptionTooltipPosX, OptionTooltipPosY)
else
call BlzFrameSetPoint(FrameItemToolTipText[frameIndex], OptionTooltipRelaPosA, FrameParent, OptionTooltipRelaPosB, OptionTooltipRelaPosX, OptionTooltipRelaPosY)
endif
call BlzFrameSetPoint(FrameItemToolTip[frameIndex], FRAMEPOINT_TOPLEFT, FrameItemToolTipIcon[frameIndex], FRAMEPOINT_TOPLEFT, -0.005, 0.005)
call BlzFrameSetPoint(FrameItemToolTip[frameIndex], FRAMEPOINT_BOTTOMRIGHT, FrameItemToolTipText[frameIndex], FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
call BlzFrameSetTooltip(FrameItem[frameIndex], tooltipFrame)
endif
set x = x + 1
endloop
set FrameSelected[y] = BlzCreateFrame("TalentHighlight", FrameItemParent, 0, 0)
call BlzFrameSetVisible(FrameSelected[y], false)
set y = y + 1
endloop
call BlzFrameSetSize(parent, 0.033 + OptionLevelSizeX + cols*OptionSizeX, 0.09 + OptionSizeY*rows)
set FrameSlider = BlzCreateFrameByType("SLIDER", "FrameFlowSlider", FrameItemParent, "QuestMainListScrollBar", 0)
call BlzFrameClearAllPoints(FrameSlider)
call BlzFrameSetStepSize(FrameSlider, 1)
call BlzFrameSetSize(FrameSlider, 0.012, BlzFrameGetHeight(FrameLevel[1]) * rows)
call BlzFrameSetPoint(FrameSlider, FRAMEPOINT_TOPRIGHT, parent, FRAMEPOINT_TOPRIGHT, -0.0075, -0.045)
call BlzFrameSetVisible(FrameSlider, true)
call BlzTriggerRegisterFrameEvent(SliderTrigger, FrameSlider, FRAMEEVENT_MOUSE_WHEEL)
call BlzTriggerRegisterFrameEvent(SliderTrigger, FrameSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
set FrameReset = BlzCreateFrameByType("GLUETEXTBUTTON", "TalentResetButton", FrameItemParent, "ScriptDialogButton", 0)
call CreateTooltip(FrameReset, "UI/Widgets/EscMenu/Human/blank-background", StringButtonResetText, StringButtonResetTooltip)
call BlzFrameSetText(FrameReset, GetLocalizedString(StringButtonResetText))
call BlzFrameSetSize(FrameReset, ResetSizeX, ResetSizeY)
call BlzFrameSetPoint(FrameReset, FRAMEPOINT_BOTTOMRIGHT, parent, FRAMEPOINT_BOTTOMRIGHT, -0.027, 0.02)
call BlzTriggerRegisterFrameEvent(MyResetTrigger, FrameReset, FRAMEEVENT_CONTROL_CLICK)
call BlzFrameSetVisible(FrameReset, HaveResetButton)
set FrameGroupMode = BlzCreateFrame("TalentButtonGroupMode", FrameItemParent, 0, 0)
set FrameSingleMode = BlzCreateFrame("TalentButtonSingleMode", FrameItemParent, 0, 0)
call BlzFrameSetPoint(FrameGroupMode, FRAMEPOINT_BOTTOMRIGHT, parent, FRAMEPOINT_BOTTOMRIGHT, -0.027 - ResetSizeX , 0.02)
call BlzFrameSetPoint(FrameSingleMode, FRAMEPOINT_BOTTOMRIGHT, parent, FRAMEPOINT_BOTTOMRIGHT, -0.027 - ResetSizeX, 0.02)
call BlzFrameSetVisible(FrameGroupMode, false)
call BlzTriggerRegisterFrameEvent(GroupModeTrigger, FrameGroupMode, FRAMEEVENT_CONTROL_CLICK)
call BlzTriggerRegisterFrameEvent(SingleModeTrigger, FrameSingleMode, FRAMEEVENT_CONTROL_CLICK)
call CreateTooltip(FrameGroupMode, StringTooltipGroupModeIcon, StringTooltipGroupModeHead, StringTooltipGroupModeText)
call CreateTooltip(FrameSingleMode, StringTooltipSingleModeIcon, StringTooltipSingleModeHead, StringTooltipSingleModeText)
call BlzFrameSetVisible(parent, false)
endfunction
private function SelectActionFunc takes nothing returns nothing
call TalentGridShow(GetTriggerUnit(), GetTriggerPlayer())
endfunction
private function TimerActionFunc takes nothing returns nothing
call GroupEnumUnitsSelected(SelectionCheckGroup, GetLocalPlayer(), null)
if AutoCloseWithoutSelection and GetHandleId(FirstOfGroup(SelectionCheckGroup)) == 0 then
call BlzFrameSetVisible(FrameParent, false)
call BlzFrameSetVisible(FrameShow, true)
else
call TalentGridUpdate(GetLocalPlayer())
endif
call GroupClear(SelectionCheckGroup)
endfunction
function TalentGridInit takes nothing returns nothing
set SelectTrigger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(SelectTrigger, EVENT_PLAYER_UNIT_SELECTED)
call TriggerAddAction(SelectTrigger, function SelectActionFunc)
set WheelTrigger = CreateTrigger()
call TriggerAddAction(WheelTrigger, function WheelActionFunc)
set CloseTrigger = CreateTrigger()
call TriggerAddAction(CloseTrigger, function CloseActionFunc)
set ShowTrigger = CreateTrigger()
call TriggerAddAction(ShowTrigger, function ShowActionFunc)
set SliderTrigger = CreateTrigger()
call TriggerAddAction(SliderTrigger, function SliderActionFunc)
set MyResetTrigger = CreateTrigger()
call TriggerAddAction(MyResetTrigger, function ResetActionFunc)
set PickTrigger = CreateTrigger()
call TriggerAddAction(PickTrigger, function PickActionFunc)
set GroupModeTrigger = CreateTrigger()
call TriggerAddAction(GroupModeTrigger, function GroupModeActionFunc)
set SingleModeTrigger = CreateTrigger()
call TriggerAddAction(SingleModeTrigger, function SingleModeActionFunc)
call TalentGridCreate()
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function TalentGridCreate)
endif
set SelectionCheckTimer = CreateTimer()
set SelectionCheckGroup = CreateGroup()
call TimerStart(SelectionCheckTimer, 0.25, true, function TimerActionFunc)
endfunction
endlibrary
//TalentPreMadeChoice 1.2b
//by Tasyen
// Contains Predefined ChoiceCreations
//API
//=========
// function TalentChoiceCreateStats takes integer strAdd, integer agiAdd, integer intAdd returns integer
// Create a new Choice which adds Str, agi and int.
// The Choice is added to the last created Tier.
// This also generates Main-Text showing the stats gained.
// If you wana add pre Text do it as shown below
// set udg_TalentChoiceText[udg_TalentChoiceLast] = "your Text" + udg_TalentChoiceText[udg_TalentChoiceLast]
// function TalentChoiceCreateStr takes integer add returns integer
// function TalentChoiceCreateAgi takes integer add returns integer
// function TalentChoiceCreateInt takes integer add returns integer
// function TalentChoiceCreateSustain takes integer lifeAdd, integer manaAdd, real armorAdd returns integer
// function TalentChoiceCreateImproveWeapon takes integer weaponIndex, integer damageAdd, real cooldownAdd returns integer
// function TalentChoiceCreateImproveSpell takes integer spell, integer manaCostAdd, real cooldownAdd returns integer
// use negative values to improve the spell.
// function TalentChoiceCreateAddSpell takes integer spell, boolean useButtonInfos returns integer
// this choice will add 1 ability, if useButtonInfos is used then text, HeadLine and Icon are taken from the spell
//=======================
function TalentChoiceAddTextInt takes string name, integer value returns nothing
if value != 0 then
set udg_TalentChoiceText[udg_TalentChoiceLast] = udg_TalentChoiceText[udg_TalentChoiceLast] +name+"|r: "+ I2S(value)
endif
endfunction
function TalentChoiceAddTextIntAsObject takes string name, integer value returns nothing
if value != 0 then
set udg_TalentChoiceText[udg_TalentChoiceLast] = udg_TalentChoiceText[udg_TalentChoiceLast] +name+ GetObjectName(value)+"|r"
endif
endfunction
function TalentChoiceAddTextReal takes string name, real value returns nothing
if value != 0 then
set udg_TalentChoiceText[udg_TalentChoiceLast] = udg_TalentChoiceText[udg_TalentChoiceLast] +name+"|r: "+ R2SW(value,1,1)
endif
endfunction
function TalentChoiceStatsLearn takes nothing returns nothing
call SetHeroStr(udg_Talent__Unit, GetHeroStr(udg_Talent__Unit,false) + udg_TalentChoiceInt1[udg_Talent__Choice],true)
call SetHeroAgi(udg_Talent__Unit, GetHeroAgi(udg_Talent__Unit,false) + udg_TalentChoiceInt2[udg_Talent__Choice],true)
call SetHeroInt(udg_Talent__Unit, GetHeroInt(udg_Talent__Unit,false) + udg_TalentChoiceInt3[udg_Talent__Choice],true)
endfunction
function TalentChoiceStatsReset takes nothing returns nothing
call SetHeroStr(udg_Talent__Unit, GetHeroStr(udg_Talent__Unit,false) - udg_TalentChoiceInt1[udg_Talent__Choice],true)
call SetHeroAgi(udg_Talent__Unit, GetHeroAgi(udg_Talent__Unit,false) - udg_TalentChoiceInt2[udg_Talent__Choice],true)
call SetHeroInt(udg_Talent__Unit, GetHeroInt(udg_Talent__Unit,false) - udg_TalentChoiceInt3[udg_Talent__Choice],true)
endfunction
function TalentChoiceSustainLearn takes nothing returns nothing
call BlzSetUnitMaxHP(udg_Talent__Unit, BlzGetUnitMaxHP(udg_Talent__Unit) + udg_TalentChoiceInt1[udg_Talent__Choice])
call BlzSetUnitMaxMana(udg_Talent__Unit, BlzGetUnitMaxMana(udg_Talent__Unit) + udg_TalentChoiceInt2[udg_Talent__Choice])
call BlzSetUnitArmor(udg_Talent__Unit, BlzGetUnitArmor(udg_Talent__Unit) + udg_TalentChoiceReal1[udg_Talent__Choice])
call SetUnitState(udg_Talent__Unit, UNIT_STATE_LIFE, GetUnitState(udg_Talent__Unit,UNIT_STATE_LIFE) + udg_TalentChoiceInt1[udg_Talent__Choice])
call SetUnitState(udg_Talent__Unit, UNIT_STATE_MANA, GetUnitState(udg_Talent__Unit,UNIT_STATE_MANA) + udg_TalentChoiceInt2[udg_Talent__Choice])
endfunction
function TalentChoiceSustainReset takes nothing returns nothing
call BlzSetUnitMaxHP(udg_Talent__Unit, BlzGetUnitMaxHP(udg_Talent__Unit) - udg_TalentChoiceInt1[udg_Talent__Choice])
call BlzSetUnitMaxMana(udg_Talent__Unit, BlzGetUnitMaxMana(udg_Talent__Unit) - udg_TalentChoiceInt2[udg_Talent__Choice])
call BlzSetUnitArmor(udg_Talent__Unit, BlzGetUnitArmor(udg_Talent__Unit) - udg_TalentChoiceReal1[udg_Talent__Choice])
endfunction
function TalentChoiceImproveWeaponLearn takes nothing returns nothing
//Weapon, Damage, Cooldown
call BlzSetUnitAttackCooldown(udg_Talent__Unit, BlzGetUnitAttackCooldown(udg_Talent__Unit, udg_TalentChoiceInt1[udg_Talent__Choice]) + udg_TalentChoiceReal1[udg_Talent__Choice], udg_TalentChoiceInt1[udg_Talent__Choice])
call BlzSetUnitBaseDamage(udg_Talent__Unit, BlzGetUnitBaseDamage(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice]) + udg_TalentChoiceInt2[udg_Talent__Choice], udg_TalentChoiceInt1[udg_Talent__Choice])
endfunction
function TalentChoiceImproveWeaponReset takes nothing returns nothing
//Weapon, Damage, Cooldown
call BlzSetUnitAttackCooldown(udg_Talent__Unit, BlzGetUnitAttackCooldown(udg_Talent__Unit, udg_TalentChoiceInt1[udg_Talent__Choice]) - udg_TalentChoiceReal1[udg_Talent__Choice], udg_TalentChoiceInt1[udg_Talent__Choice])
call BlzSetUnitBaseDamage(udg_Talent__Unit, BlzGetUnitBaseDamage(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice]) - udg_TalentChoiceInt2[udg_Talent__Choice], udg_TalentChoiceInt1[udg_Talent__Choice])
endfunction
function TalentChoiceImproveUnitSpellLearn takes nothing returns nothing
call BlzSetUnitAbilityManaCost(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice], 0, BlzGetUnitAbilityManaCost(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice], 0) + udg_TalentChoiceInt2[udg_Talent__Choice])
call BlzSetUnitAbilityCooldown(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice], 0, BlzGetUnitAbilityCooldown(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice], 0) + udg_TalentChoiceReal1[udg_Talent__Choice])
endfunction
function TalentChoiceImproveUnitSpellReset takes nothing returns nothing
call BlzSetUnitAbilityManaCost(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice], 0, BlzGetUnitAbilityManaCost(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice], 0) - udg_TalentChoiceInt2[udg_Talent__Choice])
call BlzSetUnitAbilityCooldown(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice], 0, BlzGetUnitAbilityCooldown(udg_Talent__Unit,udg_TalentChoiceInt1[udg_Talent__Choice], 0) - udg_TalentChoiceReal1[udg_Talent__Choice])
endfunction
function TalentChoiceCreateStats takes integer strAdd, integer agiAdd, integer intAdd returns integer
call TalentChoiceCreateTriggerEx(udg_TalentPreMadeChoiceTrigger[0],udg_TalentPreMadeChoiceTrigger[1])
set udg_TalentChoiceInt1[udg_TalentChoiceLast] = strAdd
set udg_TalentChoiceInt2[udg_TalentChoiceLast] = agiAdd
set udg_TalentChoiceInt3[udg_TalentChoiceLast] = intAdd
set udg_TalentChoiceText[udg_TalentChoiceLast] = udg_TalentStrings[28]
call TalentChoiceAddTextInt(udg_TalentStrings[29],udg_TalentChoiceInt1[udg_TalentChoiceLast])
call TalentChoiceAddTextInt(udg_TalentStrings[30],udg_TalentChoiceInt2[udg_TalentChoiceLast])
call TalentChoiceAddTextInt(udg_TalentStrings[31],udg_TalentChoiceInt3[udg_TalentChoiceLast])
return udg_TalentChoiceLast
endfunction
function TalentChoiceCreateStr takes integer add returns integer
return TalentChoiceCreateStats(add,0,0)
endfunction
function TalentChoiceCreateAgi takes integer add returns integer
return TalentChoiceCreateStats(0,add,0)
endfunction
function TalentChoiceCreateInt takes integer add returns integer
return TalentChoiceCreateStats(0,0,add)
endfunction
function TalentChoiceCreateSustain takes integer lifeAdd, integer manaAdd, real armorAdd returns integer
call TalentChoiceCreateTriggerEx(udg_TalentPreMadeChoiceTrigger[2],udg_TalentPreMadeChoiceTrigger[3])
set udg_TalentChoiceInt1[udg_TalentChoiceLast] = lifeAdd
set udg_TalentChoiceInt2[udg_TalentChoiceLast] = manaAdd
set udg_TalentChoiceReal1[udg_TalentChoiceLast] = armorAdd
set udg_TalentChoiceText[udg_TalentChoiceLast] = udg_TalentStrings[20]
call TalentChoiceAddTextInt(udg_TalentStrings[21],udg_TalentChoiceInt1[udg_TalentChoiceLast])
call TalentChoiceAddTextInt(udg_TalentStrings[22],udg_TalentChoiceInt2[udg_TalentChoiceLast])
call TalentChoiceAddTextReal(udg_TalentStrings[23],udg_TalentChoiceReal1[udg_TalentChoiceLast])
return udg_TalentChoiceLast
endfunction
function TalentChoiceCreateImproveWeapon takes integer weaponIndex, integer damageAdd, real cooldownAdd returns integer
call TalentChoiceCreateTriggerEx(udg_TalentPreMadeChoiceTrigger[4],udg_TalentPreMadeChoiceTrigger[5])
set udg_TalentChoiceInt1[udg_TalentChoiceLast] = weaponIndex
set udg_TalentChoiceInt2[udg_TalentChoiceLast] = damageAdd
set udg_TalentChoiceReal1[udg_TalentChoiceLast] = cooldownAdd
set udg_TalentChoiceText[udg_TalentChoiceLast] = udg_TalentStrings[15]+ I2S(udg_TalentChoiceInt1[udg_TalentChoiceLast])
call TalentChoiceAddTextInt(udg_TalentStrings[16],udg_TalentChoiceInt2[udg_TalentChoiceLast])
call TalentChoiceAddTextReal(udg_TalentStrings[17],udg_TalentChoiceReal1[udg_TalentChoiceLast])
return udg_TalentChoiceLast
endfunction
function TalentChoiceCreateImproveSpell takes integer spell, integer manaCostAdd, real cooldownAdd returns integer
call TalentChoiceCreateTriggerEx(udg_TalentPreMadeChoiceTrigger[6],udg_TalentPreMadeChoiceTrigger[7])
set udg_TalentChoiceInt1[udg_TalentChoiceLast] = spell
set udg_TalentChoiceInt2[udg_TalentChoiceLast] = manaCostAdd
set udg_TalentChoiceReal1[udg_TalentChoiceLast] = cooldownAdd
set udg_TalentChoiceText[udg_TalentChoiceLast] = udg_TalentStrings[9] + GetObjectName(spell)
call TalentChoiceAddTextInt(udg_TalentStrings[10],udg_TalentChoiceInt2[udg_TalentChoiceLast])
call TalentChoiceAddTextReal(udg_TalentStrings[11],udg_TalentChoiceReal1[udg_TalentChoiceLast])
return udg_TalentChoiceLast
endfunction
function TalentChoiceCreateAddSpell takes integer spell, boolean useButtonInfos returns integer
call TalentChoiceCreateEx(null,null)
call TalentChoiceAddAbility(udg_TalentChoiceLast, spell)
if useButtonInfos then
set udg_TalentChoiceText[udg_TalentChoiceLast] = BlzGetAbilityExtendedTooltip(spell,0)
set udg_TalentChoiceHead[udg_TalentChoiceLast] = BlzGetAbilityTooltip(spell,0)
set udg_TalentChoiceIcon[udg_TalentChoiceLast] = BlzGetAbilityIcon(spell)
endif
return udg_TalentChoiceLast
endfunction
//===========================================================================
function InitTrig_TalentPreMadeChoice takes nothing returns nothing
set udg_TalentPreMadeChoiceTrigger[0] = CreateTrigger()
set udg_TalentPreMadeChoiceTrigger[1] = CreateTrigger()
set udg_TalentPreMadeChoiceTrigger[2] = CreateTrigger()
set udg_TalentPreMadeChoiceTrigger[3] = CreateTrigger()
set udg_TalentPreMadeChoiceTrigger[4] = CreateTrigger()
set udg_TalentPreMadeChoiceTrigger[5] = CreateTrigger()
set udg_TalentPreMadeChoiceTrigger[6] = CreateTrigger()
set udg_TalentPreMadeChoiceTrigger[7] = CreateTrigger()
call TriggerAddAction(udg_TalentPreMadeChoiceTrigger[0], function TalentChoiceStatsLearn)
call TriggerAddAction(udg_TalentPreMadeChoiceTrigger[1], function TalentChoiceStatsReset)
call TriggerAddAction(udg_TalentPreMadeChoiceTrigger[2], function TalentChoiceSustainLearn)
call TriggerAddAction(udg_TalentPreMadeChoiceTrigger[3], function TalentChoiceSustainReset)
call TriggerAddAction(udg_TalentPreMadeChoiceTrigger[4], function TalentChoiceImproveWeaponLearn)
call TriggerAddAction(udg_TalentPreMadeChoiceTrigger[5], function TalentChoiceImproveWeaponReset)
call TriggerAddAction(udg_TalentPreMadeChoiceTrigger[6], function TalentChoiceImproveUnitSpellLearn)
call TriggerAddAction(udg_TalentPreMadeChoiceTrigger[7], function TalentChoiceImproveUnitSpellReset)
endfunction
//Talent GUI 1.04
//by Tasyen
//===========================================================================
// Makes Talent Registering useable using GUI only.
//===========================================================================
function TalentGuiCreateChoice takes nothing returns nothing
local integer heroTier = TalentHeroGetTier(udg_TalentGUI_UnitType, udg_TalentGUI_Level)
if heroTier == 0 then
set heroTier = TalentHeroTierCreate(udg_TalentGUI_UnitType, udg_TalentGUI_Level)
endif
call TalentTierAddChoice(heroTier, TalentChoiceCreateAllTrigger(udg_TalentGUI_ChoiceHead,udg_TalentGUI_ChoiceText,udg_TalentGUI_ChoiceIcon,udg_TalentGUI_OnLearn,udg_TalentGUI_OnReset))
set udg_TalentGUI_OnReset = null
set udg_TalentGUI_OnLearn = null
if udg_TalentGUI_Spell != 0 and udg_TalentGUI_ReplacedSpell != 0 then
call TalentChoiceReplaceAbilityEx(udg_TalentGUI_ReplacedSpell,udg_TalentGUI_Spell)
set udg_TalentGUI_Spell = 0
set udg_TalentGUI_ReplacedSpell = 0
elseif udg_TalentGUI_Spell != 0 then
call TalentChoiceAddAbilityEx(udg_TalentGUI_Spell)
set udg_TalentGUI_Spell = 0
endif
endfunction
function TalentGuiAddSpell takes nothing returns nothing
call TalentChoiceAddAbilityEx(udg_TalentGUI_Spell)
set udg_TalentGUI_Spell = 0
endfunction
function TalentGuiReplaceSpell takes nothing returns nothing
call TalentChoiceReplaceAbilityEx(udg_TalentGUI_ReplacedSpell,udg_TalentGUI_Spell)
set udg_TalentGUI_Spell = 0
endfunction
function TalentGuiFinalize takes nothing returns nothing
call TalentHeroSetFinalTier(udg_TalentGUI_UnitType, udg_TalentGUI_Level)
endfunction
function TalentGuiCopy takes nothing returns nothing
call TalentHeroSetCopy(udg_TalentGUI_UnitType, udg_TalentGUI_UnitTypeCopied)
endfunction
//===========================================================================
function InitTrig_TalentGUI takes nothing returns nothing
set gg_trg_TalentGUI = CreateTrigger( )
set udg_TalentGUICreateChoice = CreateTrigger()
set udg_TalentGUIAddSpell = CreateTrigger()
set udg_TalentGUIReplaceSpell = CreateTrigger()
set udg_TalentGUICopyUnit = CreateTrigger()
call TriggerAddAction(udg_TalentGUICreateChoice, function TalentGuiCreateChoice)
call TriggerAddAction(udg_TalentGUIAddSpell, function TalentGuiAddSpell)
call TriggerAddAction(udg_TalentGUIReplaceSpell, function TalentGuiReplaceSpell)
call TriggerAddAction(udg_TalentGUICopyUnit, function TalentGuiCopy)
call TriggerAddAction(gg_trg_TalentGUI, function TalentGuiFinalize)
endfunction
function TalentStr takes nothing returns nothing
call ModifyHeroStat( bj_HEROSTAT_STR, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 )
endfunction
function TalentStrReset takes nothing returns nothing
call ModifyHeroStat( bj_HEROSTAT_STR, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, -6 )
endfunction
function TalentAgi takes nothing returns nothing
call ModifyHeroStat( bj_HEROSTAT_AGI, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 )
endfunction
function TalentAgiReset takes nothing returns nothing
call ModifyHeroStat( bj_HEROSTAT_AGI, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, -6 )
endfunction
function TalentInt takes nothing returns nothing
call ModifyHeroStat( bj_HEROSTAT_INT, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 )
endfunction
function TalentIntReset takes nothing returns nothing
call ModifyHeroStat( bj_HEROSTAT_INT, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, -6 )
endfunction
function TalentKroneOfKing takes nothing returns nothing
call ModifyHeroStat( bj_HEROSTAT_INT, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 )
call ModifyHeroStat( bj_HEROSTAT_STR, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 )
call ModifyHeroStat( bj_HEROSTAT_AGI, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, 6 )
endfunction
function TalentKroneOfKingReset takes nothing returns nothing
call ModifyHeroStat( bj_HEROSTAT_INT, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, -6 )
call ModifyHeroStat( bj_HEROSTAT_STR, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, -6 )
call ModifyHeroStat( bj_HEROSTAT_AGI, udg_Talent__Unit, bj_MODIFYMETHOD_ADD, -6 )
endfunction
function TalentMithrilBlade takes nothing returns nothing
call BlzSetUnitBaseDamage(udg_Talent__Unit, BlzGetUnitBaseDamage(udg_Talent__Unit, 0) + 20, 0)
endfunction
function TalentMithrilBladeReset takes nothing returns nothing
call BlzSetUnitBaseDamage(udg_Talent__Unit, BlzGetUnitBaseDamage(udg_Talent__Unit, 0) - 20, 0)
endfunction
function TalentMithrilArmor takes nothing returns nothing
call BlzSetUnitArmor(udg_Talent__Unit, BlzGetUnitArmor(udg_Talent__Unit) + 10)
endfunction
function TalentMithrilArmorReset takes nothing returns nothing
call BlzSetUnitArmor(udg_Talent__Unit, BlzGetUnitArmor(udg_Talent__Unit) - 10)
endfunction
function TalentStatChange takes nothing returns nothing
call ModifyHeroStat( udg_StatType[udg_Talent__Choice], udg_Talent__Unit, bj_MODIFYMETHOD_ADD, udg_StatPower[udg_Talent__Choice] )
endfunction
function TalentStatChangeReset takes nothing returns nothing
call ModifyHeroStat( udg_StatType[udg_Talent__Choice], udg_Talent__Unit, bj_MODIFYMETHOD_ADD, -udg_StatPower[udg_Talent__Choice] )
endfunction
//Example for using Talent by Tasyen.
function TalentPaladin takes nothing returns nothing
//Which HeroType is this; Custom Paladin
local integer heroTypeId = 'H001'
local integer choice
local integer abilityId
call TalentHeroSetFinalTier(heroTypeId, 8) //Mark Level 8 as last choice
//HeroTypeId gains at Level 0: create a new Tier
call TalentHeroTierCreate(heroTypeId, 0)
//Create a new Choice and add it to the last Created Tier
set choice = TalentChoiceCreateEx( function TalentStr , function TalentStrReset) //activade function TalentStr when Picking this Talent
set udg_TalentChoiceText[choice] = "Gain 6 Str"
set udg_TalentChoiceHead[choice] = "Handschuhe der Kraft"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNGauntletsOfOgrePower.blp"
set choice = TalentChoiceCreateEx( function TalentAgi , function TalentAgiReset)
set udg_TalentChoiceText[choice] = "Gain 6 Agi"
set udg_TalentChoiceHead[choice] = "Schuhe der Beweglichkeit"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNSlippersOfAgility.blp"
set choice = TalentChoiceCreateEx( function TalentInt , function TalentIntReset)
set udg_TalentChoiceText[choice] = "Gain 6 Int"
set udg_TalentChoiceHead[choice] = "Robe der Weißen"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
//Level 2
call TalentHeroTierCreate(heroTypeId, 2)
set choice = TalentChoiceCreateEx(null, null)
set abilityId = 'Awfb'
call TalentChoiceAddAbility(choice, abilityId) //Skill gained when picking this choice
set udg_TalentChoiceText[choice] = BlzGetAbilityExtendedTooltip(abilityId,1)
set udg_TalentChoiceHead[choice] = BlzGetAbilityTooltip(abilityId,1)
set udg_TalentChoiceIcon[choice] = BlzGetAbilityIcon(abilityId)
set choice = TalentChoiceCreateEx(null, null)
set abilityId = 'AHhb'
call TalentChoiceAddAbility(choice, abilityId)
set udg_TalentChoiceText[choice] = BlzGetAbilityExtendedTooltip(abilityId,1)
set udg_TalentChoiceHead[choice] = BlzGetAbilityTooltip(abilityId,1)
set udg_TalentChoiceIcon[choice] = BlzGetAbilityIcon(abilityId)
//Level 4
call TalentHeroTierCreate(heroTypeId, 4)
set choice = TalentChoiceCreateEx(null, null)
set abilityId = 'Ainf'
call TalentChoiceAddAbility(choice, abilityId)
set udg_TalentChoiceText[choice] = BlzGetAbilityExtendedTooltip(abilityId,1)
set udg_TalentChoiceHead[choice] = BlzGetAbilityTooltip(abilityId,1)
set udg_TalentChoiceIcon[choice] = BlzGetAbilityIcon(abilityId)
set choice = TalentChoiceCreateEx(null, null)
set abilityId = 'Afbt'
call TalentChoiceAddAbility(choice, abilityId)
set udg_TalentChoiceText[choice] = BlzGetAbilityExtendedTooltip(abilityId,1)
set udg_TalentChoiceHead[choice] = BlzGetAbilityTooltip(abilityId,1)
set udg_TalentChoiceIcon[choice] = BlzGetAbilityIcon(abilityId)
//Create Own Variabes and attach them
set choice = TalentChoiceCreateEx( function TalentStatChange , function TalentStatChangeReset) //activade function TalentStr when Picking this Talent
set udg_TalentChoiceText[choice] = "Gain 8 Str"
set udg_TalentChoiceHead[choice] = "Gürtel der Gigantenkraft"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNBelt.blp"
set udg_StatType[choice] = bj_HEROSTAT_STR //choice is the index of the last create Choice, so attach custom Data to it.
set udg_StatPower[choice] = 8
set choice = TalentChoiceCreateEx( function TalentStatChange, function TalentStatChangeReset)
set udg_TalentChoiceText[choice] = "Gain 8 Int"
set udg_TalentChoiceHead[choice] = "Robe der Weißen"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
set udg_StatType[choice] = bj_HEROSTAT_INT
set udg_StatPower[choice] = 8
//Level 6
call TalentHeroTierCreate(heroTypeId, 6)
set choice = TalentChoiceCreateEx(null, null)
set abilityId = 'AHre'
call TalentChoiceAddAbility(choice, abilityId)
set udg_TalentChoiceText[choice] = BlzGetAbilityExtendedTooltip(abilityId,1)
set udg_TalentChoiceHead[choice] = BlzGetAbilityTooltip(abilityId,1)
set udg_TalentChoiceIcon[choice] = BlzGetAbilityIcon(abilityId)
set choice = TalentChoiceCreateEx(null, null)
set abilityId = 'AHav'
call TalentChoiceAddAbility(choice, abilityId)
set udg_TalentChoiceText[choice] = BlzGetAbilityExtendedTooltip(abilityId,1)
set udg_TalentChoiceHead[choice] = BlzGetAbilityTooltip(abilityId,1)
set udg_TalentChoiceIcon[choice] = BlzGetAbilityIcon(abilityId)
//Level 8
call TalentHeroTierCreate(heroTypeId, 8)
set choice = TalentChoiceCreateEx(function TalentKroneOfKing, function TalentKroneOfKingReset)
set udg_TalentChoiceText[choice] = "Gain + 6 to all stats"
set udg_TalentChoiceHead[choice] = "Krone des Königs"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHelmutPurple.blp"
set choice = TalentChoiceCreateEx(function TalentMithrilBlade, function TalentMithrilBladeReset)
set udg_TalentChoiceText[choice] = "Gain 20 ATK"
set udg_TalentChoiceHead[choice] = "Mithril Blade"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNArcaniteMelee.blp"
set choice = TalentChoiceCreateEx(function TalentMithrilArmor, function TalentMithrilArmorReset)
set udg_TalentChoiceText[choice] = "Gain 10 Armor"
set udg_TalentChoiceHead[choice] = "Mithril Armor"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHumanArmorUpThree.blp"
endfunction
//===========================================================================
function InitTrig_Talent_Paladin takes nothing returns nothing
set gg_trg_Talent_Paladin = CreateTrigger( )
call TriggerAddAction( gg_trg_Talent_Paladin, function TalentPaladin )
endfunction
//Example for using Talent by Tasyen.
function Talent_Dagren takes nothing returns nothing
call TalentHeroSetCopy('H003', 'H001') //'H003' uses the same talents as 'H001'
call TalentHeroSetCopy('H004', 'H002') //'H004' uses the same talents as 'H002'
//You also shoud copy when an unit can morph
endfunction
//===========================================================================
function InitTrig_Talent_Copy_Palaidn takes nothing returns nothing
set gg_trg_Talent_Copy_Palaidn = CreateTrigger( )
call TriggerAddAction( gg_trg_Talent_Copy_Palaidn, function Talent_Dagren )
endfunction
//Example for using Talent by Tasyen.
function TalentBloodMage takes nothing returns nothing
local integer heroTypeId = 'H005' //Custom BloodMage
local integer choice
local integer abilityId
call TalentHeroSetFinalTier(heroTypeId, 10) //Mark Level 10 as last choice, after the heroe picks it, the selection skills are removed.
call TalentHeroTierCreate(heroTypeId, 0)
set choice = TalentChoiceCreateAddSpells('AHfs','ANbf','ANfb') //Create a choice adding this 3 spells and add the choice to the last created Tier
set udg_TalentChoiceText[choice] = "Learn Firebolt, Breath of Fire and Flamestrike"
set udg_TalentChoiceHead[choice] = "Fire Magic"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNFire.blp"
set choice = TalentChoiceCreateAddSpells('ANfl','AOcl','ANmo')
//set udg_TalentChoiceText[choice] = "Learn Chaing Lighnting, Moonsoun and Foked Lightning"
set udg_TalentChoiceHead[choice] = "Lightning Magic"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNMonsoon.blp"
//LEVEL 5
call TalentHeroTierCreate(heroTypeId, 5)
set choice = TalentChoiceCreateStats(6, 3, 3)
set udg_TalentChoiceHead[choice] = "Magic Power: Str"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHelmOfValor.blp"
set choice = TalentChoiceCreateStats(3, 6, 3)
set udg_TalentChoiceHead[choice] = "Magic Power: AGI"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHoodOfCunning.blp"
set choice = TalentChoiceCreateStats(3, 3, 6)
set udg_TalentChoiceHead[choice] = "Magic Power: Int"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNPipeOfInsight.blp"
//Level 10
call TalentHeroTierCreate(heroTypeId, 10)
call TalentChoiceCreateAddSpell('AHpx',true)
call TalentChoiceCreateAddSpell('AUin',true)
endfunction
//===========================================================================
function InitTrig_Talent_BloodMag takes nothing returns nothing
set gg_trg_Talent_BloodMag = CreateTrigger( )
call TriggerAddAction( gg_trg_Talent_BloodMag, function TalentBloodMage )
endfunction
//Example for using Talent by Tasyen.
function TalentBloodMage takes nothing returns nothing
local integer heroTypeId = 'H005' //Custom BloodMage
local integer choice
local integer abilityId
call TalentHeroSetFinalTier(heroTypeId, 10) //Mark Level 10 as last choice, after the heroe picks it, the selection skills are removed.
call TalentHeroTierCreate(heroTypeId, 0)
set choice = TalentChoiceCreateAddSpellsSimple("AHfs,ANbf,ANfb") //Create a choice adding this 3 spells and add the choice to the last created Tier
set udg_TalentChoiceHead[choice] = "Fire Magic"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNFire.blp"
set choice = TalentChoiceCreateAddSpellsSimple("ANfl,AOcl,ANmo")
set udg_TalentChoiceHead[choice] = "Lightning Magic"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNMonsoon.blp"
//LEVEL 5
call TalentHeroTierCreate(heroTypeId, 5)
set udg_BlutMagierTier5[0] = udg_TalentTierLast // store this for later usage
set choice = TalentChoiceCreateStats(6, 3, 3)
set udg_TalentChoiceHead[choice] = "Magic Power: Str"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHelmOfValor.blp"
set choice = TalentChoiceCreateStats(3, 6, 3)
set udg_TalentChoiceHead[choice] = "Magic Power: AGI"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHoodOfCunning.blp"
set choice = TalentChoiceCreateStats(3, 3, 6)
set udg_TalentChoiceHead[choice] = "Magic Power: Int"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNPipeOfInsight.blp"
set udg_BlutMagierTier5[1] = TalentTierCreate() // store this for later usage // this is not used in the default Tree
set choice = TalentChoiceCreateAddSpellsSimple("AHhb,AHds,AHad") //Create a choice adding this 3 spells and add the choice to the last created Tier
set udg_TalentChoiceHead[choice] = "Holy Magic"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHolyBolt.blp"
set choice = TalentChoiceCreateAddSpellsSimple("AHad,AHab,AOae")
set udg_TalentChoiceHead[choice] = "Aura Magic"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNBrilliance.blp"
//Level 10
call TalentHeroTierCreate(heroTypeId, 10)
call TalentChoiceCreateAddSpell('AHpx',true)
call TalentChoiceCreateAddSpell('AUin',true)
endfunction
//===========================================================================
function InitTrig_Talent_BloodMag_Kopieren takes nothing returns nothing
set gg_trg_Talent_BloodMag_Kopieren = CreateTrigger( )
call TriggerAddAction( gg_trg_Talent_BloodMag_Kopieren, function TalentBloodMage )
endfunction
//Example for using Talent by Tasyen.
function TalentUther takes nothing returns nothing
local integer choice
//Which HeroType is this; Custom Uther
local integer heroTypeId = 'H002'
call TalentHeroSetFinalTier(heroTypeId, 4)
call TalentHeroTierCreate(heroTypeId, 0)
set choice = TalentChoiceCreateStr(6)
set udg_TalentChoiceText[choice] = "Gain 6 Str"
set udg_TalentChoiceHead[choice] = "Handschuhe der Kraft"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNGauntletsOfOgrePower.blp"
set choice = TalentChoiceCreateAgi(6)
set udg_TalentChoiceText[choice] = "Gain 6 Agi"
set udg_TalentChoiceHead[choice] = "Schuhe der Beweglichkeit"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNSlippersOfAgility.blp"
set choice = TalentChoiceCreateInt(6)
set udg_TalentChoiceText[choice] = "Gain 6 Int"
set udg_TalentChoiceHead[choice] = "Robe der Weißen"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
//Level 1
call TalentHeroTierCreate(heroTypeId, 1)
call TalentChoiceCreateAddSpell('Awfb',true)
call TalentChoiceCreateAddSpell('AHhb',true)
//Level 2
call TalentHeroTierCreate(heroTypeId, 2)
call TalentChoiceCreateAddSpell('Ainf',true)
call TalentChoiceCreateAddSpell('Afbt',true)
//Create Own Variabes and attach them
set choice = TalentChoiceCreateStr(8)
set udg_TalentChoiceText[choice] = "Gain 8 Str"
set udg_TalentChoiceHead[choice] = "Gürtel der Gigantenkraft"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNBelt.blp"
set choice = TalentChoiceCreateInt(8)
set udg_TalentChoiceText[choice] = "Gain 8 Int"
set udg_TalentChoiceHead[choice] = "Robe der Weißen"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
call TalentChoiceCreateAddSpell('ACam',true)
call TalentChoiceCreateAddSpell('ACmp',true)
//Level 3
call TalentHeroTierCreate(heroTypeId, 3)
call TalentChoiceCreateAddSpell('AHre',true)
call TalentChoiceCreateAddSpell('AHav',true)
//Level 4
call TalentHeroTierCreate(heroTypeId, 4)
set choice = TalentChoiceCreateStats(6, 6, 6)
set udg_TalentChoiceText[choice] = "Gain + 6 to all stats"
set udg_TalentChoiceHead[choice] = "Krone des Königs"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHelmutPurple.blp"
set choice = TalentChoiceCreateImproveWeapon(0, 20, 0)
set udg_TalentChoiceText[choice] = "Gain 20 ATK"
set udg_TalentChoiceHead[choice] = "Mithril Blade"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNArcaniteMelee.blp"
set choice = TalentChoiceCreateSustain(0, 0, 10)
set udg_TalentChoiceText[choice] = "Gain 10 Armor"
set udg_TalentChoiceHead[choice] = "Mithril Armor"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHumanArmorUpThree.blp"
endfunction
//===========================================================================
function InitTrig_Talent_Uther takes nothing returns nothing
set gg_trg_Talent_Uther = CreateTrigger( )
call TriggerAddAction( gg_trg_Talent_Uther, function TalentUther )
endfunction
//Example for using Talent by Tasyen.
function TalentsPitLord takes nothing returns nothing
local integer choice
local integer LoopA = 20
local integer heroTypeId = 'N000' //Custom PitLord
local integer tier = TalentTierCreate() //Create a Tier and remember it
call TalentHeroSetFinalTier(heroTypeId, 20)
set choice = TalentChoiceCreateStr(6)
set udg_TalentChoiceText[choice] = "Gain 6 Str"
set udg_TalentChoiceHead[choice] = "Handschuhe der Kraft"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNGauntletsOfOgrePower.blp"
set choice = TalentChoiceCreateAgi(6)
set udg_TalentChoiceText[choice] = "Gain 6 Agi"
set udg_TalentChoiceHead[choice] = "Schuhe der Beweglichkeit"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNSlippersOfAgility.blp"
set choice = TalentChoiceCreateInt(6)
set udg_TalentChoiceText[choice] = "Gain 6 Int"
set udg_TalentChoiceHead[choice] = "Robe der Weißen"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
loop //Add tier for Level 20 to 1 (count down), uses always the same tier and choices
call TalentHeroSetTier(heroTypeId, LoopA, tier)
set LoopA = LoopA - 1
exitwhen LoopA == 0
endloop
endfunction
//===========================================================================
function InitTrig_Talent_GrubenLord takes nothing returns nothing
set gg_trg_Talent_GrubenLord = CreateTrigger( )
call TriggerAddAction( gg_trg_Talent_GrubenLord, function TalentsPitLord )
endfunction
//Example for using Talent by Tasyen.
function TalentFootmen takes nothing returns nothing
local integer choice
//Which HeroType is this; Footmen
local integer heroTypeId = 'hfoo'
call TalentHeroSetFinalTier(heroTypeId, 1)
call TalentHeroTierCreate(heroTypeId, 1)
//Create a new Choice and add it to the last Created Tier
set choice = TalentChoiceCreateImproveWeapon(0, 6, 0)
set udg_TalentChoiceHead[choice] = "Deadly Footman"
set udg_TalentChoiceText[choice] = "Increases Base AttackDamage by 6"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNSteelMelee.blp"
set choice = TalentChoiceCreateSustain(0, 0, 4)
set udg_TalentChoiceHead[choice] = "Tanky Footman"
set udg_TalentChoiceText[choice] = "Increases Armor by 4"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHumanArmorUpOne.blp"
endfunction
//===========================================================================
function InitTrig_Talent_FootMen takes nothing returns nothing
set gg_trg_Talent_FootMen = CreateTrigger( )
call TriggerAddAction( gg_trg_Talent_FootMen, function TalentFootmen )
endfunction
//Example for using Talent by Tasyen.
function TalentShadowPriest takes nothing returns nothing
local integer choice
//Which HeroType is this; Wald-Troll-Schattenpriester
local integer heroTypeId = 'nfsp'
call TalentHeroSetFinalTier(heroTypeId, 1)
call TalentHeroTierCreate(heroTypeId, 1)
set choice = TalentChoiceCreateReplaceSpell('Anh1','Anh2')
set udg_TalentChoiceHead[choice] = "More Heal"
set udg_TalentChoiceText[choice] = "Increases Heal by 13"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHealOn.blp"
set choice = TalentChoiceCreateImproveSpell('Anh1', -2, -0.2)
set udg_TalentChoiceHead[choice] = "Cheaper Heal"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNHealOn.blp"
set choice = TalentChoiceCreateSustain(200, 100, 1)
set udg_TalentChoiceHead[choice] = "Sustain Healer"
set udg_TalentChoiceIcon[choice] = "ReplaceableTextures\\CommandButtons\\BTNForestTrollShadowPriest.blp"
endfunction
//===========================================================================
function InitTrig_Talent_ShadowPriest takes nothing returns nothing
set gg_trg_Talent_ShadowPriest = CreateTrigger( )
call TriggerAddAction( gg_trg_Talent_ShadowPriest, function TalentShadowPriest )
endfunction
//Example for using Talent by Tasyen.
function TalentPriestTOC takes nothing returns nothing
call BlzLoadTOCFile("war3mapImported/TalentPriest.toc")
endfunction
function TalentPriest1Learn takes nothing returns nothing
call BlzSetUnitMaxMana(udg_Talent__Unit, BlzGetUnitMaxMana(udg_Talent__Unit) + 100)
call SetUnitState(udg_Talent__Unit, UNIT_STATE_MANA, GetUnitState(udg_Talent__Unit, UNIT_STATE_MANA) + 100)
call BlzSetUnitRealField(udg_Talent__Unit, UNIT_RF_MANA_REGENERATION, BlzGetUnitRealField(udg_Talent__Unit, UNIT_RF_MANA_REGENERATION) + 1)
endfunction
function TalentPriest2Learn takes nothing returns nothing
local ability abi = BlzGetUnitAbility(udg_Talent__Unit, 'Ahea')
call BlzSetAbilityRealLevelField(abi, ABILITY_RLF_HIT_POINTS_GAINED_HEA1, 0, BlzGetAbilityRealLevelField(abi, ABILITY_RLF_HIT_POINTS_GAINED_HEA1, 0) + 5)
set abi = BlzGetUnitAbility(udg_Talent__Unit, 'Adis')
call BlzSetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, 0, BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, 0) + 50)
set abi = BlzGetUnitAbility(udg_Talent__Unit, 'Ainf')
call BlzSetAbilityRealLevelField(abi, ABILITY_RLF_DURATION_HERO, 0, BlzGetAbilityRealLevelField(abi, ABILITY_RLF_DURATION_HERO, 0) + 20)
call BlzSetAbilityRealLevelField(abi, ABILITY_RLF_DURATION_NORMAL, 0, BlzGetAbilityRealLevelField(abi, ABILITY_RLF_DURATION_NORMAL, 0) + 20)
endfunction
function TalentPriest3Learn takes nothing returns nothing
call BlzSetUnitMaxHP(udg_Talent__Unit, BlzGetUnitMaxHP(udg_Talent__Unit) + 200)
call SetUnitState(udg_Talent__Unit, UNIT_STATE_LIFE, GetUnitState(udg_Talent__Unit, UNIT_STATE_LIFE) + 200)
call BlzSetUnitRealField(udg_Talent__Unit, UNIT_RF_HIT_POINTS_REGENERATION_RATE, BlzGetUnitRealField(udg_Talent__Unit, UNIT_RF_HIT_POINTS_REGENERATION_RATE) + 2)
endfunction
function TalentPriest1Reset takes nothing returns nothing
call BlzSetUnitMaxMana(udg_Talent__Unit, BlzGetUnitMaxMana(udg_Talent__Unit) - 100)
call SetUnitState(udg_Talent__Unit, UNIT_STATE_MANA, GetUnitState(udg_Talent__Unit, UNIT_STATE_MANA) - 100)
call BlzSetUnitRealField(udg_Talent__Unit, UNIT_RF_MANA_REGENERATION, BlzGetUnitRealField(udg_Talent__Unit, UNIT_RF_MANA_REGENERATION) - 1)
endfunction
function TalentPriest2Reset takes nothing returns nothing
local ability abi = BlzGetUnitAbility(udg_Talent__Unit, 'Ahea')
call BlzSetAbilityRealLevelField(abi, ABILITY_RLF_HIT_POINTS_GAINED_HEA1, 0, BlzGetAbilityRealLevelField(abi, ABILITY_RLF_HIT_POINTS_GAINED_HEA1, 0) - 5)
set abi = BlzGetUnitAbility(udg_Talent__Unit, 'Adis')
call BlzSetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, 0, BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, 0) - 50)
set abi = BlzGetUnitAbility(udg_Talent__Unit, 'Ainf')
call BlzSetAbilityRealLevelField(abi, ABILITY_RLF_DURATION_HERO, 0, BlzGetAbilityRealLevelField(abi, ABILITY_RLF_DURATION_HERO, 0) - 20)
call BlzSetAbilityRealLevelField(abi, ABILITY_RLF_DURATION_NORMAL, 0, BlzGetAbilityRealLevelField(abi, ABILITY_RLF_DURATION_NORMAL, 0) - 20)
endfunction
function TalentPriest3Reset takes nothing returns nothing
call BlzSetUnitMaxHP(udg_Talent__Unit, BlzGetUnitMaxHP(udg_Talent__Unit) - 200)
call SetUnitState(udg_Talent__Unit, UNIT_STATE_LIFE, GetUnitState(udg_Talent__Unit, UNIT_STATE_LIFE) - 200)
call BlzSetUnitRealField(udg_Talent__Unit, UNIT_RF_HIT_POINTS_REGENERATION_RATE, BlzGetUnitRealField(udg_Talent__Unit, UNIT_RF_HIT_POINTS_REGENERATION_RATE) - 2)
endfunction
function TalentPriest takes nothing returns nothing
local integer choice
//Which HeroType is this; Human-Priest
local integer heroTypeId = 'hmpr'
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function TalentPriestTOC)
endif
call TalentPriestTOC()
call TalentHeroSetFinalTier(heroTypeId, 1)
call TalentHeroTierCreate(heroTypeId, 1)
set choice = TalentChoiceCreateEx( function TalentPriest1Learn, function TalentPriest1Reset) //activade function TalentPriest1Learn when Picking this Talent
set udg_TalentChoiceHead[choice] = "TalentPriest1Head"
set udg_TalentChoiceText[choice] = "TalentPriest1Text"
set udg_TalentChoiceIcon[choice] = "TalentPriest1Icon"
set choice = TalentChoiceCreateEx( function TalentPriest2Learn, function TalentPriest2Reset)
set udg_TalentChoiceHead[choice] = "TalentPriest2Head"
set udg_TalentChoiceText[choice] = "TalentPriest2Text"
set udg_TalentChoiceIcon[choice] = "TalentPriest2Icon"
set choice = TalentChoiceCreateEx( function TalentPriest3Learn, function TalentPriest3Reset)
set udg_TalentChoiceHead[choice] = "TalentPriest3Head"
set udg_TalentChoiceText[choice] = "TalentPriest3Text"
set udg_TalentChoiceIcon[choice] = "TalentPriest3Icon"
endfunction
//===========================================================================
function InitTrig_Talent_Priest takes nothing returns nothing
set gg_trg_Talent_Priest = CreateTrigger( )
call TriggerAddAction( gg_trg_Talent_Priest, function TalentPriest )
endfunction
function Trig_Demo_Info_Actions takes nothing returns nothing
local framehandle fh = BlzCreateFrame("TalentBoxTextArea", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
call BlzFrameSetSize(fh, 0.22, 0.22)
call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPRIGHT, 0.8, 0.5)
call BlzFrameSetText(fh, "Talent Jui, gives units/heroes at levels you want a tier. An unit can pick 1 option from the given options the tier has.|n|nSelect an unit and click the ShowTalent Button to show the TalentBox.|n|nWhen the talentBox is shown you can observe talents choosen from the selected unit regardless of ownerhship.|n|nYou can pick/unlearn talents from any unit you have shared control of.")
call BlzFrameAddText(fh, "You can write \"PreventReset\" to toggle enablity of the resetButton.")
call BlzFrameAddText(fh, "You can write \"Get\" to get a text that would pick the current options when used inside TalentMacroDo in this demo map you can just write it")
call BlzFrameSetEnable(fh, false)
endfunction
//===========================================================================
function InitTrig_Demo_Info takes nothing returns nothing
set gg_trg_Demo_Info = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Demo_Info, 0.00 )
call TriggerAddAction( gg_trg_Demo_Info, function Trig_Demo_Info_Actions )
endfunction