• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] SST - Skilltreesystem (Desync)

Status
Not open for further replies.
Level 4
Joined
Dec 11, 2007
Messages
74
So, i dunno if anyone of you know about this System

Skilltree1.jpg


But i added it to my map, and everytime i want to play on b-net or lan and we open the skilltree and close it all players get the message "disconect" so only the host can play...

i think there is a desync with if get triggering player = local player but i cant find the problem, hope someone can help me...

Here the code :

JASS:
function h2i takes handle h returns integer
 return h
 return 0
endfunction
function i2u takes integer i returns unit
 return i
 return null
endfunction
function i2timer takes integer i returns timer
 return i
 return null
endfunction
function i2cs takes integer i returns camerasetup
 return i
 return null
endfunction
function i2dest takes integer i returns destructable
 return i
 return null
endfunction
function i2track takes integer i returns trackable
 return i
 return null
endfunction
function i2mb takes integer i returns multiboard
 return i
 return null
endfunction
function i2tt takes integer i returns texttag
 return i
 return null
endfunction
function i2fm takes integer i returns fogmodifier
 return i
 return null
endfunction
function i2trg takes integer i returns trigger
 return i
 return null
endfunction
function i2ta takes integer i returns triggeraction
 return i
 return null
endfunction
function MBSetItemStyleBR takes multiboard mb,integer col,integer row,boolean showValue,boolean showIcon returns nothing
    local multiboarditem mbitem=MultiboardGetItem(mb,row-1,col-1)
    call MultiboardSetItemStyle(mbitem,showValue,showIcon)
    call MultiboardReleaseItem(mbitem)
    set mbitem=null
endfunction
function MBSetItemValueBR takes multiboard mb,integer col,integer row,string Val returns nothing
    local multiboarditem mbitem=MultiboardGetItem(mb,row-1,col-1)
    call MultiboardSetItemValue(mbitem,Val)
    call MultiboardReleaseItem(mbitem)
    set mbitem=null
endfunction
function MBSetItemColorBR takes multiboard mb,integer col,integer row,integer r,integer g,integer b,integer alpha returns nothing
    local multiboarditem mbitem=MultiboardGetItem(mb,row-1,col-1)
    call MultiboardSetItemValueColor(mbitem,r,g,b,255-alpha)
    call MultiboardReleaseItem(mbitem)
    set mbitem=null
endfunction
function MBSetItemWidthBR takes multiboard mb, integer col, integer row, real width returns nothing
    local multiboarditem mbitem=MultiboardGetItem(mb,row-1,col-1)
    call MultiboardSetItemWidth(mbitem,width/100)
    call MultiboardReleaseItem(mbitem)
    set mbitem=null
endfunction
function MBSetItemIconBR takes multiboard mb, integer col, integer row,string icon returns nothing
    local multiboarditem mbitem=MultiboardGetItem(mb,row-1,col-1)
    call MultiboardSetItemIcon(mbitem,icon)
    call MultiboardReleaseItem(mbitem)
    set mbitem=null
endfunction
function SetSSTInt takes string s,integer i returns nothing
 call StoreInteger(udg_SSTcache,"_SST_",s,i)
endfunction 
function GetSSTInt takes string s returns integer
 return GetStoredInteger(udg_SSTcache,"_SST_",s)
endfunction 
function SetSSTReal takes string s,real i returns nothing
 call StoreReal(udg_SSTcache,"_SST_",s,i)
endfunction 
function GetSSTReal takes string s returns real
 return GetStoredReal(udg_SSTcache,"_SST_",s)
endfunction 
function SetSSTStr takes string s,string i returns nothing
 call StoreString(udg_SSTcache,"_SST_",s,i)
endfunction 
function GetSSTStr takes string s returns string
 return GetStoredString(udg_SSTcache,"_SST_",s)
endfunction 
function SSTCoordinates takes nothing returns nothing
 local real x=GetSSTReal("SST_X")
 local real y=GetSSTReal("SST_Y")
 set udg_SSTReal[1]=x-50 
 set udg_SSTReal[2]=y+75 
 set udg_SSTReal[3]=x 
 set udg_SSTReal[4]=y+75
 set udg_SSTReal[5]=x+50
 set udg_SSTReal[6]=y+75 
 set udg_SSTReal[7]=x-50 
 set udg_SSTReal[8]=y+25 
 set udg_SSTReal[9]=x 
 set udg_SSTReal[10]=y+25
 set udg_SSTReal[11]=x+50 
 set udg_SSTReal[12]=y+25   
 set udg_SSTReal[13]=x-50  
 set udg_SSTReal[14]=y-25 
 set udg_SSTReal[15]=x  
 set udg_SSTReal[16]=y-25 
 set udg_SSTReal[17]=x+50 
 set udg_SSTReal[18]=y-25 
 set udg_SSTReal[19]=x-50 
 set udg_SSTReal[20]=y-75
 set udg_SSTReal[21]=x  
 set udg_SSTReal[22]=y-75 
 set udg_SSTReal[23]=x+50      
 set udg_SSTReal[24]=y-75  
 set udg_SSTReal[30]=-14.5
 set udg_SSTReal[31]=0  
 set udg_SSTReal[32]=1.5 
 set udg_SSTReal[33]=0  
 set udg_SSTReal[34]=-6.5 
 set udg_SSTReal[35]=9.5 
 set udg_SSTReal[36]=-6.5 
 set udg_SSTReal[37]=-9.5
 set udg_SSTReal[50]=-6.5  
 set udg_SSTReal[51]=9 
 set udg_SSTReal[52]=5
 set udg_SSTReal[53]=6
 set udg_SSTReal[54]=5  
 set udg_SSTReal[55]=3 
 set udg_SSTReal[56]=5 
 set udg_SSTReal[57]=0  
 set udg_SSTReal[58]=5  
 set udg_SSTReal[59]=-3  
 set udg_SSTReal[60]=5  
 set udg_SSTReal[61]=-6  
 set udg_SSTReal[81]=-11 
 set udg_SSTReal[82]=6  
 set udg_SSTReal[83]=-6.5 
 set udg_SSTReal[84]=6  
 set udg_SSTReal[85]=-2 
 set udg_SSTReal[86]=6  
 set udg_SSTReal[87]=-11
 set udg_SSTReal[88]=2  
 set udg_SSTReal[89]=-6.5
 set udg_SSTReal[90]=2  
 set udg_SSTReal[91]=-2  
 set udg_SSTReal[92]=2  
 set udg_SSTReal[93]=-11  
 set udg_SSTReal[94]=-2 
 set udg_SSTReal[95]=-6.5 
 set udg_SSTReal[96]=-2 
 set udg_SSTReal[97]=-2  
 set udg_SSTReal[98]=-2  
 set udg_SSTReal[99]=-11  
 set udg_SSTReal[100]=-6  
 set udg_SSTReal[101]=-6.5 
 set udg_SSTReal[102]=-6 
 set udg_SSTReal[103]=-2  
 set udg_SSTReal[104]=-6  
 set udg_SSTReal[129]=0.8  
 set udg_SSTReal[130]=-0.8 
 set udg_SSTReal[131]=-17   
 set udg_SSTReal[132]=7    
 set udg_SSTReal[133]=-17  
 set udg_SSTReal[134]=5  
 set udg_SSTReal[135]=-17
 set udg_SSTReal[136]=3   
 set udg_SSTReal[137]=-17  
 set udg_SSTReal[138]=1  
 set udg_SSTReal[139]=-17 
 set udg_SSTReal[140]=-1  
 set udg_SSTReal[141]=-17  
 set udg_SSTReal[142]=-3  
 set udg_SSTReal[143]=-17  
 set udg_SSTReal[144]=-5 
 set udg_SSTReal[145]=-17 
 set udg_SSTReal[146]=-7 
 set udg_SST[4000]=GetSSTInt("Spell")
 set udg_SST[4001]=GetSSTInt("PointsByLevel")
 set udg_SST[4002]=GetSSTInt("BackgroundId")   
 set udg_SST[4003]=GetSSTInt("BorderId")       
 set udg_SST[4004]=GetSSTInt("ArrowId")    
 set udg_SST[4005]=GetSSTInt("SelectionId") 
 set udg_SST[4006]=GetSSTInt("SSlotId")  
endfunction
function SetSSTValue takes string s returns nothing
 call StoreString(udg_SSTcache,I2S(h2i(null)),"Value",s)
endfunction
function GetSSTValue takes string func returns string
 call ExecuteFunc(func)
 return GetStoredString(udg_SSTcache,I2S(h2i(null)),"Value")
endfunction
function SSTStoreUnit takes unit u returns nothing
 call StoreInteger(udg_SSTcache,I2S(h2i(null)),"Unit",h2i(u))
endfunction
function GetSSTUnit takes nothing returns unit
 return i2u(GetStoredInteger(udg_SSTcache,I2S(h2i(null)),"Unit"))
endfunction
function IsSkillEnable takes unit u,integer id returns boolean
 return GetStoredBoolean(udg_SSTcache,I2S(h2i(u)),I2S(id))
endfunction
function SetSSTUnitLevel takes unit u,integer i returns nothing
 call StoreInteger(udg_SSTcache,I2S(h2i(u)),"Level",i)
endfunction
function GetSSTUnitLevel takes unit u returns integer
 return GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"Level")
endfunction
function SetUnitSkill takes integer uid,integer slot,integer sid returns nothing
 call StoreInteger(udg_SSTcache,"_SST_",I2S(uid)+"Slot"+I2S(sid),slot)
 call StoreInteger(udg_SSTcache,"_SST_",I2S(uid)+"Skill"+I2S(slot),sid)
endfunction 
function GetUnitSkillLevel takes unit u,integer id returns integer
 local integer i=0
 if GetUnitAbilityLevel(u,id)>0 then
  if GetSSTInt(I2S(id)+"IsBook")>0 then
   set i=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"Level"+I2S(GetSSTInt(I2S(id)+"AbilityInBook")))
  else
   set i=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"Level"+I2S(id))
  endif
 endif
 return i
endfunction
function SetUnitAbilityState takes player p,integer id,boolean state,unit u returns nothing
 local integer b=0
 local integer i=0
 local integer l=0
 if GetSSTInt(I2S(id)+"IsBook")>0 then
  set b=GetSSTInt(I2S(id)+"SGroup")
  set i=GetStoredInteger(udg_SSTcache,I2S(GetPlayerId(p)),I2S(b))
  if i<0 then
   set i=0
  endif
  if b>0 then
   if state then
    call UnitAddAbility(u,b)
    call StoreInteger(udg_SSTcache,I2S(GetPlayerId(p)),I2S(b),i+1)
   else
    call SetPlayerAbilityAvailable(p,id,false)
    if i-1<1 then
     call UnitRemoveAbility(u,b)
    endif
    call StoreInteger(udg_SSTcache,I2S(GetPlayerId(p)),I2S(b),i-1)
   endif
  else
   if GetSSTInt(I2S(id)+"Invisible")>0 and state==true then
    call SetPlayerAbilityAvailable(p,id,false)   
   else
    call SetPlayerAbilityAvailable(p,id,state) 
   endif
  endif
  call SetPlayerAbilityAvailable(p,GetSSTInt(I2S(id)+"AbilityInBook"),state)   
 else
  if GetSSTInt(I2S(id)+"Invisible")<1 then
   set b=GetSSTInt(I2S(id)+"InBook")
   set i=GetStoredInteger(udg_SSTcache,I2S(GetPlayerId(p)),I2S(b))
   if i<0 then
    set i=0
    endif
   if b>0 then
    if state then
     call SetPlayerAbilityAvailable(p,b,true)
     call StoreInteger(udg_SSTcache,I2S(GetPlayerId(p)),I2S(b),i+1)
    else
     if i-1<1 then
      call SetPlayerAbilityAvailable(p,b,false)
     endif
     call StoreInteger(udg_SSTcache,I2S(GetPlayerId(p)),I2S(b),i-1)
    endif
   endif
   call SetPlayerAbilityAvailable(p,id,state)
  endif
 endif
endfunction
function SSTEditTT takes texttag tt,real x,real y,string s,real size returns nothing
 call SetTextTagText(tt,s,size)
 if StringLength(s)==1 then
  call SetTextTagPos(tt,x-0.2,y-0.45,0.004)
 elseif StringLength(s)==2 then
  call SetTextTagPos(tt,x-0.4,y-0.45,0.004)
 else
  call SetTextTagPos(tt,x-0.6,y-0.45,0.004)
 endif
endfunction
function SetUnitSkillLevel takes unit u,integer id,integer lev returns boolean
 local boolean b=true 
 local integer p=GetPlayerId(GetOwningPlayer(u))
 local integer i=0
 local integer max=GetSSTInt(I2S(id)+"MaxLevel")
 local integer pg=0
 local real x=udg_SSTReal[p*2+1]
 local real y=udg_SSTReal[p*2+2]
 local string ss=null
 if lev>max or lev<0 then
  set b=false
 else
  if GetSSTInt(I2S(id)+"IsBook")>0 then
   call StoreInteger(udg_SSTcache,I2S(h2i(u)),"Level"+I2S(GetSSTInt(I2S(id)+"AbilityInBook")),lev)
   call SetUnitAbilityLevel(u,GetSSTInt(I2S(id)+"AbilityInBook"),lev)
   if GetSSTInt(I2S(id)+"Passive")>0 then
    if lev>0 then 
     call SetUnitAbilityState(Player(p),GetSSTInt(I2S(id)+"AbilityInBook"),true,u) 
     set i=GetSSTInt(I2S(id)+"SGroup")
     if i>0 then
      call UnitAddAbility(u,i)
      call StoreInteger(udg_SSTcache,I2S(p),I2S(i),GetStoredInteger(udg_SSTcache,I2S(p),I2S(i))+1)
     endif 
     set i=0
    else
     call SetUnitAbilityState(Player(p),GetSSTInt(I2S(id)+"AbilityInBook"),false,u)  
     set ss=GetSSTStr(I2S(GetSSTInt(I2S(id)+"AbilityInBook"))+"OnUnlearn")
     if ss!=null and ss!="" then
      call SSTStoreUnit(u)
      call ExecuteFunc(ss)
     endif
     set i=GetSSTInt(I2S(id)+"SGroup")
     if i>0 then
      set pg=GetStoredInteger(udg_SSTcache,I2S(p),I2S(i))
      call StoreInteger(udg_SSTcache,I2S(p),I2S(i),pg-1)
      if pg-1<1 then
       call UnitRemoveAbility(u,id)
      endif
     endif 
     set i=0
    endif
   endif
  else
   call StoreInteger(udg_SSTcache,I2S(h2i(u)),"Level"+I2S(id),lev)
   call SetUnitAbilityLevel(u,id,lev)
   if GetSSTInt(I2S(id)+"Passive")>0 then
    call SetUnitAbilityState(Player(p),id,true,u)  
   endif 
  endif
  if i2u(udg_SST[200+p*300])==u then
   set i=GetSSTInt(I2S(GetUnitTypeId(u))+"Slot"+I2S(id))
   set pg=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"PageOn")
   if i>pg*12-12 and i<=pg*12 then
    set i=i-(pg*12-12)
    call SSTEditTT(i2tt(udg_SST[i+70+p*300]),x+udg_SSTReal[79+i*2]+udg_SSTReal[129],y+udg_SSTReal[80+i*2]+udg_SSTReal[130],I2S(GetUnitSkillLevel(u,id)),0.025)
    if lev==GetSSTInt(I2S(id)+"MaxLevel") then
     call SetTextTagText(i2tt(udg_SST[i+70+p*300]),"|c00ff0000"+I2S(lev),0.025)
    endif
   endif
  endif
  if GetUnitSkillLevel(u,id)==0 and lev>0 then
   set ss=GetSSTStr(I2S(GetSSTInt(I2S(id)+"AbilityInBook"))+"OnLearn")
   if ss!=null and ss!="" then
    call SSTStoreUnit(u)
    call ExecuteFunc(ss)
   endif
  endif
 endif
 return b
endfunction
function GetUnitSkillPoints takes unit u returns integer
 return GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SSTPoints")
endfunction
function SetUnitSkillPoints takes unit u,integer i returns nothing
 local integer p=GetPlayerId(GetOwningPlayer(u))
 local real x=udg_SSTReal[p*2+1]
 local real y=udg_SSTReal[p*2+2]
 call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SSTPoints",i)
 if i2u(udg_SST[200+p*300])==u then
  call SSTEditTT(i2tt(udg_SST[70+p*300]),x+udg_SSTReal[50],y+udg_SSTReal[51],I2S(GetUnitSkillPoints(u)),0.025)
 endif
endfunction
function GetLevelNeed takes integer id,integer lev returns integer
 local integer NLev=GetSSTInt(I2S(id)+"NLevel")
 if lev>0 then
  set NLev=NLev+((GetSSTInt(I2S(id)+"NLevConst")-1)*lev)
 endif
 return NLev
endfunction
function GetManaCost takes integer id,integer lev returns integer
 local integer MCost=GetSSTInt(I2S(id)+"MCostLev"+I2S(lev))
 if MCost<1 then
  set MCost=GetSSTInt(I2S(id)+"MCostLev1")+(GetSSTInt(I2S(id)+"NLevConst")*lev)
 endif
 return MCost
endfunction
function SST_Spell_Condition takes nothing returns boolean
 return GetSpellAbilityId()==udg_SST[4000]
endfunction
function ArrowsCreate takes unit u,integer id returns nothing
 local destructable des=null
 local integer pId=GetPlayerId(GetOwningPlayer(u))
 local integer page=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"PageOn")
 local integer i=1
 local integer ACount=udg_SST[202+pId*300]
 local integer need=0
 local real X=udg_SSTReal[1+pId*2]
 local real Y=udg_SSTReal[2+pId*2]
 local real x=0
 local real y=0
 local real z=0
 local real face=0
 local location l=null
 local boolean can=true
 local integer UId=GetUnitTypeId(u)
 local integer slot=GetSSTInt(I2S(UId)+"Slot"+I2S(id))
 if page>1 then
  set slot=slot-(page*12-12)
 endif
 set x=X+udg_SSTReal[79+slot*2]
 set y=Y+udg_SSTReal[80+slot*2]
 set l=Location(x,y)
 set z=GetLocationZ(l)
 call RemoveLocation(l)
 set l=null
 loop
 exitwhen i>12
  set can=true
  set need=GetSSTInt(I2S(UId)+"Slot"+I2S(GetSSTInt(I2S(id)+"Need"+I2S(i))))
  if need>0 then
   if page>1 then
    set need=need-(page*12-12)
   endif 
    if need==slot+3 or need+3==slot then
     set face=90
     set X=x
     if need==slot+3 then
      set Y=y-2
     else
      set Y=y+2
     endif
    elseif need==slot+1 or need+1==slot then
     set face=0
     set Y=y
     if need==slot+1 then
      set X=x+2.25
     else
      set X=x-2.25
     endif
    elseif (slot!=3 and slot!=6 and slot!=9 and slot!=12) and (slot+4==need or slot-2==need) then 
     if slot+4==need then
      set face=135 
      set X=x+2.25
      set Y=y-2
     else
      set face=45
      set X=x+2.25
      set Y=y+2
     endif
    elseif (slot!=1 and slot!=4 and slot!=7 and slot!=10) and (slot-4==need or slot+2==need) then 
     if slot-4==need then
      set face=135 
      set X=x-2.25
      set Y=y+2
     else
      set face=45
      set X=x-2.25
      set Y=y-2
     endif
    elseif (slot==1 or slot==4 or slot==7 or slot==10) and slot+2==need then
     if udg_SST[211+slot+pId*300]==0 then
      set face=0
      set Y=y
      set X=x+2.75
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X+4
     else
      set can=false
     endif
    elseif (slot==3 or slot==6 or slot==9 or slot==12) and slot-2==need then
     if udg_SST[209+slot+pId*300]==0 then
      set face=0
      set Y=y
      set X=x-2.75
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X-4
     else
      set can=false
     endif
    elseif need==slot+6 or need+6==slot then
     set face=90
     set X=x
     if need==slot+6 and udg_SST[213+slot+pId*300]==0 then
      set Y=y-2
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set Y=Y-4
     elseif need==slot-6 and udg_SST[207+slot+pId*300]==0 then
      set Y=y+2
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set Y=Y+4
     else
      set can=false
     endif
    elseif need==slot+9 or need+9==slot then
     set face=90
     set X=x
     if need==slot+9 and udg_SST[213+slot+pId*300]==0 and udg_SST[216+slot+pId*300]==0 then
      set Y=y-2
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set Y=Y-4
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set Y=Y-4
     elseif need==slot-9 and udg_SST[207+slot+pId*300]==0 and udg_SST[204+slot+pId*300]==0 then
      set Y=y+2
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set Y=Y+4
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set Y=Y+4
     else
      set can=false
     endif
    elseif (slot==7 or slot==10) and slot-4==need then
     if udg_SST[208+slot+pId*300]==0 then
      set face=45
      set X=x+2.25
      set Y=y+2    
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X+2.25
      set Y=Y+2.25    
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X+2.25
      set Y=Y+2.25
     else
      set can=false
     endif
    elseif (slot==9 or slot==12) and slot-8==need then
     if udg_SST[206+slot+pId*300]==0 then
      set face=135
      set X=x-2.25
      set Y=y+2    
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X-2.25
      set Y=Y+2.25    
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X-2.25
      set Y=Y+2.25
     else
      set can=false
     endif
    elseif (slot==1 or slot==4) and slot+8==need then
     if udg_SST[214+slot+pId*300]==0 then
      set face=135
      set X=x+2.25
      set Y=y-2    
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X+2.25
      set Y=Y-2.25    
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X+2.25
      set Y=Y-2.25
     else
      set can=false
     endif
    elseif (slot==3 or slot==6) and slot+4==need then
     if udg_SST[212+slot+pId*300]==0 then
      set face=45
      set X=x-2.25
      set Y=y-2    
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X-2.25
      set Y=Y-2.25    
      set ACount=ACount+1
      set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
      set X=X-2.25
      set Y=Y-2.25
     else
      set can=false
     endif
    else
     set can=false
    endif
   if can then
    set ACount=ACount+1
    set udg_SST[pId*300+ACount+100]=h2i(CreateDestructableZ(udg_SST[4004],X,Y,z+0.05,face,0.05,0))
   endif
  endif
  set i=i+1
 endloop
 set udg_SST[202+pId*300]=ACount
endfunction
function LoadSSTVisibles takes unit u returns nothing
 local string s=I2S(GetPlayerId(GetOwningPlayer(u)))
 local integer PId=GetPlayerId(GetOwningPlayer(u))*300
 local integer p=GetPlayerId(GetOwningPlayer(u))
 local real x=udg_SSTReal[p*2+1]
 local real y=udg_SSTReal[p*2+2]
 local integer id=GetUnitTypeId(u)
 local integer abil=0
 local location l=Location(x,y)
 local real z=GetLocationZ(l)+0.005
 local real z2=z
 local integer i=0
 local integer i2=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"PageOn")*12-12
 call RemoveLocation(l)
 set l=null
 loop
 exitwhen i>12
  set udg_SST[210+i+PId]=GetSSTInt(I2S(id)+"Skill"+I2S(i+i2))
  set i=i+1
 endloop
 set i=1
 loop
  exitwhen i>12
  set abil=GetSSTInt(I2S(id)+"Skill"+I2S(i+i2))
  if abil>0 then
   call ShowDestructable(i2dest(udg_SST[i+16+PId]),true)  
   call ShowDestructable(i2dest(udg_SST[i+28+PId]),true)  
   call EnableTrigger(i2trg(GetSSTInt(I2S(p)+"STTrack"+I2S(i))))
   call EnableTrigger(i2trg(GetSSTInt(I2S(p)+"STHit"+I2S(i))))
   call SetSSTInt(I2S(GetSSTInt(s+"SkillTrack"+I2S(i)))+"Enable",1)
   set udg_SST[i+48+PId]=h2i(CreateDestructableZ(GetSSTInt(I2S(abil)+"Icon"),x+udg_SSTReal[79+(i*2)],y+udg_SSTReal[80+(i*2)],z+0.05,270,0.3,0))
   call SSTEditTT(i2tt(udg_SST[i+70+PId]),x+udg_SSTReal[79+(i*2)]+udg_SSTReal[129],y+udg_SSTReal[80+(i*2)]+udg_SSTReal[130],I2S(GetUnitSkillLevel(u,abil)),0.025)
   call SetTextTagVisibility(i2tt(udg_SST[i+70+PId]),true)
   if GetUnitSkillLevel(u,abil)==GetSSTInt(I2S(abil)+"MaxLevel") then
    call SetTextTagText(i2tt(udg_SST[i+70+PId]),"|c00ff0000"+I2S(GetUnitSkillLevel(u,abil)),0.025)
   endif
   call ArrowsCreate(u,abil)
  endif
  set i=i+1
 endloop
endfunction
function SSTDisplayLoad takes unit u returns nothing
 local integer p=GetPlayerId(GetOwningPlayer(u))
 local string s=I2S(p)
 local integer PId=p*300
 local real x=udg_SSTReal[p*2+1]
 local real y=udg_SSTReal[p*2+2]
 local integer id=0
 local integer abil=0
 local location l=Location(x,y)
 local real z=GetLocationZ(l)+0.005
 local real z2=z
 local integer i=GetSSTInt(I2S(GetUnitTypeId(u))+"Pages")
 local integer i2=0
 call RemoveLocation(l)
 call ShowDestructable(i2dest(udg_SST[1+PId]),true)
 call ShowDestructable(i2dest(udg_SST[2+PId]),true)
 call ShowDestructable(i2dest(udg_SST[3+PId]),true)
 call ShowDestructable(i2dest(udg_SST[4+PId]),true)
 call ShowDestructable(i2dest(udg_SST[5+PId]),true)
 call ShowDestructable(i2dest(udg_SST[16+PId]),true)
 call SSTEditTT(i2tt(udg_SST[70+PId]),x+udg_SSTReal[50],y+udg_SSTReal[51],I2S(GetUnitSkillPoints(u)),0.025)
 if GetLocalPlayer()==Player(p) then
  call SetTextTagVisibility(i2tt(udg_SST[70+PId]),true)
 endif
 if i>1 then
  set i2=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"PageOn")
  if i2<1 then
   set i2=1
   call StoreInteger(udg_SSTcache,I2S(h2i(u)),"PageOn",1)
  endif
  loop
   exitwhen i<1
   call ShowDestructable(i2dest(udg_SST[i+40+PId]),true)  
   call EnableTrigger(i2trg(GetSSTInt(s+"PTTrack"+I2S(i))))
   call EnableTrigger(i2trg(GetSSTInt(s+"PTHit"+I2S(i))))
   if i==i2 then
    set udg_SST[61+PId+i]=h2i(CreateDestructableZ(GetSSTInt(I2S(GetUnitTypeId(u))+"IconOnPage"+I2S(i)),x+udg_SSTReal[129+i*2],y+udg_SSTReal[130+i*2],z+0.1,270,0.22,0))
   else
    set udg_SST[61+PId+i]=h2i(CreateDestructableZ(GetSSTInt(I2S(GetUnitTypeId(u))+"IconOffPage"+I2S(i)),x+udg_SSTReal[129+i*2],y+udg_SSTReal[130+i*2],z+0.1,270,0.22,0))
   endif
   set i=i-1
  endloop
 else
  call StoreInteger(udg_SSTcache,I2S(h2i(u)),"PageOn",1)
  set i2=1
 endif
 set i=1
 set i2=i2*12-12
 set id=GetUnitTypeId(u)
 loop
 exitwhen i>12
  set udg_SST[210+i+PId]=GetSSTInt(I2S(id)+"Skill"+I2S(i+i2))
  set i=i+1
 endloop
 set i=1
 loop
  exitwhen i>12
  set abil=GetSSTInt(I2S(id)+"Skill"+I2S(i+i2))
  if abil>0 then
   call ShowDestructable(i2dest(udg_SST[i+16+PId]),true)  
   call ShowDestructable(i2dest(udg_SST[i+28+PId]),true)  
   call EnableTrigger(i2trg(GetSSTInt(s+"STTrack"+I2S(i))))
   call EnableTrigger(i2trg(GetSSTInt(s+"STHit"+I2S(i))))
   call SetSSTInt(I2S(GetSSTInt(s+"SkillTrack"+I2S(i)))+"Enable",1)
   set udg_SST[i+48+PId]=h2i(CreateDestructableZ(GetSSTInt(I2S(abil)+"Icon"),x+udg_SSTReal[79+(i*2)],y+udg_SSTReal[80+(i*2)],z+0.05,270,0.3,0))
   call SSTEditTT(i2tt(udg_SST[i+70+PId]),x+udg_SSTReal[79+(i*2)]+udg_SSTReal[129],y+udg_SSTReal[80+(i*2)]+udg_SSTReal[130],I2S(GetUnitSkillLevel(u,abil)),0.025)
   if GetLocalPlayer()==Player(p) then
    call SetTextTagVisibility(i2tt(udg_SST[i+70+PId]),true)
   endif
   if GetUnitSkillLevel(u,abil)==GetSSTInt(I2S(abil)+"MaxLevel") then
    call SetTextTagText(i2tt(udg_SST[i+70+PId]),"|c00ff0000"+I2S(GetUnitSkillLevel(u,abil)),0.025)
   endif
   call ArrowsCreate(u,abil)
  endif
  set i=i+1
 endloop
 set i=GetSSTInt(I2S(GetUnitTypeId(u))+"Slots")
 loop
  exitwhen i<1 
  set i2=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot"+I2S(i))
  call ShowDestructable(i2dest(udg_SST[PId+5+i]),true)
  call EnableTrigger(i2trg(GetSSTInt(s+"ATTrack"+I2S(i))))
  call EnableTrigger(i2trg(GetSSTInt(s+"ATHit"+I2S(i))))
  if i2>0 then
   set udg_SST[10+i+PId]=h2i(CreateDestructableZ(GetSSTInt(I2S(i2)+"Icon"),x+udg_SSTReal[50+i*2],y+udg_SSTReal[51+i*2],z+0.05,270,0.3,0))
  endif
  set i=i-1
 endloop
 set l=null
endfunction
function ClearSSTVisibles takes integer p returns nothing
 local string s=I2S(p)
 local integer PId=p*300
 local integer a=0
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit1")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack1")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit2")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack2")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit3")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack3")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit4")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack4")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit5")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack5")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit6")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack6")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit7")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack7")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit8")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack8")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit9")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack9")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit10")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack10")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit11")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack11")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STHit12")))
 call DisableTrigger(i2trg(GetSSTInt(s+"STTrack12")))
 call ShowDestructable(i2dest(udg_SST[17+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[18+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[19+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[20+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[21+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[22+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[23+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[24+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[25+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[26+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[27+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[28+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[29+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[30+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[31+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[32+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[33+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[34+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[35+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[36+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[37+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[38+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[39+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[40+PId]),false)
 if udg_SST[49+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[49+PId]))
  set udg_SST[49+PId]=0
 endif
 if udg_SST[50+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[50+PId]))
  set udg_SST[50+PId]=0
 endif
 if udg_SST[51+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[51+PId]))
  set udg_SST[51+PId]=0
 endif
 if udg_SST[52+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[52+PId]))
  set udg_SST[52+PId]=0
 endif
 if udg_SST[53+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[53+PId]))
  set udg_SST[53+PId]=0
 endif
 if udg_SST[54+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[54+PId]))
  set udg_SST[54+PId]=0
 endif
 if udg_SST[55+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[55+PId]))
  set udg_SST[55+PId]=0
 endif
 if udg_SST[56+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[56+PId]))
  set udg_SST[56+PId]=0
 endif
 if udg_SST[57+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[57+PId]))
  set udg_SST[57+PId]=0
 endif
 if udg_SST[58+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[58+PId]))
  set udg_SST[58+PId]=0
 endif
 if udg_SST[59+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[59+PId]))
  set udg_SST[59+PId]=0
 endif
 if udg_SST[60+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[60+PId]))
  set udg_SST[60+PId]=0
 endif
 if GetSSTInt(s+"SSkill")<13 then
  if udg_SST[61+PId]>0 then
   call RemoveDestructable(i2dest(udg_SST[61+PId]))
   set udg_SST[61+PId]=0
   call SetSSTInt(s+"VisualS",0) 
  endif 
  call SetSSTInt(s+"SSkill",0) 
 endif
 if udg_SST[203+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[203+PId]))
  set udg_SST[203+PId]=0
 endif
 call SetTextTagVisibility(i2tt(udg_SST[71+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[72+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[73+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[74+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[75+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[76+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[77+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[78+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[79+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[80+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[81+PId]),false)
 call SetTextTagVisibility(i2tt(udg_SST[82+PId]),false)
 set udg_SST[211+PId]=0
 set udg_SST[212+PId]=0
 set udg_SST[213+PId]=0
 set udg_SST[214+PId]=0
 set udg_SST[215+PId]=0
 set udg_SST[216+PId]=0
 set udg_SST[217+PId]=0
 set udg_SST[218+PId]=0
 set udg_SST[219+PId]=0
 set udg_SST[220+PId]=0
 set udg_SST[221+PId]=0
 set udg_SST[222+PId]=0
 set a=udg_SST[202+PId]
 loop
  exitwhen a<1
  call RemoveDestructable(i2dest(udg_SST[100+PId+a]))
  set udg_SST[100+PId+a]=0
  set a=a-1
 endloop
 set udg_SST[202+PId]=0
endfunction 
function ClearSSTDisplay takes integer p returns nothing
 local string s=I2S(p)
 local integer PId=p*300
 call DisableTrigger(i2trg(GetSSTInt(s+"ATHit1")))
 call DisableTrigger(i2trg(GetSSTInt(s+"ATTrack1")))
 call DisableTrigger(i2trg(GetSSTInt(s+"ATHit2")))
 call DisableTrigger(i2trg(GetSSTInt(s+"ATTrack2")))
 call DisableTrigger(i2trg(GetSSTInt(s+"ATHit3")))
 call DisableTrigger(i2trg(GetSSTInt(s+"ATTrack3")))
 call DisableTrigger(i2trg(GetSSTInt(s+"ATHit4")))
 call DisableTrigger(i2trg(GetSSTInt(s+"ATTrack4")))
 call DisableTrigger(i2trg(GetSSTInt(s+"ATHit5")))
 call DisableTrigger(i2trg(GetSSTInt(s+"ATTrack5")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTHit1")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTTrack1")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTHit2")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTTrack2")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTHit3")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTTrack3")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTHit4")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTTrack4")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTHit5")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTTrack5")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTHit6")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTTrack6")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTHit7")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTTrack7")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTHit8")))
 call DisableTrigger(i2trg(GetSSTInt(s+"PTTrack8")))
 call ShowDestructable(i2dest(udg_SST[1+PId]),false)   
 call ShowDestructable(i2dest(udg_SST[2+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[3+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[4+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[5+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[6+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[7+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[8+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[9+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[10+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[16+PId]),false)   
 call ShowDestructable(i2dest(udg_SST[41+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[42+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[43+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[44+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[45+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[46+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[47+PId]),false) 
 call ShowDestructable(i2dest(udg_SST[48+PId]),false) 
 if udg_SST[11+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[11+PId]))
  set udg_SST[11+PId]=0
 endif
 if udg_SST[12+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[12+PId]))
  set udg_SST[12+PId]=0
 endif
 if udg_SST[13+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[13+PId]))
  set udg_SST[13+PId]=0
 endif
 if udg_SST[14+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[14+PId]))
  set udg_SST[14+PId]=0
 endif
 if udg_SST[15+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[15+PId]))
  set udg_SST[15+PId]=0
 endif
 if udg_SST[62+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[62+PId]))
  set udg_SST[62+PId]=0
 endif
 if udg_SST[63+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[63+PId]))
  set udg_SST[63+PId]=0
 endif
 if udg_SST[64+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[64+PId]))
  set udg_SST[64+PId]=0
 endif
 if udg_SST[65+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[65+PId]))
  set udg_SST[65+PId]=0
 endif
 if udg_SST[66+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[66+PId]))
  set udg_SST[66+PId]=0
 endif
 if udg_SST[67+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[67+PId]))
  set udg_SST[67+PId]=0
 endif
 if udg_SST[68+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[68+PId]))
  set udg_SST[68+PId]=0
 endif
 if udg_SST[69+PId]>0 then
  call RemoveDestructable(i2dest(udg_SST[69+PId]))
  set udg_SST[69+PId]=0
 endif
 if GetSSTInt(s+"SSkill")>12 then
  if udg_SST[61+PId]>0 then
   call RemoveDestructable(i2dest(udg_SST[61+PId]))
   set udg_SST[61+PId]=0
   call SetSSTInt(s+"VisualS",0) 
  endif 
  call SetSSTInt(s+"SSkill",0) 
 endif
 call SetTextTagVisibility(i2tt(udg_SST[70+PId]),false)
 call ClearSSTVisibles(p)
 if GetLocalPlayer()==Player(p) then
  call MultiboardDisplay(i2mb(GetSSTInt("Multiboard")),false)
 endif
endfunction
function SSTCameraApply takes nothing returns nothing
 local integer p=GetStoredInteger(udg_SSTcache,I2S(h2i(GetExpiredTimer())),"player")
 if udg_SST[200+p*300]!=0 then
  if GetLocalPlayer()==Player(p) then
   call CameraSetupApply(i2cs(GetSSTInt(I2S(p)+"CSetup")),true,false)
   call ClearSelection()
   call SelectUnit(i2u(udg_SST[200+p*300]),true)
  endif
 endif
endfunction
function ClearSSTMB takes integer p returns nothing
 if GetLocalPlayer()==Player(p) then
  call MultiboardDisplay(i2mb(GetSSTInt(I2S(p)+"Multiboard")),false)
 endif
endfunction
function PreloadSSTUnit takes unit u returns nothing
 local integer p=GetPlayerId(GetOwningPlayer(u))
 local integer skl=0
 local integer i=0
 local integer pg=0
 if GetStoredBoolean(udg_SSTcache,I2S(h2i(u)),"SSTPreload")==false then
  set pg=GetSSTInt(I2S(GetUnitTypeId(u))+"Pages")
  call StoreBoolean(udg_SSTcache,I2S(h2i(u)),"SSTPreload",true)
  call SetUnitSkillPoints(u,GetHeroLevel(u)*udg_SST[4001])
  call StoreInteger(udg_SSTcache,I2S(h2i(u)),"LastLevel",GetHeroLevel(u))
  if pg<1 then
   set pg=1
  endif
  loop
   exitwhen i>pg*12
   set skl=GetSSTInt(I2S(GetUnitTypeId(u))+"Skill"+I2S(i))
   if skl>0 then
    if GetSSTInt(I2S(skl)+"InBook")>0 then
     call UnitAddAbility(u,GetSSTInt(I2S(skl)+"InBook"))  
     call SetUnitAbilityState(Player(p),GetSSTInt(I2S(skl)+"InBook"),false,u) 
    else
     call UnitAddAbility(u,skl)
    endif
    call SetUnitAbilityState(Player(p),skl,false,u)
    if GetSSTInt(I2S(skl)+"IsBook")>0 then
     set skl=GetSSTInt(I2S(skl)+"AbilityInBook")
     call UnitAddAbility(u,skl)
     call SetUnitAbilityState(Player(p),skl,false,u)  
    endif
   endif
   set i=i+1
  endloop
 endif
endfunction
function SSTAntiOrder_Actions takes nothing returns nothing
 if GetIssuedOrderId()==851971 then
  call TriggerSleepAction(0)
  call IssueImmediateOrder(GetTriggerUnit(),"stop")
 endif
endfunction
function SSTAntiOrder takes unit u, boolean b returns nothing
 local integer i=GetPlayerId(GetOwningPlayer(u))
 local trigger t=i2trg(udg_SST[205+i*300])
 if b then
  if udg_SST[205+i*300]==0 then
   set t=CreateTrigger()
   set udg_SST[206+i*300]=h2i(TriggerAddAction(t,function SSTAntiOrder_Actions))
   call TriggerRegisterUnitEvent(t,u,EVENT_UNIT_ISSUED_POINT_ORDER)
   set udg_SST[205+i*300]=h2i(t)
  endif
 else
  if udg_SST[205+i*300]>0 then
   call TriggerRemoveAction(t,i2ta(udg_SST[206+i*300]))
   call DestroyTrigger(t)
   set udg_SST[206+i*300]=0
   set udg_SST[205+i*300]=0
  endif
 endif
 set t=null
endfunction
function SST_Activation takes unit u returns nothing
 local integer p=GetPlayerId(GetOwningPlayer(u))
 local timer t=null
 local camerasetup s=null
 local real x=udg_SSTReal[p*2+1]
 local real y=udg_SSTReal[p*2+2]
 local location l=Location(x,y)
 local fogmodifier fm=i2fm(udg_SST[204+(p*300)])
 local integer i=1
 if GetPlayerController(Player(p))==MAP_CONTROL_USER and u!=null then
  if udg_SST[200+p*300]==0 then
    set udg_Cam[GetConvertedPlayerId(GetOwningPlayer(i2u(udg_SST[200+p*300])))] = false
   call PreloadSSTUnit(u)
   call SSTDisplayLoad(u)
   if GetSSTInt(I2S(p)+"CSetup")<1 then
    set s=CreateCameraSetup()
    call CameraSetupSetField(s,CAMERA_FIELD_TARGET_DISTANCE,135.00,0.0)
    call CameraSetupSetField(s,CAMERA_FIELD_FARZ,500.00,0.0)
    call CameraSetupSetField(s,CAMERA_FIELD_ZOFFSET,0.00,0.0)
    call CameraSetupSetField(s,CAMERA_FIELD_ANGLE_OF_ATTACK,270.00,0.0)
    call CameraSetupSetField(s,CAMERA_FIELD_FIELD_OF_VIEW,20.00,0.0)
    call CameraSetupSetField(s,CAMERA_FIELD_ROLL,0.00,0.0)
    call CameraSetupSetField(s,CAMERA_FIELD_ROTATION,90.00,0.0)
    call CameraSetupSetDestPosition(s,x,y,0.0)
    call SetSSTInt(I2S(p)+"CSetup",h2i(s))
   endif
   set t=CreateTimer()
   set udg_SST[200+p*300]=h2i(u)
   call SetSSTInt(I2S(p)+"TimerCam",h2i(t))
   call StoreInteger(udg_SSTcache,I2S(h2i(t)),"player",p)
   call TimerStart(t,0.04,true,function SSTCameraApply)
   set fm=CreateFogModifierRadiusLoc(Player(p),FOG_OF_WAR_VISIBLE,l,130,false,false)
   call FogModifierStart(fm)
   set udg_SST[204+(p*300)]=h2i(fm)
   if GetLocalPlayer()==Player(p) then
    call SetCameraBounds(x,y,x,y,x,y,x,y) 
    call SetCameraPosition(x,y)
    call CameraSetSmoothingFactor(1)
   endif
   call SSTAntiOrder(u,true)
  else 
   call SSTAntiOrder(u,false)
   call FlushStoredInteger(udg_SSTcache,I2S(GetSSTInt(I2S(p)+"TimerCam")),"player")
   call DestroyTimer(i2timer(GetSSTInt(I2S(p)+"TimerCam")))
   call DestroyFogModifier(fm)
   set udg_SST[204+(p*300)]=0
   if GetLocalPlayer()==Player(p) then
    call SetCameraBounds(GetRectMinX(GetPlayableMapRect()),GetRectMinY(GetPlayableMapRect()),GetRectMaxX(GetPlayableMapRect()),GetRectMaxY(GetPlayableMapRect()),GetRectMinX(GetPlayableMapRect()),GetRectMaxY(GetPlayableMapRect()),GetRectMaxX(GetPlayableMapRect()),GetRectMinY(GetPlayableMapRect()))  
    call ResetToGameCamera(0.000)
    call CameraSetSmoothingFactor(0)
    call SetCameraTargetControllerNoZForPlayer( GetOwningPlayer(i2u(udg_SST[200+p*300])), i2u(udg_SST[200+p*300]), 0, 0, false )
    set udg_Cam[GetConvertedPlayerId(GetOwningPlayer(i2u(udg_SST[200+p*300])))] = true
   endif
   call ClearSSTDisplay(p)
   call SetSSTInt(I2S(p)+"TimerCam",0)
   set udg_SST[200+p*300]=0
   call ClearSSTMB(p)
  endif
 endif
 call RemoveLocation(l)
 set fm=null
 set l=null
 set t=null
 set s=null
endfunction
function SST_Spell_Action takes nothing returns nothing
 call SST_Activation(GetTriggerUnit())
endfunction
function VisibleSSTSelection takes integer p,integer skill,boolean vis returns nothing
 local location loc=null
 local integer PId=p*300
 local real X=udg_SSTReal[p*2+1]
 local real Y=udg_SSTReal[p*2+2]
 local real z=0
 local real x=0
 local real y=0
 if vis and skill>0 then
  if skill<13 then
   set x=X+udg_SSTReal[79+skill*2]
   set y=Y+udg_SSTReal[80+skill*2]
  else
   set skill=skill-12
   set x=X+udg_SSTReal[50+skill*2]
   set y=Y+udg_SSTReal[51+skill*2]
  endif 
  if udg_SST[61+PId]>0 then
   call RemoveDestructable(i2dest(udg_SST[61+PId]))
   set udg_SST[61+PId]=0
  endif
  set loc=Location(x,y)
  set z=GetLocationZ(loc)+0.1
  call SetSSTInt(I2S(p)+"SSkill",skill)
  set udg_SST[61+PId]=h2i(CreateDestructableZ('B006',x,y,z,0,0.4,0))
  call RemoveLocation(loc)
 elseif not vis then
  if udg_SST[61+PId]>0 then
   call RemoveDestructable(i2dest(udg_SST[61+PId]))
   set udg_SST[61+PId]=0
  endif
  call SetSSTInt(I2S(p)+"SSkill",0)
 endif
 set loc=null
endfunction 
function SSTDontNeed takes unit u,integer id returns boolean
 local integer i=1 
 local boolean b=true
 loop
 exitwhen i>12 or not b
  if GetSSTInt(I2S(id)+"Need"+I2S(i))>0 and GetUnitSkillLevel(u,GetSSTInt(I2S(id)+"Need"+I2S(i)))<1 then
   set b=false
  endif
  set i=i+1
 endloop
 return b
endfunction
function SSTSkillAboutShow takes integer p,integer abil,string form returns nothing
 local multiboard mb=null
 local unit u=i2u(udg_SST[200+p*300]) 
 local integer skill=0
 local integer rows=1
 local string s=null
 local string array str
 local integer i=1
 local integer i2=0
 local string word=null
 local string func=null
 local boolean find=false
 local boolean spec=false
 local boolean exit=false
 local integer lev=0
 local integer NLev=0
 local integer MCost=0
 local integer nn=0
 if form=="Skill" or form=="Ability" then
  set s=GetSSTStr(I2S(abil)+"About")
  set lev=GetUnitSkillLevel(u,abil)
  set NLev=GetLevelNeed(abil,lev)
  set MCost=GetManaCost(abil,lev)
  if lev>0 and GetSSTStr(I2S(abil)+"AboutLev"+I2S(lev))!=null then
   set s=GetSSTStr(I2S(abil)+"AboutLev"+I2S(lev))
  elseif lev>0 then
   set s=GetSSTStr(I2S(abil)+"AboutLev1")
  endif
  loop
   if not find and (SubString(s,i-1,i)==" " or SubString(s,i-1,i)==null) then
    set find=true
   elseif not find and SubString(s,i-1,i)!=" " and SubString(s,i-1,i)!=null then
    if SubString(s,i-1,i)=="<" and not spec then
     set spec=true
    elseif SubString(s,i-1,i)==">" and spec then
     set spec=false
     call SSTStoreUnit(u)
     set word=word+GetSSTValue(func) 
    elseif spec then
     set func=func+SubString(s,i-1,i)
    elseif not spec then
     set word=word+SubString(s,i-1,i)
    endif
   endif
   if find then
    if str[rows]!=null and StringLength(str[rows]+" "+word)<=40 then
     set str[rows]=str[rows]+" "+word
    elseif str[rows]!=null and StringLength(str[rows]+" "+word)>40 then
     set rows=rows+1
     set str[rows]=word
    else
     set str[rows]=word
    endif
    set word=null
    set find=false
   endif
   set i=i+1
  exitwhen i>StringLength(s)+2
  endloop
 elseif form=="Page" then
  set s=GetSSTStr(I2S(GetUnitTypeId(u))+"AboutPage"+I2S(abil))
  loop
   if not find and (SubString(s,i-1,i)==" " or SubString(s,i-1,i)==null) then
    set find=true
   elseif not find and SubString(s,i-1,i)!=" " and SubString(s,i-1,i)!=null then
    set word=word+SubString(s,i-1,i)
   endif
   if find then
    if str[rows]!=null and StringLength(str[rows]+" "+word)<=40 then
     set str[rows]=str[rows]+" "+word
    elseif str[rows]!=null and StringLength(str[rows]+" "+word)>40 then
     set rows=rows+1
     set str[rows]=word
    else
     set str[rows]=word
    endif
    set word=null
    set find=false
   endif
   set i=i+1
  exitwhen i>StringLength(s)+2
  endloop
 endif
 set i2=1
 set i=1
 if form=="Skill" or form=="Ability" then
  if MCost>0 then
   set rows=rows+1
  endif
  if form=="Skill" then
   if GetSSTInt(I2S(abil)+"Passive")>0 then
    set rows=rows+1
   endif
   if IsUnitType(u,UNIT_TYPE_HERO) then
    if GetHeroLevel(u)<NLev+(GetSSTInt(I2S(abil)+"NLevConst")*(lev-1)) then
     set rows=rows+1
    endif
   else
    if GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"Level")<NLev+(GetSSTInt(I2S(abil)+"NLevConst")*(lev-1)) then
     set rows=rows+1
    endif
   endif
   loop
   exitwhen i2>12
    if GetSSTInt(I2S(abil)+"Need"+I2S(i2))>0 and GetUnitSkillLevel(u,GetSSTInt(I2S(abil)+"Need"+I2S(i2)))<1 then
     set rows=rows+1
    endif
    set i2=i2+1
   endloop
  endif
 endif
 set mb=i2mb(udg_SST[260+rows+p*300])
  if form=="Skill" or form=="Ability" then
   if form=="Skill" then
    if GetSSTInt(I2S(abil)+"Passive")>0 then
     call MBSetItemStyleBR(mb,1,i,true,false)
     call MBSetItemWidthBR(mb,1,i,23)
     call MBSetItemValueBR(mb,1,i,"|c0000ff00-Passiv")
     set i=i+1
    endif
    if IsUnitType(u,UNIT_TYPE_HERO) then
     if GetHeroLevel(u)<NLev then
      call MBSetItemStyleBR(mb,1,i,true,false)
      call MBSetItemWidthBR(mb,1,i,23)
      call MBSetItemValueBR(mb,1,i,"|c00ff0000Benötig Level: "+I2S(NLev+(GetSSTInt(I2S(abil)+"NLevConst")*(lev-1))))
      set i=i+1
     endif
    else
     if GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"Level")<NLev then
      call MBSetItemStyleBR(mb,1,i,true,false)
      call MBSetItemWidthBR(mb,1,i,23)
      call MBSetItemValueBR(mb,1,i,"|c00ff0000Benötig Level: "+I2S(NLev+(GetSSTInt(I2S(abil)+"NLevConst")*(lev-1))))
      set i=i+1
     endif
    endif
    set i2=1
    loop
    exitwhen i2>12
     if GetSSTInt(I2S(abil)+"Need"+I2S(i2))>0 and GetUnitSkillLevel(u,GetSSTInt(I2S(abil)+"Need"+I2S(i2)))<1 then
      call MBSetItemStyleBR(mb,1,i,true,false)
      call MBSetItemWidthBR(mb,1,i,23)
      set nn=GetSSTInt(I2S(abil)+"Need"+I2S(i2))
      if GetSSTInt(I2S(nn)+"IsBook")>0 then
       set nn=GetSSTInt(I2S(nn)+"AbilityInBook")
      endif
      call MBSetItemValueBR(mb,1,i,"|c00ff0000Benötigt: "+GetObjectName(nn))
      set i=i+1
     endif
     set i2=i2+1
    endloop
   endif
   if MCost>0 then
    set rows=rows-1
   endif 
  endif
  set i2=0
  loop
   set i2=i2+1
   call MBSetItemStyleBR(mb,1,i,true,false)
   call MBSetItemWidthBR(mb,1,i,23)
   call MBSetItemValueBR(mb,1,i,str[i2])
   set i=i+1
  exitwhen i>rows
  endloop
  if form=="Skill" or form=="Ability" then
   if MCost>0 then
    call MBSetItemStyleBR(mb,1,i,true,true)
    call MBSetItemWidthBR(mb,1,i,23)
    call MBSetItemIconBR(mb,1,i,"UI\\Widgets\\ToolTips\\Human\\ToolTipManaIcon.blp")
    call MBSetItemValueBR(mb,1,i,I2S(MCost))
    set i=i+1
   endif
   set s=GetSSTStr(I2S(abil)+"Name")
   if s!=null and s!="" then
    call MultiboardSetTitleText(mb,"|cffffffff"+s+" [|cffffcc00Level "+I2S(lev)+"|cffffffff]")
   else
    if GetSSTInt(I2S(abil)+"IsBook")>0 then
     set abil=GetSSTInt(I2S(abil)+"AbilityInBook")
    endif
    call MultiboardSetTitleText(mb,"|cffffffff"+GetObjectName(abil)+" [|cffffcc00Level "+I2S(lev)+"|cffffffff]")
   endif
  else
   call MultiboardSetTitleText(mb,"|cffffffff"+GetSSTStr(I2S(GetUnitTypeId(u))+"PageName"+I2S(abil)))
  endif
 if GetLocalPlayer()==Player(p) then
  call MultiboardDisplay(mb,true)
  call MultiboardMinimize(mb,false)
 endif
 call SetSSTInt(I2S(p)+"Multiboard",h2i(mb))
 set mb=null
 set u=null
endfunction
function SSTSkillHit takes nothing returns nothing
 local trackable tr=GetTriggeringTrackable()
 local integer p=GetSSTInt(I2S(h2i(tr)))
 local string typ=GetStoredString(udg_SSTcache,I2S(h2i(tr)),"Type")
 local integer skill=GetSSTInt(I2S(h2i(tr))+"Skill")
 local unit u=i2u(udg_SST[200+p*300])
 local integer id=udg_SST[210+GetSSTInt(I2S(h2i(GetTriggeringTrackable()))+"Skill")+p*300]
 local integer lev=GetUnitSkillLevel(u,id)
 local integer Nlev=GetLevelNeed(id,lev+1)
 local integer max=0
 local integer hLev=GetHeroLevel(u)
 if not IsUnitType(u,UNIT_TYPE_HERO) then
  set hLev=GetSSTUnitLevel(u)
 endif
 if GetSSTInt(I2S(p)+"SSkill")==skill then
  if GetUnitSkillPoints(u)>0 then
   if hLev>=Nlev+(GetSSTInt(I2S(id)+"NLevConst")*(lev-1)) then
    set max=GetSSTInt(I2S(id)+"MaxResearchLevel")
    if max<1 then
     set max=GetSSTInt(I2S(id)+"MaxLevel")
    endif
    if lev<max and SSTDontNeed(u,id) then
     if SetUnitSkillLevel(u,id,lev+1) then
      call SetUnitSkillPoints(u,GetUnitSkillPoints(u)-1)
     endif
     call SSTSkillAboutShow(p,id,"Skill")
    endif
   endif
  endif
 else
  call SetSSTInt(I2S(p)+"SSkill",skill)
  call VisibleSSTSelection(p,skill,true)
 endif
endfunction
function SSTSkillTrack takes nothing returns nothing
 local integer p=GetSSTInt(I2S(h2i(GetTriggeringTrackable())))
 call SSTSkillAboutShow(p,udg_SST[210+GetSSTInt(I2S(h2i(GetTriggeringTrackable()))+"Skill")+p*300],"Skill")
endfunction
function SSTClearning takes nothing returns nothing
 local integer p=GetSSTInt(I2S(h2i(GetTriggeringTrackable())))
 local integer i=udg_SST[p*300+203]
 local location l=null
 call ClearSSTMB(p)
 if i>0 then
  call RemoveDestructable(i2dest(udg_SST[p*300+203]))
  set udg_SST[p*300+203]=0
 endif
endfunction 
function SSTVisClearning takes nothing returns nothing
 local integer p=GetSSTInt(I2S(h2i(GetTriggeringTrackable())))
 call SetSSTInt(I2S(p)+"SSkill",0)
 call VisibleSSTSelection(p,0,false)
endfunction
function SSTAbilityHit takes nothing returns nothing
 local trackable tr=GetTriggeringTrackable()
 local string p=I2S(GetSSTInt(I2S(h2i(tr))))
 local integer PId=GetSSTInt(I2S(h2i(tr)))*300
 local integer abil=GetSSTInt(I2S(h2i(tr))+"Ability")
 local integer skill=GetSSTInt(p+"SSkill")
 local unit u=i2u(udg_SST[200+S2I(p)*300])
 local integer page=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"PageOn")
 local integer id=GetSSTInt(I2S(GetUnitTypeId(u))+"Skill"+I2S(skill+(page*12-12)))
 local integer id2=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot"+I2S(abil))
 local real x=udg_SSTReal[S2I(p)*2+1]
 local real y=udg_SSTReal[S2I(p)*2+2]
 local string ss=null
 local location l=Location(x,y)
 local real z=GetLocationZ(l)
 call RemoveLocation(l)
 if skill==12+abil then
  call SetUnitAbilityState(Player(S2I(p)),id2,false,u)
  call ClearSSTMB(S2I(p))
  call VisibleSSTSelection(S2I(p),skill,false)
  call SetSSTInt(p+"SSkill",0)
  call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot"+I2S(abil),0)
  call RemoveDestructable(i2dest(udg_SST[10+abil+PId]))
  set udg_SST[10+abil+PId]=0
  set ss=GetSSTStr(I2S(id2)+"OnDeactivation")
  if ss!=null and ss!="" then
   call SSTStoreUnit(u)
   call ExecuteFunc(ss)   
  endif
 elseif skill>0 and skill<13 and GetSSTInt(I2S(id)+"Passive")<1 then
  if GetUnitSkillLevel(u,id)>0 then
   if GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot1")==id then
    call RemoveDestructable(i2dest(udg_SST[11+PId]))
    set udg_SST[11+PId]=0
    call SetUnitAbilityState(Player(S2I(p)),GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot1"),false,u)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot1",0)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot1S",0)
   elseif GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot2")==id then
    call RemoveDestructable(i2dest(udg_SST[12+PId]))
    set udg_SST[12+PId]=0
    call SetUnitAbilityState(Player(S2I(p)),GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot2"),false,u)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot2",0)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot2S",0)
   elseif GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot3")==id then
    call RemoveDestructable(i2dest(udg_SST[13+PId]))
    set udg_SST[13+PId]=0
    call SetUnitAbilityState(Player(S2I(p)),GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot3"),false,u)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot3",0)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot3S",0)
   elseif GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot4")==id then
    call RemoveDestructable(i2dest(udg_SST[14+PId]))
    set udg_SST[14+PId]=0
    call SetUnitAbilityState(Player(S2I(p)),GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot4"),false,u)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot4",0)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot4S",0)
   elseif GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot5")==id then
    call RemoveDestructable(i2dest(udg_SST[15+PId]))
    set udg_SST[15+PId]=0
    call SetUnitAbilityState(Player(S2I(p)),GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot5"),false,u)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot5",0)
    call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot5S",0)
   endif
  endif
  if id2>0 and GetUnitSkillLevel(u,id)>0 then
   call RemoveDestructable(i2dest(udg_SST[10+abil+PId]))
   set udg_SST[10+abil+PId]=0
   call VisibleSSTSelection(S2I(p),12+abil,true)
   call SetUnitAbilityState(Player(S2I(p)),id2,false,u)
  endif
  call SetSSTInt(p+"SSkill",0) 
  call VisibleSSTSelection(S2I(p),skill,false) 
  call SetSSTInt(p+"AbilInSlot"+I2S(abil),0)
  if GetUnitSkillLevel(u,id)>0 then
   call SetUnitAbilityState(Player(S2I(p)),id,true,u)
   set udg_SST[10+PId+abil]=h2i(CreateDestructableZ(GetSSTInt(I2S(id)+"Icon"),x+udg_SSTReal[50+abil*2],y+udg_SSTReal[51+abil*2],z+0.1,270,0.3,0))
   call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot"+I2S(abil),id)
   call StoreInteger(udg_SSTcache,I2S(h2i(u)),"SST_Slot"+I2S(abil)+"S",skill)
   call SetSSTInt(p+"AbilInSlot"+I2S(abil),skill)
   call SSTSkillAboutShow(S2I(p),id,"Ability")
   set ss=GetSSTStr(I2S(id2)+"OnActivation")
   if ss!=null and ss!="" then
    call SSTStoreUnit(u)
    call ExecuteFunc(ss)   
   endif
  endif
 elseif id2>0 then
  call VisibleSSTSelection(S2I(p),12+abil,true)  
  call SetSSTInt(p+"SSkill",12+abil)
 else
  call VisibleSSTSelection(S2I(p),0,false)  
  call SetSSTInt(p+"SSkill",0)
 endif
 set tr=null
 set u=null
endfunction
function SSTAbilityTrack takes nothing returns nothing
 local integer p=GetSSTInt(I2S(h2i(GetTriggeringTrackable())))
 local integer abil=GetSSTInt(I2S(h2i(GetTriggeringTrackable()))+"Ability")
 local integer id=GetStoredInteger(udg_SSTcache,I2S(udg_SST[200+p*300]),"SST_Slot"+I2S(abil))
 set abil=GetSSTInt(I2S(p)+"AbilInSlot"+I2S(abil))
 if id>0 then
  call SSTSkillAboutShow(p,id,"Ability")
 else
  call ClearSSTMB(p)
 endif
endfunction
function SSTPageHit takes nothing returns nothing
 local integer page=GetSSTInt(I2S(h2i(GetTriggeringTrackable()))+"Page")
 local integer p=GetSSTInt(I2S(h2i(GetTriggeringTrackable())))
 local integer pageOn=GetStoredInteger(udg_SSTcache,I2S(udg_SST[200+p*300]),"PageOn")
 local unit u=i2u(udg_SST[p*300+200])
 local location l=null
 if page!=pageOn then
  call RemoveDestructable(i2dest(udg_SST[61+pageOn+p*300]))
  call RemoveDestructable(i2dest(udg_SST[61+page+p*300]))
  call RemoveDestructable(i2dest(udg_SST[p*300+203]))
  set udg_SST[p*300+203]=0
  set l=Location(udg_SSTReal[p*2+1],udg_SSTReal[p*2+2])
  set udg_SST[61+pageOn+p*300]=h2i(CreateDestructableZ(GetSSTInt(I2S(GetUnitTypeId(u))+"IconOffPage"+I2S(pageOn)),udg_SSTReal[p*2+1]+udg_SSTReal[129+pageOn*2],udg_SSTReal[p*2+2]+udg_SSTReal[130+pageOn*2],GetLocationZ(l)+0.1,270,0.22,0))
  set udg_SST[61+page+p*300]=h2i(CreateDestructableZ(GetSSTInt(I2S(GetUnitTypeId(u))+"IconOnPage"+I2S(page)),udg_SSTReal[p*2+1]+udg_SSTReal[129+page*2],udg_SSTReal[p*2+2]+udg_SSTReal[130+page*2],GetLocationZ(l)+0.1,270,0.22,0))
  call RemoveLocation(l)
  set l=null
  call ClearSSTVisibles(GetSSTInt(I2S(h2i(GetTriggeringTrackable()))))
  call StoreInteger(udg_SSTcache,I2S(udg_SST[200+300*p]),"PageOn",GetSSTInt(I2S(h2i(GetTriggeringTrackable()))+"Page"))
  call LoadSSTVisibles(u)
 endif
endfunction
function SSTPageTrack takes nothing returns nothing
 local integer page=GetSSTInt(I2S(h2i(GetTriggeringTrackable()))+"Page")
 local integer p=GetSSTInt(I2S(h2i(GetTriggeringTrackable())))
 local integer i=udg_SST[p*300+203]
 local location l=null
 call SSTSkillAboutShow(p,page,"Page")
 if i>0 then
  call RemoveDestructable(i2dest(i))  
  set udg_SST[p*300+203]=0
 endif
 if page!=GetStoredInteger(udg_SSTcache,I2S(udg_SST[200+p*300]),"PageOn") then
  set l=Location(udg_SSTReal[p*2+1],udg_SSTReal[p*2+2])
  set udg_SST[p*300+203]=h2i(CreateDestructableZ(udg_SST[4005],udg_SSTReal[p*2+1]+udg_SSTReal[129+page*2],udg_SSTReal[p*2+2]+udg_SSTReal[130+page*2],GetLocationZ(l)+0.2,270,0.25,0))
  call RemoveLocation(l)
  set l=null
 endif
endfunction
function CreateSSTVisualisation takes nothing returns nothing
 local integer i=0
 local integer i2=1
 local destructable des=null
 local location l=null
 local real z=0
 local real x=0
 local real y=0
 local integer p=0
 loop 
  if GetSSTInt("player"+I2S(i))==1 and GetPlayerController(Player(i))==MAP_CONTROL_USER then
   set p=i*300
   set x=udg_SSTReal[i*2+1]
   set y=udg_SSTReal[i*2+2]
   set l=Location(x,y)
   set z=GetLocationZ(l)+0.05
   call RemoveLocation(l)
   set des=CreateDestructableZ(udg_SST[4002],x,y,z,0,1,0)
   set udg_SST[1+p]=h2i(des)
   call ShowDestructable(des,false)
   set des=CreateDestructableZ(udg_SST[4003],x+udg_SSTReal[30],y+udg_SSTReal[31],z+0.009,270,0.4,0)
   set udg_SST[2+p]=h2i(des)
   call ShowDestructable(des,false)
   set des=CreateDestructableZ(udg_SST[4003],x+udg_SSTReal[32],y+udg_SSTReal[33],z+0.01,90,0.4,0)
   set udg_SST[3+p]=h2i(des)
   call ShowDestructable(des,false)
   set des=CreateDestructableZ(udg_SST[4003],x+udg_SSTReal[34],y+udg_SSTReal[35],z+0.01,180,0.4,0)
   set udg_SST[4+p]=h2i(des)
   call ShowDestructable(des,false)
   set des=CreateDestructableZ(udg_SST[4003],x+udg_SSTReal[36],y+udg_SSTReal[37],z+0.01,0,0.4,0)
   set udg_SST[5+p]=h2i(des)
   call ShowDestructable(des,false)
   set des=CreateDestructableZ(udg_SST[4006],x+udg_SSTReal[50],y+udg_SSTReal[51],z+0.09,0,0.21,0)
   set udg_SST[16+p]=h2i(des)
   call ShowDestructable(des,false)
   set udg_SST[70+p]=h2i(CreateTextTag())
   set i2=1
   loop
    exitwhen i2>12
    set udg_SST[70+i2+p]=h2i(CreateTextTag())
    set des=CreateDestructableZ(udg_SST[4006],x+udg_SSTReal[79+(i2*2)],y+udg_SSTReal[80+(i2*2)],z+0.001,0,0.45,0)
    set udg_SST[16+p+i2]=h2i(des)
    call ShowDestructable(des,false)
    set des=CreateDestructableZ(udg_SST[4006],x+udg_SSTReal[79+(i2*2)]+udg_SSTReal[129],y+udg_SSTReal[80+(i2*2)]+udg_SSTReal[130],z+0.1,0,0.17,0)
    set udg_SST[28+p+i2]=h2i(des)
    call ShowDestructable(des,false)
    set i2=i2+1
   endloop
   set i2=1
   loop
    exitwhen i2>5
    set des=CreateDestructableZ(udg_SST[4006],x+udg_SSTReal[50+(i2*2)],y+udg_SSTReal[51+(i2*2)],z+0.001,0,0.45,0)
    set udg_SST[5+p+i2]=h2i(des)
    call ShowDestructable(des,false)
    set i2=i2+1
   endloop
   set i2=1
   loop
    exitwhen i2>8
    set des=CreateDestructableZ(udg_SST[4006],x+udg_SSTReal[129+(i2*2)],y+udg_SSTReal[130+(i2*2)],z+0.001,0,0.30,0)
    set udg_SST[40+p+i2]=h2i(des)
    call ShowDestructable(des,false)
    set i2=i2+1
   endloop
  endif
  set i=i+1
 exitwhen i==12
 endloop
 set des=null
 set l=null
endfunction
function CreateSSTDisplayActions takes nothing returns nothing
 local integer i=0
 local integer i2=1
 local trackable tr=null
 local trigger t=null
 local real x=0
 local real y=0
 local integer p=0
 loop 
  if GetSSTInt("player"+I2S(i))==1 and GetPlayerController(Player(i))==MAP_CONTROL_USER then
   set p=i*300
   set x=udg_SSTReal[i*2+1]
   set y=udg_SSTReal[i*2+2]
   set tr=CreateTrackable("SST\\TtrkBack.mdx",x,y,0)
   set t=CreateTrigger()
   call SetSSTInt(I2S(h2i(tr)),i)
   call StoreString(udg_SSTcache,I2S(h2i(tr)),"Type","Background")
   call TriggerRegisterTrackableTrackEvent(t,tr)
   call TriggerAddAction(t,function SSTClearning)
   set t=CreateTrigger()
   call TriggerAddAction(t,function SSTVisClearning)
   call TriggerRegisterTrackableHitEvent(t,tr)
   set i2=1
   loop
    exitwhen i2>12
    set tr=CreateTrackable("SST\\Ttrk.mdx",x+udg_SSTReal[79+(i2*2)],y+udg_SSTReal[80+(i2*2)],0)
    set t=CreateTrigger()
    call SetSSTInt(I2S(i)+"STHit"+I2S(i2),h2i(t))
    call SetSSTInt(I2S(h2i(tr)),i)
    call SetSSTInt(I2S(h2i(tr))+"Skill",i2)
    call TriggerAddAction(t,function SSTSkillHit)
    call TriggerRegisterTrackableHitEvent(t,tr)
    call DisableTrigger(t)
    set t=CreateTrigger()
    call SetSSTInt(I2S(i)+"STTrack"+I2S(i2),h2i(t))
    call TriggerRegisterTrackableTrackEvent(t,tr)
    call TriggerAddAction(t,function SSTSkillTrack)
    call DisableTrigger(t)
    set i2=i2+1
   endloop
   set i2=1
   loop
    exitwhen i2>5
    set tr=CreateTrackable("SST\\Ttrk.mdx",x+udg_SSTReal[50+(i2*2)],y+udg_SSTReal[51+(i2*2)],0)
    set t=CreateTrigger()
    call SetSSTInt(I2S(i)+"ATHit"+I2S(i2),h2i(t))
    call SetSSTInt(I2S(h2i(tr)),i)
    call SetSSTInt(I2S(h2i(tr))+"Ability",i2)
    call TriggerAddAction(t,function SSTAbilityHit)
    call TriggerRegisterTrackableHitEvent(t,tr)
    call DisableTrigger(t)
    set t=CreateTrigger()
    call SetSSTInt(I2S(i)+"ATTrack"+I2S(i2),h2i(t))
    call TriggerRegisterTrackableTrackEvent(t,tr)
    call TriggerAddAction(t,function SSTAbilityTrack)
    call DisableTrigger(t)
    set i2=i2+1
   endloop
   set i2=1
   loop
    exitwhen i2>8
    set tr=CreateTrackable("SST\\Ttrk.mdx",x+udg_SSTReal[129+(i2*2)],y+udg_SSTReal[130+(i2*2)],0)
    set t=CreateTrigger()
    call SetSSTInt(I2S(i)+"PTHit"+I2S(i2),h2i(t))
    call SetSSTInt(I2S(h2i(tr)),i)
    call SetSSTInt(I2S(i)+"Page"+I2S(i2),h2i(tr))
    call SetSSTInt(I2S(h2i(tr))+"Page",i2)
    call TriggerAddAction(t,function SSTPageHit)
    call TriggerRegisterTrackableHitEvent(t,tr)
    call DisableTrigger(t)
    set t=CreateTrigger()
    call SetSSTInt(I2S(i)+"PTTrack"+I2S(i2),h2i(t))
    call TriggerRegisterTrackableTrackEvent(t,tr)
    call TriggerAddAction(t,function SSTPageTrack)
    call DisableTrigger(t)
    set i2=i2+1
   endloop
  endif
  set i=i+1
 exitwhen i==12
 endloop
 call CreateSSTVisualisation()
 set tr=null
 set t=null
endfunction
function ClearSSTMain takes nothing returns nothing
 local integer i=0
 loop
  exitwhen i>11
  if GetSSTInt("player"+I2S(i))==1 and GetPlayerController(Player(i))==MAP_CONTROL_USER then
   call RemoveDestructable(i2dest(udg_SST[i*300+1]))
   call RemoveDestructable(i2dest(udg_SST[i*300+2]))
   call RemoveDestructable(i2dest(udg_SST[i*300+3]))
   call RemoveDestructable(i2dest(udg_SST[i*300+4]))
   call RemoveDestructable(i2dest(udg_SST[i*300+5]))
   call RemoveDestructable(i2dest(udg_SST[i*300+16]))
   call RemoveDestructable(i2dest(udg_SST[i*300+17]))
   call RemoveDestructable(i2dest(udg_SST[i*300+18]))
   call RemoveDestructable(i2dest(udg_SST[i*300+19]))
   call RemoveDestructable(i2dest(udg_SST[i*300+20]))
   call RemoveDestructable(i2dest(udg_SST[i*300+21]))
   call RemoveDestructable(i2dest(udg_SST[i*300+22]))
   call RemoveDestructable(i2dest(udg_SST[i*300+23]))
   call RemoveDestructable(i2dest(udg_SST[i*300+24]))
   call RemoveDestructable(i2dest(udg_SST[i*300+25]))
   call RemoveDestructable(i2dest(udg_SST[i*300+26]))
   call RemoveDestructable(i2dest(udg_SST[i*300+27]))
   call RemoveDestructable(i2dest(udg_SST[i*300+28]))
   call RemoveDestructable(i2dest(udg_SST[i*300+29]))
   call RemoveDestructable(i2dest(udg_SST[i*300+30]))
   call RemoveDestructable(i2dest(udg_SST[i*300+31]))
   call RemoveDestructable(i2dest(udg_SST[i*300+32]))
   call RemoveDestructable(i2dest(udg_SST[i*300+33]))
   call RemoveDestructable(i2dest(udg_SST[i*300+34]))
   call RemoveDestructable(i2dest(udg_SST[i*300+35]))
   call RemoveDestructable(i2dest(udg_SST[i*300+36]))
   call RemoveDestructable(i2dest(udg_SST[i*300+37]))
   call RemoveDestructable(i2dest(udg_SST[i*300+38]))
   call RemoveDestructable(i2dest(udg_SST[i*300+39]))
   call RemoveDestructable(i2dest(udg_SST[i*300+40]))
   call RemoveDestructable(i2dest(udg_SST[i*300+41]))
   call RemoveDestructable(i2dest(udg_SST[i*300+42]))
   call RemoveDestructable(i2dest(udg_SST[i*300+43]))
   call RemoveDestructable(i2dest(udg_SST[i*300+44]))
   call RemoveDestructable(i2dest(udg_SST[i*300+45]))
   call RemoveDestructable(i2dest(udg_SST[i*300+46]))
   call RemoveDestructable(i2dest(udg_SST[i*300+47]))
   call RemoveDestructable(i2dest(udg_SST[i*300+48]))
   call DestroyTextTag(i2tt(udg_SST[i*300+70]))
   call DestroyTextTag(i2tt(udg_SST[i*300+71]))
   call DestroyTextTag(i2tt(udg_SST[i*300+72]))
   call DestroyTextTag(i2tt(udg_SST[i*300+73]))
   call DestroyTextTag(i2tt(udg_SST[i*300+74]))
   call DestroyTextTag(i2tt(udg_SST[i*300+75]))
   call DestroyTextTag(i2tt(udg_SST[i*300+76]))
   call DestroyTextTag(i2tt(udg_SST[i*300+77]))
   call DestroyTextTag(i2tt(udg_SST[i*300+78]))
   call DestroyTextTag(i2tt(udg_SST[i*300+79]))
   call DestroyTextTag(i2tt(udg_SST[i*300+80]))
   call DestroyTextTag(i2tt(udg_SST[i*300+81]))
   call DestroyTextTag(i2tt(udg_SST[i*300+82]))
  endif
  set i=i+1
 endloop
endfunction
function SST_LevelUP_Action takes nothing returns nothing
 local unit u=GetTriggerUnit()
 local integer id=GetPlayerId(GetOwningPlayer(u))
 local integer llev=GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"LastLevel")
 call StoreInteger(udg_SSTcache,I2S(h2i(u)),"LastLevel",GetHeroLevel(u))
 if GetHeroLevel(u)>llev+1 then
  call SetUnitSkillPoints(GetTriggerUnit(),GetUnitSkillPoints(u)+(GetSSTInt("PointsByLevel")*(GetHeroLevel(u)-llev))) 
 else
  call SetUnitSkillPoints(GetTriggerUnit(),GetUnitSkillPoints(u)+GetSSTInt("PointsByLevel")) 
 endif 
 if u==i2u(udg_SST[200+id*300]) then
  call SetTextTagText(i2tt(udg_SST[51+(id*300)]),I2S(GetUnitSkillPoints(u)),0.025)
 endif
 set u=null
endfunction
function SST_DeathCondition takes nothing returns boolean
 return GetTriggerUnit()==i2u(udg_SST[200+(GetPlayerId(GetOwningPlayer(GetTriggerUnit()))*300)])
endfunction
function SST_DeathAction takes nothing returns nothing
 call ExecuteFunc("SST_Spell_Action")
endfunction
function HaveBook takes nothing returns boolean
 local unit u=GetFilterUnit()
 local integer i=1
 local integer id=0
 local integer p=0
 if GetStoredBoolean(udg_SSTcache,I2S(h2i(u)),"SSTPreload") then
  set p=GetSSTInt(I2S(GetUnitTypeId(u))+"Pages")
  if p<1 then
   set p=1
  endif
  loop
   exitwhen i>p*12
   set id=GetSSTInt(I2S(GetUnitTypeId(u))+"Skill"+I2S(i))
   if GetSSTInt(I2S(id)+"IsBook")>0 then
    call SetUnitAbilityLevel(u,GetSSTInt(I2S(id)+"AbilityInBook"),GetUnitSkillLevel(u,id))
   elseif GetSSTInt(I2S(id)+"InBook")>0 then
    if GetUnitAbilityLevel(u,id)<1 then
     call UnitAddAbility(u,id)
    endif
    call SetUnitSkillLevel(u,id,GetStoredInteger(udg_SSTcache,I2S(h2i(u)),"Level"+I2S(id)))
   endif
   set i=i+1
  endloop
 endif
 return true
endfunction
function LoadSST takes nothing returns nothing
 local group g=CreateGroup()
 call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,Condition(function HaveBook))
 call DestroyGroup(g)
 set g=null
 call ClearSSTMain()
 call CreateSSTVisualisation()
endfunction
function SaveGameSST takes nothing returns nothing
 local integer i=0
 loop
  exitwhen i>11
  if udg_SST[i*300+200]>0 then
   call SST_Activation(i2u(udg_SST[i*300+200]))
  endif
  set i=i+1
 endloop
endfunction
function SST_INIT takes nothing returns nothing
 local trigger spell=CreateTrigger()
 call TriggerAddAction(spell,function SST_Spell_Action)
 call TriggerAddCondition(spell,Condition(function SST_Spell_Condition))
 call TriggerRegisterAnyUnitEventBJ(spell,EVENT_PLAYER_UNIT_SPELL_EFFECT)
 call CreateSSTDisplayActions()
 set spell=CreateTrigger()
 call TriggerRegisterAnyUnitEventBJ(spell,EVENT_PLAYER_HERO_LEVEL)
 call TriggerAddAction(spell,function SST_LevelUP_Action)
 set spell=CreateTrigger()
 call TriggerRegisterAnyUnitEventBJ(spell,EVENT_PLAYER_UNIT_DEATH)
 call TriggerAddAction(spell,function SST_DeathAction)
 call TriggerAddCondition(spell,Condition(function SST_DeathCondition))
 set spell=CreateTrigger()
 call TriggerRegisterGameEvent(spell,EVENT_GAME_LOADED)
 call TriggerAddAction(spell,function LoadSST)
 set spell=CreateTrigger()
 call TriggerRegisterGameEvent(spell,EVENT_GAME_SAVE)
 call TriggerAddAction(spell,function SaveGameSST)
 set spell=null
endfunction
function InitTrig_SSTData takes nothing returns nothing
 set udg_SSTcache=InitGameCache("SST.w3v")
 call FlushGameCache(udg_SSTcache)
 set udg_SSTcache=InitGameCache("SST.w3v")
 call ExecuteFunc("InitSSTSetup")
 call ExecuteFunc("SSTCoordinates")
 set gg_trg_SSTData=CreateTrigger()
 call TriggerAddAction(gg_trg_SSTData,function SST_INIT)
endfunction

Skill's Init:

JASS:
function InitSSTSetup takes nothing returns nothing
 call SetSSTInt("player0",1) 
 call SetSSTInt("player1",1)
 call SetSSTInt("player2",1)
 call SetSSTInt("player3",1)
 call SetSSTInt("player4",1)
 call SetSSTInt("player5",1)
 call SetSSTInt("player6",1)
 call SetSSTReal("SST_X",2000)     
 call SetSSTReal("SST_Y",-800)     
 call SetSSTInt("PointsByLevel",1)  
 call SetSSTInt("Spell",'A62C')       
 call SetSSTInt("BackgroundId",'B64U') 
 call SetSSTInt("BorderId",'B64V')    
 call SetSSTInt("ArrowId",'B64Z')     
 call SetSSTInt("SelectionId",'B64X')  
 call SetSSTInt("SSlotId",'B64W')       

 call SetSSTInt(I2S('H00A')+"Slots",5)              
 call SetSSTInt(I2S('H00A')+"Pages",3)                           
 call SetSSTInt(I2S('H00A')+"IconOnPage1",'B008')                
 call SetSSTInt(I2S('H00A')+"IconOffPage1",'B007')               
 call SetSSTInt(I2S('H00A')+"IconOnPage2",'B00E')                 
 call SetSSTInt(I2S('H00A')+"IconOffPage2",'B00D') 
 call SetSSTInt(I2S('H00A')+"IconOnPage3",'B00C')                 
 call SetSSTInt(I2S('H00A')+"IconOffPage3",'B00B')   
 
 call SetUnitSkill('H00A',1,'A07E')
 
Level 4
Joined
Dec 11, 2007
Messages
74
cause i have the system from a russian site and dont no who made it o_O


(and i edited littlethings on his system)
 
Level 4
Joined
Dec 11, 2007
Messages
74
yeah i know this system causes no desync's ...


but after i edited some things... and i cant find the problem.
 
Last edited:
Level 4
Joined
Dec 11, 2007
Messages
74
yeah i know but thats not the problem...!!!

this system was done with destructables and multiboards and runned well

i tried to remove the multiboard and now we get the problem with desync's

so i hoped that someone can help me to remove the desync's i build...
 
Level 4
Joined
Dec 11, 2007
Messages
74
(the destructables are not in the if local player function... but in the system)

mhmmm wait i show you the functions i pasted in to the system... maybe you can tell me if they cause the desyncs...


JASS:
   if GetLocalPlayer()==Player(p) then
    call SetCameraBounds(GetRectMinX(GetPlayableMapRect()),GetRectMinY(GetPlayableMapRect()),GetRectMaxX(GetPlayableMapRect()),GetRectMaxY(GetPlayableMapRect()),GetRectMinX(GetPlayableMapRect()),GetRectMaxY(GetPlayableMapRect()),GetRectMaxX(GetPlayableMapRect()),GetRectMinY(GetPlayableMapRect()))
    call ResetToGameCamera(0.000)
    call CameraSetSmoothingFactor(0)
    call SetCameraTargetControllerNoZForPlayer( GetOwningPlayer(i2u(udg_SST[200+p*300])), i2u(udg_SST[200+p*300]), 0, 0, false ) // this line is mine
    set udg_Cam[GetConvertedPlayerId(GetOwningPlayer(i2u(udg_SST[200+p*300])))] = true // and this line is mine
   endif
 
Level 4
Joined
Dec 11, 2007
Messages
74
thats the only problem ? well i test it and you will get rep... ^^ ty



Edit: woaaahh yeah that was it thank you so much + rep =3
 
Status
Not open for further replies.
Top