| 09-28-2006, 12:11 PM | #1 |
K making a spell Sway Of illusion - Creates a image replica of all nearby friendly units. JASS:function Trig_swayofillusion_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A05R' endfunction function swayofillusion_Conditions takes nothing returns boolean return (GetWidgetLife(GetFilterUnit()) > 0.405) and IsUnitAlly(GetFilterUnit(), udg_tempplayer) endfunction function Trig_swayofillusion_Actions takes nothing returns nothing local unit caster = GetTriggerUnit() local real newx = GetUnitX(caster) local real newy = GetUnitY(caster) local unit dummy local unit temp local player owner = GetOwningPlayer(caster) local integer level = GetUnitAbilityLevel(caster,'A05R') local group g = CreateGroup() set udg_tempplayer = owner call GroupEnumUnitsInRange(g, newx, newy, 500, Condition(function swayofillusion_Conditions)) loop set dummy = FirstOfGroup(g) exitwhen (dummy==null) call CreateUnit(udg_tempplayer, 'h00L', newx, newy, 0.) set temp = GetLastCreatedUnit() call UnitAddAbility (temp, 'A07G') call SetUnitAbilityLevel (temp, 'A07G', level) call IssueTargetOrderById(temp, 852274, dummy) call GroupRemoveUnit(g,dummy) endloop call DestroyGroup(g) endfunction //=========================================================================== function InitTrig_swayofillusion takes nothing returns nothing set gg_trg_swayofillusion = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_swayofillusion, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_swayofillusion, Condition( function Trig_swayofillusion_Conditions ) ) call TriggerAddAction( gg_trg_swayofillusion, function Trig_swayofillusion_Actions ) endfunction I dont understand why it doesnt work? The GetLastCreatedUnit{} doesnt become the dummy. I know this cause the hero spawned at start of map becomes it. EDIT: it works if I use this to create dummy unit? JASS:call CreateNUnitsAtLoc( 1, 'h00L', udg_tempplayer, GetUnitLoc(dummy), bj_UNIT_FACING ) Confusing :< |
| 09-28-2006, 12:19 PM | #2 |
GetLastCreatedUnit() is a BJ function that just returns a global: JASS:function GetLastCreatedUnit takes nothing returns unit return bj_lastCreatedUnit endfunction It instead returns the unit created, so you can replace this: JASS:call CreateUnit(udg_tempplayer, 'h00L', newx, newy, 0.) set temp = GetLastCreatedUnit() JASS:set temp = CreateUnit(udg_tempplayer, 'h00L', newx, newy, 0.) |
