• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Converting [Need Help]

Status
Not open for further replies.
Level 31
Joined
May 3, 2008
Messages
3,155

JASS:
function Electric_Chain_Conditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetAttacker(),'B612')>0) and (IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))==true)
endfunction

function Electric_Chain_Actions takes nothing returns nothing
    local unit attacker=GetAttacker()
    local unit attacked=GetTriggerUnit()
    local unit lastcreated
    local real x1=GetUnitX(attacker)
    local real y1=GetUnitY(attacker)
    local real facing=GetUnitFacing(attacker)
    local effect sfx
    local integer hid = GetHandleId(attacker)
    if LoadInteger(udg_Hash, hid, 0)==9-GetUnitAbilityLevel(attacker,'A626') then
        set sfx=AddSpecialEffectTarget("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldTarget.mdl",attacker,("weapon" + "left"))
        call SaveEffectHandle(udg_Hash,hid,0,sfx)
        call SaveInteger(udg_Hash, hid, 0, LoadInteger(udg_Hash, hid, 0)+1)
    else
        if LoadInteger(udg_Hash, hid, 0)==10-GetUnitAbilityLevel(attacker,'A626') then
            call SaveInteger(udg_Hash, hid, 0, 0)
            set lastcreated=CreateUnit(GetOwningPlayer(attacker),'h60W',x1,y1,facing)
            call UnitAddAbility(lastcreated,'A61X')
            call SetUnitAbilityLevel(lastcreated,'A61X',GetUnitAbilityLevel(attacker,'A626'))
            call IssueTargetOrder(lastcreated,"chainlightning",attacked)
            call UnitApplyTimedLife(lastcreated,'BTLF',0.50)
            set sfx=LoadEffectHandle(udg_Hash,hid,0)
            call DestroyEffect(sfx)
        else
            call SaveInteger(udg_Hash, hid, 0, LoadInteger(udg_Hash, hid, 0)+1)
        endif
    endif
    set attacker=null
    set attacked=null
    set lastcreated=null
    set sfx=null
endfunction

//===========================================================================

constant function GSEC takes nothing returns boolean
    return true
endfunction

function InitTrig_Electric_Chain takes nothing returns nothing
    local trigger T=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function GSEC)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_ATTACKED,FF)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    set udg_Hash=InitHashtable()
    call TriggerAddAction(T,function Electric_Chain_Actions)
    call TriggerAddCondition(T,Condition(function Electric_Chain_Conditions))
    set FF=null
    set T=null
endfunction




  • Lightning Strike1
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Lightning Strike (Prophet)
    • Actions
      • Set LS_TempPoint[1] = (Position of (Triggering unit))
      • Set LS_TempPoint[2] = (Target point of ability being cast)
      • Set LS_TempPoint[3] = (LS_TempPoint[2] offset by 400.00 towards (Angle from LS_TempPoint[2] to LS_TempPoint[1]) degrees)
      • Unit - Create 1 Dummy 2 (Lightning Strike) for (Owner of (Triggering unit)) at LS_TempPoint[2] facing Default building facing degrees
      • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
      • Unit - Make (Last created unit) Explode on death
      • Set LS_Dummy = (Last created unit)
      • For each (Integer LS_GeneralInteger) from 1 to 3, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dummy 1 (Lightning Strike) for (Owner of (Triggering unit)) at LS_TempPoint[3] facing Default building facing degrees
          • Unit - Order (Last created unit) to Special Archimonde - Finger Of Death LS_Dummy
          • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
          • Unit - Make (Last created unit) Explode on death
      • Special Effect - Create a special effect at LS_TempPoint[2] using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at LS_TempPoint[2] using Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
      • Special Effect - Destroy (Last created special effect)
      • Set LS_Groups[1] = (Units within 250.00 of LS_TempPoint[2] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of
      • Unit Group - Pick every unit in LS_Groups[1] and do (Actions)
        • Loop - Actions
          • Unit - Cause (Triggering unit) to damage (Picked unit), dealing (500.00 x (Real((Level of Lightning Strike (Prophet) for (Triggering unit))))) damage of attack type Spells and damage type Normal
          • -------- Knockback System --------
          • Set KBA_Caster = (Triggering unit)
          • Set KBA_TargetUnit = (Picked unit)
          • Set KBA_StartingPosition = (Target point of ability being cast)
          • Set KBA_Level = (Level of (Ability being cast) for (Triggering unit))
          • Set KBA_Speed = 9.00
          • Set KBA_DistancePerLevel = 300.00
          • Set KBA_SpecialEffects[1] = Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
          • Set KBA_SpecialEffects[2] = Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
          • Set KBA_DestroyTrees = True
          • Trigger - Run Cast A Knockback <gen> (checking conditions)
          • -------- End System --------
      • Custom script: call RemoveLocation (udg_LS_TempPoint[1])
      • Custom script: call RemoveLocation (udg_LS_TempPoint[2])
      • Custom script: call RemoveLocation (udg_LS_TempPoint[3])
      • Custom script: call DestroyGroup (udg_LS_Groups[1])
JASS:
function Trig_Lightning_Strike1_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A621' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Lightning_Strike1_Func013002003001 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false )
endfunction

function Trig_Lightning_Strike1_Func013002003002001 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false )
endfunction

function Trig_Lightning_Strike1_Func013002003002002001 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Lightning_Strike1_Func013002003002002002 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Trig_Lightning_Strike1_Func013002003002002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Lightning_Strike1_Func013002003002002001(), Trig_Lightning_Strike1_Func013002003002002002() )
endfunction

function Trig_Lightning_Strike1_Func013002003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Lightning_Strike1_Func013002003002001(), Trig_Lightning_Strike1_Func013002003002002() )
endfunction

function Trig_Lightning_Strike1_Func013002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Lightning_Strike1_Func013002003001(), Trig_Lightning_Strike1_Func013002003002() )
endfunction

function Trig_Lightning_Strike1_Func014A takes nothing returns nothing
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), ( 500.00 * I2R(GetUnitAbilityLevelSwapped('A621', GetTriggerUnit())) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    // Knockback System
    set udg_KBA_Caster = GetTriggerUnit()
    set udg_KBA_TargetUnit = GetEnumUnit()
    set udg_KBA_StartingPosition = GetSpellTargetLoc()
    set udg_KBA_Level = GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetTriggerUnit())
    set udg_KBA_Speed = 9.00
    set udg_KBA_DistancePerLevel = 300.00
    set udg_KBA_SpecialEffects[1] = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl"
    set udg_KBA_SpecialEffects[2] = "Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl"
    set udg_KBA_DestroyTrees = true
    call ConditionalTriggerExecute( gg_trg_Cast_A_Knockback )
    // End System
endfunction

function Trig_Lightning_Strike1_Actions takes nothing returns nothing
    set udg_LS_TempPoint[1] = GetUnitLoc(GetTriggerUnit())
    set udg_LS_TempPoint[2] = GetSpellTargetLoc()
    set udg_LS_TempPoint[3] = PolarProjectionBJ(udg_LS_TempPoint[2], 400.00, AngleBetweenPoints(udg_LS_TempPoint[2], udg_LS_TempPoint[1]))
    call CreateNUnitsAtLoc( 1, 'e603', GetOwningPlayer(GetTriggerUnit()), udg_LS_TempPoint[2], bj_UNIT_FACING )
    call UnitApplyTimedLifeBJ( 0.50, 'BTLF', GetLastCreatedUnit() )
    call SetUnitExplodedBJ( GetLastCreatedUnit(), true )
    set udg_LS_Dummy = GetLastCreatedUnit()
    set udg_LS_GeneralInteger = 1
    loop
        exitwhen udg_LS_GeneralInteger > 3
        call CreateNUnitsAtLoc( 1, 'e602', GetOwningPlayer(GetTriggerUnit()), udg_LS_TempPoint[3], bj_UNIT_FACING )
        call IssueTargetOrderBJ( GetLastCreatedUnit(), "fingerofdeath", udg_LS_Dummy )
        call UnitApplyTimedLifeBJ( 0.50, 'BTLF', GetLastCreatedUnit() )
        call SetUnitExplodedBJ( GetLastCreatedUnit(), true )
        set udg_LS_GeneralInteger = udg_LS_GeneralInteger + 1
    endloop
    call AddSpecialEffectLocBJ( udg_LS_TempPoint[2], "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call AddSpecialEffectLocBJ( udg_LS_TempPoint[2], "Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    set udg_LS_Groups[1] = GetUnitsInRangeOfLocMatching(250.00, udg_LS_TempPoint[2], Condition(function Trig_Lightning_Strike1_Func013002003))
    call ForGroupBJ( udg_LS_Groups[1], function Trig_Lightning_Strike1_Func014A )
    call RemoveLocation (udg_LS_TempPoint[1])
    call RemoveLocation (udg_LS_TempPoint[2])
    call RemoveLocation (udg_LS_TempPoint[3])
    call DestroyGroup (udg_LS_Groups[1])
endfunction

//===========================================================================
function InitTrig_Lightning_Strike1 takes nothing returns nothing
    set gg_trg_Lightning_Strike1 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Strike1, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Lightning_Strike1, Condition( function Trig_Lightning_Strike1_Conditions ) )
    call TriggerAddAction( gg_trg_Lightning_Strike1, function Trig_Lightning_Strike1_Actions )
endfunction

JASS:
function Lightning_Strike_JASS_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A621'
endfunction

function Lightning_Strike_Actions_Filter takes nothing returns boolean
    return (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)==false) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)==false) and (GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) <=0) and (IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit()))==true)
endfunction

function Lightning_Strike_JASS_Actions takes nothing returns nothing
    local unit caster=GetTriggerUnit()
    local unit dummy
    local unit lastcreated
    local integer LS
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real x2=GetSpellTargetX()
    local real y2=GetSpellTargetY()
    local real facing=GetUnitFacing(caster)
    local effect sfx
    local group g = CreateGroup()
    set dummy=CreateUnit(GetOwningPlayer(caster),'e603',x2,y2,facing )
    call UnitApplyTimedLife (dummy, 'BTLF', 0.50)
    call SetUnitExploded( dummy, true )
    set LS = 1
    loop
        exitwhen LS > 3
        set lastcreated=CreateUnit(GetOwningPlayer(caster),'e602',x2,y2,facing )
        call IssueTargetOrder( lastcreated, "fingerofdeath", dummy )
        call UnitApplyTimedLife( lastcreated, 'BTLF', 0.50 )
        call SetUnitExploded( lastcreated, true )
        set LS = LS + 1
    endloop
    set sfx =AddSpecialEffect ("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", x2,y2)
    call DestroyEffect(sfx)
    set sfx = AddSpecialEffect ("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl", x2,y2)
    call DestroyEffect(sfx)
    call GroupEnumUnitsInRange(g,x2,y2,250.00,Condition(function Lightning_Strike_Actions_Filter ))
    set caster=null
    set dummy=null
    set lastcreated=null
    set sfx=null
    set g=null
endfunction

//===========================================================================

constant function GSLS takes nothing returns boolean
    return true
endfunction

function InitTrig_Lightning_Strike takes nothing returns nothing
    local trigger T=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function GSLS)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_SPELL_EFFECT,FF)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Lightning_Strike_JASS_Actions)
    call TriggerAddCondition(T,Condition(function Lightning_Strike_JASS_Conditions))
    set FF=null
    set T=null
endfunction





  • Holy Exorcism 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Exorcism (Holy Knight)
    • Actions
      • Set HE_castpt = (Position of (Triggering unit))
      • Set HE_real2 = (Facing of (Triggering unit))
      • Set HE_ang = (HE_real2 - 180.00)
      • For each (Integer Holy_Exorcism) from 1 to 3, do (Actions)
        • Loop - Actions
          • Set HE_tmppt1 = (HE_castpt offset by 150.00 towards (HE_ang + 90.00) degrees)
          • Set HE_tmppt2 = (HE_tmppt1 offset by 1000.00 towards HE_real2 degrees)
          • Unit - Create 1 Dummy (Holy Exorcism) for (Owner of (Triggering unit)) at HE_tmppt1 facing HE_real2 degrees
          • Special Effect - Create a special effect at HE_tmppt1 using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
          • Set HE_real = ((Distance between HE_tmppt1 and HE_tmppt2) / 1000.00)
          • Unit - Add a HE_real second Generic expiration timer to (Last created unit)
          • Set HE_ang = (HE_ang + 90.00)
          • Custom script: call RemoveLocation(udg_HE_tmppt1)
          • Custom script: call RemoveLocation(udg_HE_tmppt2)
      • Set HE_ang = 0.00
      • Trigger - Turn on Holy Exorcism 2 <gen>
  • Holy Exorcism 2
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set HE_dummygrp = (Units of type Dummy (Holy Exorcism))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in HE_dummygrp) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in HE_dummygrp and do (Actions)
            • Loop - Actions
              • Set HE_real = (Facing of (Picked unit))
              • Set HE_tmppt1 = (Position of (Picked unit))
              • Set HE_tmppt2 = (HE_tmppt1 offset by 25.00 towards HE_real degrees)
              • Special Effect - Create a special effect at HE_tmppt2 using Abilities\Spells\Human\Slow\SlowCaster.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Move (Picked unit) instantly to HE_tmppt2
              • Custom script: call RemoveLocation(udg_HE_tmppt1)
              • Custom script: call RemoveLocation(udg_HE_tmppt2)
        • Else - Actions
          • Trigger - Turn off (This trigger)
      • Custom script: call DestroyGroup(udg_HE_dummygrp)
  • Holy Exorcism 3
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Dummy (Holy Exorcism)
    • Actions
      • Set HE_tmppt1 = (Position of (Triggering unit))
      • Set HE_real = 50.00
      • Special Effect - Create a special effect at HE_tmppt1 using Abilities\Spells\Undead\ReplenishHealth\ReplenishHealthCasterOverhead.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at HE_tmppt1 using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 200.00 of HE_tmppt1 matching ((((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True) or ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit))))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Not equal to (Unit-type of (Triggering unit))
            • Then - Actions
              • Set HE_tmppt2 = (Position of (Picked unit))
              • Special Effect - Create a special effect at HE_tmppt2 using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 50.00)
              • Custom script: call RemoveLocation(udg_HE_tmppt2)
            • Else - Actions
      • Unit - Remove (Triggering unit) from the game
      • Custom script: call RemoveLocation(udg_HE_tmppt1)
JASS:
function Trig_Holy_Exorcism_1_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A63C' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Holy_Exorcism_1_Actions takes nothing returns nothing
    set udg_HE_castpt = GetUnitLoc(GetTriggerUnit())
    set udg_HE_real2 = GetUnitFacing(GetTriggerUnit())
    set udg_HE_ang = ( udg_HE_real2 - 180.00 )
    set udg_Holy_Exorcism = 1
    loop
        exitwhen udg_Holy_Exorcism > 3
        set udg_HE_tmppt1 = PolarProjectionBJ(udg_HE_castpt, 150.00, ( udg_HE_ang + 90.00 ))
        set udg_HE_tmppt2 = PolarProjectionBJ(udg_HE_tmppt1, 1000.00, udg_HE_real2)
        call CreateNUnitsAtLoc( 1, 'n60Q', GetOwningPlayer(GetTriggerUnit()), udg_HE_tmppt1, udg_HE_real2 )
        call AddSpecialEffectLocBJ( udg_HE_tmppt1, "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
        set udg_HE_real = ( DistanceBetweenPoints(udg_HE_tmppt1, udg_HE_tmppt2) / 1000.00 )
        call UnitApplyTimedLifeBJ( udg_HE_real, 'BTLF', GetLastCreatedUnit() )
        set udg_HE_ang = ( udg_HE_ang + 90.00 )
        call RemoveLocation(udg_HE_tmppt1)
        call RemoveLocation(udg_HE_tmppt2)
        set udg_Holy_Exorcism = udg_Holy_Exorcism + 1
    endloop
    set udg_HE_ang = 0.00
    call EnableTrigger( gg_trg_Holy_Exorcism_2 )
endfunction

//===========================================================================
function InitTrig_Holy_Exorcism_1 takes nothing returns nothing
    set gg_trg_Holy_Exorcism_1 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Holy_Exorcism_1, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Holy_Exorcism_1, Condition( function Trig_Holy_Exorcism_1_Conditions ) )
    call TriggerAddAction( gg_trg_Holy_Exorcism_1, function Trig_Holy_Exorcism_1_Actions )
endfunction

JASS:
function Trig_Holy_Exorcism_2_Func002Func002A takes nothing returns nothing
    set udg_HE_real = GetUnitFacing(GetEnumUnit())
    set udg_HE_tmppt1 = GetUnitLoc(GetEnumUnit())
    set udg_HE_tmppt2 = PolarProjectionBJ(udg_HE_tmppt1, 25.00, udg_HE_real)
    call AddSpecialEffectLocBJ( udg_HE_tmppt2, "Abilities\\Spells\\Human\\Slow\\SlowCaster.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call SetUnitPositionLoc( GetEnumUnit(), udg_HE_tmppt2 )
    call RemoveLocation(udg_HE_tmppt1)
    call RemoveLocation(udg_HE_tmppt2)
endfunction

function Trig_Holy_Exorcism_2_Func002C takes nothing returns boolean
    if ( not ( CountUnitsInGroup(udg_HE_dummygrp) > 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Holy_Exorcism_2_Actions takes nothing returns nothing
    set udg_HE_dummygrp = GetUnitsOfTypeIdAll('n60Q')
    if ( Trig_Holy_Exorcism_2_Func002C() ) then
        call ForGroupBJ( udg_HE_dummygrp, function Trig_Holy_Exorcism_2_Func002Func002A )
    else
        call DisableTrigger( GetTriggeringTrigger() )
    endif
    call DestroyGroup(udg_HE_dummygrp)
endfunction

//===========================================================================
function InitTrig_Holy_Exorcism_2 takes nothing returns nothing
    set gg_trg_Holy_Exorcism_2 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Holy_Exorcism_2 )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Holy_Exorcism_2, 0.03 )
    call TriggerAddAction( gg_trg_Holy_Exorcism_2, function Trig_Holy_Exorcism_2_Actions )
endfunction

JASS:
function Trig_Holy_Exorcism_3_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'n60Q' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Holy_Exorcism_3_Func008001003001 takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Trig_Holy_Exorcism_3_Func008001003002 takes nothing returns boolean
    return ( GetOwningPlayer(GetFilterUnit()) == GetOwningPlayer(GetTriggerUnit()) )
endfunction

function Trig_Holy_Exorcism_3_Func008001003 takes nothing returns boolean
    return GetBooleanOr( Trig_Holy_Exorcism_3_Func008001003001(), Trig_Holy_Exorcism_3_Func008001003002() )
endfunction

function Trig_Holy_Exorcism_3_Func008Func001C takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetEnumUnit()) != GetUnitTypeId(GetTriggerUnit()) ) ) then
        return false
    endif
    return true
endfunction

function Trig_Holy_Exorcism_3_Func008A takes nothing returns nothing
    if ( Trig_Holy_Exorcism_3_Func008Func001C() ) then
        set udg_HE_tmppt2 = GetUnitLoc(GetEnumUnit())
        call AddSpecialEffectLocBJ( udg_HE_tmppt2, "Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        call SetUnitLifeBJ( GetEnumUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetEnumUnit()) + 50.00 ) )
        call RemoveLocation(udg_HE_tmppt2)
    else
    endif
endfunction

function Trig_Holy_Exorcism_3_Actions takes nothing returns nothing
    set udg_HE_tmppt1 = GetUnitLoc(GetTriggerUnit())
    set udg_HE_real = 50.00
    call AddSpecialEffectLocBJ( udg_HE_tmppt1, "Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCasterOverhead.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call AddSpecialEffectLocBJ( udg_HE_tmppt1, "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    set bj_wantDestroyGroup = true
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(200.00, udg_HE_tmppt1, Condition(function Trig_Holy_Exorcism_3_Func008001003)), function Trig_Holy_Exorcism_3_Func008A )
    call RemoveUnit( GetTriggerUnit() )
    call RemoveLocation(udg_HE_tmppt1)
endfunction

//===========================================================================
function InitTrig_Holy_Exorcism_3 takes nothing returns nothing
    set gg_trg_Holy_Exorcism_3 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Holy_Exorcism_3, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Holy_Exorcism_3, Condition( function Trig_Holy_Exorcism_3_Conditions ) )
    call TriggerAddAction( gg_trg_Holy_Exorcism_3, function Trig_Holy_Exorcism_3_Actions )
endfunction

JASS:
function Holy_Exorcism_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A63C'
endfunction

function Holy_Exorcism_Actions takes nothing returns nothing
    local unit caster=GetTriggerUnit()
    local unit lastcreated
    local integer HE
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real facing = GetUnitFacing(caster)
    local real x2=x1+150*Cos(facing*bj_DEGTORAD)
    local real y2=y1+150*Sin(facing*bj_DEGTORAD)
    local real angle
    local real expired
    local effect sfx
    local real t1=GetSpellTargetX()
    local real t2=GetSpellTargetY()
    set HE = 1
    loop
        exitwhen HE > 3
        set x2= x2+45*Cos(facing*bj_DEGTORAD)
        set y2= y2+45*Sin(facing*bj_DEGTORAD)
        set lastcreated=CreateUnit(GetOwningPlayer(caster),'n60Q',x2,y2,facing)
        set sfx=AddSpecialEffect("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", x2,y2)
        call DestroyEffect(sfx)
        set expired=SquareRoot((t1-x2)*(t1-x2)+(t2-y2)*(t2-y2))/1000
        call UnitApplyTimedLife( lastcreated,'BTLF',expired)
        set HE = HE + 1
    endloop
    set angle = 0.00
    call EnableTrigger( gg_trg_Holy_Exorcism_2 )
endfunction

//===========================================================================

constant function LGHE takes nothing returns boolean
    return true
endfunction

function InitTrig_Holy_Exorcism takes nothing returns nothing
    local trigger T=CreateTrigger()
    local trigger T2=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function LGHE)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI),EVENT_PLAYER_UNIT_DEATH,null)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Holy_Exorcism_Actions)
    call TriggerAddCondition(T,Condition(function Holy_Exorcism_Conditions))
    set FF=null
    set T=null
    set T2=null
endfunction



I post the GUI version along with the converted JASS version and the JASS version which I personally editing it.

Electric Chain - I currently making my own version of electric chain. I am not familiar with hashtable since I never use it. I was planning to use hashtable to replace the integer.

Electric Strike - Currently trying to fix the lightning facing position and make it deal damage to enemy units. As for the knockback effect, it would be implement after I found a JASS KB system.

Holy Exorcism - Currently doesn't have any idea on converting the 2nd and 3rd trigger. As for the 1st trigger, I am having a maths problem regarding the arrow position.
 
Last edited:
Try this for the Flashlight:
JASS:
function FlashlightCond takes nothing returns boolean
    return GetSpellAbilityId() == 'A61T'
endfunction

function FlashlightAct takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local unit tar = GetSpellTargetUnit()
    local real tx = GetUnitX(tar)
    local real ty = GetUnitY(tar)
    local real dist = 522
    local real expr = 0.2
    local integer l = GetUnitAbilityLevel(u,'A61T')
    local real ang = Atan2(ty-y,tx-x)
    local player p = GetOwningPlayer(u)
    local unit dum = CreateUnit(p,'n61I',x,y,ang*bj_DEGTORAD)
    local integer i = 0
    local real nAng = 0
    local real newX
    local real newY
    
    call IssueTargetOrder(dum,"chainlightning",tar)
    call UnitApplyTimedLife(dum,'BTLF',expr)
    set dum = CreateUnit(p,'n61I',tx,ty,ang*bj_DEGTORAD)
    call UnitApplyTimedLife(dum,'BTLF',expr)
    call IssueTargetOrder(dum,"thunderbolt",tar) 
    
    loop
        exitwhen i > 9
        set newX = tx+dist*Cos(nAng)
        set newY = ty+dist*Sin(nAng)
        set dum = CreateUnit(p,'n61J',tx,ty,Atan2(newY-ty,newX-tx)*bj_RADTODEG)
        call UnitApplyTimedLife(dum,'BTLF',expr+1.3)
        call IssuePointOrder(dum,"move",newX,newY)
        set dum = CreateUnit(p,'n61K',newX,newY,Atan2(ty-newY,tx-newX)*bj_RADTODEG)
        call SetUnitAbilityLevel(dum,'A61V',l)
        call IssueTargetOrder(dum,"chainlightning",tar)
        set nAng = nAng + 36
        set i = i + 1
    endloop                   

    set u = null
    set tar = null
    set dum = null
    //no need to null "p" since they're never destroyed
endfunction

function InitTrig_Flashlight takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    //no need to really inline this neither, since the null leak no longer applies
    //as of patch 1.24b or something
    call TriggerAddCondition(t, Condition(function FlashlightCond))
    call TriggerAddAction(t, function FlashlightAct )
endfunction

It should work, unless I've made some error or something. It parses just fine though.
 
Local variables just act as pointers. They point to handles/agents. The reason we null variables is because when something needs to be destroyed/removed (eventually), it should not have any [local] variables pointing to it. Else its handle index won't be recycled.

That's why we don't have to null triggers and players. Since they are never destroyed, its handle index doesn't need to be recycled, ever. Since we are simply "moving" the pointer to point to something else, we are effectively removing the pointer to the previous variable, allowing all its recycling procedures and whatnot. You really only need to null them at the end. There isn't much harm in doing so though, but it just means less lines of code.

EDIT: Anyway, do you need help optimizing or do your JASS versions not work?
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
I tried converting the first trigger of Arrow Prison, but I got a bit confused in the middle of the code, so there are probably errors in it.
JASS:
function Trig_Arrow_Prison_1_Jass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A637'
endfunction

function Trig_Arrow_Prison_1_Jass_Filter takes nothing returns boolean //You can do actions in the group filter
    local unit u = GetFilterUnit() //Used multiple times so better to store as a local
    if u != GetTriggerUnit() and GetWidgetLife(u) > 0.405 then //Your conditional for checking which units can match. 
        call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIre\\AIreTarget.mdl",u,"origin"))
        call SetUnitTimeScale(u,0)
        call PauseUnit(u,true)
    endif
    set u = null
    return false //Since we're doing everything in the filter, the group doesn't need to have units in it
endfunction

function Trig_Arrow_Prison_1_Jass_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit() //Used multiple times so better to use a local
    local integer i = GetUnitAbilityLevel(cast,'A637')
    local real x = GetSpellTargetX()
    local real y = GetSpellTargetY()    
    local unit dum = CreateUnit(GetOwningPlayer(cast),'n60L',x,y,0) //Wouldn't the angle between the same points be 0? Also I moved it up here to save a line of code
    local real expire = 0 //If expire is 0 by default and doesn't get changed, shouln't you just kill the dummy unit instead of giving an expiration timer of 0 to it? I didn't actually change it in the code though in case you wanted to do it anyway
    local integer index = 1 //Used for looping
    local real offset = 0 //I assumed this was the default value...?
    local real offx //Used for the offsetting
    local real offy
    local real ang //Used to make code look nicer   
    local group g = CreateGroup()
    call GroupEnumUnitsInRange(g,x,y,500.,Condition(function Trig_Arrow_Prison_1_Jass_Filter)) //There might be a boolexpr leak here    
    call DestroyGroup(g)    
    call SetUnitAbilityLevel(dum,'A637',i)
    
    //After this point, I didn't have any idea what you were doing so I probably did something wrong. :\
    
    set i = 4 + i //I think multiplying by 1 achieves nothing...? Also I used i since i was already set to the level of the spell for the caster
    if 0 < i and i < 4 then //This condition didn't make sense to me since i should always be larger than 3 given that the caster was able to cast this spell
        set expire = i + 4 //If i == 1, just add four to get the number you wanted
    endif    
    call UnitApplyTimedLife(dum,'BTLF',expire)    
    loop
        exitwhen index > 12
        set offx = x + 500. * Cos(offset+0.523598776) //I converted to radians, 30 * Pi/180 = 1/6*Pi
        set offy = y + 500. * Sin(offset+0.523598776)
        set ang = bj_RADTODEG * Atan2(y - offy, x - offx) //Needs deg to set unit facing
        set dum = CreateUnit(GetOwningPlayer(cast), 'n60N', offx,offy, ang)
        call UnitApplyTimedLife(dum,'BTLF',expire)
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl",offx,offy))
        set offset = offset + 0.523598776
        set index = index + 1
    endloop  
    //Null all the handles
    set cast = null
    set dum = null
    set g = null
endfunction

function InitTrig_Arrow_Prison_1_Jass takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(t, Condition( function Trig_Arrow_Prison_1_Jass_Conditions ) )
    call TriggerAddAction(t, function Trig_Arrow_Prison_1_Jass_Actions )
endfunction
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Glad it helped.
I started trying to convert the second trigger, but it used a global, udg_SA_tmppt, which wasn't used by the trigger.
So, what is that variable supposed to refer to? (Was it a mistake and actually supposed to be udg_SA_tmppt3?)
Also, I assume you want the spell to be MUI, right?
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
of course spell gotta be mui. :=/
Just checking. =P

Anyway, here's the second trigger for Arrow Prison:
JASS:
function Trig_Arrow_Prison_2_Jass_Conditions takes nothing returns  boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'n60L'
endfunction

function Trig_Arrow_Prison_2_Jass_Filter takes nothing returns boolean
    local unit u = GetFilterUnit()
    if IsUnitPaused(u) and GetWidgetLife(u) > 0.405 then
        call PauseUnit(u,false)
        call  DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIre\\AIreTarget.mdl",u,"origin"))
        call SetUnitTimeScale(u,1)
    endif
    set u = null
    return false
endfunction

function Trig_Arrow_Prison_2_Jass_Actions takes nothing returns nothing
    local unit dead = GetTriggerUnit()
    local real x = GetUnitX(dead)
    local real y = GetUnitY(dead)
    local integer lvl = GetUnitAbilityLevel(dead,'A635')
    local integer index = 1
    local unit dum
    local real ang
    local real offx
    local real offy
    local real offset = 0
    local group g = CreateGroup()
    loop
        exitwhen index > 12
        set offx = x + 500. * Cos(offset+0.523598776)  //Already  converted to radians
        set offy = y + 500. * Sin(offset+0.523598776)  
        set ang = bj_RADTODEG * Atan2(y - offy, x - offx)
        set dum = CreateUnit(GetOwningPlayer(dead),'n60O',offx,offy,ang)
        call SetUnitAbilityLevel(dum,'A636',lvl)
        call IssuePointOrder(dum,"shockwave",x,y)
        call UnitApplyTimedLife(dum,'BTLF',0.2)
        set offset = offset + 0.523598776     
        set index = index + 1
    endloop
    call GroupEnumUnitsInRange(g,x,y,500.,Condition(function  Trig_Arrow_Prison_2_Jass_Filter))
    call DestroyGroup(g)
    set dead = null
    set dum = null
    set g = null
endfunction

//===========================================================================
function InitTrig_Arrow_Prison_2_Jass takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function  Trig_Arrow_Prison_2_Jass_Conditions ) )
    call TriggerAddAction( t, function Trig_Arrow_Prison_2_Jass_Actions )
endfunction
Once again, I'll warn you that I probably made some mistakes.
I assumed that the dummy unit which died never gets moved so the coordinates of the unit's position should be the same as the target point of ability being cast from the first trigger.
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Well, I looked at Electric Chain and it's pretty messy...

You'll probably need to use a global hashtable (to replace the custom value) along with a global group and a damage detection system if you want this to be converted to Jass easily. Most damage detection systems are coded in vJass though so I'm not sure if you would be able to use them.
 
Level 31
Joined
May 3, 2008
Messages
3,155
Well, I looked at Electric Chain and it's pretty messy...

You'll probably need to use a global hashtable (to replace the custom value) along with a global group and a damage detection system if you want this to be converted to Jass easily. Most damage detection systems are coded in vJass though so I'm not sure if you would be able to use them.

Yeah!! I import it into my campaign and did not notice it use custom values until I start editing it.

I make my own version of it, somehow need a solution regarding the hashtable.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
For the Electric Chain something like this should work (I haven't tested):
JASS:
//=============Create this global
    hashtable hash = InitHashtable()
//==============================

function Electric_Chain_Conditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetAttacker(),'B612')>0) and (IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))==true)
endfunction

function Electric_Chain_Actions takes nothing returns nothing
    local unit attacker=GetAttacker()
    local unit attacked=GetTriggerUnit()
    local unit lastcreated
    local real x1=GetUnitX(attacker)
    local real y1=GetUnitY(attacker)
    local real facing=GetUnitFacing(attacker)
    local integer EC
    local effect sfx
    local integer hid = GetHandleId(attacker)
    if LoadInteger(hash, hid, 0)==10-GetUnitAbilityLevel(attacker,'A626') then
        set sfx=AddSpecialEffectTarget("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldTarget.mdl",attacker,("weapon" + "left"))
        call SaveInteger(hash, hid, 0, LoadInteger(hash, hid, 0)+1)
    else
        if LoadInteger(hash, hid, 0)==11-GetUnitAbilityLevel(attacker,'A626') then
            call SaveInteger(hash, hid, 0, 0)
            set lastcreated=CreateUnit(GetOwningPlayer(attacker),'h60W',x1,y1,facing)
            call UnitAddAbility(lastcreated,'A61X')
            call SetUnitAbilityLevel(lastcreated,'A61X',GetUnitAbilityLevel(attacker,'A626'))
            call IssueTargetOrder(lastcreated,"chainlightning",attacked)
            call UnitApplyTimedLife(lastcreated,'BTLF',0.50)
        else
            call SaveInteger(hash, hid, 0, LoadInteger(hash, hid, 0)+1)
        endif
    endif
    set attacker=null
    set attacked=null
    set lastcreated=null
    set effect=null
endfunction

//===========================================================================

function InitTrig_Multiple_Shot takes nothing returns nothing
    local trigger T=CreateTrigger()
    local integer TI=0
    loop
        exitwhen TI==bj_MAX_PLAYER_SLOTS
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_ATTACKED,null)
        set TI=TI+1
    endloop
    call TriggerAddAction(T,function Electric_Chain_Actions)
    call TriggerAddCondition(T,Condition(function Electric_Chain_Conditions))
    set T=null
endfunction
 
Level 31
Joined
May 3, 2008
Messages
3,155
JASS:
function Electric_Chain_Conditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetAttacker(),'B612')>0) and (IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))==true)
endfunction

function Electric_Chain_Actions takes nothing returns nothing
    local unit attacker=GetAttacker()
    local unit attacked=GetTriggerUnit()
    local unit lastcreated
    local real x1=GetUnitX(attacker)
    local real y1=GetUnitY(attacker)
    local real facing=GetUnitFacing(attacker)
    local effect sfx
    local integer hid = GetHandleId(attacker)
    local hashtable hash = InitHashtable()
    if LoadInteger(hash, hid, 0)==10-GetUnitAbilityLevel(attacker,'A626') then
        set sfx=AddSpecialEffectTarget("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldTarget.mdl",attacker,("weapon" + "left"))
        call SaveInteger(hash, hid, 0, LoadInteger(hash, hid, 0)+1)
    else
        if LoadInteger(hash, hid, 0)==11-GetUnitAbilityLevel(attacker,'A626') then
            call SaveInteger(hash, hid, 0, 0)
            set lastcreated=CreateUnit(GetOwningPlayer(attacker),'h60W',x1,y1,facing)
            call UnitAddAbility(lastcreated,'A61X')
            call SetUnitAbilityLevel(lastcreated,'A61X',GetUnitAbilityLevel(attacker,'A626'))
            call IssueTargetOrder(lastcreated,"chainlightning",attacked)
            call UnitApplyTimedLife(lastcreated,'BTLF',0.50)
            call DestroyEffect(sfx)
            set sfx=null
        else
            call SaveInteger(hash, hid, 0, LoadInteger(hash, hid, 0)+1)
        endif
    endif
    set attacker=null
    set attacked=null
    set lastcreated=null
endfunction

//===========================================================================

constant function GSEC takes nothing returns boolean
    return true
endfunction

function InitTrig_Electric_Chain takes nothing returns nothing
    local trigger T=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function GSEC)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_ATTACKED,FF)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Electric_Chain_Actions)
    call TriggerAddCondition(T,Condition(function Electric_Chain_Conditions))
    set FF=null
    set T=null
endfunction

the global hashtable you say, is it hashtable variable or just go to action > create hashtable?
 
Global hashtable. On map init, use InitHashtable() (or in the InitTrig if your spell, but you shouldn't really use a hashtable for one spell, just use one you are already using)

Here is the code:
JASS:
function Electric_Chain_Conditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetAttacker(),'B612')>0) and (IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))==true)
endfunction

function Electric_Chain_Actions takes nothing returns nothing
    local unit attacker=GetAttacker()
    local unit attacked=GetTriggerUnit()
    local unit lastcreated
    local real x1=GetUnitX(attacker)
    local real y1=GetUnitY(attacker)
    local real facing=GetUnitFacing(attacker)
    local effect sfx
    local integer hid = GetHandleId(attacker)
    //local hashtable hash = InitHashtable()
    //use a global hashtable, example: udg_MyHashtable
    if LoadInteger(hash, hid, 0)==10-GetUnitAbilityLevel(attacker,'A626') then
        set sfx=AddSpecialEffectTarget("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldTarget.mdl",attacker,("weapon" + "left"))
        call SaveInteger(udg_MyHashtable, hid, 0, LoadInteger(udg_MyHashtable, hid, 0)+1)
    else
        if LoadInteger(udg_MyHashtable, hid, 0)==11-GetUnitAbilityLevel(attacker,'A626') then
            call SaveInteger(udg_MyHashtable, hid, 0, 0)
            set lastcreated=CreateUnit(GetOwningPlayer(attacker),'h60W',x1,y1,facing)
            call UnitAddAbility(lastcreated,'A61X')
            call SetUnitAbilityLevel(lastcreated,'A61X',GetUnitAbilityLevel(attacker,'A626'))
            call IssueTargetOrder(lastcreated,"chainlightning",attacked)
            call UnitApplyTimedLife(lastcreated,'BTLF',0.50)
            call DestroyEffect(sfx)
            set sfx=null
        else
            call SaveInteger(udg_MyHashtable, hid, 0, LoadInteger(udg_MyHashtable, hid, 0)+1)
        endif
    endif
    set attacker=null
    set attacked=null
    set lastcreated=null
endfunction

//===========================================================================

//constant function GSEC takes nothing returns boolean
//    return true
//endfunction

function InitTrig_Electric_Chain takes nothing returns nothing
    local trigger T=CreateTrigger()
    local integer TI=0
    //local filterfunc FF=Filter(function GSEC)
    loop
        exitwhen (TI==bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_ATTACKED,null)//FF) Just use null
        //it only leaks for people running before 1.24 and they won't really play on Battle.net anyway
        set TI=TI+1
    endloop
    //call DestroyBoolExpr(FF)
    //call DestroyFilter(FF)
    call TriggerAddAction(T,function Electric_Chain_Actions)
    call TriggerAddCondition(T,Condition(function Electric_Chain_Conditions))
   // set FF=null
    set T=null
endfunction

I basically commented stuff you don't need.
 
Level 31
Joined
May 3, 2008
Messages
3,155
JASS:
function Electric_Chain_Hash takes nothing returns boolean
    set udg_EC_Hash = InitHashtable()
endfunction

function Electric_Chain_Conditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetAttacker(),'B612')>0) and (IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))==true)
endfunction

function Electric_Chain_Actions takes nothing returns nothing
    local unit attacker=GetAttacker()
    local unit attacked=GetTriggerUnit()
    local unit lastcreated
    local real x1=GetUnitX(attacker)
    local real y1=GetUnitY(attacker)
    local real facing=GetUnitFacing(attacker)
    local effect sfx
    local integer hid = GetHandleId(attacker)
    if LoadInteger(udg_EC_Hash, hid, 0)==10-GetUnitAbilityLevel(attacker,'A626') then
        set sfx=AddSpecialEffectTarget("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldTarget.mdl",attacker,("weapon" + "left"))
        call SaveInteger(udg_EC_Hash, hid, 0, LoadInteger(udg_EC_Hash, hid, 0)+1)
    else
        if LoadInteger(udg_EC_Hash, hid, 0)==11-GetUnitAbilityLevel(attacker,'A626') then
            call SaveInteger(udg_EC_Hash, hid, 0, 0)
            set lastcreated=CreateUnit(GetOwningPlayer(attacker),'h60W',x1,y1,facing)
            call UnitAddAbility(lastcreated,'A61X')
            call SetUnitAbilityLevel(lastcreated,'A61X',GetUnitAbilityLevel(attacker,'A626'))
            call IssueTargetOrder(lastcreated,"chainlightning",attacked)
            call UnitApplyTimedLife(lastcreated,'BTLF',0.50)
            call DestroyEffect(sfx)
            set sfx=null
        else
            call SaveInteger(udg_EC_Hash, hid, 0, LoadInteger(udg_EC_Hash, hid, 0)+1)
        endif
    endif
    set attacker=null
    set attacked=null
    set lastcreated=null
endfunction

//===========================================================================

constant function GSEC takes nothing returns boolean
    return true
endfunction

function InitTrig_Electric_Chain takes nothing returns nothing
    local trigger T=CreateTrigger()
    local trigger T2=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function GSEC)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI),EVENT_PLAYER_UNIT_ATTACKED,FF)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Electric_Chain_Hash)
    call TriggerAddAction(T2,function Electric_Chain_Actions)
    call TriggerAddCondition(T2,Condition(function Electric_Chain_Conditions))
    set FF=null
    set T=null
endfunction

sry, not certain on the way to declare the hashtable. :p
 
If you want to declare a hashtable specifically for that spell, then you can just use:
JASS:
function InitTrig_Electric_Chain takes nothing returns nothing
    local trigger T2=CreateTrigger()
    local integer TI=0
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI),EVENT_PLAYER_UNIT_ATTACKED,null)
        set TI=TI+1
    endloop
    set udg_EC_Hash = InitHashtable()
    call TriggerAddAction(T2,function Electric_Chain_Actions)
    call TriggerAddCondition(T2,Condition(function Electric_Chain_Conditions))
endfunction

Press "CTRL+B" and make a hashtable variable named "EC_Hash".
 
Level 31
Joined
May 3, 2008
Messages
3,155
JASS:
function Electric_Chain_Conditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetAttacker(),'B612')>0) and (IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))==true)
endfunction

function Electric_Chain_Actions takes nothing returns nothing
    local unit attacker=GetAttacker()
    local unit attacked=GetTriggerUnit()
    local unit lastcreated
    local real x1=GetUnitX(attacker)
    local real y1=GetUnitY(attacker)
    local real facing=GetUnitFacing(attacker)
    local effect sfx
    local integer hid = GetHandleId(attacker)
    if LoadInteger(udg_EC_Hash, hid, 0)==9-GetUnitAbilityLevel(attacker,'A626') then
        set sfx=AddSpecialEffectTarget("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldTarget.mdl",attacker,("weapon" + "left"))
        call SaveInteger(udg_EC_Hash, hid, 0, LoadInteger(udg_EC_Hash, hid, 0)+1)
    else
        if LoadInteger(udg_EC_Hash, hid, 0)==10-GetUnitAbilityLevel(attacker,'A626') then
            call SaveInteger(udg_EC_Hash, hid, 0, 0)
            set lastcreated=CreateUnit(GetOwningPlayer(attacker),'h60W',x1,y1,facing)
            call UnitAddAbility(lastcreated,'A61X')
            call SetUnitAbilityLevel(lastcreated,'A61X',GetUnitAbilityLevel(attacker,'A626'))
            call IssueTargetOrder(lastcreated,"chainlightning",attacked)
            call UnitApplyTimedLife(lastcreated,'BTLF',0.50)
            call DestroyEffect(sfx)
            set sfx=null
        else
            call SaveInteger(udg_EC_Hash, hid, 0, LoadInteger(udg_EC_Hash, hid, 0)+1)
        endif
    endif
    set attacker=null
    set attacked=null
    set lastcreated=null
endfunction

//===========================================================================

constant function GSEC takes nothing returns boolean
    return true
endfunction

function InitTrig_Electric_Chain takes nothing returns nothing
    local trigger T=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function GSEC)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_ATTACKED,FF)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    set udg_EC_Hash=InitHashtable()
    call TriggerAddAction(T,function Electric_Chain_Actions)
    call TriggerAddCondition(T,Condition(function Electric_Chain_Conditions))
    set FF=null
    set T=null
endfunction

Ok!! it work, but how do i destroy the special effect?

By the way, got idea how to convert the 2nd and 3rd trigger of holy exorcism? i don't have any idea to convert it.
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Here's the second trigger of Holy Exorcism:
JASS:
function Trig_Holy_Exorcism_2_Dummy_Filter takes nothing returns boolean //Once again, I directly did the actions of the group enumeration here.
    local unit u = GetFilterUnit()
    local real face = GetUnitFacing(u)
    local real offx
    local real offy
    local boolean b = false
    if GetUnitTypeId(u)=='n60Q' then //Only does it if the unit matches this
        set offx = GetUnitX(u) + 25 * Cos(face * bj_DEGTORAD)
        set offy = GetUnitY(u) + 25 * Sin(face * bj_DEGTORAD)
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Slow\\SlowCaster.mdl",offx,offy))
        call SetUnitPosition(u,offx,offy)
        set b = true
    endif
    set u = null
    return b
endfunction

function Trig_Holy_Exorcism_2_Actions takes nothing returns nothing
    local group g = CreateGroup()
    local integer i = 0
    local boolean on = false //Determines if the trigger should be disabled or not
    loop
        call GroupEnumUnitsOfPlayer(g,Player(i),function Trig_Holy_Exorcism_2_Dummy_Filter)
        if not on and FirstOfGroup(g) != null then //This is a bit of experimentation. I think it should work to see if there were any dummy units that got enumed
            set on = true
        endif
        set i = i + 1
        exitwhen i == 16
    endloop
    if not on then
        call DisableTrigger(GetTriggeringTrigger())
    endif    
    call DestroyGroup(g)
    set g = null
endfunction

function InitTrig_Holy_Exorcism_2 takes nothing returns nothing
    set gg_trg_Holy_Exorcism_2 = CreateTrigger() //Since you seemed to reference this in your first trigger, I didn't use a local.
    call DisableTrigger(gg_trg_Holy_Exorcism_2)
    call TriggerRegisterTimerEvent(gg_trg_Holy_Exorcism_2, 0.03,true)
    call TriggerAddAction(gg_trg_Holy_Exorcism_2, function Trig_Holy_Exorcism_2_Actions)
endfunction
Tell me if something's not working. I'll edit this post when I do the 3rd one.
Edit: 3rd one done.
JASS:
function Trig_Holy_Exorcism_3_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'n60Q'
endfunction

function Trig_Holy_Exorcism_3_Filter takes nothing returns boolean //Same concept as the thing I've been doing in all the conversions
    local unit u = GetFilterUnit()
    if IsUnitAlly(u, GetOwningPlayer(GetTriggerUnit())) and GetUnitTypeId(u) != GetUnitTypeId(GetTriggerUnit()) then //I think the second condition was not needed since a player is considered his own ally. I also combined the other condition.
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl",GetUnitX(u),GetUnitY(u)))
        call SetWidgetLife(u,GetWidgetLife(u)+50) //Using this is faster than using GetUnitState/SetUnitState
    endif
    set u = null
    return false 
endfunction

function Trig_Holy_Exorcism_3_Actions takes nothing returns nothing
    local unit dead = GetTriggerUnit()
    local real x = GetUnitX(dead)
    local real y = GetUnitY(dead)
    local group g = CreateGroup()
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCasterOverhead.mdl",x,y))
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl",x,y))
    //I removed HE_real which seemed to do nothing in this trigger.
    call GroupEnumUnitsInRange(g,x,y,200,Condition(function Trig_Holy_Exorcism_3_Filter))
    call DestroyGroup(g)
    set g = null
    set dead = null
endfunction

//===========================================================================
function InitTrig_Holy_Exorcism_3 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function Trig_Holy_Exorcism_3_Conditions ) )
    call TriggerAddAction( t, function Trig_Holy_Exorcism_3_Actions )
endfunction
 
Ok, it might not work but hopefully it does:
JASS:
function Electric_Chain_Actions takes nothing returns nothing
    local unit attacker=GetAttacker()
    local unit attacked=GetTriggerUnit()
    local unit lastcreated
    local real x1=GetUnitX(attacker)
    local real y1=GetUnitY(attacker)
    local real facing=GetUnitFacing(attacker)
    local effect sfx
    local integer hid = GetHandleId(attacker)
    local integer i = 0
    if LoadInteger(udg_EC_Hash, hid, 0)==9-GetUnitAbilityLevel(attacker,'A626') then
        set sfx=AddSpecialEffectTarget("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldTarget.mdl",attacker,("weapon" + "left"))
        call SaveEffectHandle(udg_EC_Hash,hid,0,LoadInteger(udg_EC_Hash,hid,0),sfx)
        call SaveInteger(udg_EC_Hash, hid, 0, LoadInteger(udg_EC_Hash, hid, 0)+1)
    else
        if LoadInteger(udg_EC_Hash, hid, 0)==10-GetUnitAbilityLevel(attacker,'A626') then
            loop
                exitwhen i > (10-GetUnitAbilityLevel(attacker,'A626'))
                if HaveSavedHandle(udg_EC_Hash,hid,i) then
                    call DestroyEffect(LoadEffectHandle(udg_EC_Hash,hid,i))
                endif
                set i = i + 1
            endloop
        endif
            call SaveInteger(udg_EC_Hash, hid, 0, 0)
            set lastcreated=CreateUnit(GetOwningPlayer(attacker),'h60W',x1,y1,facing)
            call UnitAddAbility(lastcreated,'A61X')
            call SetUnitAbilityLevel(lastcreated,'A61X',GetUnitAbilityLevel(attacker,'A626'))
            call IssueTargetOrder(lastcreated,"chainlightning",attacked)
            call UnitApplyTimedLife(lastcreated,'BTLF',0.50)
        else
            call SaveInteger(udg_EC_Hash, hid, 0, LoadInteger(udg_EC_Hash, hid, 0)+1)
        endif
    endif
    set sfx = null
    set attacker=null
    set attacked=null
    set lastcreated=null
endfunction

Test it out, it might have some flaws but we can work that out later.
 
Level 31
Joined
May 3, 2008
Messages
3,155
The electric chain spells seem to have a lot of problem upon checking it.

JASS:
function Electric_Chain_Conditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetAttacker(),'B612')>0) and (IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))==true)
endfunction

function Electric_Chain_Actions takes nothing returns nothing
    local unit attacker=GetAttacker()
    local unit attacked=GetTriggerUnit()
    local unit lastcreated
    local real x1=GetUnitX(attacker)
    local real y1=GetUnitY(attacker)
    local real facing=GetUnitFacing(attacker)
    local effect sfx
    local integer hid = GetHandleId(attacker)
    local integer i = 0
    if LoadInteger(udg_EC_Hash, hid, 0)==9-GetUnitAbilityLevel(attacker,'A626') then
        set sfx=AddSpecialEffectTarget("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldTarget.mdl",attacker,("weapon" + "left"))
        call SaveEffectHandle(udg_EC_Hash,hid,0,LoadInteger(udg_EC_Hash,hid,0),sfx)
        call SaveInteger(udg_EC_Hash, hid, 0, LoadInteger(udg_EC_Hash, hid, 0)+1)
    else
        if LoadInteger(udg_EC_Hash, hid, 0)==10-GetUnitAbilityLevel(attacker,'A626') then
            loop
                exitwhen i > (10-GetUnitAbilityLevel(attacker,'A626'))
                if HaveSavedHandle(udg_EC_Hash,hid,i) then
                    call DestroyEffect(LoadEffectHandle(udg_EC_Hash,hid,i))
                endif
                set i = i + 1
            endloop
        endif
            call SaveInteger(udg_EC_Hash, hid, 0, 0)
            set lastcreated=CreateUnit(GetOwningPlayer(attacker),'h60W',x1,y1,facing)
            call UnitAddAbility(lastcreated,'A61X')
            call SetUnitAbilityLevel(lastcreated,'A61X',GetUnitAbilityLevel(attacker,'A626'))
            call IssueTargetOrder(lastcreated,"chainlightning",attacked)
            call UnitApplyTimedLife(lastcreated,'BTLF',0.50)
        else
            call SaveInteger(udg_EC_Hash, hid, 0, LoadInteger(udg_EC_Hash, hid, 0)+1)
        endif
    endif
    set attacker=null
    set attacked=null
    set lastcreated=null
    set sfx=null
endfunction

//===========================================================================

constant function GSEC takes nothing returns boolean
    return true
endfunction

function InitTrig_Electric_Chain takes nothing returns nothing
    local trigger T=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function GSEC)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_ATTACKED,FF)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    set udg_EC_Hash=InitHashtable()
    call TriggerAddAction(T,function Electric_Chain_Actions)
    call TriggerAddCondition(T,Condition(function Electric_Chain_Conditions))
    set FF=null
    set T=null
endfunction

As for the holy exorcism, it look like the 2nd trigger have problem :=/

I compile it into 1 trigger and here is the result.

JASS:
function Holy_Exorcism_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A63C'
endfunction

function Holy_Exorcism_Actions takes nothing returns nothing
    local unit caster=GetTriggerUnit()
    local unit lastcreated
    local integer HE
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real facing = GetUnitFacing(caster)
    local real x2=x1+150*Cos(facing*bj_DEGTORAD)
    local real y2=y1+150*Sin(facing*bj_DEGTORAD)
    local real angle
    local real expired
    local effect sfx
    local real t1=GetSpellTargetX()
    local real t2=GetSpellTargetY()
    set HE = 1
    loop
        exitwhen HE > 3
        set x2= x2+45*Cos(facing*bj_DEGTORAD)
        set y2= y2+45*Sin(facing*bj_DEGTORAD)
        set lastcreated=CreateUnit(GetOwningPlayer(caster),'n60Q',x2,y2,facing)
        set sfx=AddSpecialEffect("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", x2,y2)
        call DestroyEffect(sfx)
        set expired=SquareRoot((t1-x2)*(t1-x2)+(t2-y2)*(t2-y2))/1000
        call UnitApplyTimedLife( lastcreated,'BTLF',expired)
        set HE = HE + 1
    endloop
    set angle = 0.00
endfunction

function Holy_Exorcism_Move_Filter takes nothing returns boolean //Once again, I directly did the actions of the group enumeration here.
    local unit u = GetFilterUnit()
    local real face = GetUnitFacing(u)
    local real offx
    local real offy
    local boolean b = false
    if GetUnitTypeId(u)=='n60Q' then //Only does it if the unit matches this
        set offx = GetUnitX(u) + 25 * Cos(face * bj_DEGTORAD)
        set offy = GetUnitY(u) + 25 * Sin(face * bj_DEGTORAD)
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Slow\\SlowCaster.mdl",offx,offy))
        call SetUnitPosition(u,offx,offy)
        set b = true
    endif
    set u = null
    return b
endfunction

function Holy_Exorcism_Move_Actions takes nothing returns nothing
    local group g = CreateGroup()
    local integer i = 0
    local boolean on = false //Determines if the trigger should be disabled or not
    loop
        call GroupEnumUnitsOfPlayer(g,Player(i),function Holy_Exorcism_Move_Filter)
        if not on and FirstOfGroup(g) != null then //This is a bit of experimentation. I think it should work to see if there were any dummy units that got enumed
            set on = true
        endif
        set i = i + 1
        exitwhen i == 16
    endloop
    if not on then
        call DisableTrigger(GetTriggeringTrigger())
    endif    
    call DestroyGroup(g)
    set g = null
endfunction

function Holy_Exorcism_Death_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'n60Q'
endfunction

function Holy_Exorcism_Death_Filter takes nothing returns boolean //Same concept as the thing I've been doing in all the conversions
    local unit u = GetFilterUnit()
    if IsUnitAlly(u, GetOwningPlayer(GetTriggerUnit())) and GetUnitTypeId(u) != GetUnitTypeId(GetTriggerUnit()) then //I think the second condition was not needed since a player is considered his own ally. I also combined the other condition.
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl",GetUnitX(u),GetUnitY(u)))
        call SetWidgetLife(u,GetWidgetLife(u)+50) //Using this is faster than using GetUnitState/SetUnitState
    endif
    set u = null
    return false 
endfunction

function Holy_Exorcism_Death_Actions takes nothing returns nothing
    local unit dead = GetTriggerUnit()
    local real x = GetUnitX(dead)
    local real y = GetUnitY(dead)
    local group g = CreateGroup()
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCasterOverhead.mdl",x,y))
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl",x,y))
    //I removed HE_real which seemed to do nothing in this trigger.
    call GroupEnumUnitsInRange(g,x,y,200,Condition(function Holy_Exorcism_Death_Filter))
    call DestroyGroup(g)
    set g = null
    set dead = null
endfunction

//===========================================================================

constant function LGHE takes nothing returns boolean
    return true
endfunction

function InitTrig_Holy_Exorcism takes nothing returns nothing
    local trigger T=CreateTrigger()
    local trigger T2=CreateTrigger()
    local trigger T3=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function LGHE)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        call TriggerRegisterTimerEvent(T2, 0.03,true)
        call TriggerRegisterPlayerUnitEvent(T3,Player(TI),EVENT_PLAYER_UNIT_DEATH,null)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Holy_Exorcism_Actions)
    call TriggerAddCondition(T,Condition(function Holy_Exorcism_Conditions))
    call DisableTrigger(T2)
    call TriggerAddAction(T2, function Holy_Exorcism_Move_Actions)
    call TriggerAddAction(T3, function Holy_Exorcism_Death_Actions )
    call TriggerAddCondition(T3,Condition(function Holy_Exorcism_Death_Conditions ) )
    set FF=null
    set T=null
    set T3=null
endfunction
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Don't put call TriggerRegisterTimerEvent(T2, 0.03,true) in the loop. (Not sure if that will help, but it's not like TriggerRegisterAnyUnitEventBJ

It also looks like you didn't enable the second trigger in the first one.

Could you try using debug messages like BJDebugMsg or DisplayTextToPlayer to find out what parts of the trigger worked?
Or try testing it with the triggers separate?

BTW in your Holy_Exorcism_Actions, you need to null caster and lastcreated.
You could have local integer HE = 1 instead of setting it later.
You could also remove the angle variable, which you don't seem to use, and the sfx variable.
JASS:
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", x2,y2))
 
Level 31
Joined
May 3, 2008
Messages
3,155
I forgot to mention that I had accidentally add/remove some stuff due to screw up

The null caster and lastcreated was done, but somehow it seem to screw up and not shown.

As for the angle, they're needed to fix the sword position. It just that somehow I screw up the formula for it.

For the sfx, isn't it suppose to be stored before it was destroy?
 
Level 31
Joined
May 3, 2008
Messages
3,155
JASS:
function Holy_Exorcism_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A63C'
endfunction

function Holy_Exorcism_Actions takes nothing returns nothing
    local unit caster=GetTriggerUnit()
    local unit lastcreated
    local integer HE =1
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real facing = GetUnitFacing(caster)
    local real x2=x1+150*Cos(facing*bj_DEGTORAD)
    local real y2=y1+150*Sin(facing*bj_DEGTORAD)
    local real angle
    local real expired
    local real t1=GetSpellTargetX()
    local real t2=GetSpellTargetY()
    loop
        exitwhen HE > 3
        set x2= x2+45*Cos(facing*bj_DEGTORAD)
        set y2= y2+45*Sin(facing*bj_DEGTORAD)
        set lastcreated=CreateUnit(GetOwningPlayer(caster),'n60Q',x2,y2,facing)
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", x2,y2))
        set expired=SquareRoot((t1-x2)*(t1-x2)+(t2-y2)*(t2-y2))/1000
        call UnitApplyTimedLife( lastcreated,'BTLF',expired)
        set HE = HE + 1
    endloop
    set angle = 0.00
endfunction

function Holy_Exorcism_Move_Filter takes nothing returns boolean
    local unit u = GetFilterUnit()
    local real face = GetUnitFacing(u)
    local real offx
    local real offy
    local boolean b = false
    if GetUnitTypeId(u)=='n60Q' then
        set offx = GetUnitX(u) + 25 * Cos(face * bj_DEGTORAD)
        set offy = GetUnitY(u) + 25 * Sin(face * bj_DEGTORAD)
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Slow\\SlowCaster.mdl",offx,offy))
        call SetUnitPosition(u,offx,offy)
        set b = true
    endif
    set u = null
    return b
endfunction

function Holy_Exorcism_Move_Actions takes nothing returns nothing
    local group g = CreateGroup()
    local integer i = 0
    local boolean on = false
    local boolexpr bx=Filter(function Holy_Exorcism_Move_Filter)
    loop
        call GroupEnumUnitsOfPlayer(g,Player(i),bx)
        if not on and FirstOfGroup(g) != null then
            set on = true
        endif
        set i = i + 1
        exitwhen i == 16
    endloop
    if not on then
        call DisableTrigger(GetTriggeringTrigger())
    endif    
    call DestroyGroup(g)
    set g=null
    set bx=null
endfunction

function Holy_Exorcism_Death_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'n60Q'
endfunction

function Holy_Exorcism_Death_Filter takes nothing returns boolean
    local unit u = GetFilterUnit()
    if IsUnitAlly(u, GetOwningPlayer(GetTriggerUnit())) and GetUnitTypeId(u) != GetUnitTypeId(GetTriggerUnit()) then 
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl",GetUnitX(u),GetUnitY(u)))
        call SetWidgetLife(u,GetWidgetLife(u)+50)
    endif
    set u = null
    return false 
endfunction

function Holy_Exorcism_Death_Actions takes nothing returns nothing
    local unit dead = GetTriggerUnit()
    local real x = GetUnitX(dead)
    local real y = GetUnitY(dead)
    local group g = CreateGroup()
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCasterOverhead.mdl",x,y))
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl",x,y))
    call GroupEnumUnitsInRange(g,x,y,200,Condition(function Holy_Exorcism_Death_Filter))
    call DestroyGroup(g)
    set g = null
    set dead = null
endfunction

//===========================================================================

constant function LGHE takes nothing returns boolean
    return true
endfunction

function InitTrig_Holy_Exorcism takes nothing returns nothing
    local trigger T=CreateTrigger()
    local trigger T2=CreateTrigger()
    local trigger T3=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function LGHE)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        call TriggerRegisterTimerEvent(T2, 0.03,true)
        call TriggerRegisterPlayerUnitEvent(T3,Player(TI),EVENT_PLAYER_UNIT_DEATH,null)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Holy_Exorcism_Actions)
    call TriggerAddCondition(T,Condition(function Holy_Exorcism_Conditions))
    call TriggerAddAction(T2, function Holy_Exorcism_Move_Actions)
    call TriggerAddAction(T3, function Holy_Exorcism_Death_Actions )
    call TriggerAddCondition(T3,Condition(function Holy_Exorcism_Death_Conditions ) )
    set FF=null
    set T=null
    set T3=null
endfunction

I merge all those trigger into and fix the line 55 by using boolexpr.

Still, how do i make the timer on and off after the dummy unit reach target point?
 
Status
Not open for further replies.
Top