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

Mms 4d

Status
Not open for further replies.
Level 18
Joined
Sep 14, 2012
Messages
3,413
I made this structure atm :
JASS:
library MMS4D
    globals
        private constant real FPS = 0.0312500
    endglobals
    
    private struct MMS_Core extends array
        real x
        real y
        private thistype rn
        private static integer count
        private static thistype r
        
        method destroy takes nothing returns nothing
            set r = rn
            set r = this
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this
            if r==0 then
                set count = count + 1
                set this = count
            else
                set this = r
                set r = r.rn
            endif
            return this
        endmethod
        
        static method onInit takes nothing returns nothing
            set count = 0
            set r = 0
        endmethod
    endstruct
    
    struct MMS_2D extends array
        delegate MMS_Core deleg
        private static integer dindex
        private static thistype array data
        
        method destroy takes nothing returns nothing
            call this.deleg.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.deleg = this
            return this
        endmethod
        
        method doSomething takes real x, real y returns nothing
            set this.x = x
            set this.y = y
        endmethod
        
        private static method onInit takes nothing returns nothing
            set dindex = -1
        endmethod
    endstruct
    
    struct MMS_3D extends array
        delegate MMS_Core core
        private static integer dindex
        private static thistype array data
        
        method destroy takes nothing returns nothing
            call this.core.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.core = this
            return this
        endmethod
        
        static method onInit takes nothing returns nothing
            set dindex = -1
        endmethod
    endstruct
    
    struct MMS_4D extends array
        delegate MMS_Core core
        private static integer dindex
        private static thistype array data
        
        method destroy takes nothing returns nothing
            call this.core.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.core = this
            return this
        endmethod
        
        static method onInit takes nothing returns nothing
            set dindex = -1
        endmethod
    endstruct
endlibrary

The code looks pretty ^^
The biggest bad point of this type is that we will have a maximum of 8190 KB from all different dimensions.

EDIT 1 : Implemented dynamic indexing, I think linked list will be a bit brain destruction in such code.
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
In basic (All) i think you may add them to 2D since i guess 2D is the root of 3D and 4D


Basic (All)

  • KBed Unit
  • Targeted Unit
  • Damager
  • EndFx
  • AoEEndFx
  • Fx
  • Attach
  • BounceFx
  • LineFx
  • Instances on unit
  • BounceGroup
  • LineDamageGroup
  • DamageType
  • AttackType
  • IsUnitBeingKBed
  • DisableUnit
  • DestroyTrees
  • IsSpeedPositive
  • SpeedChanger
  • HasBeenImpactDamaged
  • KillWhenHit
  • EndWhenHit
  • FaceAngle
  • KillIfOutsider
  • AllowOutSiding
  • EndWhenDead
  • KBTarget
  • AoEKB
  • iKB
  • KillatEnd
  • D_STRUCTURE
  • D_MECHANICAL
  • D_MAGIC_IMMINUE
  • D_ALLY
  • D_ENEMEY
  • D_RESISTANT
  • D_FLYING
  • DestroyDestructable
  • BounceUnit
  • BounceTarget
  • EndOnObstacle
  • EndOnTargetBounce
  • UnitPropWindow
  • ImpactDamage
  • LoopDamage
  • TargetDamage
  • LineDamage
  • AoE
  • ArcAngle
  • AoEDamage
  • KillAtTime
  • StopTime
  • AiEEndDamage
  • AoEEndDamage
  • AoEKBPower
  • BouncePower
2D

  • Range
  • Speed
  • Acceleration
  • Angle
  • Time
3D

  • IsZNotNull
  • GroundDamage
  • JumpOverCliff
  • Zoffset
  • ZSpeed
  • ZAccel
  • LastTerrainZ
  • InitialTerrainZ
  • UnitInitialHeight
4D

  • 4DEnabled (Boolean)
  • 4DLapseTime (Real)
  • 4DWasHidden (Boolean)
  • 4DRippOff (Boolean)
  • 4DBlackHole (Boolean)
  • 4DAoE_3D (Real)
  • 4D_RippOffDamage (Real)
  • 4D_BlackHoleDPS (Real)
  • 4D_RippOffSpeed (Real)
  • 4D_BlackHoleSpeed (Real)
For more info on the variable types, see here
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
1: malhone, the 4D enabled is the option that adds 4D to the Instance, like any other feature, not a global one
2: waitin the vid
3: I think the current system is fully working, but wrathion's problem is specific, not major to all the users, but anyway since we are making it from scratch, I think waiting for the first to work with wrathion is useless, working on MMS4D is better
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
JASS:
library MMS4D
    globals
        private constant real FPS = 0.0312500
        private constant boolean NEED_3D = true
        private constant boolean NEED_4D = true
        //Don't forget to implement other static if boolean :)
        
        private integer dindex = -1
        //Don't worry structs are integer. Store in this array :)
        private integer array data
    endglobals
    
    private struct MMS_Core extends array
        unit KBed_unit
        unit target
        unit damager
        string endFx
        string aoeEndFx
        string Fx
        string attach
        string bounceFx
        string lineFx
        //Wtf this one xD ? Can't we disable kb for an already existing kbed unit ?
        integer instanceOnUnit
        group bounceGroup
        group lineDamageGroup
        damagetype damageType
        attacktype attackType
        //Same there
        boolean isUnitKbed
        boolean disable
        boolean destroyTrees
        boolean isSpeedPositive
        boolean speedChanger
        boolean hasBeenImpactDamaged
        boolean killWhenHit
        boolean endWhenHit
        boolean faceAngle
        boolean killIfOutsider
        boolean allowOutSiding
        boolean endWhenDead
        boolean KBTarget
        boolean aoeKB
        boolean iKB
        boolean killAtEnd
        boolean D_Structure
        boolean D_Mechanical
        boolean D_MagicImmune
        boolean D_Ally
        boolean D_Enemy
        boolean D_Resistant
        boolean D_Flying
        boolean D_Destructable
        boolean bounceUnit
        boolean bounceTarget
        boolean endOnObstacle
        boolean endOnTargetBounce
        //No need to store unitpropwindow there is a solution :)
        //Btw the solution is GetUnitDefaultPropWindow(unit)*bj_RADTODEG
        real impactDamage
        real loopDamage
        real targetDamage
        real lineDamage
        real aoe
        real arcAngle
        real aoeDamage
        real killAtTimer
        real stopTime
        real aiEndDamage
        real aoeEndDamage
        real aoeKBDamage
        real aoeKBPower
        real bouncePower
        private thistype rn
        private static integer count
        private static thistype r
        
        method destroy takes nothing returns nothing
            set this.rn = r
            set r = this
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this
            if r==0 then
                set count = count + 1
                set this = count
            else
                set this = r
                set r = r.rn
            endif
            return this
        endmethod
        
        static method onInit takes nothing returns nothing
            set count = 0
            set r = 0
        endmethod
    endstruct
    
    struct MMS_2D extends array
        real range
        real speed
        real accel
        real angle
        real time
        delegate MMS_Core core
        
        method destroy takes nothing returns nothing
            call this.core.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.core = this
            return this
        endmethod
    endstruct
    
    static if NEED_3D then
    //Now the code of the 3D
    struct MMS_3D extends array
        boolean isZNotNull
        real groundDamage
        boolean jumpOverCliff
        real zOffset
        real zSpeed
        real zAccel
        real lastTerrainZ
        real initTerrainZ
        real unitInitialHeight
        delegate MMS_Core core
        
        method destroy takes nothing returns nothing
            call this.core.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.core = this
            return this
        endmethod
    endstruct
    //End of the code of the 3D
    endif
    
    static if NEED_4D then
    //Now the code of the 4D
    struct MMS_4D extends array
        //What's the use of this one ?
        boolean enabled
        boolean lapseTime
        boolean wasHidden
        boolean rippOff
        boolean blackHole
        real aoe3D
        real rippOffDamage
        real blackHoleDamage
        real rippOffSpeed
        real blackHoleSpeed
        delegate MMS_Core core
        
        method destroy takes nothing returns nothing
            call this.core.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.core = this
            return this
        endmethod
        
        static method onInit takes nothing returns nothing
            set dindex = -1
        endmethod
    endstruct
    //End of the code of the 4D
    endif
endlibrary
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
Ah yes forgot to say that this is pure madness coding ^^
Even if the code looks pretty it is pure madness behind xD !

To instanciate a 2d :
JASS:
local MMS_2D m = MMS_2D.create()
set m.KBed_unit = ..
set m.target = ...
set m.damager = ...
...
set m.range = ...
set m.speed = ...
For the moment you can just create and destroy struct ^^'
There is nothing more :p


EDIT : To be clear -> Delegate is a better version of extends.
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
1. You can't use a member specific to 3D in a 2D one :D !
2. What do you mean ?
- Just don't touch to the members I privated.
- You can only add things to create/destroy don't remove/change anything.
- The delegate thingy means that every member (member and method) that are not private can be access from the struct.
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
The blackhole is a special feature of the MMS_4D so you put it into the 4d :)
You add the method and everything.

Btw, members dindex and data are here for dynamic indexing.
Anyway I'm not really sure for the indexing, we will use it but I don't think we need so much things.
Since there is a limit of 8190 index.
Oh I got an idea. I'll make dindex and data globals in the library.

EDIT : I updated the code.
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
JASS:
    static if NEED_4D then
    //Now the code of the 4D
    struct MMS_4D extends array
        //What's the use of this one ?
        boolean enabled
        boolean lapseTime
        boolean wasHidden
        boolean rippOff
        boolean blackHole
        real aoe3D
        real rippOffDamage
        real blackHoleDamage
        real rippOffSpeed
        real blackHoleSpeed
        delegate MMS_Core core
        
        method destroy takes nothing returns nothing
            call this.core.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.core = this
            return this
        endmethod
        
        method test takes nothing returns nothing
            if this.KBed_unit != null then
                call KillUnit(this.KBed_unit)
            endif
        endmethod
    endstruct
    //End of the code of the 4D
    endif
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
Oh, it's easy, at least the part that i want you to do xD :
A method ( ? ) or something i don't know, like call m.apply , which will run a function/method/whatsoever in the system that will add an instance, just create this part and make it add an instance

^ that was the registration

And make a method ( ?) that runs on every FPS, just create it and i will do the rest
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
A method is a function that automatically takes a struct instance as parameters. Like m.apply will automatically take m as parameter. Static method are basic functions xD
But before we really need to know everything we'll put in every func more than before since we'll use the less code possible.
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
i'm trying to add some methods, but i have a question
there are some methods, that run in 2D, but will have more stuff in 3D, for instance, AoEEndKB will KB all units, if 3D is disabled, it will KB on the ground, if it is not, they will go flying, another one: Fx, which creates periodically an effect on the KBed unit, if the unit was flying, the effect will be created on him, if not, it will be created on it's location (well, this one doesn't really count but you got the idea of it)

SO, for those "core" methods, we will use static ifs in the areas that will need 3D, or something else?

PS: i changed the member name (KBed_unit) to Unit (since it will be used A LOT, and it is pain to write it like 100 times)
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
IsTerrainPathable by Vex is good afaik ^^
link? :p
Create a method for the 2d and one for the 3d is there difference.
useless code
Oh we can create a member in mms_core which hold the dimension and in the loop do in function of this member.
wat!?
Create a method for the 2d and one for the 3d is there difference.
Oh we can create a member in mms_core which hold the dimension and in the loop do in function of this member.
i think it would be better if we do it like this:
JASS:
method move_dimensionally takes nothing returns nothing
    call blablabla.. 2D stuff
    static if WANT_3D then
        call blachblach 3D stuff
    endif
endmethod
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
Static if will make the code unusable after the compile time.

In mms_core struct add a member called dim like this :
JASS:
library MMS4D
    globals
        private constant real FPS = 0.0312500
        private constant boolean NEED_3D = true
        private constant boolean NEED_4D = true
        //Don't forget to implement other static if boolean :)
        
        private integer dindex = -1
        //Don't worry structs are integer. Store in this array :)
        private integer array data
    endglobals
    
    private struct MMS_Core extends array
        unit KBed_unit
        unit target
        unit damager
        string endFx
        string aoeEndFx
        string Fx
        string attach
        string bounceFx
        string lineFx
        //Wtf this one xD ? Can't we disable kb for an already existing kbed unit ?
        integer instanceOnUnit
        group bounceGroup
        group lineDamageGroup
        damagetype damageType
        attacktype attackType
        //Same there
        boolean isUnitKbed
        boolean disable
        boolean destroyTrees
        boolean isSpeedPositive
        boolean speedChanger
        boolean hasBeenImpactDamaged
        boolean killWhenHit
        boolean endWhenHit
        boolean faceAngle
        boolean killIfOutsider
        boolean allowOutSiding
        boolean endWhenDead
        boolean KBTarget
        boolean aoeKB
        boolean iKB
        boolean killAtEnd
        boolean D_Structure
        boolean D_Mechanical
        boolean D_MagicImmune
        boolean D_Ally
        boolean D_Enemy
        boolean D_Resistant
        boolean D_Flying
        boolean D_Destructable
        boolean bounceUnit
        boolean bounceTarget
        boolean endOnObstacle
        boolean endOnTargetBounce
        //No need to store unitpropwindow there is a solution :)
        //Btw the solution is GetUnitDefaultPropWindow(unit)*bj_RADTODEG
        real impactDamage
        real loopDamage
        real targetDamage
        real lineDamage
        real aoe
        real arcAngle
        real aoeDamage
        real killAtTimer
        real stopTime
        real aiEndDamage
        real aoeEndDamage
        real aoeKBDamage
        real aoeKBPower
        real bouncePower
        integer dim
        private thistype rn
        private static integer count
        private static thistype r
        
        method destroy takes nothing returns nothing
            set this.rn = r
            set r = this
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this
            if r==0 then
                set count = count + 1
                set this = count
            else
                set this = r
                set r = r.rn
            endif
            return this
        endmethod
        
        static method onInit takes nothing returns nothing
            set count = 0
            set r = 0
        endmethod
    endstruct
    
    struct MMS_2D extends array
        real range
        real speed
        real accel
        real angle
        real time
        delegate MMS_Core core
        
        method destroy takes nothing returns nothing
            call this.core.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.core = this
            set this.dim = 2
            return this
        endmethod
    endstruct
    
    static if NEED_3D then
    //Now the code of the 3D
    struct MMS_3D extends array
        boolean isZNotNull
        real groundDamage
        boolean jumpOverCliff
        real zOffset
        real zSpeed
        real zAccel
        real lastTerrainZ
        real initTerrainZ
        real unitInitialHeight
        delegate MMS_Core core
        
        method destroy takes nothing returns nothing
            call this.core.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.core = this
            set this.dim = 3
            return this
        endmethod
    endstruct
    //End of the code of the 3D
    endif
    
    static if NEED_4D then
    //Now the code of the 4D
    struct MMS_4D extends array
        //What's the use of this one ?
        boolean enabled
        boolean lapseTime
        boolean wasHidden
        boolean rippOff
        boolean blackHole
        real aoe3D
        real rippOffDamage
        real blackHoleDamage
        real rippOffSpeed
        real blackHoleSpeed
        delegate MMS_Core core
        
        method destroy takes nothing returns nothing
            call this.core.destroy()
        endmethod
        
        static method create takes nothing returns thistype
            local thistype this = MMS_Core.create()
            set this.core = this
            set this.dim = 4
            return this
        endmethod
        
        static method onInit takes nothing returns nothing
            set dindex = -1
        endmethod
    endstruct
    //End of the code of the 4D
    endif
endlibrary

And then in loop check this memer.
Ofc you can wrap this into a static if WANT_3D but this will say that even the struct 3D will not be there.

http://www.wc3c.net/showthread.php?t=103862 for the path :p
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
Static if will make the code unusable after the compile time.
ummm, what code? if you are talking about the call blachblach 3D stuff, then yes, it is intended
In mms_core struct add a member called dim like this :
what does it do?
And then in loop check this memer.
what
Ofc you can wrap this into a static if WANT_3D but this will say that even the struct 3D will not be there.
yes, duh? what you mean
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
Everything specific to a 3D will be wrapped inside a 3D static if.
But if the user want a 2D and a 3D in his map.
He will maybe cast a 2D and a 3D at the same time.
So we put a member dim for each struct.
Then in the loop check this member :
JASS:
if this.dim == 3 then
    //Perform 3D code
elseif this.dim == 4 then
    //Perform 4D code
endif
 
Status
Not open for further replies.
Top