1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[vJass] Meet vJass - Extending structs

Discussion in 'JASS/AI Scripts Tutorials' started by BPower, Jul 15, 2015.

  1. Crystalknoct

    Crystalknoct

    Joined:
    Aug 15, 2012
    Messages:
    310
    Resources:
    0
    Resources:
    0
    thanks will make learning easier.
     
  2. Flux

    Flux

    Joined:
    Feb 6, 2014
    Messages:
    2,333
    Resources:
    28
    Maps:
    1
    Spells:
    19
    Tutorials:
    2
    JASS:
    6
    Resources:
    28
    Why does stub methods generate triggeractions too if there's already a triggercondition? Seems redundant if you ask me.
     
  3. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Yeah, it is redundant. I think a lot of the jasshelper features were implemented with the plan that the optimizer could come in and remove that redundancy. I don't think it does, though.
     
  4. When I learned vJASS, I was told to stay away from
    extends
    . So I did. I can only give the same suggestion here.
     
  5. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    455
    Resources:
    0
    Resources:
    0
    that's just some cargo cult bs.
     
  6. Well I remember inspecting myself what JassHelper spews out when using
    extends
    , it wasn't anything nice. JASS2 is already slow af why make it slower?

    Besides I don't want to be a rebel, I'm doing what I've been taught. WC3 modding has been thing for over a decade so we know what's fast and what is not.
     
  7. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,793
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    In most of the use-cases for struct extension, you don't care about minor speed differences.

    Extends is for readability and modular code. It's not for speed-freaks.

    I personally adore
    extends
    and use it whereever it makes sense. It creates neat, clean and - most importantly - highly maintainable code that you can easily modify or add features to later.


    Would I use it for speed-critical systems like damage detection? Hell no.
    But for stuff where speed optimization isn't top priority, like spells, buffs, etc.? Fuck yes!



    A great example for the clever use of extends is having basic spell components that you can use for rapid-prototyping new abilities.
    I basicly built base structs for "cast time spell", "basic direct missile spell", "basic cone-type spell", "basic line-type spell", "basic buff placer", etc. that I can extend upon whenever I need a spell to do something out of the norm. It saves so much time to be able to use pre-build structures and just add whatever the specific spell you code adds to the table instead of recreating everything from scratch every time. Plus, if I want to add a feature retroactively to all the spells of one group (let's say, I decided to add a mechanic that deflects missiles), I can simply edit the base struct and have it apply to all derivates automaticly.
     
  8. Yes the concept is nice, we just need a good implementation. My own will have a pool around variable, pool of what checks to include.
    WIP Syntax

    Code (vJASS):
    abstract struct Parent
        void printMsg()

    struct ChildA : Parent
        void printMsg()
            BJDebugMsg("A")

    struct ChildB : Parent
        void printMsg()
            BJDebugMsg("B")

    struct ChildC : Parent
        void printMsg()
            BJDebugMsg("C")

    INIT
        Parent myInstance = ChildB.create()
        myInstance.printMsg()
        Parent myInstance2 = ChildA.create()
        myInstance2 = ChildC.create()
        myInstance2.printMsg()
     

    Pool for
    myInstance
    has ChildB only, translates into
    call ChildB_printMsg(myInstance)
    .
    Pool for
    myInstance2
    has ChildA and ChildC, translates into:
    Code (vJASS):
    if(myInstance2_id>1)then // binary search
        call ChildC_printMsg(myInstance2)
    else // omit B (1) check, not in the pool
        call ChildA_printMsg(myInstance2)
    endif
     


    Ruke's vrJASS has better implementation as well. Also I think Nestharus is working on his own JassHelper alternative.
     
  9. Prometheus3375

    Prometheus3375

    Joined:
    Jul 20, 2018
    Messages:
    96
    Resources:
    0
    Resources:
    0
    All methods generate triggeractions and triggerconditions. triggeractions are used when you call a method using .execute().
     
    Last edited: Sep 1, 2018
  10. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,076
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Yes, the idea of what they're saying is that it's often redundant, and triples the code length.