Portal Targeting Point

Jonnycakes

New Member
Reaction score
6
Hi, I am trying to make scroll of town portal item that can target any point on the map. Since both scroll of town portal and staff of teleportation must target units, I used channel as a dummy spell and added effects to it. I am having trouble with the triggers that move the unit, though. I have a couple of questions...

Is there a way to get the spell target of a channeled spell in a trigger whose event is EVENT_PLAYER_UNIT_SPELL_FINISH or EVENT_PLAYER_UNIT_SPELL_ENDCAST? I have tried, and the trigger just moves the unit to the center of the map by default.

I want the portal ability to be interrupted by stuns and the like, so that is why I have a trigger that runs upon finishing. For the special effect, I have a trigger that runs when the spell starts channeling, waits a couple seconds, then creates the special effects. I would like these to stop if the unit is stunned, too. Is there a cleaner way to structure these triggers?

Here are the triggers I'm using:
JASS:
scope portaleffect initializer init


private function conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A010'
endfunction


private function actions takes nothing returns nothing

    local unit u=GetTriggerUnit()
    local real x=GetUnitX(u)
    local real y=GetUnitY(u)
    local location l=GetSpellTargetLoc()
    
    call TriggerSleepAction(2.7)
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl", x, y))
    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl", l))
    call RemoveLocation(l)
    set l=null
    set u=null
    
endfunction

//===========================================================================
private function init takes nothing returns nothing
    local trigger t=CreateTrigger()
    local integer i=0
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set i=i+1
        exitwhen i==8
    endloop
    call TriggerAddCondition(t, Condition(function conditions))
    call TriggerAddAction(t, function actions)
endfunction


endscope



scope portalwarp initializer init


private function conditions takes nothing returns boolean

    return GetSpellAbilityId()=='A010'
    
endfunction


private function actions takes nothing returns nothing

    local unit u=GetTriggerUnit()
    local location l=GetSpellTargetLoc()
    call SetUnitPositionLoc(u, l)
    call RemoveLocation(l)
    set l=null
    set u=null
    
endfunction

//===========================================================================
private function init takes nothing returns nothing
    local trigger t=CreateTrigger()
    local integer i=0
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_FINISH, null)
        set i=i+1
        exitwhen i==8
    endloop
    call TriggerAddCondition(t, Condition(function conditions))
    call TriggerAddAction(t, function actions)
endfunction


endscope
 

Laiev

Hey Listen!!
Reaction score
188
wrong place D: use the jass category to post, I'll review the code and will edit here or post another post if someone has posted :p

EDIT: the move to the center of the map is probably because the [ljass]local location l=GetSpellTargetLoc()[/ljass] don't got a target, the ability FINISH, when you finish we don't got a target

how to fix?

global (don't will be MUI) or struct with timer (will)

also i suggest you use the TimerUtils with Struct :)
 

Jonnycakes

New Member
Reaction score
6
Oops, how embarrassing...I initially was thinking it was something with the object editor that I needed to mess with, but then I decided to post my trigger somewhere along the line. Ah well, I was hoping I didn't have to do anything messy with structs, but I guess it will have to come to that. Thanks!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top