Please review, and give your opinion

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
DarkAngel
Newcomer
Posts: 19
Joined: March 28th, 2009, 7:57 pm

Please review, and give your opinion

Post by DarkAngel »

Okay, so "Arrow spell," Casts a projectile in the direction it is casted dealing damage to enemy units that touch the projectile.
"Dark Arrow Spell," Same idea with a special effect. Along with damage, It slows movement speed
Levels 1 slows 20. Duration 2.3
Levels 2 slows 40. Duration 2.3
Levels 3 slows 50. Duration 2.3
Levels 4 slows 100. Duration 2.8

The method I have is using an ability dummy to do it
I was hoping I could keep the slow in the trigger

Please Review this and post a better, method, or optimized trigger. Thank you.
Spoiler:

Code: Select all

scope UTD initializer Init

globals
   private unit Caster = null
   private unit Damage = null
endglobals

private function Filter1 takes nothing returns boolean
    local real x = GetUnitX(GetFilterUnit())
    local real y = GetUnitY(GetFilterUnit())
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Damage)) and GetFilterUnit() != Caster and GetWidgetLife(GetFilterUnit())>0.405 and (IsUnitVisible(GetFilterUnit(),GetOwningPlayer(Damage)) or not UnitHasBuffBJ(GetFilterUnit(),'BOwk')) and GetUnitAbilityLevel(GetFilterUnit(), 'Avul') == 0 and IsTerrainPathable( x, y, PATHING_TYPE_FLOATABILITY) == false 
endfunction  

private function Filter2 takes nothing returns boolean
    local real x = GetUnitX(GetFilterUnit())
    local real y = GetUnitY(GetFilterUnit())
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Damage)) and GetFilterUnit() != Caster and GetWidgetLife(GetFilterUnit())>0.405 and (IsUnitVisible(GetFilterUnit(),GetOwningPlayer(Damage)) or not UnitHasBuffBJ(GetFilterUnit(),'BOwk')) and GetUnitAbilityLevel(GetFilterUnit(), 'Avul') == 0
endfunction

//=======================================================================
private struct UTDS
    //! runtextmacro PUI()
    unit u
    unit d
    real dmg
    timer t
    boolean critical
    
    private method onDestroy takes nothing returns nothing
        set .u = null
        set .d = null
        set .critical = false
        call ReleaseTimer(.t)
    endmethod
endstruct

private function showtxt takes nothing returns nothing
    local UTDS d = GetCSData(GetExpiredTimer())
    local texttag txt = CreateTextTag()
    local real x = GetUnitX(d.u)
    local real y = GetUnitY(d.u)
    local integer i = 0
        if d.critical == true then
            call SetTextTagText( txt, "|cffffcc00" + "Critical!|r " + "|c00FF0000" + "-" + I2S(R2I(d.dmg)) + "|r" , 0.023 )
        else
            call SetTextTagText( txt,  "|c00FF0000" + "-" + I2S(R2I(d.dmg)) + "|r" , 0.023 ) 
        endif
    call SetTextTagPos ( txt, x, y, 150)
    call SetTextTagVelocity( txt, (64 * 0.071 / 128) * Cos(90 * 3.14/180 ) , (64 * 0.071 / 128) * Sin(90 * 3.14/180 ) )
    call SetTextTagPermanent( txt, false )
    call SetTextTagLifespan( txt, 1.70 )
    call SetTextTagFadepoint( txt, 1.00 )
    if (IsFoggedToPlayer( x, y, GetLocalPlayer()) or IsMaskedToPlayer( x, y, GetLocalPlayer())) and GetLocalPlayer() != GetOwningPlayer(d.d) then
        call SetTextTagVisibility( txt, false)
    endif

    set d.critical = false
    set txt = null
    set d.dmg = 0
    call d.release()
endfunction
    
private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit this = GetEventDamageSource()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real x1
    local real y1
    local real x2
    local real y2
    local group g
    local group g2
    local integer i
    local integer n
    local real dist
    local unit fog
    local unit dummy
    local real accuracy
    local integer SlowLevel
    local multiboarditem mbi = null
    local UTDS d = UTDS[u]
    local Arrow e
    local Arrow c
    set Caster = u
    set Damage = this
    call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodArcher.mdl",u,"origin"))
        if d == 0 then
            set d = UTDS.create()
            set d.u = u
            set d.d = GetEventDamageSource()
            set d.dmg = 0
            set d.t = NewTimer()
            set UTDS[u] = d
            call TimerStart(d.t, 0.10, false, function showtxt)
            call SetCSData(d.t,d)
        else
            call PauseTimer(d.t)
            call TimerStart(d.t, 0.10, false, function showtxt)
        endif
    set d.dmg = d.dmg + GetEventDamage()
        if GetUnitTypeId(this) == 'h00J' then
            set Hits[GetPlayerId(GetOwningPlayer(this))] = Hits[GetPlayerId(GetOwningPlayer(this))] + 1
            set accuracy = (I2R(Hits[GetPlayerId(GetOwningPlayer(this))]) / I2R(Shots[GetPlayerId(GetOwningPlayer(this))])) * 100
            set mbi = MultiboardGetItem(Stat_MB[GetPlayerId(GetOwningPlayer(this))], 8, 1)
            call MultiboardSetItemValue(mbi,I2S(R2I(accuracy)) + "%")
            call MultiboardReleaseItem(mbi)
            set mbi = null
            set e = Arrow[this]
            set dummy = CreateUnit( GetOwningPlayer(this), 'h00A', x, y, 0 )       
            if ItemCheck( e.u, 'I00P') >= 1 or ItemCheck( e.u, 'I00T') >= 1 then
                if GetRandomInt(1,100) <= 25 then
                    call SetUnitState(GetTriggerUnit(), UNIT_STATE_MANA,  GetUnitState(GetTriggerUnit(), UNIT_STATE_MANA) - ( GetEventDamage() / 50.00 ) )
                    call SetUnitState(e.u, UNIT_STATE_MANA,  GetUnitState(e.u, UNIT_STATE_MANA) + ( GetEventDamage() / 50.00 ) )
                    call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Human\\SpellSteal\\SpellStealTarget.mdl", GetTriggerUnit(), "chest"))
                    call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\NightElf\\MoonWell\\MoonWellCasterArt.mdl",  e.u, "chest" ))
                endif
            endif
            if ItemCheck( e.u, 'I00L') >= 1 then
                call SetUnitState(e.u,UNIT_STATE_LIFE, GetUnitState(e.u, UNIT_STATE_LIFE) + (0.20 * GetEventDamage()))
                call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\VampiricAura\\VampiricAuraTarget.mdl",e.u,"origin"))
            endif   
            set SlowLevel = GetUnitAbilityLevel(Hero[GetPlayerId(GetOwningPlayer(this))], 'RawCodeOfHeroDarkShootArrow(the first shoot dark arrow)')
            if SlowLevel > 0 then
                set SlowLevel = e.lvl
                set dummy = CreateUnit('h00A', x, y, 0)
                call UnitAddAbility(dummy, 'RawCodeOfDummySlow')
                call SetUnitAbilityLevel(dummy, 'RawCodeOfDummySlow', SlowLevel)
                call IssueTargetOrder(dummy, "slow", u)
            endif
            set dummy = null
                if ItemCheck( this, 'I00V') >= 1 then
                    set dummy = CreateUnit( GetOwningPlayer(this), 'h00A', x, y, 0 )
                    call UnitAddAbility(dummy, 'A00I')
                    call UnitAddAbility(dummy, 'A01M')
                    call UnitApplyTimedLife( dummy, 'BTLF', 2.00 )
                    call IssueTargetOrder( dummy, "frostnova", u )
                    set g = NewGroup()
                    set Caster = u
                    set Damage = this
                    call GroupEnumUnitsInRange(g, x, y, 200, Condition(function Filter2))
                    loop
                        set fog = FirstOfGroup(g)
                        exitwhen fog == null
                        if fog == u then
                            call UnitDamageTarget( dummy, fog, e.dmg/6 , false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )    
                        else
                            call UnitDamageTarget( dummy, fog, e.dmg/9 , false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null ) 
                        endif
                        call GroupRemoveUnit( g, fog)
                    endloop
                    call ReleaseGroup(g)
                    set g = null
                        if IsTerrainPathable ( x, y,  PATHING_TYPE_FLOATABILITY) == false then
                            call IssueTargetOrder( dummy, "thunderbolt", u )
                        endif
                endif
            set dummy = null
                if ItemCheck( this, 'I00X') >= 1 then
                    call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl", GetTriggerUnit(),"origin"))
                    set dummy = CreateUnit( GetOwningPlayer(this), 'h00A', x, y, 0 )
                    call UnitApplyTimedLife( dummy, 'BTLF', 2.00 )
                    call UnitDamageTarget( dummy, u, 100.00, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
                        if IsTerrainPathable ( x, y,  PATHING_TYPE_FLOATABILITY) == false then 
                            set g = NewGroup()                            
                            set Caster = u
                            set Damage = this
                            call GroupEnumUnitsInRange( g, x, y, 5000, Condition( function Filter1))
                            loop
                                set fog = FirstOfGroup(g)
                                exitwhen fog == null
                                call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl", fog,"origin"))
                                set x1 = GetUnitX(fog)
                                set y1 = GetUnitY(fog)
                                set dist = DistanceXY(x,y,x1,y1)
                                call UnitDamageTarget( dummy, fog, (e.dmg * 100)/dist , false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )    
                                call GroupRemoveUnit(g, fog)
                            endloop
                            call ReleaseGroup(g)
                            set g = null
                        endif   
                endif
            set dummy = null
                if ItemCheck( this, 'I00W') >= 1 then
                    set dummy = CreateUnit ( GetOwningPlayer(this), 'h00A', x, y, 0)
                    call UnitAddAbility(dummy, 'A014')
                    call UnitApplyTimedLife( dummy, 'BTLF', 15.00)
                    call UnitBurnTarget(dummy,u,e.dmg/40,1,10)
                    if IsTerrainPathable ( x, y,  PATHING_TYPE_FLOATABILITY) == true then 
                        set i = 1
                        loop
                            exitwhen i > 20
                            set x1 = PolarProjectionX( x, 200.00, 18.00 * I2R(i))
                            set y1 = PolarProjectionY( y, 200.00, 18.00 * I2R(i))
                            call SetUnitX(dummy, x1)
                            call SetUnitY(dummy, y1)
                            set x2 = PolarProjectionX( x, 250.00, 18.00 * I2R(i))
                            set y2 = PolarProjectionY( y, 250.00, 18.00 * I2R(i))                                        
                            call IssuePointOrder( dummy, "breathoffire", x2, y2 )
                            set i = i + 1
                        endloop
                        set g = NewGroup()
                        set g2 = NewGroup()
                        set Caster = u
                        set Damage = this
                        call GroupEnumUnitsInRange( g, x, y, 200, Condition( function Filter2))
                        call GroupEnumUnitsInRange( g2, x, y, 375, Condition( function Filter2))
                        call GroupRemoveGroupAdv(g, g2)
                        loop
                            set fog = FirstOfGroup(g2)
                            exitwhen fog == null
                            call UnitDamageTarget( dummy, fog, e.dmg/2, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
                            call GroupRemoveUnit(g, fog)
                        endloop
                        call ReleaseGroup(g)
                        set g = null
                        call ReleaseGroup(g2)
                        set g2 = null
                    endif
                endif
            set dummy = null
                if ItemCheck( this, 'I007') >= 1 then
                    set dummy = CreateUnit ( GetOwningPlayer(this), 'h00A', x, y, 0)
                    call UnitApplyTimedLife( dummy, 'BTLF', 4.00)
                    call UnitDamageTarget( dummy, u, GetEventDamage() * 0.25, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
                    set d.critical = true
                endif
            set dummy = null
                if ItemCheck( this, 'I006') >= 1 then
                    set dummy = CreateUnit ( GetOwningPlayer(this), 'h00A', x, y, 0)
                    call UnitApplyTimedLife( dummy, 'BTLF', 4.00)
                    call UnitDamageTarget( dummy, u, GetEventDamage() * 0.33, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
                    set d.critical = true
                endif
            set dummy = null
                if ItemCheck( this, 'I008') >= 1 then
                    set dummy = CreateUnit ( GetOwningPlayer(this), 'h00A', x, y, 0)
                    call UnitApplyTimedLife( dummy, 'BTLF', 4.00)
                    call UnitDamageTarget( dummy, u, GetEventDamage() * 0.50, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
                    set d.critical = true
                endif
            set dummy = null
        endif
    set u = null
    set this = null
    set dummy = null
endfunction

private function Conditions takes nothing returns boolean
    return GetEventDamage() > 0
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterAnyUnitDamaged(trig)
    call TriggerAddCondition(trig, Condition(function Conditions))
    call TriggerAddAction(trig, function Actions )
endfunction

endscope
[EDIT by Aero] Added a spoiler since code is 250+ lines.
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: Please review, and give your opinion

Post by Aero »

Solution posted here.

http://forum.wc3edit.net/post76767.html#p76767

Put feedback in there. That's the main thread I check so it makes things easier for me.
Locked.