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

[vJass] Velocty System + Jump

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: 88WaRCraFT3
Features
  • Coded in vJass
  • MUI
  • Performance-wise operations
  • 3D movement with support for terrain deformation
  • Etc.



Requires
  • Table2 by Vercas (ME!)
  • TerrainPathability by Rising_Dusk

Documentation found in the map...

JASS:
/*-----------------------------------------------------------------------------------*\
|                               Simple Velocity System                                |
|                           by Vercas                                                 |
|                       requires: - TerrainPathability                                |
|                                   by Rising_Dusk                                    |
|                                 - Table2                                            |
|                                   by Vercas (me)                                    |
|                                                                                     |
|       This is meant to be a simple velocity system for other people to use in their |
|   systems or just to knock the hell out of units!                                   |
|                                                                                     |
|                                                                                     |
|   Application Programming Interface (API):                                          |
|                                                                                     |
|       Vel.add( unit, x, y, z ) -> nothing                                           |
|           This sets a unit's velocity to your given values DIVIDED BY 20!!          |
|                                                         For safety reasons!         |
|       Vel.addAng( unit, ground angle, air angle, distance ) -> nothing              |
|           This calculates and sets the unit's velocity to the given values.         |
|               This is a 3D polar projection formula, and I hope you understand it!  |
\*-----------------------------------------------------------------------------------*/
/**/library Velocity initializer Init requires TerrainPathability, Table2/***********/
    
    struct Vel
      
        static constant real    INTERVAL      = 0.01 //100 times per second.
        static constant real    REDUCTION     = 0.03 //3%
        
        static constant boolean ADD_CROW_FORM = true //To enable Z-axis velocity!
      
        static handle_real_Table x
        static handle_real_Table y
        static handle_real_Table z
        
        static trigger engine = CreateTrigger ( )
        static group   flyers = CreateGroup   ( )
        
        static location L = Location          ( 0, 0 )
        
        static method set takes unit u, real a, real b, real c returns nothing
        
            set Vel.x[u] = a / 20
            set Vel.y[u] = b / 20
            set Vel.z[u] = c / 20
            
        endmethod
        
        static method add takes unit u, real a, real b, real c returns nothing
        
            set Vel.x[u] = Vel.x[u] + a / 20
            set Vel.y[u] = Vel.y[u] + b / 20
            set Vel.z[u] = Vel.z[u] + c / 20
            
        endmethod
        
        static method setAng takes unit u, real yaw, real pitch, real distance returns nothing
        
            local real ld = distance  * Cos   ( pitch * bj_DEGTORAD )
            local real lz = distance  * Sin   ( pitch * bj_DEGTORAD )
            local real lx =    ld     * Cos   (  yaw  * bj_DEGTORAD )
            local real ly =    ld     * Sin   (  yaw  * bj_DEGTORAD )
            
            set Vel.x[u]  = lx
            set Vel.y[u]  = ly
            set Vel.z[u]  = lz
            
        endmethod
        
        static method addAng takes unit u, real yaw, real pitch, real distance returns nothing
        
            local real ld = distance  * Cos   ( pitch * bj_DEGTORAD )
            local real lz = distance  * Sin   ( pitch * bj_DEGTORAD )
            local real lx =    ld     * Cos   (  yaw  * bj_DEGTORAD )
            local real ly =    ld     * Sin   (  yaw  * bj_DEGTORAD )
            
            set Vel.x[u]  = Vel.x[u] + lx
            set Vel.y[u]  = Vel.y[u] + ly
            set Vel.z[u]  = Vel.z[u] + lz
            
        endmethod
        
        
        private static method Throw takes nothing returns nothing
        
            local unit u   = GetEnumUnit      ( )
            
            local real ux  = GetUnitX         ( u )
            local real uy  = GetUnitY         ( u )
            local real uz  = GetUnitFlyHeight ( u )
            
            local real vx  = Vel.x[u]
            local real vy  = Vel.y[u]
            local real vz  = Vel.z[u]
            
            local real tx  = ux + vx
            local real ty  = uy + vy
            local real tz 
            
            local real red = 1. - Vel.REDUCTION
            
            if IsTerrainWalkable              ( tx, uy ) then
            
                call SetUnitX                 ( u, tx )
                
            endif
            
            if IsTerrainWalkable              ( ux, ty ) then
            
                call SetUnitY                 ( u, ty )
                
            endif
            
            if vz > 1. then
            
                call MoveLocation             ( Vel.L, GetUnitX( u ), GetUnitY( u ) )
                set tz = uz+vz-GetLocationZ   ( Vel.L         )
                call MoveLocation             ( Vel.L, ux, uy )
                set tz = tz   +GetLocationZ   ( Vel.L         )
                call SetUnitFlyHeight         ( u    , tz, 0. )
                set Vel.z[u] = vz * red
                
            elseif vz > 0.01 then
            
                set Vel.z[u] = -0.1
                
            elseif vz < 0. and uz > 0. then
            
                set vz = vz * ( 1.0 + Vel.REDUCTION )
                
                if uz > vz then
                
                    call SetUnitFlyHeight     ( u, uz + vz, 0. )
                    
                else
                
                    call SetUnitFlyHeight     ( u, 0.     , 0. )
                    set vz = 0.
                    
                endif
                
                set Vel.z[u] = vz
                
            endif
                
            
            if -0.5 < vx and vx < 0.5 then
            
                set Vel.x[u] = 0.
                
            else
            
                set Vel.x[u] = vx * red
                
            endif
            
            if -0.5 < vy and vy < 0.5 then
            
                set Vel.y[u] = 0.
                
            else
            
                set Vel.y[u] = vy * red
                
            endif
            
            set u = null
            
        endmethod
        
        private static method Check takes nothing returns boolean
        
            local unit u    = GetFilterUnit   ( )
            
            local boolean b = ( Vel.x[u] != 0. or Vel.y[u] != 0. or Vel.z[u] != 0. )
            
            set u = null
            
            return b
            
        endmethod
        
        private static method Prepare takes nothing returns nothing
            
            call GroupClear                   ( Vel.flyers )
            call GroupEnumUnitsInRect         ( Vel.flyers, bj_mapInitialPlayableArea, Condition( function Vel.Check ) )
            call ForGroup                     ( Vel.flyers, function Vel.Throw )
            
        endmethod
        
        static method setup takes nothing returns nothing
        
            set .x = handle_real_Table.create ( )
            set .y = handle_real_Table.create ( )
            set .z = handle_real_Table.create ( )
            
            call TriggerRegisterTimerEvent    ( Vel.engine, Vel.INTERVAL, true )
            call TriggerAddAction             ( Vel.engine, function Vel.Prepare )
            
        endmethod
        
    endstruct
    
    
    
    private function AddCrow takes nothing returns nothing
    
        local unit u = GetTriggerUnit         ( )
        
        call UnitAddAbility                   ( u, 'Amrf' )
        call UnitRemoveAbility                ( u, 'Amrf' )
        
        set u        = null
        
    endfunction
    
    private function Cond takes nothing returns boolean
    
        return GetUnitAbilityLevel            ( GetFilterUnit( ), 'Amrf' ) == 0
        
    endfunction
    
    private function Init takes nothing returns nothing
        
        local trigger t = CreateTrigger       ( )
        local region  r = CreateRegion        ( )
        
        if Vel.ADD_CROW_FORM then
            
            call RegionAddRect                    ( r, GetWorldBounds( ) )
            
            call TriggerRegisterEnterRegion       ( t, r, Condition( function Cond ) )
            call TriggerAddAction                 ( t, function AddCrow )
            
        endif
    
        call Vel.setup                        ( )
        
        set t           = null
        set r           = null
        
    endfunction
    
endlibrary

Please give credits if you use this sytem ( Velocity System ) and/or Table2 in your map!

Keywords:
vel, velocity, system, vercas, jump, fly, up, high, in, the, air, mumbo, jumbo, acceleration, gravity, magnet,
Contents

Just another Warcraft III map (Map)

Reviews
20:27, 13th Nov 2015 BPower: No update done in years. Rejected. 12:40, 30th Mar 2010 The_Reborn_Devil: Hmm.. The jump doesn't look very realistic and I found a bug. When the unit stops moving forward while jumping you can walk in the air until...

Moderator

M

Moderator

20:27, 13th Nov 2015
BPower: No update done in years. Rejected.

12:40, 30th Mar 2010
The_Reborn_Devil:
Hmm.. The jump doesn't look very realistic and I found a bug. When the unit stops moving forward while jumping you can walk in the air until it falls down. Also, you should use radians and not degrees when using Cos, Sin and the like.


Status: Rejected until updated
Rating: N/A

PM me or another mod once you've fixed this to get it reviewed again. Have a nice day!
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
Please download, try it, comment about and rate it!

P.S. This is a submission dedicated to 88WaRCraFT3's project!

Please test the system's behaviour with terrain deformations!
Please help me improve the system!

I am now working in improving my other submitted system...
 
A few things:
JASS:
    private function Init takes nothing returns nothing      
        local trigger t = CreateTrigger       ( )
        local region  r = CreateRegion        ( )    
    endfunction

Needs nulling.
JASS:
    private function Init takes nothing returns nothing
        
        local trigger t = CreateTrigger       ( )
        local region  r = CreateRegion        ( )
        
        if Vel.ADD_CROW_FORM then
            
            call RegionAddRect                    ( r, GetWorldBounds( ) )
            
            call TriggerRegisterEnterRegion       ( t, r, Condition( function Cond ) )
            call TriggerAddAction                 ( t, function AddCrow )
            
        endif
    
        call Vel.setup                        ( )

        set t = null
        set r = null
    endfunction

Also:
JASS:
    private function AddCrow takes nothing returns nothing
    
        local unit u = GetTriggerUnit         ( )
        
        call UnitAddAbility                   ( u, 'Amrf' )
        call UnitRemoveAbility                ( u, 'Amrf' )
        
    endfunction
Needs a null as well:
JASS:
    private function AddCrow takes nothing returns nothing
    
        local unit u = GetTriggerUnit         ( )
        
        call UnitAddAbility                   ( u, 'Amrf' )
        call UnitRemoveAbility                ( u, 'Amrf' )

        set u = null      
    endfunction

Those were just minor. Now we get to the slightly minor somewhat normal parts:
JASS:
        static method Prepare takes nothing returns nothing
        
            local group g    = CreateGroup    ( )
            local boolexpr c = Condition      ( function Vel.Check )
            
            call GroupEnumUnitsInRect         ( g, bj_mapInitialPlayableArea, c )
            call DestroyBoolExpr              ( c )
            call ForGroup                     ( g, function Vel.Throw )
            call DestroyGroup                 ( g )
            
            set g            = null
            
        endmethod

First, boolexprs don't need to be destroyed. If I recall correctly, CaptainGriffen stated it was dangerous to do so. Boolexprs are recycled automatically so it doesn't leak if you leave one undestroyed.

DestroyGroup(g) leaks a bit of RAM when an enumeration was called for. To fix this, you should instead use a global group, and merge the filter and the function Vel.Throw and return false.
JASS:
    globals
        private group Vg = CreateGroup()
    endglobals
JASS:
        static method Check takes nothing returns boolean
            local unit u = GetFilterUnit()
            
            local real ux
            local real uy 
            local real uz 
            
            local real vx 
            local real vy 
            local real vz 
            
            local real tx
            local real ty 
            local real tz 
            
            local real red = 1. - Vel.REDUCTION
            
            if Vel.x[u] != 0. or Vel.y[u] != 0. or Vel.z[u] != 0. then
                set ux  = GetUnitX         ( u )
                set uy  = GetUnitY         ( u )
                set uz  = GetUnitFlyHeight ( u )
            
                set vx  = Vel.x[u]
                set vy  = Vel.y[u]
                set vz  = Vel.z[u]
            
                set = ux + vx
                set = uy + vy
                //I do these calculations/functions inside the block so 
                // that it won't bother to calculate if the condition isn't met.
            
                set = 1. - Vel.REDUCTION
            
                //if IsTerrainWalkable              ( tx, ty ) then
                //    call SetUnitX                 ( u, tx )
                //    call SetUnitY                 ( u, ty )
            
                if IsTerrainWalkable              ( tx, uy ) then
            
                    call SetUnitX                 ( u, tx )
                
                endif
            
                if IsTerrainWalkable              ( ux, ty ) then
            
                    call SetUnitY                 ( u, ty )
                
                endif
            
                if vz > 1. then
            
                    call MoveLocation             ( Vel.L, ux, uy )
                    set tz = uz+vz-GetLocationZ   ( Vel.L         )
                    call MoveLocation             ( Vel.L, ux, uy )
                    set tz = tz  + GetLocationZ   ( Vel.L         )
                    call SetUnitFlyHeight         ( u    , tz, 0. )
                    set Vel.z[u] = vz * red
                
                elseif vz > 0.01 then
            
                    set Vel.z[u] = -0.1
                
                elseif vz < 0 and uz > 0 then
            
                    set vz = vz * ( 1.0 + ( 2 * Vel.REDUCTION ) )
                
                    if uz > vz then
                
                        call SetUnitFlyHeight     ( u, uz + vz, 0. )
                    
                    else
                
                        call SetUnitFlyHeight     ( u, 0.     , 0. )
                        set vz = 0.
                        
                    endif
                
                    set Vel.z[u] = vz
                
                endif
                
            
                if -0.5 < vx and vx < 0.5 then
            
                    set Vel.x[u] = 0.
                
                else
            
                    set Vel.x[u] = vx * red
                
                endif
            
                if -0.5 < vy and vy < 0.5 then
            
                    set Vel.y[u] = 0.
                
                else
            
                    set Vel.y[u] = vy * red
                
                endif
            endif

        set u = null 

        return false

        endmethod
JASS:
        static method Prepare takes nothing returns nothing

            call GroupEnumUnitsInRect         ( Vg, bj_mapInitialPlayableArea, Condition( function Vel.Check ) )

        endmethod

Also, why not use:
JASS:
            //if IsTerrainWalkable              ( tx, ty ) then
            //    call SetUnitX                 ( u, tx )
            //    call SetUnitY                 ( u, ty )

Instead of the other part? It seems like you check if the tar x with the unit's y is pathable and you check if the unit's x with the tar y is pathable.

Otherwise, nice job on the system. It is short, sweet, and simple to use. =)
 
Level 14
Joined
Nov 18, 2007
Messages
816
  • Use struct instances instead of hashtables. You wont ever reach 8190 units in your map. Use AutoIndex to associate a low integer to every unit. You can then also drop the requirement of Table2.
  • Use meaningful variable names. a, b and c are random characters which carry no meaning whatsoever.
  • Use the private keyword to prevent users from calling Vel.Throw() (and other internal methods).
  • Your add methods should actually be named set, since you dont add to the units current speed.
  • The add crow functionality is a completely separate task, so please keep it inside its own library. Also, there are already multiple scripts that do such a thing.
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
Thanks vercas. I will use it. +rep. Can you show me where will i change the distance that will unit travel and how much is flying height?
and can you make jump like on this picture View attachment 78244
I have voted for approve and rate it by 5/5

Thanks for your rating and approval, and please look at my jump trigger.
It jumps -forward- at a 40 degrees (i don't remember exactly) angle in the air, by an innitial force of 10 (units).

Just adjust the variables by your needs.

The third value in Vel.addAng is the pitch (the jumping angle) which determines the height.

A few things:
JASS:
    private function Init takes nothing returns nothing      
        local trigger t = CreateTrigger       ( )
        local region  r = CreateRegion        ( )    
    endfunction

Needs nulling.
JASS:
    private function Init takes nothing returns nothing
        
        local trigger t = CreateTrigger       ( )
        local region  r = CreateRegion        ( )
        
        if Vel.ADD_CROW_FORM then
            
            call RegionAddRect                    ( r, GetWorldBounds( ) )
            
            call TriggerRegisterEnterRegion       ( t, r, Condition( function Cond ) )
            call TriggerAddAction                 ( t, function AddCrow )
            
        endif
    
        call Vel.setup                        ( )

        set t = null
        set r = null
    endfunction

Also:
JASS:
    private function AddCrow takes nothing returns nothing
    
        local unit u = GetTriggerUnit         ( )
        
        call UnitAddAbility                   ( u, 'Amrf' )
        call UnitRemoveAbility                ( u, 'Amrf' )
        
    endfunction
Needs a null as well:
JASS:
    private function AddCrow takes nothing returns nothing
    
        local unit u = GetTriggerUnit         ( )
        
        call UnitAddAbility                   ( u, 'Amrf' )
        call UnitRemoveAbility                ( u, 'Amrf' )

        set u = null      
    endfunction

Those were just minor. Now we get to the slightly minor somewhat normal parts:
JASS:
        static method Prepare takes nothing returns nothing
        
            local group g    = CreateGroup    ( )
            local boolexpr c = Condition      ( function Vel.Check )
            
            call GroupEnumUnitsInRect         ( g, bj_mapInitialPlayableArea, c )
            call DestroyBoolExpr              ( c )
            call ForGroup                     ( g, function Vel.Throw )
            call DestroyGroup                 ( g )
            
            set g            = null
            
        endmethod

First, boolexprs don't need to be destroyed. If I recall correctly, CaptainGriffen stated it was dangerous to do so. Boolexprs are recycled automatically so it doesn't leak if you leave one undestroyed.

DestroyGroup(g) leaks a bit of RAM when an enumeration was called for. To fix this, you should instead use a global group, and merge the filter and the function Vel.Throw and return false.
JASS:
    globals
        private group Vg = CreateGroup()
    endglobals
JASS:
        static method Check takes nothing returns boolean
            local unit u = GetFilterUnit()
            
            local real ux
            local real uy 
            local real uz 
            
            local real vx 
            local real vy 
            local real vz 
            
            local real tx
            local real ty 
            local real tz 
            
            local real red = 1. - Vel.REDUCTION
            
            if Vel.x[u] != 0. or Vel.y[u] != 0. or Vel.z[u] != 0. then
                set ux  = GetUnitX         ( u )
                set uy  = GetUnitY         ( u )
                set uz  = GetUnitFlyHeight ( u )
            
                set vx  = Vel.x[u]
                set vy  = Vel.y[u]
                set vz  = Vel.z[u]
            
                set = ux + vx
                set = uy + vy
                //I do these calculations/functions inside the block so 
                // that it won't bother to calculate if the condition isn't met.
            
                set = 1. - Vel.REDUCTION
            
                //if IsTerrainWalkable              ( tx, ty ) then
                //    call SetUnitX                 ( u, tx )
                //    call SetUnitY                 ( u, ty )
            
                if IsTerrainWalkable              ( tx, uy ) then
            
                    call SetUnitX                 ( u, tx )
                
                endif
            
                if IsTerrainWalkable              ( ux, ty ) then
            
                    call SetUnitY                 ( u, ty )
                
                endif
            
                if vz > 1. then
            
                    call MoveLocation             ( Vel.L, ux, uy )
                    set tz = uz+vz-GetLocationZ   ( Vel.L         )
                    call MoveLocation             ( Vel.L, ux, uy )
                    set tz = tz  + GetLocationZ   ( Vel.L         )
                    call SetUnitFlyHeight         ( u    , tz, 0. )
                    set Vel.z[u] = vz * red
                
                elseif vz > 0.01 then
            
                    set Vel.z[u] = -0.1
                
                elseif vz < 0 and uz > 0 then
            
                    set vz = vz * ( 1.0 + ( 2 * Vel.REDUCTION ) )
                
                    if uz > vz then
                
                        call SetUnitFlyHeight     ( u, uz + vz, 0. )
                    
                    else
                
                        call SetUnitFlyHeight     ( u, 0.     , 0. )
                        set vz = 0.
                        
                    endif
                
                    set Vel.z[u] = vz
                
                endif
                
            
                if -0.5 < vx and vx < 0.5 then
            
                    set Vel.x[u] = 0.
                
                else
            
                    set Vel.x[u] = vx * red
                
                endif
            
                if -0.5 < vy and vy < 0.5 then
            
                    set Vel.y[u] = 0.
                
                else
            
                    set Vel.y[u] = vy * red
                
                endif
            endif

        set u = null 

        return false

        endmethod
JASS:
        static method Prepare takes nothing returns nothing

            call GroupEnumUnitsInRect         ( Vg, bj_mapInitialPlayableArea, Condition( function Vel.Check ) )

        endmethod

Also, why not use:
JASS:
            //if IsTerrainWalkable              ( tx, ty ) then
            //    call SetUnitX                 ( u, tx )
            //    call SetUnitY                 ( u, ty )

Instead of the other part? It seems like you check if the tar x with the unit's y is pathable and you check if the unit's x with the tar y is pathable.

Otherwise, nice job on the system. It is short, sweet, and simple to use. =)

I will null the variables
and...
If the unit's target X is blocked but the target Y is not, why not move it to the target Y?

It checks if it can move the units on both X and Y.

Gief info what the heck the systems do, I don't care in which language is coded...

You basically throw units!

  • Use struct instances instead of hashtables. You wont ever reach 8190 units in your map. Use AutoIndex to associate a low integer to every unit. You can then also drop the requirement of Table2.
  • Use meaningful variable names. a, b and c are random characters which carry no meaning whatsoever.
  • Use the private keyword to prevent users from calling Vel.Throw() (and other internal methods).
  • Your add methods should actually be named set, since you dont add to the units current speed.
  • The add crow functionality is a completely separate task, so please keep it inside its own library. Also, there are already multiple scripts that do such a thing.

  • No.
  • I was in a hurry...
  • Again, I forgot about that because I was in a hurry
  • You're right, I will make both add and set
  • No. There's a boolean for that...

One such example for is AutoFly.

I prefere my own... Always.

I really forgot to mention that this system automatically takes care of units landing, and the speed is quite high, like in the real world ~9.8 m/s! But thisone slowly accelerates.
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
Ahh, I can do a little trick about it...
Please note that this system is supposed to move a unit IN A STRAIGHT LINE in a 3D space!

Anyway, use this trick:
JASS:
    call Vel.addAng( GetTriggerUnit( ), GetUnitFacing( GetTriggerUnit( ) ), 0., 10. ) // DO NOT USE HIGHER VALUES!
    call Vel.add( GetTriggerUnit( ), 0., 0., 2. )
 
Level 13
Joined
Mar 16, 2008
Messages
941
He was right; all local handle variables must be nulled at the end of the trigger.
They leak.

Wrong :D There is nothing that could be called a leak.
The rason for nulling is the handle id of an object. Each object has it's own, end for example, if a trigger gets destroyed this id could get recycled, however, not doing this only results in higher handle-ids and a VERY low memory increasage (should be the value of an integer, so 4 bytes, not sure about this). If handles NEVER get destroyed you don't have to null them, so for example, timers from TimerUtils, players (they're handles too!) or triggers.
 
Wrong :D There is nothing that could be called a leak.
The rason for nulling is the handle id of an object. Each object has it's own, end for example, if a trigger gets destroyed this id could get recycled, however, not doing this only results in higher handle-ids and a VERY low memory increasage (should be the value of an integer, so 4 bytes, not sure about this). If handles NEVER get destroyed you don't have to null them, so for example, timers from TimerUtils, players (they're handles too!) or triggers.

@vercas: Justify is probably right. I haven't done any research on this so I am not sure. =P I didn't think it was absolutely necessary to null them, but I am curious now why it is dangerous to do so. They still have reference counting and are agents. I guess they don't get destroyed so it makes sense not to null them, just like players. But anyway, I guess you can just remove the null since it is one less call and I assume safer. =)
 
Level 14
Joined
Nov 18, 2007
Messages
816
Why not?
I was in a hurry...
So you just figured youd write up something like this in a matter of minutes and expect it to be good?
No. There's a boolean for that...
Thats not the point. The point is that your library does something it shouldnt do.
I prefere my own... Always.
Im tired of explaining why this is a bad attitude. Give it up. Thats all ill say.
There is no reason to null handles that aren't destroyed while nulling triggers could crash the tables used in warcraft (never faced this problem, wc3c says so :p)
While the first part of the sentence is correct, the second is bullcrap. Nulling handles doesnt do anything. The problem youre probably referring to is the one with DestroyTrigger. And the part in parentheses is ..., "wc3c" can say anything.
 
Level 13
Joined
Mar 16, 2008
Messages
941
@Deaod: I can't do more then retelling what I've read. Some people said (and I'm still reading this sometimes) that nulling a trigger can cause issues. It might be a rumour, but I can't test it. If there is a small chance to bug, just avoid it. If it doesn't, just avoid it too since I'm not sure about it ;D (If I remember correctly, they said that it could happen that a nulled trigger isn't "recognized" anymore, making it possible to reuse it's handle id before the trigger is destroyed (nearly the same then the dual-id-use problem after destroying while an instance is running)).
 
Level 21
Joined
Dec 9, 2007
Messages
3,096

Because hashtables are said to be 60% faster than arrays.

So you just figured youd write up something like this in a matter of minutes and expect it to be good?

I was in a hurry to upload it for a friend...
After I've finished the system, I forgot to add interface functions, so I made them up really fast...

Thats not the point. The point is that your library does something it shouldnt do.

Something OPTIONAL.
Can static if's check static constant booleans in structs?

Im tired of explaining why this is a bad attitude. Give it up. Thats all ill say.

It's self-motivational and I really need that.


__________________

I realise that this systems lacks some things, so I will make an "addons" library and module for everyone to use.
I'll post it today; I'll start by adding a jump trigger (WITH WAITS!) to it
 
Level 13
Joined
Mar 16, 2008
Messages
941
Could you send me a link please? Right after 1.24b vex said that the speed is around 2 times an array. Internaly both are arrays, but hashtables calculate their index with a hash-function, so it should be impossible to be faster. Also, anyone would use hashtables and NEVER use arrays, structs would be completly rewritten to hashtables and the limit would be gone :O
 
Level 14
Joined
Nov 18, 2007
Messages
816
Because hashtables are said to be 60% faster than arrays.
Thats a load of bullshit. Arrays are faster (as already said, about twice as fast). If you have doubts when i tell you, go do the benchmarks. There are stopwatch natives for 1.24d and maybe even 1.24e (i know the offsets are known).
Something OPTIONAL.
Again, it doesnt matter if its optional. Its there, while it should be inside its own library.
Can static if's check static constant booleans in structs?
Yes. Make sure you dont have a comment after the declaration, and you declare the constant before you use it.
It's self-motivational and I really need that.
Its fine by me if you just want to see how its done and practice by doing it yourself. That doesnt mean you should actually use it. Most things you write for practice are things you should not use in live environments.
 
Uses a hashtable object from wc3 patch 1.24b+ or later. These things are very fast though not as fast as just an array lookup. So it is the 'slowest'...

This is from TimerUtils.

Array-lookups are about twice as fast as hashtables. The only hinder is the limit but you won't really reach it that easily.

Anyway, if he did post that, it must've been a simple typo. =)
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
Ok, fine, I will use arrays and an indexing system...
I will move the AddCrow crap in a separate library, but is it okay if I keep it in the same trigger? Just for implementation purposes...

I will add these in the upcomming update...
12:40, 30th Mar 2010
The_Reborn_Devil:
Hmm.. The jump doesn't look very realistic and I found a bug. When the unit stops moving forward while jumping you can walk in the air until it falls down. Also, you should use radians and not degrees when using Cos, Sin and the like.


Status: Rejected until updated
Rating: N/A

PM me or another mod once you've fixed this to get it reviewed again. Have a nice day!

I know, the jump sucks and that's why I am completly redoing it.
The unit can walk on air, and I will use an addon buffer that pauses the unit when it's still in air.

And why the heck should I use radians?
For most people, it's easier to use degrees than radians...
And they are converted to radians when used in the Sin and Cos functions.

Before the next update, can anyone give any more suggestions? All to be implemented...
 
Last edited:
Top