| 02-18-2007, 12:48 PM | #1 |
I'm new to JASS scripting, and this is the first spell I ever made in JASS. Will it leak? and how would you know if something leaks? JASS://Spell: Torrent of Flames //Spell Idea Author: LiddleGval //Script Author: EidolonFlame function Trig_ToF_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A000' endfunction function Trig_ToF_Actions takes nothing returns nothing local location loc = GetSpellTargetLoc() local unit c = GetTriggerUnit() local integer i = GetUnitAbilityLevel(c, 'A000') local integer a local real hp set hp = GetUnitState(c, UNIT_STATE_LIFE) set a = 0 call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", loc)) loop exitwhen a>360 set a = a+72 call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", PolarProjectionBJ(loc, 200, I2R(a)))) call TriggerSleepAction(0.04) call UnitDamagePointLoc(c, 0, 250+(i*50), loc, (((hp/100)*(11+(i*4)))*(0.8+(i*0.2))/5), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC) call SetUnitLifeBJ(c, (GetUnitState(c, UNIT_STATE_LIFE)-(((hp/100)*(11+(i*4)))*(0.8+(i*0.2))/5))) endloop call RemoveLocation(loc) set loc = null set c = null endfunction //=========================================================================== function InitTrig_ToF takes nothing returns nothing set gg_trg_ToF = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_ToF, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_ToF, Condition( function Trig_ToF_Conditions ) ) call TriggerAddAction( gg_trg_ToF, function Trig_ToF_Actions ) call Preload("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl") call Preload("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl") endfunction |
| 02-18-2007, 01:02 PM | #2 |
You shoud destroy loc before nullifying it imo (I'm a newbie too, so I must not be right) |
| 02-18-2007, 01:14 PM | #3 |
done. forgot abt that :P |
| 02-18-2007, 01:32 PM | #4 |
I don't think it would leak. However: - Zero sense in using SetUnitLifeBJ when there's SetWidgetLife available. - you are calculating the same 40 characters long formula twice... - indentation is your friend. |
| 02-18-2007, 04:45 PM | #5 |
Yeah, change to: JASS:... local real r = ((hp/100)*(11+(i*4)))*(0.8+(i*0.2))/5 ... call UnitDamagePointLoc(c, 0, 250+(i*50), loc, r, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC) call SetWidgetLife(c,r) .... |
| 02-18-2007, 06:06 PM | #6 |
Oh to your question "how do you know if something leaks?", every variable leaks besides integers, reals, and booleans. |
| 02-18-2007, 06:58 PM | #7 |
I'm new too JASS too but in think you don't need to nullify it and destroy it, just destroying it will do. Please correct me if im wrong. |
| 02-18-2007, 07:01 PM | #8 |
Yes you do. Nullifying something removes its Handle reference, and on a local variable that handle will take up space but never again be used because it's local to the code. |
| 02-19-2007, 01:57 AM | #9 |
k changed it thanks all |
| 02-19-2007, 11:53 AM | #10 |
Oh, I have a question about it : should I set all integers and reals to 0 and 0.00 at the end of a function ? |
| 02-19-2007, 12:00 PM | #11 | |
Quote:
![]() btw remove those bj-functions : JASS:
call SetUnitLifeBJ(c, (GetUnitState(c, UNIT_STATE_LIFE)-(((hp/100)*(11+(i*4)))*(0.8+(i*0.2))/5)))
//becomes
SetUnitState(c, UNIT_STATE_LIFE,GetUnitState(c,UNIT_STATE_LIFE)-(((hp/100)*(11+(i*4)))*(0.8+(i*0.2))/5))
|
| 02-19-2007, 02:56 PM | #12 | ||
Quote:
Is still not as effiecent as: Quote:
|
| 02-20-2007, 08:05 PM | #13 |
I just said you don't...whatever your question is answered now. |
