• 🏆 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 and ZINC question...

Status
Not open for further replies.
Level 8
Joined
Feb 3, 2013
Messages
277
JASS:
//! zinc

library StructTesting
{
    interface Events
    {
        method onPreTermination() = null;
        method onEffectStart() = null;
        method onEffectEnd() = null;
    }
    
    struct Parent extends Events
    {
        unit cast;
        real time, st, et;
        
        static integer prev[1000], next[1000], rn[1000];
        static integer ic   = 0;
        
        static timer tmr    = CreateTimer();
        static real period  = 0.02500;
        
        private method onTermination()
        {
            BJDebugMsg(I2S(this) + "onTermination!");
            this.cast = null;
            
            prev[next[this]] = prev[this];
            next[prev[this]] = next[this];
            rn[this] = rn[0];
            rn[0] = this;
        }
        
        method onEffectStart()
        {
            BJDebugMsg(I2S(this) + "onEffectStart");
        }
        
        method onEffectEnd()
        {
            BJDebugMsg(I2S(this) + "onEffectEnd");
        }
        
        method onPreTermination()
        {
            BJDebugMsg(I2S(this) + "onPreTermination");
        }
        
        static method looping()
        {   
            thistype this = next[0];
            
            while (this!= 0)
            {
                if (this.time == this.et)
                {
                    this.onEffectEnd();
                    this.onPreTermination();
                    this.onTermination();
                }
                else if (this.time == this.st)
                {
                    this.onEffectStart();
                }
                
                this.time = this.time + period;
                
                this = next[this];
            }
            
            if (next[0] == 0)
            {
                BJDebugMsg("Paused!");
                PauseTimer(tmr);
            }
        }
        
        static method create(unit u, real st, real et) -> thistype
        {
            thistype this = rn[0];
            
            if (this == 0)
            {
                ic = ic + 1;
                this = ic;
            }
            else
            {
                rn[0] = rn[this];
            }
            
            BJDebugMsg(I2S(this) + "onCreation!");
            
            this.cast = u;
            this.time = 0.;
            this.st = st;
            this.et = et;
            
            next[this] = 0;
            prev[this] = prev[0];
            next[prev[0]] = this;
            prev[0] = this;
            
            if (prev[this] == 0)
            {
                BJDebugMsg("Timer Start!");
                TimerStart(tmr, period, true, function thistype.looping);
            }
            
            return this;
        }
    }
    
    struct Child extends Parent
    {
        static method onCast() -> boolean
        {
            unit u = GetTriggerUnit();
            thistype.create(u, 2.5, 3.5);
            
            u = null;
            
            return false;
        }
     
        static method onInit()
        {
            trigger t = CreateTrigger();
            
            TriggerRegisterPlayerUnitEvent(t, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT, null);
            TriggerAddCondition(t, function thistype.onCast);
        }
    }
}

//! endzinc

EDIT2: Fixed... copied from xe;;
 
Last edited:
Level 8
Joined
Feb 3, 2013
Messages
277
well, ^ i dont think what you said is true, looking off missile systems like xe, there are structs extending interfaces that don't have such functions...

anyways - i forgot to mention the most important point, even when i do have those functions inside, they don't even get called properly -_-;; idk why - i just think it has something to do with zinc.

EDIT: it made it so it defaults nothing and now it works;; im such a noob
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
I coded in ZinC for a while and i really liked the syntax. But face it - its not 100% compatible to vJass and lacks some of vJass' features. Those little nice things like += operators or anonymous functions arent enough to keep up with the fact that vJass is THE standard.
 
Status
Not open for further replies.
Top