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

Status
Not open for further replies.
Level 3
Joined
Oct 6, 2007
Messages
43
I made a basic jump spell on my map, which uses a variable to detect the jumping unit because I have an another trigger that actually MOVES the unit. But now to the thing: I got a problem that when there are 2 or more units jumping, and there is only one variable, then the other from the 2 units gets stuck in the air, how could I fix it so people can jump at same time?

Edit: Btw, how to link triggers into posts?
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Use [trigger]your trigger text here[/trigger].

About the jump, can't be done without leaking in GUI.
Im now trying to make something so I can't work on a jump yet, though my next project will probably be it, you can either learn JASS and do it yourself or ask someone else, or wait for me lol.
 
Level 3
Joined
Oct 6, 2007
Messages
43
But... I still didn't get the answer: How can I make jump spell so even 2 people can jump at same time? Because they use the same variables.
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,266
The first trigger checks jump skill and sets the value of the jumper
The second trigger makes the unit jump and is fired repeatedly


It's not a problem if you put the jumping unit into a unit group (JumperGroup = Unit Group) inside the "propulsion trigger", several units can move. Using a real global variable (Airheight[12] = Real) with 12 arrays (if 12 players), is identifying each unique jumping units height at every 0.05 seconds (Jumper[12] = unit). Don't forget the jump distance real variable (JumpLength[12] = real ; distance between Target point and Jumper when casting / 2); this value is also using the same arrays inside the formula, so each jumper uses the same formula. each time jumper is "jumping", a jump formula should . If it reaches pretty low height, instantly put the jumping units height to 0 and remove the jumper from the unit group + nulling his attached variables.

Arrays could be used to identify the player number. This works ONLY if each player only controls 1 jumper each.


My high jumping formula is like this: Maybe a bit extremely high height level with this, but it can be adjusted.


Code:
Set Airheight [x] = (Airheight [x] + (12.00 + (0.05 x JumpLength [x])))

condition check: jumplength [x] has a negative value, then ->

Set Airheight [x] = (Airheight [x] + (-12.00 + (0.05 x JumpLength [x])))
This works as a jump curve , when the jumplength gets a negative value


This way the GUI jump trigger should be non-leaking. I'm currently using 2 seperated jump triggers, so I haven't had time to try my current suggestion to check if my theory is correct. Correct me if I'm wrong about this!


I'm considering making projectiles this way which might hit flyers in about same height. Like in the cool wc3 map Combat Zone 1.7


___________________
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
USE UNIT GROUPS NOT UNIT VARIABLES
first trigger adds and removes from group
second one moves the group to their facing
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I made this jump code, it isn't really a good one but it works, so if you want it, here's the code

JASS:
//****************************************************************************************
//               Arc movement
//  Usage: call arcmovement(whichUnit,speed,heightspeed,distance)
//
// Example: "Custom script: call arcmovement(MyUnit,10,10,5)"
//
// PUT ME IN YOUR MAP HEADER !
//

function arc takes nothing returns nothing
       local timer t = GetExpiredTimer()
       local unit whichUnit = GetHandleUnit(t, "whichUnit")
       local real speed = GetHandleReal(t, "speed")
       local real heightspeed = GetHandleReal(t, "heightspeed")
       local real startspeed = GetHandleReal(t, "startspeed")
       local real distance = GetHandleReal(t, "distance")
       local integer i = GetHandleInt(t, "i")
       local real a = GetUnitFacing(whichUnit) * bj_DEGTORAD
       local real x = GetUnitX(whichUnit) + speed * Cos(a)
       local real y = GetUnitY(whichUnit) + speed * Sin(a)
       local real z 
       local location l = GetUnitLoc(whichUnit)
       local real lz = GetLocationZ(l)
       local location nextl = Location(x,y)
       local real nextlz = GetLocationZ(nextl)
       if lz != nextlz then
             set lz = lz-nextlz
             call SetUnitFlyHeight(whichUnit, lz, 1000000)
       endif
       set heightspeed = startspeed-i*distance
       set z = GetUnitFlyHeight(whichUnit) + heightspeed
       if startspeed+heightspeed == 0 then
            call FlushHandleLocals(t)
            call DestroyTimer(t)
       else
            call SetHandleInt(t, "i", i + 1) 
            call SetHandleReal(t, "hieghtspeed", heightspeed)
            call SetUnitPosition(whichUnit, x, y)
            call SetUnitFlyHeight(whichUnit, z, 1000000)    
       endif 
       set whichUnit = null
       set t = null  
       call RemoveLocation(l)
       set l = null
endfunction            
function arcmovement takes unit whichUnit, real speed, real heightspeed, real distance returns nothing
       local timer t = CreateTimer()
       local integer i = 0
       local real startspeed = speed
       call SetHandleReal(t, "distance", distance)
       call SetHandleReal(t, "startspeed", startspeed)
       call SetHandleInt(t, "i", i)
       call SetHandleHandle(t, "whichUnit", whichUnit)
       call SetHandleReal(t, "speed", speed)
       call SetHandleReal(t, "heightspeed", heightspeed)
       call TimerStart(t, 0.02, true, function arc)
       set t = null    
endfunction
 
Status
Not open for further replies.
Top