PDA

View Full Version : Basic attack spell


Klann
11-30-2011, 09:31 AM
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

Maker
11-30-2011, 12:26 PM
Here's something to work with:

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.

Klann
12-01-2011, 01:30 AM
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?

PurgeandFire
12-01-2011, 02:18 AM
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:
http://www.hiveworkshop.com/forums/attachments/jass-ai-scripts-tutorials-280/99582d1300342695-lua-object-generation-aerialshackles.png

'Amls' is the rawcode ID of the aerial shackles ability.

Klann
12-04-2011, 12:08 AM
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?

mckill2009
12-04-2011, 12:27 AM
see my map Fog Horror, its an open source...it has a custom ranged & melee attack, you just need to adjust the damage...

Klann
12-04-2011, 05:51 AM
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?