Spell Enflame

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Enflame

Spell_Fire_Incinerate.png


Created by Darthfett
Fire Spell
Passive

Screenshot:
attachment.php


Description:
Gives the Hero a 5%/10%/15% chance to enflame upon attacking,
releasing a fury of firebolts from him, dealing 60 damage to nearby units.

-MPI
-MUI
-Leak-less
-Lag-less

-Created in GUI



Trigger:
  • Enflame
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Enflame for (Attacking unit)) Greater than 0
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to ((Level of Enflame for (Attacking unit)) x 5)
        • Then - Actions
          • Set TEMP_Point1 = (Position of (Attacking unit))
          • Sound - Play Enflame <gen> at 100.00% volume, attached to (Attacking unit)
          • Special Effect - Create a special effect attached to the origin of (Attacking unit) using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
          • Special Effect - Destroy (Last created special effect)
          • For each (Integer A) from 1 to 8, do (Actions)
            • Loop - Actions
              • Set TEMP_Real = (45.00 x (Real((Integer A))))
              • Set TEMP_Point2 = (TEMP_Point1 offset by 16.00 towards TEMP_Real degrees)
              • Set TEMP_Point3 = (TEMP_Point1 offset by 200.00 towards TEMP_Real degrees)
              • Unit - Create 1 Enflame Dummy (Ability) for (Owner of (Attacking unit)) at TEMP_Point2 facing TEMP_Real degrees
              • Unit - Set level of Enflame (Dummy) for (Last created unit) to (Level of Enflame for (Attacking unit))
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit - Order (Last created unit) to Neutral Tinker - Cluster Rockets TEMP_Point3
              • Custom script: call RemoveLocation (udg_TEMP_Point2)
              • Custom script: call RemoveLocation (udg_TEMP_Point3)
          • Set TEMP_Group = (Units within 400.00 of TEMP_Point1 matching (((Owner of (Matching unit)) is an enemy of (Owner of (Attacking unit))) Equal to True))
          • Unit Group - Pick every unit in TEMP_Group and do (Actions)
            • Loop - Actions
              • Unit - Cause (Attacking unit) to damage (Picked unit), dealing 60.00 damage of attack type Spells and damage type Fire
          • Custom script: call DestroyGroup(udg_TEMP_Group)
          • Custom script: call RemoveLocation (udg_TEMP_Point1)
        • Else - Actions
 

Attachments

  • Enflame Screenie2.JPG
    Enflame Screenie2.JPG
    43.2 KB · Views: 1,504
  • Enflame.w3x
    47.6 KB · Views: 555

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
PurgeandFire said:
You forgot to destroy the group. Else, good job on the coding and visual effects.

Custom script: set bj_wantDestroyGroup = true

It's supposed to automatically destroy it, part of the ForGroupBJ function:

Code:
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    call ForGroup(whichGroup, callback)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
endfunction
 

vypur85

Hibernate
Reaction score
804
Code:
Set TEMP_Group = (Units within 400.00 of TEMP_Point1 matching (((Owner of (Matching unit)) is an enemy of (Owner of (Attacking unit))) Equal to True))
Isn't it considered as a leak since you set the unit group? Not sure myself.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Code:
Set TEMP_Group = (Units within 400.00 of TEMP_Point1 matching (((Owner of (Matching unit)) is an enemy of (Owner of (Attacking unit))) Equal to True))
Isn't it considered as a leak since you set the unit group? Not sure myself.

That was the reason I set the group, so I could destroy it and remove the leak :p
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
If your going set the group to a variable then use call DestroyGroup.

The function does it.

Code:
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    call ForGroup(whichGroup, callback)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        [B]call DestroyGroup(whichGroup)[/B]
    endif
endfunction
 

U are a noob

Mega Super Ultra Cool Member
Reaction score
152
The function does it.

Erm, no, it doesn't. It leaks.

I never said it leaks but your better off not setting it to a variable or use call destroy. Its faster.
The two options:
Code:
                Set TEMP_Group = (Units within 400.00 of TEMP_Point1 matching (((Owner of (Matching unit)) is an enemy of (Owner of (Attacking unit))) Equal to True))
                Unit Group - Pick every unit in TEMP_Group and do (Actions)
                    Loop - Actions
                        Unit - Cause (Attacking unit) to damage (Picked unit), dealing 60.00 damage of attack type Spells and damage type Fire
                Custom script:   call RemoveLocation (udg_TEMP_Point1)
                Custom script:   call DestroyGroup (udg_TEMP_Group)
            Else - Actions
Code:
                Custom script:   set bj_wantDestroyGroup = true
                Unit Group - Pick every unit (Units within 400.00 of TEMP_Point1 matching (((Owner of (Matching unit)) is an enemy of (Owner of (Attacking unit))) Equal to True)) and do (Actions)
                    Loop - Actions
                        Unit - Cause (Attacking unit) to damage (Picked unit), dealing 60.00 damage of attack type Spells and damage type Fire
                Custom script:   call RemoveLocation (udg_TEMP_Point1)
            Else - Actions
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Yes it does...

Here is the Converted JASS of the function.

Code:
function Trig_Enflame_Conditions takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A001', GetAttacker()) > 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Enflame_Func001Func008002003 takes nothing returns boolean
    return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(GetAttacker())) == true )
endfunction

function Trig_Enflame_Func001Func010A takes nothing returns nothing
    call UnitDamageTargetBJ( GetAttacker(), GetEnumUnit(), 60.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
endfunction

function Trig_Enflame_Func001C takes nothing returns boolean
    if ( not ( GetRandomInt(1, 100) <= ( GetUnitAbilityLevelSwapped('A001', GetAttacker()) * 5 ) ) ) then
        return false
    endif
    return true
endfunction

function Trig_Enflame_Actions takes nothing returns nothing
    if ( Trig_Enflame_Func001C() ) then
        set udg_TEMP_Point1 = GetUnitLoc(GetAttacker())
        call PlaySoundOnUnitBJ( gg_snd_Enflame, 100, GetAttacker() )
        call AddSpecialEffectTargetUnitBJ( "origin", GetAttacker(), "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 8
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            set udg_TEMP_Real = ( 45.00 * I2R(GetForLoopIndexA()) )
            set udg_TEMP_Point2 = PolarProjectionBJ(udg_TEMP_Point1, 16.00, udg_TEMP_Real)
            set udg_TEMP_Point3 = PolarProjectionBJ(udg_TEMP_Point1, 200.00, udg_TEMP_Real)
            call CreateNUnitsAtLoc( 1, 'n000', GetOwningPlayer(GetAttacker()), udg_TEMP_Point2, udg_TEMP_Real )
            call SetUnitAbilityLevelSwapped( 'A000', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A001', GetAttacker()) )
            call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
            call IssuePointOrderLocBJ( GetLastCreatedUnit(), "clusterrockets", udg_TEMP_Point3 )
            call RemoveLocation (udg_TEMP_Point2)
            call RemoveLocation (udg_TEMP_Point3)
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        call RemoveLocation (udg_TEMP_Point1)
        set udg_TEMP_Point1 = GetUnitLoc(GetAttacker())
        set udg_TEMP_Group = GetUnitsInRangeOfLocMatching(400.00, udg_TEMP_Point1, Condition(function Trig_Enflame_Func001Func008002003))
        [B]set bj_wantDestroyGroup = true
        call ForGroupBJ( udg_TEMP_Group, function Trig_Enflame_Func001Func010A )[/B]
        call RemoveLocation (udg_TEMP_Point1)
    else
    endif
endfunction

//===========================================================================
function InitTrig_Enflame takes nothing returns nothing
    set gg_trg_Enflame = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Enflame, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Enflame, Condition( function Trig_Enflame_Conditions ) )
    call TriggerAddAction( gg_trg_Enflame, function Trig_Enflame_Actions )
endfunction

As you can see, the pick every unit in unit group is run by the ForGroupBJ function:

Code:
call ForGroupBJ( udg_TEMP_Group, function Trig_Enflame_Func001Func010A )

Code:
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    [B]local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false[/B]

    call ForGroup(whichGroup, callback)

    [B]// If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)[/B]
    endif
endfunction

The function then runs the callback, and since I set the bj_wantDestroyGroup to true just before running the Pick every units..., it is destroyed.

However, this method of destroying a group only works when it uses the ForGroupBJ function, since it has the preference embedded in the function.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
I see that quite a few things have changed in the mapping world since I left and came back.

http://www.thehelper.net/forums/showthread.php?t=84524&highlight=destroy

I've always thought you had to set the variable, and use the set bj_wantDestroyGroup = true

I guess not, thanks. Working on it now.

(I did make this ability for myself originally, before I temporarily quit mapping. That's one of the reasons some things are not that great).
 

U are a noob

Mega Super Ultra Cool Member
Reaction score
152
I see that quite a few things have changed in the mapping world since I left and came back.

http://www.thehelper.net/forums/showthread.php?t=84524&highlight=destroy

I've always though you had to set the variable, and use the set bj_wantDestroyGroup = true

I guess not, thanks. Working on it now.

Don't worry about it. Just trying to help a fellow coming back to moding and mapping.

Edit:(Attacking unit) should be set to a variable because every time you use that it has to do the event response thing which is slower and inefficient.
 

PurgeandFire

zxcvmkgdfg
Reaction score
511
Yeah. You can either use bj_wantDestroyGroup or just destroy it manually.

If you use a global variable, it does still destroy it. As long as you use the global variable as the argument.

I didn't see any bj_wantDestroy when I first looked at the code. Sorry. :D
 

U are a noob

Mega Super Ultra Cool Member
Reaction score
152
Yeah. You can either use bj_wantDestroyGroup or just destroy it manually.

If you use a global variable, it does still destroy it. As long as you use the global variable as the argument.

I didn't see any bj_wantDestroy when I first looked at the code. Sorry. :D

Thats cause it has been changed and why you don't understand what we talking about.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top