- Joined
- Aug 18, 2006
- Messages
- 1,193
okay, so here is the thing. Im currently making a spell called Koboldify. It's supposed to transform a unit into a Kobold for 10 seconds. My problem? I did this by hiding the target of the spell and create a Kobold at his position. When I cast the spell, everything is fine, until I remove the Kobold and Unhide the unit I casted on in the first place. For some reason, the unit just wont Unhide.
Now, prepare yourself, for this is Very bad JASS, becouse its directly converted from GUI to JASS
all the variables are only used in this trigger and the trigger runs in JASS, not in GUI, so it can have more than 1 local
i do not want any "you could do this and that better becouse it runs faster", i just want an explaination of why the unit wont Unhide(ShowUnitShow)
if i remove the local unit udg_Caster, it work fine(when there is 1 instance that is)
now, am i just missing something or is there something that i dont know about that is causing this problem?
Now, prepare yourself, for this is Very bad JASS, becouse its directly converted from GUI to JASS
JASS:
function Trig_Koboldify_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00D' ) ) then
return false
endif
return true
endfunction
function Trig_Koboldify_Func004Func007Func002Func002Func002C takes nothing returns boolean
if ( not ( udg_TempInteger == 4 ) ) then
return false
endif
return true
endfunction
function Trig_Koboldify_Func004Func007Func002Func002C takes nothing returns boolean
if ( not ( udg_TempInteger == 3 ) ) then
return false
endif
return true
endfunction
function Trig_Koboldify_Func004Func007Func002C takes nothing returns boolean
if ( not ( udg_TempInteger == 2 ) ) then
return false
endif
return true
endfunction
function Trig_Koboldify_Func004Func007C takes nothing returns boolean
if ( not ( udg_TempInteger == 1 ) ) then
return false
endif
return true
endfunction
function Trig_Koboldify_Func004Func024C takes nothing returns boolean
if ( ( GetUnitTypeId(GetSpellTargetUnit()) != 'nkog' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetSpellTargetUnit()) != 'nkob' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetSpellTargetUnit()) != 'nkot' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetSpellTargetUnit()) != 'nkol' ) ) then
return true
endif
return false
endfunction
function Trig_Koboldify_Func004C takes nothing returns boolean
if ( not Trig_Koboldify_Func004Func024C() ) then
return false
endif
return true
endfunction
function Trig_Koboldify_Actions takes nothing returns nothing
local unit udg_TempUnit
local unit udg_Caster
set udg_Caster = GetSpellTargetUnit()
if ( Trig_Koboldify_Func004C() ) then
set udg_Point = GetUnitLoc(udg_Caster)
set udg_Real = GetUnitFacing(udg_Caster)
set udg_Real2 = GetUnitLifePercent(udg_Caster)
set udg_Real3 = GetUnitManaPercent(udg_Caster)
call ShowUnitHide( udg_Caster )
set udg_TempInteger = GetRandomInt(1, 4)
if ( Trig_Koboldify_Func004Func007C() ) then
call CreateNUnitsAtLoc( 1, 'nkob', GetOwningPlayer(udg_Caster), udg_Point, udg_Real )
else
if ( Trig_Koboldify_Func004Func007Func002C() ) then
call CreateNUnitsAtLoc( 1, 'nkog', GetOwningPlayer(udg_Caster), udg_Point, udg_Real )
else
if ( Trig_Koboldify_Func004Func007Func002Func002C() ) then
call CreateNUnitsAtLoc( 1, 'nkot', GetOwningPlayer(udg_Caster), udg_Point, udg_Real )
else
if ( Trig_Koboldify_Func004Func007Func002Func002Func002C() ) then
call CreateNUnitsAtLoc( 1, 'nkol', GetOwningPlayer(udg_Caster), udg_Point, udg_Real )
else
endif
endif
endif
endif
call RemoveLocation(udg_Point)
set udg_TempUnit = GetLastCreatedUnit()
call SetUnitLifePercentBJ( udg_TempUnit, udg_Real2 )
call SetUnitManaPercentBJ( udg_TempUnit, udg_Real3 )
else
endif
call PolledWait( 10.00 )
set udg_Real = GetUnitFacing(udg_TempUnit)
set udg_Real2 = GetUnitLifePercent(udg_TempUnit)
set udg_Real3 = GetUnitManaPercent(udg_TempUnit)
set udg_Point = GetUnitLoc(udg_TempUnit)
call RemoveUnit( udg_TempUnit )
call ShowUnitShow( udg_Caster )
call SetUnitPositionLoc( udg_Caster, udg_Point )
call RemoveLocation(udg_Point)
call SetUnitLifePercentBJ( udg_Caster, udg_Real2 )
call SetUnitManaPercentBJ( udg_Caster, udg_Real3 )
call SetUnitFacingTimed( udg_Caster, udg_Real, 0 )
set udg_Caster = null
set udg_TempUnit = null
endfunction
//===========================================================================
function InitTrig_Koboldify takes nothing returns nothing
set gg_trg_Koboldify = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Koboldify, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Koboldify, Condition( function Trig_Koboldify_Conditions ) )
call TriggerAddAction( gg_trg_Koboldify, function Trig_Koboldify_Actions )
endfunction
i do not want any "you could do this and that better becouse it runs faster", i just want an explaination of why the unit wont Unhide(ShowUnitShow)
if i remove the local unit udg_Caster, it work fine(when there is 1 instance that is)
now, am i just missing something or is there something that i dont know about that is causing this problem?