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

Spell Alteration

Status
Not open for further replies.
I need this spell to work on non-hero units.

JASS:
//******************************************************************************
//*                                                                            *
//*                               Graverobber                                  *
//*                                  v1.02                                     *
//*                                                                            *
//*                             By: Rising_Dusk                                *
//*                                                                            *
//******************************************************************************

//**************************************
//* LIBRARY REQUIREMENTS:
//*     - GroupUtils
//* 
scope Graverobber initializer Init
globals
    //*************************************************************
    //* Configuration Constants
    
    //* Raw codes
    private constant integer SPELL_ID              = 'A02W'
    private constant integer INVIS_ID              = 'Apiv'
    //* System related
    private constant real TIMER_INTERVAL           = 0.05
    
    //*************************************************************
    //* System Variables
    private timer CheckTimer                       = CreateTimer()
    private group CasterGroup                      = CreateGroup()
    private boolexpr Checker                       = null
    private trigger Trg                            = CreateTrigger()
endglobals

//*****************************************************************
//* Configuration Functions
private constant function AreaOfEffect takes integer lvl returns real
    //* Spell Area of Effect Radius
    return 450.
endfunction

private constant function Corpses takes integer lvl returns integer
    //* Number of corpses necessary
    return 3-lvl
endfunction

private function Check takes nothing returns boolean
    //* The boolexpr for finding a corpse
    return GetUnitTypeId(GetFilterUnit()) != 0 and IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_SUMMONED) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and GetWidgetLife(GetFilterUnit()) <= 0.405
endfunction

//*****************************************************************
private function Conditions takes nothing returns boolean
    return GetLearnedSkill() == SPELL_ID
endfunction

private function Enumeration takes nothing returns nothing
    local unit e      = GetEnumUnit()
    local unit s      = null
    local integer lvl = GetUnitAbilityLevel(e, SPELL_ID)
    local real x      = GetUnitX(e)
    local real y      = GetUnitY(e)
    
    //* Loop through all corpses to count them
    if GetWidgetLife(e) > 0.405 then
        set bj_groupCountUnits = 0
        call GroupEnumUnitsInRange(ENUM_GROUP, x, y, AreaOfEffect(lvl), Checker)
        call ForGroup(ENUM_GROUP, function CountUnitsInGroupEnum)
        if bj_groupCountUnits >= Corpses(lvl) and GetUnitAbilityLevel(e, INVIS_ID) <= 0 then
            call UnitAddAbility(e, INVIS_ID)
        elseif bj_groupCountUnits < Corpses(lvl) and GetUnitAbilityLevel(e, INVIS_ID) > 0 then
            call UnitRemoveAbility(e, INVIS_ID)
        endif
    endif
    
    call GroupClear(ENUM_GROUP)
    set e = null
    set s = null
endfunction

private function Callback takes nothing returns nothing
    call ForGroup(CasterGroup, function Enumeration)
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    
    if FirstOfGroup(CasterGroup) == null then
        call TimerStart(CheckTimer, TIMER_INTERVAL, true, function Callback)
    endif
    call GroupAddUnit(CasterGroup, u)
    
    set u = null
endfunction

private function Init takes nothing returns nothing
    call TriggerAddAction(Trg, function Actions)
    call TriggerAddCondition(Trg, Condition(function Conditions))
    call TriggerRegisterAnyUnitEventBJ(Trg, EVENT_PLAYER_HERO_SKILL)
    set Checker = Condition(function Check)
endfunction
endscope
 
Level 4
Joined
Apr 18, 2011
Messages
60
mayber you problem is on object editor and not on jass beause filer are:
is NOT summoned
is NOT structure
have MORe than 0.45 HP

so i dont see any problem
check your object editor targets set same for any levels (well your choise)
if spell is single target set to human-storm bolt spell targets peferable
if spell is AOE i dont see any problem
if problem persist please consult your medic xD (PM me i mean)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
JASS:
//******************************************************************************
//*                                                                            *
//*                               Graverobber                                  *
//*                                  v1.02                                     *
//*                                                                            *
//*                             By: Rising_Dusk                                *
//*                                                                            *
//******************************************************************************

//**************************************
//* LIBRARY REQUIREMENTS:
//*     - GroupUtils
//*
scope Graverobber initializer Init
globals
    //*************************************************************
    //* Configuration Constants
    
    //* Raw codes
    private constant integer UNIT_ID              = 'hkni'
    private constant integer SPELL_ID             = 'Ahea'
    private constant integer INVIS_ID              = 'Apiv'
    //* System related
    private constant real TIMER_INTERVAL           = 0.05
    
    //*************************************************************
    //* System Variables
    private timer CheckTimer                       = CreateTimer()
    private group CasterGroup                      = CreateGroup()
    private boolexpr Checker                       = null
    private trigger Trg                            = CreateTrigger()
endglobals

//*****************************************************************
//* Configuration Functions
private constant function AreaOfEffect takes integer lvl returns real
    //* Spell Area of Effect Radius
    return 450.
endfunction

private constant function Corpses takes integer lvl returns integer
    //* Number of corpses necessary
    return 3-lvl
endfunction

private function Check takes nothing returns boolean
    //* The boolexpr for finding a corpse
    return GetUnitTypeId(GetFilterUnit()) != 0 and IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_SUMMONED) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and GetWidgetLife(GetFilterUnit()) <= 0.405
endfunction

//*****************************************************************
private function Conditions takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == UNIT_ID
endfunction

private function Enumeration takes nothing returns nothing
    local unit e      = GetEnumUnit()
    local unit s      = null
    local integer lvl = GetUnitAbilityLevel(e, SPELL_ID)
    local real x      = GetUnitX(e)
    local real y      = GetUnitY(e)
    
    //* Loop through all corpses to count them
    if GetWidgetLife(e) > 0.405 then
        set bj_groupCountUnits = 0
        call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, AreaOfEffect(lvl), Checker)
        call ForGroup(bj_lastCreatedGroup, function CountUnitsInGroupEnum)
        if bj_groupCountUnits >= Corpses(lvl) and GetUnitAbilityLevel(e, INVIS_ID) <= 0 then
            call UnitAddAbility(e, INVIS_ID)
        elseif bj_groupCountUnits < Corpses(lvl) and GetUnitAbilityLevel(e, INVIS_ID) > 0 then
            call UnitRemoveAbility(e, INVIS_ID)
        endif
    endif
    
    call GroupClear(bj_lastCreatedGroup)
    set e = null
    set s = null
endfunction

private function Callback takes nothing returns nothing
    call ForGroup(CasterGroup, function Enumeration)
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    
    if FirstOfGroup(CasterGroup) == null then
        call TimerStart(CheckTimer, TIMER_INTERVAL, true, function Callback)
    endif
    call GroupAddUnit(CasterGroup, u)
    call UnitAddAbility(u, SPELL_ID)
    call BJDebugMsg("add abil 1")
    set u = null
endfunction

private function Init takes nothing returns nothing
    local region r = CreateRegion()
    local unit u
    call RegionAddRect(r, bj_mapInitialPlayableArea)
    call TriggerRegisterEnterRegion(Trg, r, function Conditions)
    call TriggerAddAction(Trg, function Actions)
    set Checker = Condition(function Check)
    
    call GroupEnumUnitsInRect(bj_lastCreatedGroup, bj_mapInitialPlayableArea, function Conditions)
    loop
        set u = FirstOfGroup(bj_lastCreatedGroup)
        exitwhen u == null
        if FirstOfGroup(CasterGroup) == null then
            call TimerStart(CheckTimer, TIMER_INTERVAL, true, function Callback)
        endif
        call UnitAddAbility(u, SPELL_ID)
        call GroupAddUnit(CasterGroup, u)
        call GroupRemoveUnit(bj_lastCreatedGroup, u)
    endloop
    
    set r = null
endfunction
endscope

Change the raw codes.
 
Status
Not open for further replies.
Top