• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Basic attack spell

Status
Not open for further replies.
Level 9
Joined
Apr 7, 2010
Messages
480
how do i make the basic attack as spell?
SPELL : damage the unit in front of the user, no required target, attack on cast

EDIT : to explain further, im going to remove the units basic attack and add a spell which would be the units new basic attack, removing some functions like auto attack when an enemy gets near the unit, and continuously attacking the enemy unit
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
Here's something to work with:

JASS:
function Attack_Filter takes nothing returns boolean
    return not IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD)
endfunction

function Attack_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'Acrs'
endfunction

function Attack_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real f = GetUnitFacing(u) * bj_DEGTORAD
    local player p = GetOwningPlayer(u)
    local unit t
    local real x2
    local real y2
    
    call GroupEnumUnitsInRange(bj_lastCreatedGroup, x ,y, 172+150, function Attack_Filter)
    loop
        set t = FirstOfGroup(bj_lastCreatedGroup)
        exitwhen t == null
        set x2 = GetUnitX(t)
        set y2 = GetUnitY(t)
        if IsUnitEnemy(t, p) and IsUnitInRangeXY(t, x, y, 150) and Cos(f-Atan2(y2-y, x2-x)) > 0 then
            call UnitDamageTarget(u, t, 50, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_CLAW_HEAVY_SLICE)
            call GroupClear(bj_lastCreatedGroup)
        else
            call GroupRemoveUnit(bj_lastCreatedGroup, t)
        endif
    endloop
    
    set u = null
    set p = null
endfunction

//===========================================================================
function InitTrig_Attack takes nothing returns nothing
    set gg_trg_Attack = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Attack, Condition( function Attack_Conditions ) )
    call TriggerAddAction( gg_trg_Attack, function Attack_Actions )
endfunction

172 is the max collision size of a unit in your map, the 150 is the range.
 
Level 9
Joined
Apr 7, 2010
Messages
480
I dont understand jass.

but i do know that it requires a spell id so the script would only work on a certain ability.
" return GetSpellAbilityId() == 'Acrs' " <- what is Acrs for?
 
That is the rawcode object ID of the ability you want to register the cast of. It is a 4 character code enclosed in single quotes. 'XXXX' You can find an object's rawcode by finding it in the object editor, and then pressing CTRL+D. Then just look where its name is.

Example:
99582d1300342695-lua-object-generation-aerialshackles.png


'Amls' is the rawcode ID of the aerial shackles ability.
 
Level 9
Joined
Apr 7, 2010
Messages
480
some text appearing after using the skill only when hitting an enemy unit
`UNIT INDEX ERROR : ATTEMPT TO LOCK NULL INDEX
`UNIT INDEX ERROR : ATTEMPT TO UNLOCK UNLOCKED INDEX

Also how do i add an animation attack in jass?
 
Level 9
Joined
Apr 7, 2010
Messages
480
still having the same problem
`UNIT INDEX ERROR : ATTEMPT TO LOCK NULL INDEX
`UNIT INDEX ERROR : ATTEMPT TO UNLOCK UNLOCKED INDEX

mckill and makers spell work fine with damage and everything, but wont play my unit's attack animation. maybe there's a problem with my other triggers?
 
Status
Not open for further replies.
Top