| 08-17-2006, 05:48 AM | #1 |
Hello Apparently im having a very small problem with my code, the failure is "Invalid Argument Type (integer)" The problem is, i dont really see an error, please look through the short code and tell me, what is wrong? The line that should be wrong is "call CreateUnit". JASS:function Trig_Walk_of_Illusions_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A001' endfunction function Trig_Walk_of_Illusions_Actions takes nothing returns nothing local unit caster = GetTriggerUnit() local real casterX = GetUnitX(caster) local real casterY = GetUnitY(caster) local unit dummy local item wand local integer i = 1 call CreateUnit(GetPlayerId(GetOwningPlayer(caster)),'n001', casterX, casterY, 0) set dummy = GetLastCreatedUnit() call UnitAddItemById(dummy, 'I000') set wand = GetLastCreatedItem() loop exitwhen i>10 call UnitUseItemTarget(dummy, wand, caster) set i = i+1 endloop call RemoveUnit(dummy) set caster = null set dummy = null set wand = null endfunction //=========================================================================== function InitTrig_Walk_of_Illusions takes nothing returns nothing set gg_trg_Walk_of_Illusions = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Walk_of_Illusions, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Walk_of_Illusions, Condition( function Trig_Walk_of_Illusions_Conditions ) ) call TriggerAddAction( gg_trg_Walk_of_Illusions, function Trig_Walk_of_Illusions_Actions ) endfunction EDIT: This item im using has no CD and can be used 1000 times, so dont comment on that :) |
| 08-17-2006, 05:59 AM | #2 |
Take away the GetPlayerId, the parameter is a player but GetPlayerId returns an integer. |
| 08-17-2006, 06:01 AM | #3 |
Thanks alot Naakaloh, im very new to jass, and sometimes won't realize the obvious. + Rep EDIT: Well, i can save without errors now, but the spell aint working? The dummy unit does have a hero inventory, but is there anything else wrong with this code? The spell is based of off Wind Walk, and the idea is to create 10 illusions of the caster, while he hides in the shadows(invisible). This is BTW the new code i have: JASS:function Trig_Walk_of_Illusions_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A001' endfunction function Trig_Walk_of_Illusions_Actions takes nothing returns nothing local unit caster = GetTriggerUnit() local real casterX = GetUnitX(caster) local real casterY = GetUnitY(caster) local unit dummy local item wand local integer i = 1 call CreateUnit(GetOwningPlayer(caster),'n001', casterX, casterY, 0) set dummy = GetLastCreatedUnit() loop exitwhen i>10 call UnitAddItemById(dummy, 'I000') set wand = GetLastCreatedItem() call UnitUseItemTarget(dummy, wand, caster) set i = i+1 endloop call RemoveUnit(dummy) set caster = null set dummy = null set wand = null endfunction //=========================================================================== function InitTrig_Walk_of_Illusions takes nothing returns nothing set gg_trg_Walk_of_Illusions = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Walk_of_Illusions, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Walk_of_Illusions, Condition( function Trig_Walk_of_Illusions_Conditions ) ) call TriggerAddAction( gg_trg_Walk_of_Illusions, function Trig_Walk_of_Illusions_Actions ) endfunction the item is now a 1 charge perishable item, so i just create a new one each time, instead of using the old one 10 times, i thought it would be more safe that way, dunno why :). Still doesnt work though |
| 08-17-2006, 06:19 AM | #4 |
GetLastCreatedUnit() returns a global variable that is set by the Blizzard.j functions. Since you're using the native directly, just do set dummy = CreateUnit(...) Same issue with items. Additionally UnitUseItemTarget will require a delay, despite the lack of cooldown. Simple fix, use one dummy per item and TriggerSleepAction(0.) before removing. Check the systems section for various dummy handlers that could make this particularly clean/easy. |
| 08-17-2006, 09:33 AM | #5 |
Pipe beat me too it! Maybe by a few hours but... I noticed the call CreateUnit(...) too Along with the call UnitAddItemById(...). As pipe said, the native dosent set GetLastCreatedUnit(), but it does return a unit. As does a item with the UnitAddItemById JASS:native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit JASS:native UnitAddItemById takes unit whichUnit, integer itemId returns item The item too. Replace JASS:call CreateUnit(GetOwningPlayer(caster),'n001', casterX, casterY, 0) set dummy = GetLastCreatedUnit() JASS:set dummy = CreateUnit(GetOwningPlayer(caster),'n001', casterX, casterY, 0) and Replace JASS:call UnitAddItemById(dummy, 'I000') set wand = GetLastCreatedItem() JASS:set wand = UnitAddItemById(dummy, 'I000') |
| 08-17-2006, 12:11 PM | #6 |
Thanks alot for the help, both of you. This is my new code, after checking the suggestions, i think its right, but it is still not working? this is the new code, sorry for all the bother: JASS:function Trig_Walk_of_Illusions_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A001' endfunction function Trig_Walk_of_Illusions_Actions takes nothing returns nothing local unit caster = GetTriggerUnit() local real casterX = GetUnitX(caster) local real casterY = GetUnitY(caster) local unit array dummy local item wand local integer i = 1 loop exitwhen i>10 set dummy[i] = CreateUnit(GetOwningPlayer(caster),'n001', casterX, casterY, 0) set wand = UnitAddItemById(dummy[i], 'I000') call TriggerSleepAction(0.10) call UnitUseItemTarget(dummy[i], wand, caster) set i = i+1 endloop call TriggerSleepAction(1.00) set i = 1 loop exitwhen i>10 call RemoveUnit(dummy[i]) set dummy[i] = null set i = i+1 endloop set caster = null set wand = null endfunction //=========================================================================== function InitTrig_Walk_of_Illusions takes nothing returns nothing set gg_trg_Walk_of_Illusions = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Walk_of_Illusions, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Walk_of_Illusions, Condition( function Trig_Walk_of_Illusions_Conditions ) ) call TriggerAddAction( gg_trg_Walk_of_Illusions, function Trig_Walk_of_Illusions_Actions ) endfunction |
| 08-17-2006, 12:27 PM | #7 |
I suggest not removing the dummy, and let it remove itself, by using an expiration timer. Like this: JASS:function Trig_Walk_of_Illusions_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A001' endfunction function Trig_Walk_of_Illusions_Actions takes nothing returns nothing local unit caster = GetTriggerUnit() local real casterX = GetUnitX(caster) local real casterY = GetUnitY(caster) local unit array dummy local item wand local integer i = 1 loop exitwhen i>10 set dummy[i] = CreateUnit(GetOwningPlayer(caster),'n001', casterX, casterY, 0) set wand = UnitAddItemById(dummy[i], 'I000') call TriggerSleepAction(0.10) call UnitUseItemTarget(dummy[i], wand, caster) call UnitApplyTimedLife(dummy[i], 'BTLF', 5.) set i = i+1 endloop set caster = null set wand = null endfunction //=========================================================================== function InitTrig_Walk_of_Illusions takes nothing returns nothing set gg_trg_Walk_of_Illusions = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Walk_of_Illusions, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Walk_of_Illusions, Condition( function Trig_Walk_of_Illusions_Conditions ) ) call TriggerAddAction( gg_trg_Walk_of_Illusions, function Trig_Walk_of_Illusions_Actions ) endfunction |
| 08-17-2006, 01:55 PM | #8 |
Thank you so much! It got the ability to work, i would have given you more rep if it wasnt for: You must spread some Reputation around before giving it to The)TideHunter( again. . Well, thanks alot, thats all i can say. |
| 08-17-2006, 02:25 PM | #9 |
Its ok, i enjoy helping people. |
