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

[JASS] IMported a spell not working

Status
Not open for further replies.
Level 19
Joined
Feb 15, 2008
Messages
2,184
JASS:
//=========================================================================================
//*******
//Slash *
//*******
//
//by: wyrmlord
//
//How to Implement:
//1. Copy the custom script section into your map's custom script section.
//(Make sure to have a global gamecache variable named udg_cache)
//2. Make a new trigger named "Slash" and convert that trigger to custom text.
//3. Delete all text shown and then paste in this spell
//4. Replace the spell ability rawcode with the one being used for this spell in your map.
//5. Save the map.
//6. Have fun using the spell!
//=========================================================================================

constant function Slash_Id takes nothing returns integer
    return 'A05N' //Slash Ability rawcode
endfunction

constant function Slash_Damage takes real level returns real
    return 5. + level * 30. //Damage delt to enemies.
endfunction

constant function Slash_Amount takes real level returns real
    return 70. + level * 0. //Amount of times the unit will warp around in an area.
endfunction 

constant function Slash_Radius takes real level returns real
    return 500. + level * 0. //Radius that the hero will warp around in.
endfunction

constant function Slash_Hit_Radius takes nothing returns real
    return 100. //Damages units withing this radius from caster.
endfunction

constant function Slash_Timer_Speed takes nothing returns real
    return .01 //Rate at which the hero will warp around in an area.
endfunction

constant function Slash_Attack_Type takes nothing returns attacktype
    return ATTACK_TYPE_CHAOS
endfunction

constant function Slash_Damage_Type takes nothing returns damagetype
    return DAMAGE_TYPE_NORMAL
endfunction

constant function Slash_Weapon_Type takes nothing returns weapontype
    return WEAPON_TYPE_METAL_HEAVY_SLICE
endfunction

constant function Slash_Hit_Effect takes nothing returns string
    return "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" //Effect when an enemy is damaged.
endfunction

constant function Slash_Caster_Effect takes nothing returns string
    return "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl" //Effect used on the caster.
endfunction

constant function Slash_Attach takes nothing returns string
    return "weapon" //Attachment point for the caster effect.
endfunction

//=========================================================================

function Slash_Destructables takes nothing returns nothing
    call KillDestructable(GetEnumDestructable())
endfunction

function Slash_Effect takes nothing returns nothing
    local timer t=GetExpiredTimer()
    local unit u=GetHandleUnit(t,"caster")
    local real x=GetHandleReal(t,"startX")
    local real y=GetHandleReal(t,"startY")
    local integer i=GetHandleInt(t,"number")-1
    local group g=CreateGroup()
    local unit d
    local real a=GetHandleReal(t,"slash_level")
    local real x2=GetRandomReal(x-Slash_Radius(a),x+Slash_Radius(a))
    local real y2=GetRandomReal(y-Slash_Radius(a),x+Slash_Radius(a))
    local rect r=Rect(x2-150,y2-150,x2+150,y2+150)

    if i<R2I(Slash_Amount(a)) then

        call EnumDestructablesInRect(r,null,function Slash_Destructables)
        call SetUnitPosition(u,x2,y2)
        call SetUnitAnimation(u,"attack")
        call GroupEnumUnitsInRange(g,x2,y2,Slash_Hit_Radius(),null)

        loop

            set d=FirstOfGroup(g)
            exitwhen d==null
            if IsUnitEnemy(d,GetOwningPlayer(u)) then

                call UnitDamageTarget(u,d,Slash_Damage(a),true,false,Slash_Attack_Type(),Slash_Damage_Type(),Slash_Weapon_Type())
                call DestroyEffect(AddSpecialEffect(Slash_Hit_Effect(),GetUnitX(d),GetUnitY(d)))

            endif

            call GroupRemoveUnit(g,d)

        endloop

        call SetHandleInt(t,"number",i+2)

    else

        call SetUnitPosition(u,x,y)
        call SetUnitInvulnerable(u,false)
        call SetUnitPathing(u,true)
        call SetUnitTimeScale(u,1.)
        call DestroyEffect(GetHandleEffect(t,"slash_effect"))
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)

    endif

    call RemoveRect(r)
    call DestroyGroup(g)
    set r=null
    set t=null
    set u=null
    set g=null
    set d=null
endfunction
function Slash_Main takes nothing returns nothing
    local timer t=CreateTimer()
    local unit u=GetTriggerUnit()
    local real x=GetUnitX(u)
    local real y=GetUnitY(u)

    call SetHandleReal(t,"slash_level",I2R(GetUnitAbilityLevel(u,Slash_Id())))
    call SetHandleHandle(t,"slash_effect",AddSpecialEffectTarget(Slash_Caster_Effect(),u,Slash_Attach()))
    call SetHandleReal(t,"startX",x)
    call SetHandleReal(t,"startY",y)
    call SetHandleInt(t,"number",1)
    call SetHandleHandle(t,"caster",u)

    call SetUnitInvulnerable(u,true)
    call SetUnitTimeScale(u,1000)
    call SetUnitPathing(u,false)
    call TimerStart(t,Slash_Timer_Speed(),true,function Slash_Effect)

    set t=null
    set u=null
endfunction
function Slash_Condition takes nothing returns boolean
    return GetSpellAbilityId()==Slash_Id()
endfunction
function InitTrig_Random_Slash takes nothing returns nothing
    local trigger t=CreateTrigger()
    local integer i=0
    loop
        exitwhen i==16
        call TriggerRegisterPlayerUnitEvent(t,Player(i),ConvertPlayerUnitEvent(274),null)
        set i=i+1
    endloop
    call TriggerAddCondition(t,Condition(function Slash_Condition))
    call TriggerAddAction(t,function Slash_Main)
    set t=null
endfunction

what have i done wrong? i missed sumthing?
 
Level 5
Joined
Dec 18, 2007
Messages
205
1. have you added a global variable as a gamecache called "cache"? (in jass udg_cache)
2. is the rawcode of your ability 'A05N'? (can be seen by pressing ctrl+d)
3. is the trigger's name "Random Slash" ?
greetz
 
Status
Not open for further replies.
Top