• 🏆 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] It works, but something is very worng and i don't know what

Status
Not open for further replies.
Hi guys, i've been reading some JESP spells lately and i found this approved spell.
The spell works perfectly and i must say that it is quite impressive ... However when JassCraft runs the syntax checker it founds lots of errors ... and i don't know why ... the main error is that it can't convert Handlers to something else ... I don't know why because the spell actually works, but i will not use bugged spells that cause tremendous lag in map multiplayer map.

Anyway here is the spell:

JASS:
// Bloody // Bloody Pile Spell Configuration:

constant function BloodyPile_SpellId takes nothing returns integer
    return 'A000' //Rawcode of the BloodyPile Ability
endfunction   

constant function BloodyPile_SlideDuration takes nothing returns real
    return 0.60 //Defines the slide duration of target
endfunction

constant function BloodyPile_SpellDemage takes integer level returns real
    return level*90.00
    //This formula adds 90 demage per level of the spell
    //Starting from 90
endfunction 

constant function BloodyPile_TargetConditions takes unit Caster, unit Target returns boolean
    return (Target != Caster) and ( IsPlayerEnemy(GetOwningPlayer(Target), GetOwningPlayer(Caster)) ) and not(IsUnitType(Target, UNIT_TYPE_STRUCTURE)) and not(IsUnitType(Target,UNIT_TYPE_DEAD)) and not(IsUnitType(Target, UNIT_TYPE_MAGIC_IMMUNE))
    //Defines the targetable units which will get demage from unit sliding effect
endfunction

// This spell is playing target units death animation while sliding
// This gives a pain effect but if you use units which has no fleshy
// body animation modify this function

constant function BloodyPile_DeathAnimation takes nothing returns boolean
    return true //Make this "false" to disable targets death animation.
endfunction
//===================================================================================================

function BloodyPile_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == BloodyPile_SpellId()
endfunction

//Kills Picked Destructables near target when sliding
function BloodyPile_KillTreesOnTheWay takes nothing returns nothing
    call KillDestructable( GetEnumDestructable() )
endfunction

//Makes target unit slide and demage nearby units and throw them avay from it
function BloodyPile_SlideUnit takes nothing returns nothing    
    local timer Loop = GetExpiredTimer() 
    local unit Target = H2U(GetHandleHandle(Loop, "Target"))
    local unit Caster = H2U(GetHandleHandle(Loop, "Caster"))
    local unit PickedUnit
    local group UnitsInRange
    local real Angle = GetHandleReal(Loop, "Angle")
    local real AngleSmall
    local location TargetPoint = GetUnitLoc(Target)
    local location TargetPointSmall
    local location MovePoint = PolarProjectionBJ(TargetPoint,20.00,Angle)
    local location MovePointSmall
    local effect MiniEffect

    call SetUnitPositionLoc(Target, MovePoint)
    set MiniEffect = AddSpecialEffectTarget("Abilities\\Weapons\\FrostWyrmMissile\\FrostWyrmMissile.mdl",Target,"origin")
    call DestroyEffect(MiniEffect)
    call EnumDestructablesInCircleBJ( 200.00, TargetPoint, function BloodyPile_KillTreesOnTheWay )
    set UnitsInRange = GetUnitsInRangeOfLocAll(250, TargetPoint)
    call GroupRemoveUnit(UnitsInRange,Target)
    set PickedUnit = FirstOfGroup(UnitsInRange)

    loop
        exitwhen PickedUnit==null
        set PickedUnit = FirstOfGroup(UnitsInRange)
        call GroupRemoveUnit(UnitsInRange,PickedUnit)
        if (BloodyPile_TargetConditions(Caster, PickedUnit)) then            
            set TargetPointSmall = GetUnitLoc(PickedUnit)
            set AngleSmall = AngleBetweenPoints(TargetPoint,TargetPointSmall)
            set MovePointSmall = PolarProjectionBJ(TargetPointSmall,80,AngleSmall)
            call SetUnitPositionLoc(PickedUnit, MovePointSmall)
            call UnitDamageTarget(Caster,PickedUnit,25*GetUnitAbilityLevel(Caster, BloodyPile_SpellId()),false,false,null,null,null)

            call RemoveLocation(TargetPointSmall)
            call RemoveLocation(MovePointSmall)
        endif
    endloop      
  
    call RemoveLocation(MovePoint)
    call RemoveLocation(TargetPoint)
    call DestroyGroup(UnitsInRange)    
    set Caster = null
    set Target = null
endfunction

function BloodyPile_Actions takes nothing returns nothing
    local timer Loop = CreateTimer()
    local effect StunEffect
    local unit Target = GetSpellTargetUnit()
    local unit Caster = GetSpellAbilityUnit()
    local location TargetPoint = GetUnitLoc(Target)
    local location CasterPoint = GetUnitLoc(Caster)
    local real Angle = AngleBetweenPoints(CasterPoint, TargetPoint)
    local real Demage = BloodyPile_SpellDemage(GetUnitAbilityLevel(Caster, BloodyPile_SpellId()))
    local real Duration = BloodyPile_SlideDuration()

 
    call SetHandleHandle(Loop, "Target", Target) 
    call SetHandleHandle(Loop, "Caster", Caster)
    call SetHandleReal(Loop, "Angle", Angle)
    call SetUnitFacingToFaceUnitTimed( Target, Caster, 0 )
    call PauseUnit(Target,true)
    
    if (BloodyPile_DeathAnimation()) then
        call SetUnitAnimation( Target, "death" )
    endif
    
    call UnitDamageTarget(Caster,Target,Demage,false,false,null,null,null)
    call TimerStart(Loop, 0.03, true, function BloodyPile_SlideUnit)    
    call TriggerSleepAction( Duration )
    call PauseTimer(Loop) 
    call FlushHandleLocals(Loop)
    call DestroyTimer(Loop) 

    if not (IsUnitType(Target,UNIT_TYPE_DEAD)) then
        set StunEffect = AddSpecialEffectTarget( "Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl", Target, "overhead")        
        call TriggerSleepAction( 1.25 * GetUnitAbilityLevel(Caster, BloodyPile_SpellId()))
        call DestroyEffectBJ( StunEffect )
    endif
    call PauseUnit(Target,false)

    call RemoveLocation(TargetPoint)
    call RemoveLocation(CasterPoint)
    set Caster = null
    set Target = null    
endfunction

// ===========================================================================
function InitTrig_BloodyPile takes nothing returns nothing
    local trigger gg_trg_BloodyPile = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_BloodyPile, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_BloodyPile, Condition( function BloodyPile_Conditions ) )
    call TriggerAddAction( gg_trg_BloodyPile, function BloodyPile_Actions )
endfunction



as you can see it is a knockback spell ... and i think it is easy to understand.
Any suggestions about why this is wrong ?? please ?
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
JassCraft probably doesn't have the Local Handle Vars functions inside it. You can add some functions to their syntax check by making a .j file in the JassCraft directory (add all the Local Handle Vars functions inside it), and then going to the options in JassCraft, and enabling the syntax check for the newly created .j file.

If the world editor lets you play it and it works... then there is no problem.
 
Level 9
Joined
Mar 25, 2005
Messages
252
If I understand your problem correctly, you should get the Local Handle Vars from somewhere (for example here) and copy paste them to your maps header. You can find your maps header by opening the trigger editor and clicking your map's name at top left.
I havent tried many jasseditors so my preference propably doesnt matter much, but Im using JassCraft and JassHelper since it comes with jassnewgenpack. If you want to have syntax hilighting in jassnewgenpack you should check this out:
Trigger Editor Syntax Highlighting
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Click the "Save" button and then the "Test Map" button.

CS_Cache and Handle Vars are gamecache handle 'attaching' systems, which allow you to attach variables to handles, and retrieve them later. Very useful.

You need to create a gamecache global variable, which is different depending on if you're using an old version of CS_Cache, the newer version of CS_Cache or Handle Vars.
 
Last edited:
Status
Not open for further replies.
Top