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

Library Testers...

Status
Not open for further replies.
Level 29
Joined
Mar 10, 2009
Messages
5,016
My Library Resources...

This is just a collection of my resources for easy copy and paste...

If someone will use this, please give credits...

NOTE: If somebody will suggest, then pls dont suggest that I should use another library like GroupUtils, TimerUtils, T32 etc...coz Im not gonna do it...


JASS:
//Spell Name: AoS SpawnSystem 
//Created by: Mckill2009

//INFO:
//- This library allows you to spawn units and will attack enemy's main base, just like DotA.
//- The units will be attacking each other as well when they encountered.

//===HOW TO USE:
//- Make a new trigger and convert to custom text via EDIT >>> CONVERT CUSTOM TEXT
//- Copy ALL that is written here and overwrite the existing texts in the custom text
//- Copy the Dummy/custom abilities/buffs etc... to your object editor
//- Make sure you inputed the correct RAW CODES...
//- You can view the raw codes by pressing CTRL+D in the object editor
//- Examples of raw codes are 'edry', 'edot' etc...see the example written in the global block...
//- You MUST create a Base Units first and store it in a variable...
//- After creating a Base Unit, make a trigger that runs periodically then do this >>> call onAttackForm(BASE1, BASE2) 

//REQUIRES:
//- Jass New Gen Pack (JNGP) by Vexorian

library AosSys initializer init

globals
    private constant player        TEAM1_AI = Player(2) //This is the computer AI, owner of TEAM1BASE
    private constant player        TEAM2_AI = Player(5) //This is the computer AI, owner of TEAM2BASE
    private constant integer        MINUNIT = 3 //Next wave will appear if it reaches below this number
    private constant integer        MAXUNIT = 9 //This is the MAX number of units created and MUST be the same as the Preload units below
    //Never touch this...
    private constant group           GROUP1 = CreateGroup() //Group for TEAM1BASE
    private constant group           GROUP2 = CreateGroup() //Group for TEAM2BASE
    private unit TEAM1BASE
    private unit TEAM2BASE
    private integer array UNITID
endglobals

private function onAttackEnemyBase1 takes nothing returns boolean
    call IssuePointOrder(GetEnumUnit(), "attack", GetUnitX(TEAM1BASE), GetUnitY(TEAM1BASE))
    return false
endfunction

private function onAttackEnemyBase2 takes nothing returns boolean
    call IssuePointOrder(GetEnumUnit(), "attack", GetUnitX(TEAM2BASE), GetUnitY(TEAM2BASE))
    return false
endfunction

private function onRemoveGroup takes nothing returns boolean
    if GetTriggerPlayer()==TEAM1_AI then
        call GroupRemoveUnit(GROUP1, GetTriggerUnit())  
    elseif GetTriggerPlayer()==TEAM2_AI then
        call GroupRemoveUnit(GROUP2, GetTriggerUnit())
    endif
    return false
endfunction

//This is the only thing you can call outside this script
function onAttackForm takes unit u1, unit u2 returns nothing 
    local unit u
    local real x
    local real y
    local integer i
    set TEAM1BASE = u1
    set TEAM2BASE = u2
    
    if GetPlayerUnitCount(TEAM1_AI, false) <= MINUNIT then
        set x = GetUnitX(TEAM1BASE)
        set y = GetUnitY(TEAM1BASE)
        set i = 0
        loop
            set i = i + 1
            set u = CreateUnit(TEAM1_AI, UNITID[i], x, y, 0)  
            call GroupAddUnit(GROUP1, u)
            exitwhen i > MAXUNIT 
        endloop
    endif
    
    if GetPlayerUnitCount(TEAM2_AI, false) <= MINUNIT then
        set x = GetUnitX(TEAM2BASE)
        set y = GetUnitY(TEAM2BASE)
        set i = 0
        loop
            set i = i + 1
            set u = CreateUnit(TEAM2_AI, UNITID[i], x, y, 0)
            call GroupAddUnit(GROUP2, u)  
            exitwhen i > MAXUNIT 
        endloop
    endif
    call ForGroup(GROUP1, function onAttackEnemyBase2)
    call ForGroup(GROUP2, function onAttackEnemyBase1)
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger() 
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH) 
    call TriggerAddCondition(t, Condition(function onRemoveGroup))
    set t = null
    //Preload units here, you may create your own spawned unit
    set UNITID[1] = 'nhrr' //Default Harpy Rogue
    set UNITID[2] = 'ndtt' //Default Dark Troll Trapper
    set UNITID[3] = 'nndk' //Default Neither Drake
    set UNITID[4] = 'ndth' //Default Dark Troll High Priest
    set UNITID[5] = 'nfrl' //Default Furbolg 
    set UNITID[6] = 'nfrl' //Default Furbolg
    set UNITID[7] = 'ndtt' //Default Dark Troll Trapper
    set UNITID[8] = 'nfrg' //Default Furbolg Champion
    set UNITID[9] = 'nfrg' //Default Furbolg Champion
    //set UNITID[10] = 'PUT RAW CODE HERE' //Optional description here
endfunction

endlibrary



JASS:
library HeroAttackRetreatSys

globals
    private constant hashtable          HASH = InitHashtable()
    private constant real      ATTACKLOCKDUR = 30.
    private constant real         TIMERSPEED = 3.
    private constant real     RETREATPERCENT = 0.5
    private constant real           RANGEAOE = 700. //Range on which the AI will pick a target
    private constant player         NHOSTILE = Player(12)
endglobals

private struct AosH
    unit hero
    unit base1
    unit base2
    real duration 
    real atttime
    integer randomize
    static thistype DATA
    
    static method onFilterComputer takes unit u returns boolean
        return IsUnitType(u, UNIT_TYPE_HERO) and  GetPlayerController(GetOwningPlayer(u))==MAP_CONTROL_COMPUTER        
    endmethod
    
    static method onRangeAttack takes nothing returns boolean
        local thistype this = DATA
        local unit u = GetFilterUnit()
        local boolean b = GetWidgetLife(u) > 0.405 and IsUnitEnemy(u, GetOwningPlayer(.hero))
        set u = null
        return b
    endmethod 
    
    static method onCreepLoc takes nothing returns boolean
        local unit u = GetFilterUnit()
        local boolean b = GetWidgetLife(u) > 0.405
        set u = null
        return b
    endmethod
    
    static method onBaseEnemyLoc takes nothing returns boolean
        local thistype this = DATA
        local unit u = GetFilterUnit()
        local boolean b = GetWidgetLife(u) > 0.405 and IsUnitEnemy(u, GetOwningPlayer(.hero)) and GetOwningPlayer(u) != Player(PLAYER_NEUTRAL_AGGRESSIVE)
        set u = null
        return b
    endmethod
    
    static method onAttackNow takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local thistype this = LoadInteger(HASH, GetHandleId(t), 1)
        local unit u
        local string o
        local group g
        local integer i = 0
        local real maxlife = GetUnitState(.hero, UNIT_STATE_MAX_LIFE)
        if .duration > 0 then
            set .duration = .duration - TIMERSPEED
            set o = OrderId2String(GetUnitCurrentOrder(.hero)) 
            set DATA = this
            if o=="smart" or o == "attack" or (o == "patrol") or (o == "move") or (o == "stop") or (o == "hold") or (o == null) then
                set g = CreateGroup()
                if .randomize==1 then
                    call BJDebugMsg(GetHeroProperName(.hero) + " attacking BASE")
                    loop
                        call GroupEnumUnitsOfPlayer(g, Player(i), Filter(function thistype.onBaseEnemyLoc))
                        set i = i+1
                        exitwhen i >= bj_MAX_PLAYERS
                    endloop
                    set u = FirstOfGroup(g)
                    call IssueTargetOrder(.hero, "attack", u)  
                    //=====In Range
                    if .atttime != TIMERSPEED*3 then
                        set .atttime = .atttime+TIMERSPEED
                        call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(.hero), GetUnitY(.hero), RANGEAOE, Filter(function thistype.onRangeAttack)) 
                        set u = FirstOfGroup(bj_lastCreatedGroup)
                        call IssueTargetOrder(.hero, "attack", u)
                    else
                        call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(.hero), GetUnitY(.hero), RANGEAOE, Filter(function thistype.onRangeAttack)) 
                        set u = FirstOfGroup(bj_lastCreatedGroup)
                        call IssuePointOrder(.hero, "attack", GetUnitX(u), GetUnitY(u))
                        set .atttime = 0
                    endif  
                
                elseif .randomize==2 then
                    call BJDebugMsg(GetHeroProperName(.hero) + " attacking CREEPS")
                    call GroupEnumUnitsOfPlayer(g, NHOSTILE, Filter(function thistype.onCreepLoc))
                    set u = FirstOfGroup(g)
                    call IssueTargetOrder(.hero, "attack", u)
                    //=====In Range
                    if .atttime != TIMERSPEED*3 then
                        set .atttime = .atttime+TIMERSPEED
                        call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(.hero), GetUnitY(.hero), RANGEAOE, Filter(function thistype.onRangeAttack)) 
                        set u = FirstOfGroup(bj_lastCreatedGroup)
                        call IssueTargetOrder(.hero, "attack", u)
                    else
                        call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(.hero), GetUnitY(.hero), RANGEAOE, Filter(function thistype.onRangeAttack)) 
                        set u = FirstOfGroup(bj_lastCreatedGroup)
                        call IssuePointOrder(.hero, "attack", GetUnitX(u), GetUnitY(u))
                        set .atttime = 0
                    endif
                endif
                call DestroyGroup(g)
            endif
            //Retreat code
            if GetWidgetLife(.hero) <= maxlife*RETREATPERCENT then
                if IsUnitEnemy(.hero, GetOwningPlayer(.base1)) then
                    call IssuePointOrder(.hero, "move", GetUnitX(.base2), GetUnitY(.base2))
                else
                    call IssuePointOrder(.hero, "move", GetUnitX(.base1), GetUnitY(.base1))
                endif
            endif
        else
            call AosH.onAttackSetup(.hero, .base1, .base2)
            call PauseTimer(t)
            call DestroyTimer(t)
            call FlushChildHashtable(HASH, GetHandleId(t))      
        endif
        set t = null
        set u = null
        set g = null
    endmethod
    
    static method onAttackSetup takes unit hero, unit base1, unit base2 returns thistype
        local thistype this = thistype.create()
        local timer t = CreateTimer()
        local integer randomizer = GetRandomInt(1,2)
        set .hero = hero
        set .base1 = base1
        set .base2 = base2
        set .duration = ATTACKLOCKDUR
        set .atttime = 0
        set .randomize = randomizer
        call SaveInteger(HASH, GetHandleId(t), 1, this)
        call TimerStart(t, TIMERSPEED, true, function thistype.onAttackNow) 
        set t = null
        return this
    endmethod

endstruct

function onAttackH takes unit hero, unit base1, unit base2 returns nothing
    call AosH.onAttackSetup(hero, base1, base2)
endfunction

endlibrary



JASS:
library ReviveHeroLib

globals 
    private constant hashtable         HASH = InitHashtable()
    private constant real       REVIVETIMER = 10.    
endglobals

private struct REV
    unit hero
    unit base1
    unit base2
    timerdialog d
    
    static method onReviveNow takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local thistype this = LoadInteger(HASH, GetHandleId(t), 1)
        if IsUnitAlly(.base1, GetOwningPlayer(.hero)) then
            call ReviveHero(.hero, GetUnitX(.base1), GetUnitY(.base1),true)
        else        
            call ReviveHero(.hero, GetUnitX(.base2), GetUnitY(.base2),true)
        endif
        call PauseTimer(t)
        call DestroyTimer(t)
        call DestroyTimerDialog(.d)
        set t = null
    endmethod
    
    static method onReviveH takes unit hero, unit base1, unit base2 returns thistype
        local thistype this = thistype.allocate()
        local timer t = CreateTimer()
        set .d = CreateTimerDialog(t)
        set .hero = hero
        set .base1 = base1
        set .base2 = base2
        call TimerDialogDisplay(.d, true)
        call TimerDialogSetTitle(.d, GetHeroProperName(hero))
        call SaveInteger(HASH, GetHandleId(t), 1, this)
        call TimerStart(t, REVIVETIMER, false, function thistype.onReviveNow) 
        return this
    endmethod
    
endstruct

function onHeroDeath takes unit hero, unit base1, unit base2 returns nothing
    if IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) then
        call REV.onReviveH(hero, base1, base2)    
    endif
endfunction

endlibrary



JASS:
//System; Ammo Attack System
//Created by: Mckill2009
//Requires: Jass New Gen Pack (JNGP) by Vexorian

//Instructions:
//- Make a new trigger and convert to custom text via EDIT >>>CONVERT TO CUSTOM TEXT
//- Replace ALL the text written in the new trigger or custom texts by this code (copy and paste method)
//- Make a new ability or normal ability as long as it's a TARGET UNIT and replace the raw code below
//- Make a new item or normal item long as it has a charge and replace the raw code below
//- Raw codes are 'A000' and 'wlsd' as seen below
//- You can view the raw code by pressing CTRL+D in the object editor

//Features:
//- Pretty much you can configure everything but NOT the hashtable
//- This system is good for modern warfare type games in which you load Ammo, if Ammo is empty then you cant fire

library AmmoAttackSystem initializer init

globals
    private constant hashtable                     HASH = InitHashtable() //Never touch this!
    private constant integer                      ATKID = 'A000' //Default Target Unit Custom Ability
    private constant integer                     AMMOID = 'wlsd' //Default lightning Shield Item Ability
    private constant attacktype                   DMGTY = ATTACK_TYPE_CHAOS
    private constant damagetype                   ATKTY = DAMAGE_TYPE_NORMAL
    private constant string                 ATTACHPOINT = "chest"
    private constant string                         SFX = "Abilities\\Weapons\\Rifle\\RifleImpact.mdl"
    private constant real                           AOE = 200.
    private constant real                     MINDAMAGE = 2.
    private constant real                     MAXDAMAGE = 10.
    private constant integer             AOE_REDUCE_DAM = 3 //the damage divisor of AOE
    private constant boolean                   STRENGTH = true //you should pick one only, the other 2 must be false
    private constant boolean                   AGILITY  = false
    private constant boolean               INTELLIGENCE = false
    private constant boolean             ENABLE_AOE_DAM = true
    private constant boolean       ENABLE_INFINITE_AMMO = false
    private constant boolean          ENABLE_SET_MANUAL = false //If true, then you must use other method like GUI to use this code
    private integer BASEATTRIBUTEDAM
endglobals

private struct CA
    unit caster
    unit target
    real damage
    static integer DATA
    
    static method caFilter takes nothing returns boolean
        local thistype cast = DATA
        local unit u = GetFilterUnit()
        
        if IsUnitEnemy(u, GetOwningPlayer(cast.caster)) then
            call UnitDamageTarget(cast.caster, u, cast.damage/AOE_REDUCE_DAM, false, false, DMGTY, ATKTY, null)
            call DestroyEffect(AddSpecialEffectTarget(SFX, u, ATTACHPOINT))
        endif
        set u = null
        return false
    endmethod

    static method caCast takes unit caster, unit target, integer basedamage returns thistype
        local thistype cast
        local texttag tag
        local item mainitem
        if ENABLE_INFINITE_AMMO==false then 
            if GetItemCharges(LoadItemHandle(HASH, GetHandleId(caster), 1)) > 0 then
                set cast = thistype.allocate()
                set cast.caster = caster
                set cast.target = target
                set cast.damage = GetRandomReal(basedamage+MINDAMAGE, basedamage+MAXDAMAGE)
                set mainitem = LoadItemHandle(HASH, GetHandleId(caster), 1)
                call DestroyEffect(AddSpecialEffectTarget(SFX, target, ATTACHPOINT))
                call UnitDamageTarget(caster, target, cast.damage, false, false, DMGTY, ATKTY, null)
                set tag = CreateTextTag()
                call SetTextTagPosUnit(tag, target, 0.) 
                call SetTextTagText(tag, I2S(R2I(cast.damage)), 0.02)
                call SetTextTagPermanent(tag, false)
                call SetTextTagVelocity(tag, 0.03, 0.03)
                call SetTextTagLifespan(tag, 3)
                call SetTextTagFadepoint(tag, 0.01)
                call SetUnitAnimation(caster, "attack")
                call SetItemCharges(mainitem, GetItemCharges(mainitem)-1)
                if ENABLE_AOE_DAM==true then
                    set DATA = cast
                    call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(target), GetUnitY(target), AOE, Filter(function thistype.caFilter))
                endif
            else
                set tag = CreateTextTag()
                call IssueImmediateOrder(caster, "stop")
                call SetTextTagPosUnit(tag, caster, 0.) 
                call SetTextTagText(tag, "you dont have ammo!", 0.02)
                call SetTextTagPermanent(tag, false)
                call SetTextTagVelocity(tag, 0.03, 0.03)
                call SetTextTagLifespan(tag, 3)
                call SetTextTagFadepoint(tag, 0.01)            
            endif
        else //Infinite Ammo
            set cast = thistype.allocate()
            set cast.caster = caster
            set cast.target = target
            set cast.damage = GetRandomReal(basedamage+MINDAMAGE, basedamage+MAXDAMAGE)
            call DestroyEffect(AddSpecialEffectTarget(SFX, target, ATTACHPOINT))
            call UnitDamageTarget(caster, target, cast.damage, false, false, DMGTY, ATKTY, null)
            set tag = CreateTextTag()
            call SetTextTagPosUnit(tag, target, 0.) 
            call SetTextTagText(tag, I2S(R2I(cast.damage)), 0.02)
            call SetTextTagPermanent(tag, false)
            call SetTextTagVelocity(tag, 0.03, 0.03)
            call SetTextTagLifespan(tag, 3)
            call SetTextTagFadepoint(tag, 0.01)
            call SetUnitAnimation(caster, "attack")
            if ENABLE_AOE_DAM==true then
                set DATA = cast
                call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(target), GetUnitY(target), AOE, Filter(function thistype.caFilter))
            endif
        endif
        set mainitem = null
        set tag = null
        return cast
    endmethod
endstruct

//Can be used Manually in by GUI
function CA_COND takes nothing returns boolean
    if GetSpellAbilityId()==ATKID then
        if STRENGTH==true then
            set BASEATTRIBUTEDAM = GetHeroStr(GetTriggerUnit(), false)
        elseif AGILITY==true then
            set BASEATTRIBUTEDAM = GetHeroAgi(GetTriggerUnit(), false)
        elseif INTELLIGENCE==true then    
            set BASEATTRIBUTEDAM = GetHeroInt(GetTriggerUnit(), false)
        else
            set BASEATTRIBUTEDAM = GetRandomInt(10, 30)
        endif
        
        call CA.caCast(GetTriggerUnit(), GetSpellTargetUnit(), BASEATTRIBUTEDAM) 
    endif
    return false
endfunction

//Can be used Manually in by GUI
function ITEM_HAVE takes unit u, item it returns boolean
    local integer id = GetHandleId(u)
    local item mainitem
    if ENABLE_INFINITE_AMMO==false then
        if not HaveSavedHandle(HASH, id, 1) then
            call SaveItemHandle(HASH, id, 1, it)
        else
            set mainitem = LoadItemHandle(HASH, id, 1)
            call SetItemCharges(mainitem, GetItemCharges(mainitem)+GetItemCharges(it))
            call SetItemCharges(it, GetItemCharges(it)-GetItemCharges(it))
            call UnitDropItemPoint(u, it, GetUnitX(u), GetUnitY(u))
        endif
    endif
    set mainitem = null
    set u = null
    return false
endfunction

//Can be used Manually in by GUI
function ITEM_PICK takes nothing returns boolean
    local item it
    local unit u
    if ENABLE_INFINITE_AMMO==false then
        if GetItemTypeId(GetManipulatedItem())==AMMOID then
            set it = GetManipulatedItem()
            set u = GetTriggerUnit()
            if GetItemCharges(it) > 0 then
                call ITEM_HAVE(u,it)
            else
                call UnitDropItemPoint(u, it, GetUnitX(u), GetUnitY(u))
            endif
        endif
    endif
    set it = null
    set u = null
    return false
endfunction

//Can be used Manually in by GUI
function ITEM_DROP takes nothing returns boolean
    local item it
    local unit u
    if ENABLE_INFINITE_AMMO==false then
        if GetItemTypeId(GetManipulatedItem())==AMMOID then
            set it = GetManipulatedItem()
            set u = GetTriggerUnit()
            call UnitDropItemPoint(u, it, GetUnitX(u), GetUnitY(u))
            if it==LoadItemHandle(HASH, GetHandleId(u), 1) then
                call RemoveSavedHandle(HASH, GetHandleId(u), 1) //Bullets
            endif
        endif
    endif
    set it = null
    set u = null   
    return false
endfunction

private function init takes nothing returns nothing
    local trigger t1 = CreateTrigger()          
    local trigger t2 = CreateTrigger()
    local trigger t3 = CreateTrigger()
    if ENABLE_SET_MANUAL==false then 
        call TriggerRegisterAnyUnitEventBJ(t1, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerRegisterAnyUnitEventBJ(t2, EVENT_PLAYER_UNIT_PICKUP_ITEM)
        call TriggerRegisterAnyUnitEventBJ(t3, EVENT_PLAYER_UNIT_DROP_ITEM)
        call TriggerAddCondition(t1, Condition(function CA_COND))
        call TriggerAddCondition(t2, Condition(function ITEM_PICK))
        call TriggerAddCondition(t3, Condition(function ITEM_DROP))
    endif
    set t1 = null
    set t2 = null
    set t3 = null
endfunction

endlibrary



JASS:
//System Name: Item Charges Merger
//Made by: Mckill2009

//REQUIRED VARIABLES:
//- HASH = hashtable (already initialize)

//INSTRUCTIONS:
//- Make a new trigger and convert to custom text
//- Copy ALL these codes and overwrite ALL existing text in the custom text
//- Make necessary changes of item type raw code

//===CONFIGURABLES:

constant function floatingtxt takes nothing returns string
    return "Item type already full!" //Sets the floating text
endfunction

constant function maxItem takes nothing returns integer
    return 30 //Max Item stack
endfunction

constant function maxItemBull takes nothing returns integer
    return 150 //Max Item stack
endfunction

constant function item1 takes nothing returns integer
    return 'I000' //Bullets
endfunction

constant function item2 takes nothing returns integer
    return 'I002' //Grenade
endfunction

constant function item3 takes nothing returns integer
    return 'I006' //Land Mine
endfunction

//constant function item4 takes nothing returns integer
  //  return 'ANOTHER ITEM HERE' //Optional description
//endfunction

//===END OF CONFIGURABLES:

function onPick takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local item it = GetManipulatedItem()
    local item mainitem
    local integer charges = GetItemCharges(it)
    local integer i = 0 
    local integer id = GetHandleId(u)
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local texttag tag
    
    if GetItemCharges(it) > 0 then
        //Saving the charges for Item 1: Bullets
        if GetItemTypeId(it)==item1() then
            if not HaveSavedHandle(udg_HASH, id, 1) and GetItemTypeId(it)==item1()  then
                call SaveItemHandle(udg_HASH, id, 1, it)
    
            elseif GetItemTypeId(it)==item1() and charges <= maxItemBull() then
                set mainitem = LoadItemHandle(udg_HASH, id, 1)
                if GetItemCharges(mainitem) <= maxItemBull() then
                    call SetItemCharges(mainitem, GetItemCharges(mainitem)+charges)
                    call SetItemCharges(it, 0)
                else
                    set tag = CreateTextTag()
                    call SetTextTagPos(tag, x, y, 150)  
                    call SetTextTagText(tag, floatingtxt(), 0.025)
                    call SetTextTagPermanent(tag, false)
                    call SetTextTagVelocity(tag, 0.03, 0.03)
                    call SetTextTagLifespan(tag, 3)
                    call SetTextTagFadepoint(tag, 0.01)
                    
                    call UnitDropItemPoint(u, it, x, y)
                endif
            endif
        endif
            
            
        //Saving the charges for Item 2: Grenade    
        if GetItemTypeId(it)==item2() then
            if not HaveSavedHandle(udg_HASH, id, 2) and GetItemTypeId(it)==item2()  then
                call SaveItemHandle(udg_HASH, id, 2, it)
    
            elseif GetItemTypeId(it)==item2() and charges <= maxItem() then
                set mainitem = LoadItemHandle(udg_HASH, id, 2)
                if GetItemCharges(mainitem) <= maxItem() then
                    call SetItemCharges(mainitem, GetItemCharges(mainitem)+charges)
                    call SetItemCharges(it, 0)
                else
                    set tag = CreateTextTag()
                    call SetTextTagPos(tag, x, y, 150)  
                    call SetTextTagText(tag, floatingtxt(), 0.025)
                    call SetTextTagPermanent(tag, false)
                    call SetTextTagVelocity(tag, 0.03, 0.03)
                    call SetTextTagLifespan(tag, 3)
                    call SetTextTagFadepoint(tag, 0.01)
                    
                    call UnitDropItemPoint(u, it, x, y)
                endif
            endif
        endif
        
        
        //Saving the charges for Item 3: Land Mine
        if GetItemTypeId(it)==item3() then
            if not HaveSavedHandle(udg_HASH, id, 3) and GetItemTypeId(it)==item3()  then
                call SaveItemHandle(udg_HASH, id, 3, it)
    
            elseif GetItemTypeId(it)==item3() and charges <= maxItem() then
                set mainitem = LoadItemHandle(udg_HASH, id, 3)
                if GetItemCharges(mainitem) <= maxItem() then
                    call SetItemCharges(mainitem, GetItemCharges(mainitem)+charges)
                    call SetItemCharges(it, 0)
                else
                    set tag = CreateTextTag()
                    call SetTextTagPos(tag, x, y, 150)  
                    call SetTextTagText(tag, floatingtxt(), 0.025)
                    call SetTextTagPermanent(tag, false)
                    call SetTextTagVelocity(tag, 0.03, 0.03)
                    call SetTextTagLifespan(tag, 3)
                    call SetTextTagFadepoint(tag, 0.01)
                    
                    call UnitDropItemPoint(u, it, x, y)
                endif
            endif
        endif
        
        //Add another if/then here if you have more items 
        
        //This line removes the empty item
        if GetItemCharges(it) < 1 then
            call UnitDropItemPoint(u, it, x, y)
            call RemoveItem(it)
        endif
    else
        //Drops item automatically if empty
        call UnitDropItemPoint(u, it, x, y)
        call RemoveItem(it)
    endif
    set u = null
    set it = null
    set tag = null
    set mainitem = null
endfunction

function onDrop takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local item it = GetManipulatedItem()
    local integer id = GetHandleId(u)
    
    if it==LoadItemHandle(udg_HASH, id, 1) then
        call RemoveSavedHandle(udg_HASH, id, 1) //Bullets
    elseif it==LoadItemHandle(udg_HASH, id, 2) then 
        call RemoveSavedHandle(udg_HASH, id, 2) //
    elseif it==LoadItemHandle(udg_HASH, id, 3) then
        call RemoveSavedHandle(udg_HASH, id, 3)      
    //elseif it==LoadItemHandle(udg_HASH, id, 4) then
        //call RemoveSavedHandle(udg_HASH, id, 4) 
    endif
    set it = null
    set u = null
endfunction

function onCond takes nothing returns boolean
    local item it = GetManipulatedItem() 
    local boolean b = GetItemTypeId(it)==item1() or GetItemTypeId(it)==item2() or GetItemTypeId(it)==item3()  
    set it = null
    return b
endfunction

function InitTrig_ItemChargesMerger takes nothing returns nothing
    local trigger t1 = CreateTrigger()          
    local trigger t2 = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t1, EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerRegisterAnyUnitEventBJ(t2, EVENT_PLAYER_UNIT_DROP_ITEM)
    call TriggerAddCondition(t1, Condition(function onCond))
    call TriggerAddAction(t1, function onPick)
    call TriggerAddAction(t2, function onDrop)
    set udg_HASH = InitHashtable()
    set t1 = null
    set t2 = null
endfunction



JASS:
library FollowUserHero

globals
    private constant hashtable                    HASH = InitHashtable()
    private constant integer                   SHOOTID = 852119 //Custom based Chain Lightning      
    private constant real                          AOE = 1500
    private constant boolean      ENABLE_CUSTOM_ATTACK = false //This is for the SHOOTID only
    boolean FOLLOW = false //set to true to follow hero
endglobals

private struct FUH
    unit comp
    real atk
    static integer DATA
    
    static method follow2 takes nothing returns boolean
        local thistype fol = DATA
        local unit u = GetFilterUnit()
        local real x
        local real y
        if ENABLE_CUSTOM_ATTACK==false then
            if IsUnitEnemy(u, GetOwningPlayer(fol.comp)) and GetWidgetLife(u) > 0.405 and fol.atk==0.5 then
                call IssueTargetOrderById(fol.comp, SHOOTID, u)   
            endif
        endif
        
        if not IsUnitEnemy(u, GetOwningPlayer(fol.comp)) and IsUnitType(u, UNIT_TYPE_HERO) and GetWidgetLife(u) > 0.405 and GetPlayerController(GetOwningPlayer(u))==MAP_CONTROL_USER and FOLLOW==true then
            set x = GetUnitX(u)+GetRandomReal(150, 300) *Cos(GetRandomReal(0,360))
            set y = GetUnitY(u)+GetRandomReal(150, 300) *Sin(GetRandomReal(0,360))
            call IssuePointOrder(fol.comp, "move", x, y)   
        endif      
        set u = null
        return false
    endmethod
    
    static method follow takes nothing returns nothing
        local timer t = GetExpiredTimer()        
        local thistype fol = LoadInteger(HASH, GetHandleId(t), 1)
        local real x = GetUnitX(fol.comp)
        local real y = GetUnitY(fol.comp)
        set fol.atk = fol.atk+0.5
        if fol.atk==1.0 then
            set fol.atk=0
        endif
        set DATA = fol
        call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, AOE, function thistype.follow2)
    endmethod
    
    static method create takes unit u returns thistype
        local thistype fol = thistype.allocate()
        local timer t = CreateTimer()
        set fol.comp = u
        set fol.atk = 0
        call SaveInteger(HASH, GetHandleId(t), 1, fol)
        call TimerStart(t, 2.0, true, function thistype.follow)
        set t = null
        return fol
    endmethod
endstruct

function FH_GetUnit takes unit comp returns nothing
    call FUH.create(comp)
endfunction

endlibrary



JASS:
library MyCam initializer init

globals
    private constant hashtable                      HASH = InitHashtable()
    private constant integer                  MAXPLAYERS = 3 //starting with "0" coz Player 1 is Player(0)
    private constant real             CAMERA_ANGLE_SPEED = 2.0
    private constant real             ZOOM_ADJUST_OFFSET = 20.
    private constant real                   ANGLE_OF_ATT = 304.    
    private constant real                          DELAY = 0.03
    private constant boolean               ENABLE_LAUNCH = true //set to false to set arrow keys manually via GUI or another code
    private constant boolean            ENABLE_UNIT_LOCK = true //recommended setting
    private constant boolean                 ENABLE_LOCK = true //enables lock Zoom and Angle
    private constant boolean    ENABLE_LOCK_ANGLE_OF_ATT = true //enables lock Angle of Attack 
    private real                            CAMERA_ANGLE
    private real                                    ZOOM
    private unit array                          DUMMYCAM
    private integer array                          DUMID
    private timer array                         CAMTIMER
    boolean CAMCHECK = false
endglobals

//===CAMERA MOVEMENTS: DO NOT TOUCH THIS
private function CamOn takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer tID = GetHandleId(t)
    local player p = LoadPlayerHandle(HASH, tID, 1)
    local integer ID = GetPlayerId(p)    
    if GetLocalPlayer()==Player(ID) and LoadBoolean(HASH, DUMID[ID], 3)==true and CAMCHECK==true then
        
        if LoadStr(HASH, tID, 2)=="up" then
            set ZOOM = LoadReal(HASH, DUMID[ID], 1)
            call SaveReal(HASH, DUMID[ID], 1, ZOOM - ZOOM_ADJUST_OFFSET)      
            set ZOOM = LoadReal(HASH, DUMID[ID], 1)
            call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, ZOOM, 0.03) 
            
        elseif LoadStr(HASH, tID, 2)=="down" then
            set ZOOM = LoadReal(HASH, DUMID[ID], 1)
            call SaveReal(HASH, DUMID[ID], 1, ZOOM + ZOOM_ADJUST_OFFSET)      
            set ZOOM = LoadReal(HASH, DUMID[ID], 1)
            call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, ZOOM, 0.03) 
        
        elseif LoadStr(HASH, tID, 2)=="left" then
            set CAMERA_ANGLE = LoadReal(HASH, DUMID[ID], 2)
            call SaveReal(HASH, DUMID[ID], 2, CAMERA_ANGLE - CAMERA_ANGLE_SPEED)      
            set CAMERA_ANGLE = LoadReal(HASH, DUMID[ID], 2)
            call SetCameraField(CAMERA_FIELD_ROTATION, CAMERA_ANGLE, 0.03)
            
        elseif LoadStr(HASH, tID, 2)=="right" then
            set CAMERA_ANGLE = LoadReal(HASH, DUMID[ID], 2)
            call SaveReal(HASH, DUMID[ID], 2, CAMERA_ANGLE + CAMERA_ANGLE_SPEED)      
            set CAMERA_ANGLE = LoadReal(HASH, DUMID[ID], 2)
            call SetCameraField(CAMERA_FIELD_ROTATION, CAMERA_ANGLE, 0.03)
        endif
    else
        call SaveBoolean(HASH, DUMID[ID], 4, true)
        call PauseTimer(CAMTIMER[ID])    
    endif
    set t = null
endfunction

function CamOff takes nothing returns boolean
    local integer i = 0 
    loop
        if GetTriggerPlayer()==Player(i) then
            call SaveBoolean(HASH, DUMID[i], 3, false)
        endif
        set i = i+1
        exitwhen i > MAXPLAYERS
    endloop
    return false
endfunction

private function LockUnit takes nothing returns boolean
    local integer i = 0
    if CAMCHECK==true and GetTriggerPlayer()==GetOwningPlayer(GetTriggerUnit()) then
        loop
            if GetLocalPlayer()==Player(i) then
                call SetCameraTargetController(GetTriggerUnit(), 0, 0, true)
                call SaveUnitHandle(HASH, DUMID[i], 4, GetTriggerUnit())
            endif
            set i = i+1
            exitwhen i > MAXPLAYERS
        endloop
    endif
    return false
endfunction

//============================================================
//===CAMERA LEFT:
function CamLEFT_Cond takes nothing returns boolean
    local integer i = GetPlayerId(GetTriggerPlayer())
    call SaveBoolean(HASH, DUMID[i], 3, true)
    call SaveBoolean(HASH, DUMID[i], 4, false)
    call SavePlayerHandle(HASH, GetHandleId(CAMTIMER[i]), 1, Player(i)) 
    call SaveStr(HASH, GetHandleId(CAMTIMER[i]), 2, "left")
    call TimerStart(CAMTIMER[i], DELAY, true, function CamOn) 
    return false
endfunction
//============================================================
//===CAMERA RIGHT:
function CamRIGHT_Cond takes nothing returns boolean
    local integer i = GetPlayerId(GetTriggerPlayer())
    call SaveBoolean(HASH, DUMID[i], 3, true)
    call SaveBoolean(HASH, DUMID[i], 4, false)
    call SavePlayerHandle(HASH, GetHandleId(CAMTIMER[i]), 1, Player(i)) 
    call SaveStr(HASH, GetHandleId(CAMTIMER[i]), 2, "right")
    call TimerStart(CAMTIMER[i], DELAY, true, function CamOn) 
    return false
endfunction
//============================================================
//===CAMERA UP:
function CamUP_Cond takes nothing returns boolean
    local integer i = GetPlayerId(GetTriggerPlayer())
    call SaveBoolean(HASH, DUMID[i], 3, true)
    call SaveBoolean(HASH, DUMID[i], 4, false)
    call SavePlayerHandle(HASH, GetHandleId(CAMTIMER[i]), 1, Player(i)) 
    call SaveStr(HASH, GetHandleId(CAMTIMER[i]), 2, "up")
    call TimerStart(CAMTIMER[i], DELAY, true, function CamOn) 
    return false
endfunction
//============================================================
//===CAMERA DOWN:
function CamDOWN_Cond takes nothing returns boolean
    local integer i = GetPlayerId(GetTriggerPlayer())
    call SaveBoolean(HASH, DUMID[i], 3, true)
    call SaveBoolean(HASH, DUMID[i], 4, false)
    call SavePlayerHandle(HASH, GetHandleId(CAMTIMER[i]), 1, Player(i)) 
    call SaveStr(HASH, GetHandleId(CAMTIMER[i]), 2, "down")
    call TimerStart(CAMTIMER[i], DELAY, true, function CamOn) 
    return false
endfunction
//============================================================
//============================================================
//============================================================
private function LockDownAll takes nothing returns boolean
    local integer i = 0
    if CAMCHECK==true then
        loop
            if GetLocalPlayer()==Player(i) and LoadBoolean(HASH, DUMID[i], 4)==true then
                set ZOOM = LoadReal(HASH, DUMID[i], 1)
                set CAMERA_ANGLE = LoadReal(HASH, DUMID[i], 2)
                call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, ZOOM, 0.03) 
                call SetCameraField(CAMERA_FIELD_ROTATION, CAMERA_ANGLE, 0.03)        
            endif
            set i = i+1
            exitwhen i > MAXPLAYERS
        endloop
        
        if ENABLE_LOCK_ANGLE_OF_ATT==true then
            call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, ANGLE_OF_ATT, 0.03) 
        endif
    endif
    return false
endfunction

//============================================================
//THIS CODE IS OPTIONAL, YOU CAN RUN MANUALLY WITHOUT THIS:
//SET "ENABLE_LAUNCH" TO FALSE TO DISABLE THIS:
private function Launch takes nothing returns nothing
    local trigger t1 = CreateTrigger()//UP         
    local trigger t2 = CreateTrigger()//DOWN
    local trigger t3 = CreateTrigger()//LEFT
    local trigger t4 = CreateTrigger()//RIGHT
    local trigger t5 = CreateTrigger()//CamOff
    local integer i
    
    call TriggerAddCondition(t1, Condition(function CamUP_Cond))
    call TriggerAddCondition(t2, Condition(function CamDOWN_Cond))
    call TriggerAddCondition(t3, Condition(function CamLEFT_Cond))
    call TriggerAddCondition(t4, Condition(function CamRIGHT_Cond))
    call TriggerAddCondition(t5, Condition(function CamOff))
    
    //==PRESSING UP:
    set i = 0
    loop
        call TriggerRegisterPlayerEvent(t1, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
        set i = i+1
        exitwhen i > MAXPLAYERS
    endloop
    
    //==PRESSING DOWN:
    set i = 0
    loop
        call TriggerRegisterPlayerEvent(t2, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
        set i = i+1
        exitwhen i > MAXPLAYERS
    endloop
    
     //==PRESSING LEFT:
    set i = 0
    loop
        call TriggerRegisterPlayerEvent(t3, Player(i), EVENT_PLAYER_ARROW_LEFT_DOWN)
        set i = i+1
        exitwhen i > MAXPLAYERS
    endloop
    
     //==PRESSING RIGHT:
    set i = 0
    loop
        call TriggerRegisterPlayerEvent(t4, Player(i), EVENT_PLAYER_ARROW_RIGHT_DOWN)
        set i = i+1
        exitwhen i > MAXPLAYERS
    endloop
    
    //==CAMERA OFF:
    set i = 0
    loop
        call TriggerRegisterPlayerEvent(t5, Player(i), EVENT_PLAYER_ARROW_LEFT_UP)
        call TriggerRegisterPlayerEvent(t5, Player(i), EVENT_PLAYER_ARROW_RIGHT_UP)
        call TriggerRegisterPlayerEvent(t5, Player(i), EVENT_PLAYER_ARROW_UP_UP)
        call TriggerRegisterPlayerEvent(t5, Player(i), EVENT_PLAYER_ARROW_DOWN_UP)
        set i = i+1
        exitwhen i > MAXPLAYERS
    endloop
    
    set t1 = null
    set t2 = null
    set t3 = null
    set t4 = null    
    set t5 = null 
endfunction

private function init takes nothing returns nothing
    local trigger t1 = CreateTrigger()
    local trigger t2 = CreateTrigger()
    local integer i = 0
    loop
        set DUMMYCAM[i] = CreateUnit(Player(i), 'hpea', 0,0,0)
        set DUMID[i] = GetHandleId(DUMMYCAM[i])
        call UnitAddAbility(DUMMYCAM[i], 'Amrf')
        call UnitAddAbility(DUMMYCAM[i], 'Aloc')
        call SetUnitPathing(DUMMYCAM[i], false)
        call ShowUnit(DUMMYCAM[i], false)
        call SaveReal(HASH, DUMID[i], 1, 2000.) //Distance
        call SaveReal(HASH, DUMID[i], 2, 90.) //Angle        
        call SaveBoolean(HASH, DUMID[i], 3, false) //Checking
        call SaveBoolean(HASH, DUMID[i], 4, true) //Checking Lock
        set CAMTIMER[i] = CreateTimer()
        set i = i+1
        exitwhen i > MAXPLAYERS
    endloop
    
    //===UNIT LOCK:
    if ENABLE_UNIT_LOCK==true then
        set i = 0
        loop
            call TriggerRegisterPlayerUnitEvent(t1, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)   
            set i = i+1
            exitwhen i > MAXPLAYERS
        endloop 
        call TriggerAddCondition(t1, Condition(function LockUnit))
    endif
    
    //===LAUNCH TRIGGER:
    if ENABLE_LAUNCH==true then
        call Launch() 
    endif
    
    //LOCK ZOOM and ANGLE:
    if ENABLE_LOCK==true then
        call TriggerRegisterTimerEvent(t2, 0.03, true)
        call TriggerAddCondition(t2, Condition(function LockDownAll))        
    endif
    
    set t1 = null
    set t2 = null
endfunction

endlibrary



JASS:
//Spell Name: Damage Shield
//Made by: Mckill2009

//===HOW TO USE:
//- Make a new trigger and convert to custom text via EDIT >>> CONVERT CUSTOM TEXT
//- Copy ALL that is written here and overwrite the existing texts in the custom text
//- Copy the Dummy/custom abilities/buffs etc... to your object editor
//- Make sure you inputed the correct raw codes of the base spell/buffs/dummy etc...
//- You can view the raw codes by pressing CTRL+D in the object editor
//- Examples of raw codes are 'A000', 'h000' etc... 

scope DShield initializer init

globals
    private constant integer                 SPELLID = 'A000' //Raw code of the Hero spell
    private constant integer           SHIELDDUMMYID = 'h002' //Raw code of the Breath of Fire
    private constant real                 TIMERSPEED = 0.03125
    private constant real               INTERVAL_DUR = 10
    private constant real        INTERVAL_DAM_AMOUNT = 200
    private constant integer                BASE_DUR = 30
    private constant integer         BASE_DAM_AMOUNT = 250
    private constant hashtable                  HASH = InitHashtable()
    private constant trigger                    TRIG = CreateTrigger()
endglobals

private constant function DS_DURATION takes integer i returns real
    return BASE_DUR + i * INTERVAL_DUR
endfunction

private constant function DS_DAMAGEAMOUNT takes integer i returns real
    return BASE_DAM_AMOUNT + i * INTERVAL_DAM_AMOUNT
endfunction

//THIS IS JUST FOR ROTATION EFFECT:
private struct DAMS
    unit target
    unit dummy
    real angle
        
    static method onRotate takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local thistype this = LoadInteger(HASH, GetHandleId(t), 1)
        local real x
        local real y
        if GetWidgetLife(.target) > 0.405 and GetWidgetLife(.dummy) > 0.405 then    
            set x = GetUnitX(.target)
            set y = GetUnitY(.target)
            set .angle = .angle+5
            call SetUnitX(.dummy, x+100*Cos(.angle*bj_DEGTORAD))
            call SetUnitY(.dummy, y+100*Sin(.angle*bj_DEGTORAD))
        else
            call PauseTimer(t)
            call DestroyTimer(t)
        endif
        set t = null
    endmethod
    
    static method onShield takes unit target, unit dummy, integer level returns thistype
        local thistype this = thistype.allocate()
        local timer t = CreateTimer()
        set .target = target        
        set .dummy = dummy
        set .angle = GetUnitFacing(.target)
        call SaveInteger(HASH, GetHandleId(t), 1, this)
        call TimerStart(t, TIMERSPEED, true, function thistype.onRotate)
        set t = null
        return this
    endmethod
endstruct 

//THE DAMAGE:
private function DS_DAMTAKEN takes unit target, real damAdd, unit shielddummy returns nothing
    local real damageamount = LoadReal(HASH, GetHandleId(target), 3)
    if GetWidgetLife(shielddummy) > 0.405 and damageamount > 0 then
        call SetWidgetLife(target, GetWidgetLife(target)+damAdd)
        call SaveReal(HASH, GetHandleId(target), 3, damageamount-(damAdd/3))
        //call BJDebugMsg(R2S(damageamount))
    else
        call UnitApplyTimedLife(shielddummy, 'BTLF', 0.001)
    endif
endfunction

private function DS_TRIG takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local real damAdd = GetEventDamage()
    local integer ID = GetHandleId(u)
    local unit shielddummy = LoadUnitHandle(HASH, ID, 2)
    call DS_DAMTAKEN(u, damAdd, shielddummy)
    set u = null
    set shielddummy = null
    return false
endfunction

private function DS_ACTION takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local integer ID = GetHandleId(u)
    local integer level = GetUnitAbilityLevel(GetTriggerUnit(), SPELLID)
    
    if not HaveSavedHandle(HASH, GetHandleId(u), 1) then
        //this is used only ONE TIME per unit
        set bj_lastCreatedUnit = CreateUnit(GetTriggerPlayer(), 'hpea', GetUnitX(u), GetUnitY(u), 0)
        call UnitAddAbility(bj_lastCreatedUnit, 'Aloc')
        call ShowUnit(bj_lastCreatedUnit, false)
        call SaveUnitHandle(HASH, GetHandleId(u), 1, bj_lastCreatedUnit)
        set bj_lastCreatedUnit = CreateUnit(GetTriggerPlayer(), SHIELDDUMMYID, GetUnitX(u), GetUnitY(u), 0)
        call TriggerRegisterUnitEvent(TRIG, u, EVENT_UNIT_DAMAGED)
        call TriggerAddCondition(TRIG, Condition(function DS_TRIG))
        //===========================
        call DAMS.onShield(u, bj_lastCreatedUnit, level)
        call SaveUnitHandle(HASH, ID, 2, bj_lastCreatedUnit)
        call SaveReal(HASH, ID, 3, DS_DAMAGEAMOUNT(level))
        call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', DS_DURATION(level))
    else            
        set bj_lastCreatedUnit = CreateUnit(GetTriggerPlayer(), SHIELDDUMMYID, GetUnitX(u), GetUnitY(u), 0)
        call DAMS.onShield(u, bj_lastCreatedUnit, level)
        call SaveUnitHandle(HASH, ID, 2, bj_lastCreatedUnit)
        call SaveReal(HASH, ID, 3, DS_DAMAGEAMOUNT(level))
        call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', DS_DURATION(level))
    endif
    set u = null
endfunction

private function DS_CAST takes nothing returns boolean
    return GetSpellAbilityId()==SPELLID
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()      
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function DS_CAST))
    call TriggerAddAction(t, function DS_ACTION)
    set t = null        
endfunction

endscope
 
Last edited:
Level 29
Joined
Mar 10, 2009
Messages
5,016
its very easy to implement this...

sample, the HeroAttackRetreatSys, you can copy the code then use GUI...

  • Event
    • Time elapse 5 seconds
  • Actions
    • Custom Scriptr: call onAttackH(yourunit, yourbase, enemybase)
yourunit/yourbase/enemybase are a unit variables, it doesnt matter if the unit is a hero or not as long as it is a unit...
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
@Mags
Let me quote once again what I said in the first page...
NOTE: Pls dont suggest that I should use another library like GroupUtils, TimerUtils, T32 etc...coz Im not gonna do it...

but dont get me wrong, Im a very very very big fan of TimerUtils and now T32 but I feel like dont apply it here...

@rysnt11
I have JNGP but Im in the office this afternoon, now Im home...coding again...
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
Thanks, i'll test it tomorrow
:)
Edit:eek:ne word...
Amazing...
The spawn system is great, and..
The hero attack and retreat system is also great..
The revival..
Seems it can be done in gui one(i think..)
But overall it's great!
Btw, can you make new options, like adding hero ai to cast spell, and to 'think', like buying some items, and upgrade them if they has enough money, to sum it up, could you even make it like dota's ai??
 
Last edited:
Status
Not open for further replies.
Top