• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

need a spell like this

Status
Not open for further replies.
Level 6
Joined
Jul 21, 2011
Messages
139
its a target ground spell
it must be MUI

you target somewhere
a invisible dummy will go there 65 range at a time on 0.03 periodic
when the dummy reaches the location the caster gets teleported there

thanks to whoever takes the time, i really cant get it done myself, the break that i took from the world editor hasnt been too kind on my brain
 
Level 21
Joined
Nov 4, 2013
Messages
2,016
You should create two triggers, Cast Spell and Move Dummy. Move Dummy should not be initially on. Create a unit variable called Caster and another one called Dummy. Finally, create a point variable called CastPoint

  • Cast Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (Your skill)
    • Actions
      • Set Caster = (Casting Unit)
      • Set CastPoint = (Target point of ability being cast)
      • Unit - Create a Dummy for (Owner of Caster) at (Position of Caster) facing CastPoint
      • Set Dummy = (Last created unit)
      • Trigger - Turn on Move Dummy <gen>
  • Move Dummy
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
      • (Distance between (Position of Dummy) and CastPoint Greater than 65.00)
    • Actions
      • Unit - Move Dummy instantly to ((Position of Dummy) offset by 65.00 towards (Facing of Dummy) degrees
      • Wait until ((Distance between (Position of Dummy) and CastPoint Less than or equal to 65.00), checking every 0.10 seconds
      • Unit - Move Caster instantly to (Position of Dummy)
      • Trigger - Turn off (This Trigger)
These are the main triggers, it's up to you to make them leakless (I'm not really good at doing that).
 
caleman, this should be posted in request section next time.
You have an idea, but you don't have any approach and clearly
say that you want someone to create it for you.
It is a request.

Shadow Fury, sorry, but your approach is just not acceptable.
The approach with this usage of "Wait" is false and horrible.
The concept is not MUI. He clearly wants the spell to be MUI.

I don't say this to blame you, but to warn caleman not to do it like this.
 
Level 21
Joined
Nov 4, 2013
Messages
2,016
caleman, this should be posted in request section next time.
You have an idea, but you don't have any approach and clearly
say that you want someone to create it for you.
It is a request.

Shadow Fury, sorry, but your approach is just not acceptable.
The approach with this usage of "Wait" is false and horrible.
The concept is not MUI. He clearly wants the spell to be MUI.

I don't say this to blame you, but to warn caleman not to do it like this.

I'm not really pro about such stuff but as long as it works and doesn't lag, it's fine for me.
 
ShadowFury
Dummy is a global variable, thus overridden if two caster casts it.
This breaks the spell directly, since the earlier casts will be broken (the effect of teleport never applies) and the last one is the only one which works.
I suggest checking Tutorial Section for Dynamic Indexing and Hashtables, and perhaps check Unit Indexers as well.

caleman
Try using blink? A little math should do ^^
 
It should work. I didn't test that but I'm pretty confident. Otherwise, what's wrong? (I might improve if you tell me xD)

There is only one CastPoint that is shared across the map.

As soon as another instance acquires the critical section the variable will be changed and the first instance will fail to execute.

Edit: Here's my implementation, haven't tested it. vJass. Requires DummyUnitStack and RegisterAnyUnitEvent.

JASS:
scope DelayedTeleport initializer init
    private struct DummyDat
        real delX
        real delY
        real distLeft
        unit dummy
        unit caster
    endstruct

    globals
        // raw code of the ability cast
        private constant integer DELAY_TELEPORT_ID = 'A000'

        // how far the projectile should start, offset from the caster
        private constant real OFFSET = 64.

        // specification calls for 100/3 frames per second
        private constant real CLOCK_PERIOD = .03

        // specification calls for 65 units per 0.03 seconds, but velocities
        // should be in units per second - this does both
        private constant real VELOCITY = 65. / CLOCK_PERIOD

        // stack variables
        private DummyDat array stack
        private integer stackIndex = -1

        // static timer
        private timer clock = CreateTimer()
    endglobals

    private function periodic takes nothing returns nothing
        local DummyDat d
        local integer index = 0
        local real dumX
        local real dumY

        loop
            exitwhen index > stackIndex
            set d = stack[index]

            set dumX = GetUnitX(d.dummy)
            set dumY = GetUnitY(d.dummy)

            call SetUnitX(d.dummy, dumX + d.delX)
            call SetUnitY(d.dummy, dumY + d.delY)

            set d.distLeft = d.distLeft - VELOCITY * CLOCK_PERIOD

            // re-use OFFSET value as a collision buffer because why not
            if d.distLeft <= OFFSET then
                call DummyUnitStack.release(d.dummy)
                call SetUnitX(d.caster, dumX)
                call SetUnitY(d.caster, dumY)

                // now de-index the instance
                call d.destroy()
                set stack[index] = stack[stackIndex]
                set index = index - 1
                set stackIndex = stackIndex - 1

                // check for termination
                if stackIndex == -1 then
                    call PauseTimer(clock)
                endif
            endif

            set index = index + 1
        endloop
    endfunction

    private function act takes nothing returns nothing
        local DummyDat d
        local real targetX
        local real targetY
        local real ang
        local real uX
        local real uY

        if GetSpellAbilityId() == DELAY_TELEPORT_ID then
            set targetX = GetSpellTargetX()
            set targetY = GetSpellTargetY()
            
            set d = DummyDat.create()
            set d.dummy = DummyUnitStack.get()
            set d.caster = GetTriggerUnit()

            set uX = GetUnitX(d.caster)
            set uY = GetUnitY(d.caster)
            set ang = Atan2(targetY - uY, targetX - uX)

            call SetUnitX(d.dummy, uX + OFFSET * Cos(ang))
            call SetUnitY(d.dummy, uY + OFFSET * Sin(ang))

            set d.delX = VELOCITY * CLOCK_PERIOD * Cos(ang)
            set d.delY = VELOCITY * CLOCK_PERIOD * Sin(ang)

            set d.distLeft = SquareRoot((targetX - uX) * (targetX - uX) + (targetY - uY) * (targetY - uY)) - OFFSET

            set stackIndex = stackIndex + 1
            set stack[stackIndex] = d
            if stackIndex == 0 then
                call TimerStart(clock, CLOCK_PERIOD, true, function periodic)
            endif
        endif
    endfunction

    private function init takes nothing returns nothing
        call RegisterAnyUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, function act)
    endfunction
endscope
 
Last edited:
Status
Not open for further replies.
Top