• 🏆 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!

jump spell

Status
Not open for further replies.
Level 8
Joined
Jul 25, 2009
Messages
194
JASS:
scope TestProjectiles initializer init

globals
    private location loc = Location(0, 0)
    
endglobals

public function jumpfilter takes nothing returns boolean
    return GetSpellAbilityId()=='A0H9'
endfunction
public function jumpmain takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real xA = GetUnitX(caster)
    local real yA = GetUnitY(caster)
    local real xB = GetSpellTargetX()
    local real yB = GetSpellTargetY()
    local vector vA
    local vector vB
    local projectile p
    
    call IssuePointOrder(caster, "move", xB, yB)
    
    call MoveLocation(loc, xA, yA)
    set vA = vector.create(xA, yA, GetLocationZ(loc)+GetUnitFlyHeight(caster))
    call MoveLocation(loc, xB, yB)
    set vB = vector.create(xB, yB, GetLocationZ(loc))
    
    set p = projectile.create(caster)
    call p.launch(vA, vB, 600, 0.4)
    set p.activePitch           = false
    set p.activeRotation        = true
    set p.activeUnitCollision   = false
    set p.toKill                = false
    
    call vA.destroy()
    call vB.destroy()
    set caster = null
endfunction


public function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local trigger jump = CreateTrigger()
    local timer h = NewTimer()
    
    call TriggerRegisterPlayerUnitEvent(jump, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
    call TriggerAddCondition(jump, Filter(function jumpfilter))
    call TriggerAddAction(jump, function jumpmain) 
    
endfunction    

endscope

hey this is a jump spell from berb's projectile map.
is there any way of making this jump spell work for all players with only 1 trigger?
I got it to work but i had to make 12 seperate triggers since i dont know any jass
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
It alredy works for any amount of units and players, there's no need to create more. You just need to replace the "return GetSpellAbilityId()=='A0H9'" with the custom Id of your Jump ability.
 
Level 8
Joined
Jul 25, 2009
Messages
194
so.. is player(0) supposed to be all players?
for some reason player(0) is actually player(1).

anyways figured it out.
just had to add
JASS:
call TriggerRegisterPlayerUnitEvent(jump, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
for players 0-11

turns out this was a stupid question hehe
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ooooooooh, see there:
JASS:
call TriggerRegisterPlayerUnitEvent(jump, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
// TriggerRegisterPlayerUnitEvent is the "A unit owned by player X" generic event.

1. Create a trigger
2. Add the event "A unit starts the effect of an ability"
3. Convert it to custom text
4. Look there for the trigger event, that should contain this "EVENT_PLAYER_UNIT_SPELL_EFFECT"
5. Replace the "call TriggerRegisterPlayerUnitEvent(jump, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)" with the jass equivalent of the "A unit starts the effect of an ability" which is the one we need.
6. Delete the other trigger, which was just to know how "A unit starts the effect of an ability" was written in JASS
 
Status
Not open for further replies.
Top