| 11-02-2004, 07:49 PM | #1 |
I am unsure how to condense this bit of code to include only 2 functions, the event and actions functions. Anyone willing to take a look at it? Will the Special effect leak? I dont know if it would or not becuase of my lack of knowledge in this field. Thanks for taking the time to read this. Code:
function Trig_Corpse_Explosion_Copy_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'Adis' ) ) then
return false
endif
return true
endfunction
function Trig_Corpse_Explosion_Copy_Func001001003 takes nothing returns boolean
return ( IsUnitDeadBJ(GetFilterUnit()) == true )
endfunction
function Trig_Corpse_Explosion_Copy_Func001A takes nothing returns nothing
call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), "Objects\\Spawnmodels\\Orc\\OrcLargeDeathExplode\\OrcLargeDeathExplode.mdl" )
call UnitDamagePointLoc( GetSpellAbilityUnit(), 0.00, 200.00, GetUnitLoc(GetEnumUnit()), 100, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL )
call RemoveUnit( GetEnumUnit() )
endfunction
function Trig_Corpse_Explosion_Copy_Actions takes nothing returns nothing
call ForGroupBJ( GetUnitsInRangeOfLocMatching(200.00, GetSpellTargetLoc(), Condition(function Trig_Corpse_Explosion_Copy_Func001001003)), function Trig_Corpse_Explosion_Copy_Func001A )
endfunction
//===========================================================================
function InitTrig_Corpse_Explosion_Copy takes nothing returns nothing
set gg_trg_Corpse_Explosion_Copy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Corpse_Explosion_Copy, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Corpse_Explosion_Copy, Condition( function Trig_Corpse_Explosion_Copy_Conditions ) )
call TriggerAddAction( gg_trg_Corpse_Explosion_Copy, function Trig_Corpse_Explosion_Copy_Actions )
endfunction |
| 11-02-2004, 09:41 PM | #2 | ||
Quote:
That's impossible you have a unit group loop. Quote:
|
| 11-02-2004, 11:00 PM | #3 | |
Quote:
So how would I stop the memory leaks? So the code is as good as it will get minus the leaks? |
| 11-02-2004, 11:24 PM | #4 |
1. Look at the tutorials section. There's tons of tutorials on preventing memory leaks. 2. Triggers made with GUI are never the best it can be. Ex: GUI Code:
function Trig_Corpse_Explosion_Copy_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'Adis' ) ) then
return false
endif
return true
endfunctionThe best it can be Code:
function SHORT FUNCTION NAME takes nothing returns boolean if GetSpellAbilityId()!='Adis' then return false endif return true endfunction |
| 11-02-2004, 11:33 PM | #5 |
nope. it can be Code:
function SHORT FUNCTION NAME takes nothing returns boolean return GetSpellAbilityId()!='Adis' endfunction |
| 11-03-2004, 12:03 AM | #6 |
So this should be fine then? I didnt know how to destroy a effect when its in a loop like that. Code:
function CEConditions takes nothing returns boolean
if GetSpellAbilityId()!='Adis' then
return false
endif
return true
endfunction
function CEConditions2 takes nothing returns boolean
return ( IsUnitDeadBJ(GetFilterUnit()) == true )
endfunction
function CEActions2 takes nothing returns nothing
local effect tempeffect
call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), "Objects\\Spawnmodels\\Orc\\OrcLargeDeathExplode\\OrcLargeDeathExplode.mdl" )
set tempeffect = GetLastCreatedEffectBJ()
call UnitDamagePointLoc( GetSpellAbilityUnit(), 0.00, 200.00, GetUnitLoc(GetEnumUnit()), 100, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL )
call RemoveUnit( GetEnumUnit() )
//call TriggerSleepAction( 1.00 )
call DestroyEffect( tempeffect )
endfunction
function CEActions takes nothing returns nothing
local group tempgroup
call ForGroupBJ( GetUnitsInRangeOfLocMatching(200.00, GetSpellTargetLoc(), Condition(function CEConditions2)), function CEActions2 )
set tempgroup = GetLastCreatedGroup()
call DestroyGroup( tempgroup )
endfunction
//===========================================================================
function InitTrig_Corpse_Explosion takes nothing returns nothing
set gg_trg_Corpse_Explosion = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Corpse_Explosion, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Corpse_Explosion, Condition( function CEConditions ) )
call TriggerAddAction( gg_trg_Corpse_Explosion, function CEActions )
endfunction |
| 11-03-2004, 12:44 AM | #7 |
you did the effect right, but for the group, instead of setting it to last created group.. you actually have to set it to the group. Code:
local group tempgroup = GetUnitsInRangeOfLocMatching(200.00, GetSpellTargetLoc())
call ForGroupBJ( tempgroup, Condition(function CEConditions2)), function CEActions2 )
set tempgroup = GetLastCreatedGroup()
call DestroyGroup( tempgroup )
endfunction |
| 11-03-2004, 12:46 AM | #8 | |
Quote:
Thank you for the help, both of you. |
