• 🏆 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] Jass Loop Help

Status
Not open for further replies.
Level 10
Joined
Feb 20, 2008
Messages
448
IM noob in jass i know how to read jass or use it but i cannot make it from scratch :/ im tryng to learn how to make simple spell that use Vjass system it!! atm i can do alot but i suck about making Loop

Spell use Jump library made by Dynasti

whats spell suposed to do :the caster jump to the target ,when he jumps finish he does dmg around him with a aoe 200......

Bug nothing happened after Loop Mean picked unit of the group doesnt get damage, maybe the height thingy isnt right any tips ?

p.s. 4 sure its incomplete becuz i dont know what to add ,Im also Visual reading any tutorial didnt very helped me for now any proper help alway Thanks :p


JASS:
scope JumpFunctionExample initializer Init

    globals
        private constant integer AW_ABIL_ID = 'A002'
        
        private constant real    X       = 0.5
        private constant integer Speed   = 1750
        private constant boolean Arced   = true
        private constant boolean AffectZ = true
        private constant boolean Paused  = true
        private constant string  Effect  = "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl"
        private constant string  EAttach = "" //I leave it empty for a spawn on the ground
        private constant string  Art     = "Abilities\\Weapons\\RedDragonBreath\\RedDragonMissile.mdl"
        private constant string  AAttach = "origin"
    endglobals

    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId(  ) == AW_ABIL_ID
    endfunction

function Debug takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction

function Trig_tr2_dot takes nothing returns nothing
local real damage = ( 5.00 * ( I2R(GetUnitAbilityLevel(GetSpellAbilityUnit(),AW_ABIL_ID)) * ( I2R(GetHeroStatBJ(GetHeroStr(GetTriggerUnit(),true), GetSpellAbilityUnit(), false)) + 25.00 ) ) )
call UnitDamageTarget( GetTriggerUnit(),GetFilterUnit(),  damage, true,false,ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL ,WEAPON_TYPE_WOOD_HEAVY_BASH )
endfunction


function Trig_tr2_group takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), GetLocalPlayer()) == false )
endfunction    
    
    
    private function Actions takes nothing returns nothing
        local unit Object = GetTriggerUnit(  )
        //>> Used for finding the distance
            local real x0 = GetUnitX( Object )
            local real y0 = GetUnitY( Object )
            local real x1 = GetSpellTargetX()
            local real y1 = GetSpellTargetY()
            local real dx = x1 - x0
            local real dy = y1 - y0
            local real aoe = 200
            local group g = CreateGroup()
            local player P1 = GetOwningPlayer(Object)
            local real height = GetUnitFlyHeight(Object)
            

        local real Dist = SquareRoot( dx * dx + dy * dy ) // SquareRoot(( x1 - x0 )*( x1 - x0 )+( y1 - y0 )*( y1 - y0 ))
        local real RadAngle = Atan2( dy, dx ) // Atan2( y1 - y0, x1 - x0 )
        //>> IMPORTANT: If you set the Pause to true then you need to make sure that you order your unit to "stop" beafore calling the jump.
                       //Why? Well you could end up with an infinite cast loop!
        call IssueImmediateOrder( Object, "stop" )
        //<<
        //>> Done with setup, now for the call
        //this line also use the Vjass system
        call Jump( Object, RadAngle, X, Speed, Dist, Arced, AffectZ, Paused, Effect, EAttach, Art, AAttach )
        //<<
        set g  = GetUnitsInRangeOfLocMatching(aoe, Location(x1, y1), Condition(function Trig_tr2_group))  
            call Debug("spell")
    loop
             set height = GetUnitFlyHeight(Object)
             call Debug("LOOP")
        exitwhen height <= 0 
    endloop  
    

         call ForGroup(g,function Trig_tr2_dot)
         call Debug("spell end")
       //>> nulling the variables        
            set Object = null
            set P1 = null
            set g = null
            call DestroyGroup(g)
        //<<
    endfunction


    //===========================================================================
private function Init takes nothing returns nothing
        local trigger trg = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(trg, Condition(function Conditions))
        call TriggerAddAction(trg, function Actions)
        set trg = null
endfunction

endscope

 
Last edited:
& im also tryng to know what is boolexpr filter ? to complete the group unit o_O

It's like a condition, for the group.

JASS:
function thefilter takes nothing returns boolean
    return GetUnitName(GetFilterUnit()) = "n00b"
endfunction

function actions takes nothing returns nothing
   call GroupEnumblah(......, Filter(thefilter))
endfunction

That will only add units to the group with the name n00b.
 
Level 10
Joined
Feb 20, 2008
Messages
448
It's like a condition, for the group.

JASS:
function thefilter takes nothing returns boolean
    return GetUnitName(GetFilterUnit()) = "n00b"
endfunction

function actions takes nothing returns nothing
   call GroupEnumblah(......, Filter(thefilter))
endfunction

That will only add units to the group with the name n00b.
Thanks ^^, now i only need to make my Loop work!!

i need to make a loop that run at interval 0,03 within this trigger whats the best way to do it ? im tryng to search in jass tutorial and some information are incomplete :/
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
Use this:
JASS:
native TriggerRegisterTimerEvent takes trigger whichTrigger, real timeout, boolean periodic returns event
A few comments too:
A) Don't use locations. X&Y is faster.
B) Don't use Loop A. Create your own variable.
C) An aesthetic change, make your constants full caps.
(eg AwesomeAbilityId -> ABIL_ID)
 
Level 10
Joined
Feb 20, 2008
Messages
448
Use this:
JASS:
native TriggerRegisterTimerEvent takes trigger whichTrigger, real timeout, boolean periodic returns event
A few comments too:
A) Don't use locations. X&Y is faster.
B) Don't use Loop A. Create your own variable.
C) An aesthetic change, make your constants full caps.
(eg AwesomeAbilityId -> ABIL_ID)

a)Thx for tips but dont i aleady use X & y ?
b)could u give me an exemple of Loop im also Visual like i probly said in first post ^^
c) Indeed it is more aesthetic

d) Thx for ur comment :)

but im wondering for the timer.... i might have to read a timer tutorial lol will it solve my Loop problem! hmmm

i will post feedback if i succed atm , i got script error o_O
 
Level 10
Joined
Feb 20, 2008
Messages
448
The problem is you're using the spell targeted location instead of the GetSpellTargetX() and GetSpellTargetY() natives.

like this ?
JASS:
local real x1 = GetSpellTargetX()
local real y1 = GetSpellTargetY()
it is normal that i dont find those natives in my function list ?

i still need a Loop exemple >.> with interval

edit i get it now ... about the spell target they returns real i thought it was a loc or idk &
i also update main code with few comments i had :p

i think i need to check if height = 0 between caster and target within a loop & when it end do actions...
any idea ? i think a timer with 0,03 would be good o_O unless theres a way to make a loop with a private constant ?
 
Last edited:
Status
Not open for further replies.
Top