• 🏆 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] Unit Group

Status
Not open for further replies.
Level 5
Joined
Sep 16, 2008
Messages
47
Hi
I need help with unit group.
How to fix it to damage enemy and also add conditions for damage units?
I am just asking abouy unit group. I know that i ahve to fix some things in this spell code:)

JASS:
function Trig_Chidori_Spear_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction 

function Chidori_Spear_Loop takes nothing returns nothing
    local timer t                       = GetExpiredTimer()
    local integer id                    = GetHandleId(t)
    local unit u1                       = LoadUnitHandle(udg_t3,id,1)
    local real Distance                 = LoadReal(udg_t3,id,2)
    local real MaxDistance              = LoadReal(udg_t3,id,3)
    local real DistanceIncrease         = LoadReal(udg_t3,id,4)
    local real Damage                   = LoadReal(udg_t3,id,5)
    local real DamageRange              = LoadReal(udg_t3,id,6)
    local real Angle                    = LoadReal(udg_t3,id,7)
    local real x                        = LoadReal(udg_t3,id,8)
    local real y                        = LoadReal(udg_t3,id,9)
    local real CastTime                 = LoadReal(udg_t3,id,10)
    local real Intervival               = LoadReal(udg_t3,id,11)
    local unit u2
    local unit u3
    local group g
    if CastTime <= 0 then 
        if Distance == MaxDistance then
            call                   PauseUnit(u1, false)
            call                   FlushChildHashtable(udg_t3,GetHandleId(t))
            set t                  = null
            set u1                 = null
            call                   DestroyTimer(GetExpiredTimer()) 
            else
                set u2                      = CreateUnit(GetOwningPlayer(u1),'h001',x,y,Angle)
                call                        UnitApplyTimedLifeBJ(( MaxDistance * ( DistanceIncrease / Intervival ) ), 'BTLF', u2)
                call SaveReal               (udg_t3,GetHandleId(t),2,Distance + DistanceIncrease)
                call SaveReal               (udg_t3,GetHandleId(t),8,x + DistanceIncrease)
                call SaveReal               (udg_t3,GetHandleId(t),9,y + DistanceIncrease)
                set t                       = null
                set u1                      = null
                call GroupEnumUnitsInRange(g,x,y,DamageRange,null)
                set u3 = GetEnumUnit()
                call UnitDamageTarget(u1, u3, Damage, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_DEATH, WEAPON_TYPE_AXE_MEDIUM_CHOP)
            endif
    else
        call SaveReal(udg_t3,id,10,CastTime - Intervival)
        call AddSpecialEffectTargetUnitBJ( "left hand", u1, "Abilities\\Spells\\Orc\\Purge\\PurgeBuffTarget.mdl" )
        set udg_Effects_Effect = GetLastCreatedEffectBJ()
        set udg_Effects_Time = 0.20
        call ConditionalTriggerExecute( gg_trg_Timed_Effect_Run )
    endif 

            
endfunction

function Trig_Chidori_Spear_Actions takes nothing returns nothing
    local unit u1                       = GetTriggerUnit()
    local integer SpellID               = 'A002'
    local real Distance                 = 0.00
    local real MaxDistance              = 1000.00
    local real DistanceIncrease         = 25.00
    local real Intervival               = 0.03
    local real DamagePerLvl             = 50.00
    local real Damage                   = DamagePerLvl *  I2R(GetUnitAbilityLevel(u1,SpellID))
    local real DamageRange              = 100.00
    local real CastTime                 = 1.00
    local string Animation              = "Spell Two"
    local location l1                   = GetUnitLoc(u1)
    local location l2                   = GetSpellTargetLoc()
    local real Angle                    = AngleBetweenPoints(l1, l2)
    local timer t                       = CreateTimer()
    local integer id                    = GetHandleId(t)
    local real x                        = GetUnitX(u1) + 75
    local real y                        = GetUnitY(u1) + 75
    
    
    call SaveUnitHandle         (udg_t3,id,1,u1)
    call SaveReal               (udg_t3,id,2,Distance)
    call SaveReal               (udg_t3,id,3,MaxDistance)
    call SaveReal               (udg_t3,id,4,DistanceIncrease)
    call SaveReal               (udg_t3,id,5,Damage)
    call SaveReal               (udg_t3,id,6,DamageRange) 
    call SaveReal               (udg_t3,id,7,Angle)
    call SaveReal               (udg_t3,id,8,x)
    call SaveReal               (udg_t3,id,9,y)
    call SaveReal               (udg_t3,id,10,CastTime)
    call SaveReal               (udg_t3,id,11,Intervival)
    
    call PauseUnit(u1, true)
    call SetUnitAnimation(u1, Animation)     
    call TimerStart(t, Intervival, true, function Chidori_Spear_Loop)
endfunction
//===========================================================================
function InitTrig_Chidori_Spear takes nothing returns nothing
    set gg_trg_Chidori_Spear = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Chidori_Spear, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Chidori_Spear, Condition( function Trig_Chidori_Spear_Conditions ) )
    call TriggerAddAction( gg_trg_Chidori_Spear, function Trig_Chidori_Spear_Actions )
endfunction
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =O

Well, what is THAT?! ^^

Anyhow, can't you create an extra function for filter and damage units like this:

JASS:
function filter takes nothing returns boolean
   local unit u = GetFilterUnit()

   if GetWidgetLife(u) > 0.405 and IsUnitEnemy(u,GetOwningPlayer(caster)) then //more filter here
      call UnitDamageTarget(caster,u,true,false,attacktype,damagetype,weapontype)
   endif
   set u = null
   return false
endfunction

Now you call this function with:
JASS:
call GroupEnumUnitsInRange(g,x,y,DamageRange,Condition(function filter))

Well, I don't know if this works for your type of coding, never seen this, but something like that will do it^^
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
udg is user defined global, meaning its a variable you created using CTRL+B, you may however predefine them, like this...

JASS:
globals
    hashtable t3 = InitHashtable()
    effect effects
    real effects_time
endglobals

that way you can remove those 'udg' stuffs like...

JASS:
    call SaveUnitHandle         (t3,id,1,u1)
    call SaveReal               (t3,id,2,Distance)
    call SaveReal               (t3,id,3,MaxDistance)
    call SaveReal               (t3,id,4,DistanceIncrease)
    call SaveReal               (t3,id,5,Damage)
    call SaveReal               (t3,id,6,DamageRange) 
    call SaveReal               (t3,id,7,Angle)
    call SaveReal               (t3,id,8,x)
    call SaveReal               (t3,id,9,y)
    call SaveReal               (t3,id,10,CastTime)
    call SaveReal               (t3,id,11,Intervival)

take note that this is just a tip, Im not teaching coz I myself al still learning vJASS...
 
Status
Not open for further replies.
Top