• 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.

[JASS] Item Spell Problem

Status
Not open for further replies.
Hi guys, i am trying to create an item just like scroll of protection but which give s frost armor to unit in 900 radius. To do this possible i created 1 item, and 2 abilities.

Item - Ice Path
Dummy Ability 1 - Thunder clan (when the hero uses this ability it triggers the code and calls the dummy unit). This ability also provides the item with an unique cold down time and prevents bugs [i think].
Dummy ability 2 - The frost Armor. the dummy unit will cast this ability in friendly units. It needs to be a different ability because it must not have mana cost and the duration time is different.

But somehow i have several errors in my script code and i don't know how to correct them ... i am the first to admit i have a lot to learn about AOE JASS spells.

Anyway here is the code:
JASS:
function IcePath_Conds takes nothing returns boolean
    return GetItemTypeId(GetManipulatedItem()) == 'I012'
endfunction
//================================================================
function IcePath_Acts takes nothing returns nothing
   local group Targets = CreateGroup()  
   local unit vic 
   local unit caster = GetTriggerUnit() 
   local unit dummmy 
   call GroupEnumUnitsInRange( Targets, GetLocationX( caster ), GetLocationY( caster ), 900, Filter(null) )  
       loop  
   set vic = FirstOfGroup( Targets )  
   exitwhen vic==null  
       if IsUnitAlly(vic, GetOwningPlayer(caster)) then  
   set dummmy = CreateUnit(GetOwningPlayer(caster), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)  
   call UnitAddAbility(dummmy, 'A043')  
   call IssueTargetOrder(dummmy, "frostarmor", vic)  
   call UnitApplyTimedLife(dummmy, 'BTLF', 2.5)  
       endif  
   call GroupRemoveUnit(Targets,vic)  
       endloop  
   call DestroyGroup(Targets)   
   set Targets = null  
   set caster = null   
   set dummmy = null 
endfunction 
//===========================================================================
function InitTrig_Ice_Path takes nothing returns nothing
    local trigger IcePath = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( IcePath, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( IcePath, Condition( function IcePath_Conds) )
    call TriggerAddAction( IcePath, function IcePath_Acts )
endfunction


As you can see when the hero uses the item this code is fired. The codes picks all allied units in a 900 AOE and gives them frost armor.
The main error is: Cannot convert unit to location .... ( i make no idea what this means). Anyway plz help ...
 
Thx by the tip PurplePoot. Here is the upgarded, spell, i am open minded toi new improvements you may have to say.

JASS:
function IcePath_Conds takes nothing returns boolean
    return GetItemTypeId(GetManipulatedItem()) == 'I012'
endfunction
//================================================================
function IcePath_Acts takes nothing returns nothing
   local group Targets = CreateGroup()  
   local unit vic 
   local unit caster = GetTriggerUnit() 
   local unit dummmy 
   call GroupEnumUnitsInRange( Targets, GetUnitX( caster ), GetUnitY( caster ), 600, Filter(null) )  
       loop  
   set vic = FirstOfGroup( Targets )  
   exitwhen vic==null  
       if IsUnitAlly(vic, GetOwningPlayer(caster)) then  
   set dummmy = CreateUnit(GetOwningPlayer(caster), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)  
   call UnitAddAbility(dummmy, 'A043')  
   call IssueTargetOrder(dummmy, "frostarmor", vic)  
   call UnitApplyTimedLife(dummmy, 'BTLF', 2.5)
   call SetUnitExploded(dummy, true)  
       endif  
   call GroupRemoveUnit(Targets,vic)  
       endloop  
   call DestroyGroup(Targets)   
   set Targets = null  
   set caster = null   
   set dummmy = null 
endfunction 
//===========================================================================
function InitTrig_Ice_Path takes nothing returns nothing
    local trigger IcePath = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( IcePath, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( IcePath, Condition( function IcePath_Conds) )
    call TriggerAddAction( IcePath, function IcePath_Acts )
endfunction

As you can see i added the "SetUnitExploded" to my spell, as you recommended in the other thread i have. Now when the unit dies it leaves no corpses. However i wonder, if i change the decaying field to "Does not decay, doesn't raise" i think the unit will leave no corpses rit ???
By the way, i hope i am using the explode stuff correctly, never did that before =S

And by the way, what is the meaning of the word "indenting" ???
and "awful" = very bad, correct ???
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
awful=very bad, yes.

And indenting means placing blank space at the start of a line; eg, when you indent paragraphs, it may look like

This is a paragraph. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx​
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Thus, what I mean is, the indenting seems fairly random in this code, and makes it alot less readable. It's generally a good idea to indent the bodies of statements more, thus being able to tell what starts and ends where alot easier.
 
I have a probelm with the "SetUnitExploded". It says that i have an undeclared variable called "dummy" ... problem is that the variable is declared !!

Here is the code... plz help ..
JASS:
function IcePath_Conds takes nothing returns boolean
    return GetItemTypeId(GetManipulatedItem()) == 'I012'
endfunction
//================================================================
function IcePath_Acts takes nothing returns nothing
   local group Targets = CreateGroup()  
   local unit vic 
   local unit caster = GetTriggerUnit() 
   local unit dummmy 
   call GroupEnumUnitsInRange( Targets, GetUnitX( caster ), GetUnitY( caster ), 600, Filter(null) )  
       loop  
   set vic = FirstOfGroup( Targets )  
   exitwhen vic==null  
       if IsUnitAlly(vic, GetOwningPlayer(caster)) then  
   set dummmy = CreateUnit(GetOwningPlayer(caster), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)  
   call UnitAddAbility(dummmy, 'A043')  
   call IssueTargetOrder(dummmy, "frostarmor", vic)  
   call UnitApplyTimedLife(dummmy, 'BTLF', 2.5)
       endif  
   call GroupRemoveUnit(Targets,vic)  
       endloop  
   call DestroyGroup(Targets) 
   call SetUnitExploded(dummy, true)  
   set Targets = null  
   set caster = null   
   set dummmy = null 
endfunction 
//===========================================================================
function InitTrig_Ice_Path takes nothing returns nothing
    local trigger IcePath = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( IcePath, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( IcePath, Condition( function IcePath_Conds) )
    call TriggerAddAction( IcePath, function IcePath_Acts )
endfunction
 
Status
Not open for further replies.
Top