• 🏆 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] 2 Triggers nearly the same , one works the other not

Status
Not open for further replies.
Level 1
Joined
Jun 14, 2008
Messages
3
Hi,

i am fairly new to Jass and been scripting some easy stuff ... but now i have 2 triggers
1 shooting bullets in a direction and 1 shooting bullets at a point

JASS:
function Trig_mmgfacing_Actions takes nothing returns nothing
    local real dummyfacing = GetUnitFacing(GetSpellAbilityUnit())
    local location shottemp = null
    local unit dummy = null
    local unit caster = GetSpellAbilityUnit()
    local integer LoopIndex = 1
    local integer LoopIndexEnd = 10
    loop
        exitwhen LoopIndex > LoopIndexEnd
        set dummy =  CreateUnitAtLoc( GetOwningPlayer(caster), 'h005',  GetUnitLoc(caster), dummyfacing )
        call ShowUnitHide ( dummy )
        call SetUnitInvulnerable( dummy , true )
        call SelectUnitRemoveForPlayer( dummy, GetOwningPlayer(dummy) )
	set shottemp = PolarProjectionBJ ( GetUnitLoc(dummy) , 50 , dummyfacing)
        call IssuePointOrderLocBJ( dummy, "shockwave", shottemp )
        call RemoveUnit( dummy )
        call PolledWait(0.1)

        set LoopIndex = LoopIndex + 1
    endloop
    call RemoveLocation(shottemp)
    set dummy = null
    set shottemp = null
endfunction

this one works fine , the dummys cast the spell and everything


and now the on where the dummys dont shoot ...

JASS:
function Trig_mmgpoint_Actions takes nothing returns nothing
    local real x = GetLocationX(GetSpellTargetLoc())
    local real y = GetLocationY(GetSpellTargetLoc())
    local unit dummy = null
    local unit caster = GetSpellAbilityUnit()
    local integer LoopAIndex = 1
    local integer LoopAIndexEnd = 10
    loop
        exitwhen LoopAIndex > LoopAIndexEnd

        set dummy =  CreateUnitAtLoc( GetOwningPlayer(caster), 'h005',  GetUnitLoc(caster), 0 )
        call ShowUnitHide ( dummy )
        call SetUnitInvulnerable( dummy , true )
        call SelectUnitRemoveForPlayer( dummy, GetOwningPlayer(dummy) )
        call IssuePointOrder( dummy, "shockwave", x , y )
        call PolledWait(0.1)
        call RemoveUnit( dummy )

        set LoopAIndex = LoopAIndex + 1
    endloop
    set dummy = null
endfunction

the loop is executed , i have tested this with some text displayed , the dummys are created , but the dont use the ability.
also the use of location or x and y in issuepointorder does not change anything
i dont know why and really need help here :/
 
Last edited by a moderator:
Level 12
Joined
Apr 27, 2008
Messages
1,228
There are a variety of problems I can think of:
What is the casting time of the "shockwave" spell.
What is the dummy's cast backswing.
What is the casting range of both abilities.
Also there are a number of issues in both triggers.
Do not use SelectUnitRemoveForPlayer, no one, and I do mean NO ONE is able to select a unit that fast.
Removing a hidden unit has problems, it is better if you first killed it.
But anyway you better to add a timed life: UnitApplyTimedLife(whichunit, buffID, duration)
Also:
set caster=null
 
Level 11
Joined
Apr 6, 2008
Messages
760
also

JASS:
local real x = GetLocationX(GetSpellTargetLoc())
local real y = GetLocationY(GetSpellTargetLoc())

is a leak, do instead

JASS:
local location loc = GetSpellTargetLoc()
local real x = GetLocationX(loc)
local real y = GetLocationY(loc)
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
Also you have to use this line:
call RemoveLocation(shottemp)
Inside the loop
 
Level 1
Joined
Jun 14, 2008
Messages
3
okay thank u for ur replies.

it seems like u can do pretty much wrong in a so short trigger :D

the problem was that both spells trigger with ENDCAST so the GetSpellTargetLoc didnt work :/

to ur questions:
cast time is 0
dummys castbackswing is 0
range is 500
dummys turnrate is 3

well as said problem was i triggered with endcast...
thx for the leakadvice
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Endcast should be used for channeling spells.
For normal spell start the effect of an ability(just after the casting time has finished)
 
Level 1
Joined
Jun 14, 2008
Messages
3
k i will remember that , but for the mmgfacing i had to use endcast , because if u are facing 0 and cast the triggeringspell at 180 , the unit turns and starts casting at 90, which then would be the direction in wich all the shockwaves would have been casted ... edit: well that was the first wich came to mind :D
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
If there is channeling time, use End cast.
But if there is no channeling time than end cast and starts the effect of an ability are the same.
 
Status
Not open for further replies.
Top