• 🏆 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] Spell Problem

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2008
Messages
253
Hey guys, I have a problem with my spell. I'm new to JASS so don't be to harsh. When I test the spell it gives a error that says "Invaled argument type (integer)" on a line. But when I delete that line then the error just goes to a other line.

Trigger:

JASS:
function ChillingWind_Condition takes nothing returns boolean
    return GetSpellAbilityId() == 'A004'
endfunction

function ChillingWind_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local player p = GetOwningPlayer(caster)
    local integer level = GetUnitAbilityLevel(caster, 'A004')
    local location loc = GetSpellTargetLoc()
    local location loc2
    local integer level = GetUnitAbilityLevel(caster,'A01L')
    local string SFXmodel = "Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathMissile.mdl"
    local real distance = 120.
    local real duration = 1.
    local real angle = 0.
    local integer x = 0
    local unit u
    local group g
    local effect SFX
    local unit spawn
    loop
        exitwhen x > 6
        set loc2 = PolarProjectionBJ(loc, distance, angle)
        set SFX = AddSpecialEffectLoc(SFXmodel,loc)
        call DestroyEffect(SFX)
        set SFX = null
        call RemoveLocation(loc2)
        set loc2 = null 
        set angle = angle + 60
        set x = x + 1
    endloop
    set g = GetUnitsInRangeOfLocAll(200, loc)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        if IsUnitEnemy(u, GetOwningPlayer(caster)) then            
            set spawn = CreateUnitAtLoc(p,'o009', GetUnitLoc(u),angle)
            call SetUnitAbilityLevel(spawn, 'A029', level)
            call IssueTargetOrder(spawn, 'A029', u)
            call UnitApplyTimedLife(spawn, 'BTLF', duration)
            set spawn = null     
        endif
        call GroupRemoveUnit(g,u)
        set u = null
    endloop
    call DestroyGroup(g)
    set g = null
    call RemoveLocation(loc)
    set caster = null
    set p = null
    set loc = null
    set SFXmodel = null
endfunction

function InitTrig_ChillingWind takes nothing returns nothing
    set gg_trg_ChillingWind = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_ChillingWind, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_ChillingWind, Condition(function ChillingWind_Condition))
    call TriggerAddAction(gg_trg_ChillingWind, function ChillingWind_Actions)
endfunction
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
Urmm instead of locations, use GetUnitX/Y, like local real x = GetUnitX(caster) and local real y = GetUnitY(caster) and thus CreateUnit instead of CreateUnitAtLoc
Also, the angle is x*60 and therefore not needed - just do for the angle x*60
Also, delete the local effect and do: call DestroyEffect(AddSpecialEffect(SFXmodel,x,y))


Besides - which line shows the error? :D
 
Level 7
Joined
Jul 9, 2008
Messages
253
It errors in line: "call UnitApplyTimedLife(spawn, 'BTLF', duration)" but if I remove this then it goes to the "set spawn = null" line.
 
Level 7
Joined
Jul 9, 2008
Messages
253
About GetUnitX and GetUnitY, how do I use this in:

set loc2 = PolarProjectionBJ(loc, distance, angle)

EDIT: I have another problem

JASS:
function Trig_Melt_Ore_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction

function Trig_Melt_Ore_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local player p = GetOwningPlayer(caster)
    local integer level = GetUnitAbilityLevel(caster, 'A003')
    local location loc = GetUnitLoc(caster)
    local location loc2
    local real X = GetUnitX(caster)
    local real Y = GetUnitY(caster)
    local string SFXmodel = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl"
    local real distance = 200.
    local real damage = (((I2R(level)) * 90.) + 30.)
    local real duration = 1.
    local real angle = 0.
    local integer x = 0
    local unit u
    local group g
    local unit spawn
    set spawn = CreateUnit(p,'h003',X,Y,angle)
    call UnitApplyTimedLife(spawn, 'BTLF', duration)
    call IssueImmediateOrder(spawn, 'A004')
    loop
        exitwhen x > 6
        set loc2 = PolarProjectionBJ(loc, distance, angle)
        call DestroyEffect(AddSpecialEffect(SFXmodel,X,Y))
        call RemoveLocation(loc2)
        set loc2 = null 
        set angle = x * 60
        set x = x + 1
    endloop
    set g = GetUnitsInRangeOfLocAll(350, loc)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        if IsUnitEnemy(u, GetOwningPlayer(caster)) then            
            call UnitDamageTarget(caster,u,damage,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_METAL_HEAVY_SLICE)     
        endif
        call GroupRemoveUnit(g,u)
        set u = null
    endloop
    call DestroyGroup(g)
    set g = null
    call RemoveLocation(loc)
    set caster = null
    set p = null
    set loc = null
    set SFXmodel = null
    set spawn = null
endfunction

//===========================================================================
function InitTrig_Melt_Ore takes nothing returns nothing
    set gg_trg_Melt_Ore = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Melt_Ore, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Melt_Ore, Condition( function Trig_Melt_Ore_Conditions ) )
    call TriggerAddAction( gg_trg_Melt_Ore, function Trig_Melt_Ore_Actions )
endfunction

The error says that there is a problem with the loop
 
Level 9
Joined
Nov 28, 2008
Messages
704
May I question the purpose of this:

JASS:
        call DestroyEffect(AddSpecialEffect(SFXmodel,X,Y))

It does.. nothing. At all. Why do you have it?

This is simple: DestroyEffect() is used to remove leaks, yes, but a leak happens because even if the variable (effect) is gone after the end of a function, a leak remains. The effect is not the actual effect - it is a handle to it (a pointer if you know C++). Because a handle is not the actual thing, if the variable is gone there is no way for wc3 to destroy the thing. By Destroying it as you create it, you do nothing because the functtion DestroyEffect() destroys the actual data, removing the leak.

Do you have JNGP? I thjink it gives better debug info.
 
Level 7
Joined
Jul 9, 2008
Messages
253
call DestroyEffect(AddSpecialEffect(SFXmodel,X,Y)) does work or do you suggest that my pc is magical and makes effects on it's own? I don't think so.
 
Level 9
Joined
Nov 28, 2008
Messages
704
You completely misinterpreted my point. Destroying the effect as you make it does NOTHING. You do not call DestroyEffect, you just call AddSpecialEffect.

By destroying the thing you just made, NOTHING happens excepted wasted processing power. Get rid of the DestroyEffect and your good.
 
Level 12
Joined
Dec 10, 2008
Messages
850
Um.. No, your totally wrong. It creates the effect FIRST then instanly destroys it. Theres only a handfull of effects which will NOT work with this. You show signs of not acually testing this. And destroying at the end of a script shouldn't cuase problems as long as it exists.

Now, you have my old friend, PolarProjectionBJ, get ride of it by using Sin and Cos, like so
JASS:
 local real X1 = CR + 400 * Cos(90*bj_DEGTORAD)
 local real Y1= RC + 400 * Sin(90*bj_DEGTORAD)
Now, RC is the Y of the caster, and CR is the X of the caster. 400 is the point I want to offset from my caster, and the stuff inside Cos and Sin convert my degrees to Raidans. This will take up an extra line for every replaced Polar, but its worth it. (so I'm told).

I do Believe your problem is the "A004" part in
JASS:
call IssueImmidieateOrder(spawn, 'A004')
. Could you please tell what spell that is?
 
Level 7
Joined
Jul 9, 2008
Messages
253
Thanks Coolty44, for actually posting something useful that is related to my thread, unlike some others. I won't be testing it atm because I'm pretty tired. So I will let you know the result as soon as possible.

+rep to you :)
 
Level 12
Joined
Dec 10, 2008
Messages
850
After further analisis, your probelm is, infact, that line I posted. That calls for a unit and an order in the means of a adtring, like "stop", but you have a rawcode instead. If you tell me what kind of spell it is(like AOE or unit target), I can give you the proper line to order an ability.
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
You completely misinterpreted my point. Destroying the effect as you make it does NOTHING. You do not call DestroyEffect, you just call AddSpecialEffect.

By destroying the thing you just made, NOTHING happens excepted wasted processing power. Get rid of the DestroyEffect and your good.
Try it yourself

Removing the DestroyEffect would even make it leak -.-
 
Level 24
Joined
May 9, 2007
Messages
3,563
You completely misinterpreted my point. Destroying the effect as you make it does NOTHING. You do not call DestroyEffect, you just call AddSpecialEffect.

By destroying the thing you just made, NOTHING happens excepted wasted processing power. Get rid of the DestroyEffect and your good.

Do not post in Triggers & Scripts until you know what the fuck you are talking about.

It's NOT helpful.
 
Level 7
Joined
Jul 9, 2008
Messages
253
Yea I figured the problem out I used 'A004' instead of "thunderclap" :p
Stupid mistake that I didn't know off :)

+rep to Element of Water, (even though someone else told me already ;D), for his commitment.
 
Status
Not open for further replies.
Top