help with this script.. please

G

gonecase

Guest
Can someone help me convert this script from this to Local Vars or CS Cache or tell me what to change where and stuff

heres the custom script:
Code:
function LB_Cache takes nothing returns gamecache
   if (udg_LBcache==null) then
      set udg_LBcache=InitGameCache("LBcache")
   endif
      return udg_LBcache
endfunction

function LB_HandToInt takes handle h returns integer
   return h
   return 0
endfunction

function LB_StoreHandle takes handle m_key, handle stored, string key returns nothing
   call StoreInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key,LB_HandToInt(stored))
endfunction

function LB_StoreInt takes handle m_key, integer stored, string key returns nothing
   call StoreInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key,stored)
endfunction

function LB_StoreFloat takes handle m_key, real stored, string key returns nothing
   call StoreReal(LB_Cache(),I2S(LB_HandToInt( m_key )),key,stored)
endfunction

function LB_StoreBool takes handle m_key, boolean stored, string key returns nothing
   call StoreBoolean(LB_Cache(),I2S(LB_HandToInt( m_key )),key,stored)
endfunction

function LB_RetrieveUnit takes handle m_key,string key returns unit
   return GetStoredInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
   return null
endfunction

function LB_RetrieveTimer takes handle m_key,string key returns timer
   return GetStoredInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
   return null
endfunction

function LB_RetrieveInt takes handle m_key,string key returns integer
   return GetStoredInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
endfunction

function RetrieveBool takes handle m_key,string key returns boolean
   return GetStoredBoolean(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
endfunction

function LB_RetrieveFloat takes handle m_key,string key returns real
   return GetStoredReal(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
endfunction

function LB_RetrieveGroup takes handle m_key,string key returns group
   return GetStoredInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
   return null
endfunction

function LB_RetrieveLocation takes handle m_key,string key returns location
   return GetStoredInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
   return null
endfunction

function LB_RetrieveTrigger takes handle m_key,string key returns trigger
   return GetStoredInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
   return null
endfunction

function LB_RetrieveTriggerAct takes handle m_key,string key returns triggeraction
   return GetStoredInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
   return null
endfunction

function LB_RetrieveTriggerCond takes handle m_key,string key returns triggercondition
   return GetStoredInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
   return null
endfunction

function LB_FlushInt takes handle m_key,string key returns nothing
   call FlushStoredInteger(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
endfunction

function LB_FlushUnit takes handle m_key,string key returns nothing
   call FlushStoredUnit(LB_Cache(),I2S(LB_HandToInt( m_key )),key)
endfunction

function LB_Flush takes handle m_key returns nothing
   call FlushStoredMission(LB_Cache(),I2S(LB_HandToInt( m_key )))
endfunction

function LB_PreloadUnit takes integer unitid returns nothing
   local unit u = CreateUnit(Player(15),unitid,0,0,0)
   call RemoveUnit(u)
   set u = null
endfunction

function LB_PreloadAbility takes integer abilid returns nothing
   local unit u = CreateUnit(Player(15),LB_RawDummyGen(),0,0,0)
   call UnitAddAbility(u,abilid)
   call UnitRemoveAbility(u,abilid)
   call RemoveUnit(u)
   set u = null
endfunction

function LB_PreloadModel takes string filename returns nothing
   local unit u = CreateUnit(Player(15),LB_RawDummyGen(),0,0,0)
   local effect e = AddSpecialEffectTarget(filename,u,"chest")  
   call DestroyEffect(e) 
   call RemoveUnit(u)
   set u = null
   set e = null
endfunction

the main trigger :

Code:
//Tweak this costomization part as your favor
//Customization
function BR_RawAbil takes nothing returns integer
    return 'A003' //Raw code of 'Beast Rage' ability 
endfunction

function BR_RawSpeedBonus takes nothing returns integer
    return 'A004' //Raw code of 'Beast Rage (Attack Speed Bonus)' ability
endfunction

function BR_AttackCont takes integer level returns integer
    local integer array acont
    set acont[1] = 4   //Adjust this integer depends on your favor for continous attack for each level
    set acont[2] = 3   
    set acont[3] = 2  
    set acont[4] = 1  
    return acont[level]     
endfunction

function BR_Cooldown takes nothing returns real
    return 2.0 //Maximum time between attack which is still considered as continous
endfunction
//===========================================================================

function BR_TakeDamageCond takes nothing returns boolean
    local unit attacker = LB_RetrieveUnit(GetTriggeringTrigger(), "attacker")

    if ( GetEventDamageSource() == attacker ) then
        set attacker = null
        return true
    else
        set attacker = null
        return false
    endif 
endfunction

function BR_TakeDamageAct takes nothing returns nothing
    local unit attacker = LB_RetrieveUnit(GetTriggeringTrigger(), "attacker")
    local unit target = GetTriggerUnit()
    local unit prey = LB_RetrieveUnit(attacker, "BR_Prey")
    local integer BR_Acont = LB_RetrieveInt(attacker, "BR_Acont") + 1
    local integer level = GetUnitAbilityLevel(attacker,BR_RawAbil())
    local effect e
   
    call DisableTrigger(GetTriggeringTrigger())
    if (prey != null) then 
        call LB_StoreInt(attacker,BR_Acont,"BR_Acont")
        //call DisplayTextToForce(GetPlayersAll(),"attack"+I2S(BR_Acont)+" lvl" + I2S(GetUnitAbilityLevel(attacker,BR_RawSpeedBonus())))
        if ((ModuloInteger(BR_Acont,BR_AttackCont(level)) == 0) and (GetUnitAbilityLevel(attacker,BR_RawSpeedBonus())!=11)) then
            call SetUnitAbilityLevel(attacker,BR_RawSpeedBonus(),GetUnitAbilityLevel(attacker,BR_RawSpeedBonus())+1)
            set e = AddSpecialEffectTarget("Abilities\\Weapons\\LordofFlameMissile\\LordofFlameMissile.mdl",attacker,"head")  
            call DestroyEffect(e)
        endif
    endif 
    set e = null
    set attacker = null
    set target = null
endfunction

function BR_InitCond takes nothing returns boolean
    return ( GetUnitAbilityLevel(GetAttacker(),BR_RawAbil()) > 0 )
endfunction

function BR_InitAct takes nothing returns nothing
    local unit attacker = GetAttacker()
    local unit atktarg = GetTriggerUnit()
    local unit prey = LB_RetrieveUnit(attacker,"BR_Prey")
    local integer ec = GetTriggerExecCount(GetTriggeringTrigger())  
    local integer BR_Acont = LB_RetrieveInt(attacker,"BR_Acont")
  
    if (prey!=null)then
        return
    endif
    call TriggerSleepAction(BR_Cooldown())
    loop
        exitwhen (ec == GetTriggerExecCount(GetTriggeringTrigger()))
        set ec = GetTriggerExecCount(GetTriggeringTrigger())
        call TriggerSleepAction(BR_Cooldown())
    endloop
    call LB_StoreHandle(attacker,null,"BR_Prey")
    call UnitRemoveAbility(attacker,BR_RawSpeedBonus())
    set attacker = null
    set atktarg = null
    set prey = null
endfunction

function Trig_BeastRage_Conditions takes nothing returns boolean
    return ( GetUnitAbilityLevel(GetAttacker(),BR_RawAbil()) > 0 )
endfunction

function Trig_BeastRage_Actions takes nothing returns nothing
    local unit attacker = GetAttacker()
    local unit atktarg = GetTriggerUnit()
    local trigger BR_TakeDamage = CreateTrigger()
    local triggeraction BR_TDAct
    local triggercondition BR_TDCond
    local unit prey = LB_RetrieveUnit(attacker,"BR_Prey")
    local integer i = 1

    if (prey!= atktarg) then
        call LB_StoreHandle(attacker,atktarg,"BR_Prey")
        call LB_StoreInt(attacker,0,"BR_Acont")
        if (GetUnitAbilityLevel(attacker,BR_RawSpeedBonus())==0) then
            call UnitAddAbility(attacker,BR_RawSpeedBonus())
        else
            call UnitRemoveAbility(attacker,BR_RawSpeedBonus())
            call UnitAddAbility(attacker,BR_RawSpeedBonus())
        endif
    endif
    call LB_StoreHandle(BR_TakeDamage,attacker,"attacker")
    call TriggerRegisterUnitEvent( BR_TakeDamage, atktarg, EVENT_UNIT_DAMAGED )
    set BR_TDCond = TriggerAddCondition( BR_TakeDamage, Condition( function BR_TakeDamageCond ) )
    set BR_TDAct = TriggerAddAction( BR_TakeDamage, function BR_TakeDamageAct )
   
    loop
        exitwhen (GetTriggerExecCount(BR_TakeDamage)>0) or (i>=10)
        call TriggerSleepAction(0.1)
        set i = i + 1
    endloop
    
    call TriggerSleepAction(1)
    call LB_Flush(BR_TakeDamage)
    call TriggerRemoveAction(BR_TakeDamage,BR_TDAct) 
    call TriggerRemoveCondition(BR_TakeDamage,BR_TDCond)
    call DestroyTrigger(BR_TakeDamage) 
    set attacker = null
    set atktarg = null
    set BR_TDAct = null
    set BR_TDCond = null
    set BR_TakeDamage = null
endfunction

//===========================================================================
function InitTrig_BeastRage takes nothing returns nothing
    local trigger BR_Init = CreateTrigger()
    set gg_trg_BeastRage = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( BR_Init, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( BR_Init, Condition( function BR_InitCond ) )
    call TriggerAddAction( BR_Init, function BR_InitAct )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_BeastRage, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_BeastRage, Condition( function Trig_BeastRage_Conditions ) )
    call TriggerAddAction( gg_trg_BeastRage, function Trig_BeastRage_Actions )
    call LB_PreloadModel("Abilities\\Weapons\\LordofFlameMissile\\LordofFlameMissile.mdl")
    call LB_PreloadAbility(BR_RawAbil())
    call LB_PreloadAbility(BR_RawSpeedBonus())
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top