Smooth on the spot Jump

shiFt

Member
Reaction score
8
How would I use
Code:
SetUnitFlyHeight
in a periodic so that I can get a smooth on the spot jump, mainly just setting a units height quite high, then falling dramatically.
 

Ayanami

칼리
Reaction score
288
Well, to make it realistic, you could set the initial increase rate at the maximum rate. Then, decrease the rate as the hero jumps upwards. This way, you can stimulate "gravity".
 

shiFt

Member
Reaction score
8
So far ive got this, it looks ok and i can change the values to perfect it, however the I cant seem to find a way to turn off the periodic, or activate .destroy(), ive tried when .z is under 15 or == 0, but nothing, what is wrong.

The code is the working trigger with the troubling bits commented out.
 

Sevion

The DIY Ninja
Reaction score
413
I'm having trouble seeing what .up has to do with anything.

Your code has much bloat code.
 

Ayanami

칼리
Reaction score
288
What does .up do? o.o

And wouldn't KeyTimers2 be a better option for periodic functions with a specific interval that you want to use? Just asking.
 

shiFt

Member
Reaction score
8
I tried using .up to make the .call destroy fire, its just supoosed to record the stages of movement, 0 - cast, 1- unit moves up, 2- unit moving down, 3 -. destroy. How else do you suggest I code it?

Got it working :)
Code:
library UP requires T32,Recycle

    globals
        private constant integer SPELL_ID =  'A017'
    endglobals
    
    private struct Data
        private static thistype d
        unit cs
        unit t
        real height
        real rate
        integer lvl
        real x
        real y
        integer up
        real z
        private method onDestroy takes nothing returns nothing
            call SetUnitFlyHeight(.t, 0.,900.)
            call .stopPeriodic()
        endmethod
        
        private method periodic takes nothing returns nothing
           set .z = GetUnitFlyHeight(t)
         
           if .up == 0 then
                call SetUnitFlyHeight(.t, .z + 15.,.rate - 450.)
           endif
        
           call BJDebugMsg(R2S(.z))
           
           if .z >= 750. then
                set.up = 1
           endif
            
            if .up == 1 then
                set .z2 = GetUnitFlyHeight(t)
                call SetUnitFlyHeight(.t, .z - 15.,.rate + 550.)
            endif
            
            if .z2 <= 16.and .up == 1 then
                set.up = 2
            endif
            
            if .up ==2 then
                call .destroy()
            endif
        
        endmethod
        
        implement T32x
        
        private static method Trig_LearnUlti_Conditions takes nothing returns boolean
            return GetLearnedSkill() == SPELL_ID
        endmethod
        
        private static method act takes nothing returns boolean
            local thistype this = thistype.allocate()
            set .cs = GetTriggerUnit()
            set .t = GetSpellTargetUnit()
            set .x = GetUnitX(.t)
            set .y = GetUnitY(.t)
            set .lvl = GetUnitAbilityLevel(.cs,SPELL_ID)
            set .height = 750.
            set .rate = 12400.
            set .up = 0
            call UnitAddAbility(.t, 'A04H')
            call UnitRemoveAbility(.t, 'A04H')
            call .startPeriodic()
            return false
        endmethod
        private static method onInit takes nothing returns nothing
            call TriggerAddAction(GT_RegisterStartsEffectEvent(CreateTrigger(),SPELL_ID), function Data.act )
        endmethod
    endstruct
endlibrary
 

Sevion

The DIY Ninja
Reaction score
413
Simply use a parabolic function o_o'

y=ax^2+bx+c

Where y is Z, ax^2 is -16t^2 (gravity) + bx (jump velocity) + c (start at).

Then, if t > 0 and z <= 0 then destroy.
 

tooltiperror

Super Moderator
Reaction score
231
You know you're not using your condition, right?

And why are you using actions?
 

shiFt

Member
Reaction score
8
Sorry Sevion can you run that past me again, my maths clearly sucks.

Tooltip
I removed the conditions due to Gtrigger, but what do you mean about my actions?
 

Sevion

The DIY Ninja
Reaction score
413
y=ax^2+bx+c

That's a basic quadratic function.

It creates a curve:

url
 

tooltiperror

Super Moderator
Reaction score
231
>I removed the conditions due to Gtrigger, but what do you mean about my actions?
That's not an excuse? :p

Code:
scope KillSpell initializer onInit // requires GTrigger

	globals
		private constant integer SPELL_ID = "A000"
	endglobals
	
	private function Actions takes nothing returns nothing
		call KillUnit(GetTriggerUnit())
		return false
	endfunction

	private function onInit takes nothing returns nothing
		call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(),SPELL_ID),Condition(function Actions))
	endfunction

endscope

That's how you should be working with GTrigger.
 
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