User Tag List

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 30

Thread: Plans for the future, part 1: AngelScript

  1. #1
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    34
    Posts
    3,292
    Mentioned
    141 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    5,841
    Level
    23
    vBActivity - Bars
    Lv. Percent
    69.54%
    Daily Activity
    0%
    Weekly Activity
    19.83%
    Monthly Activity
    7.51%

    Plans for the future, part 1: AngelScript

    A lot of details about ZC 3.0 have yet to be decided, but at least one thing is settled. All of the objects in the game - Link, enemies, weapons, items, and probably more - will be removed from the program code and converted to scripts. This isn't just a matter of making the engine more versatile; I believe it's the only viable way forward. However, ZScript is not remotely up to the task, and so it's going to be abandoned in favor of AngelScript.

    First of all: no, this does not mean losing backward compatibility. In fact, that's one of the primary reasons for doing this. ZScript won't be available in new quests, but it will continue to work in existing quests.

    And secondly: no, you won't have to learn to work with scripts to make simple quests. A default set of items, enemies, etc. will be loaded up automatically. You won't even notice they're there.


    It's pretty well known now that the game's code is a mess. Just as a random example, here's the main update function for phasing Wizzrobes.
    Spoiler: show
    Code:
    void eWizzrobe::wizzrobe_attack()
    {
        if(clk<0 || dying || stunclk || watch || ceiling)
            return;
            
        if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(fix)1,spw_door) && !misc))
        {
            fix_coords();
            
            switch(misc)
            {
            case 1:                                               //walking
                if(!m_walkflag(x,y,spw_door))
                    misc=0;
                else
                {
                    clk3=16;
                    
                    if(!canmove(dir,(fix)1,spw_wizzrobe))
                    {
                        wizzrobe_newdir(0);
                    }
                }
                
                break;
                
            case 2:                                               //phasing
            {
                int jx=x;
                int jy=y;
                int jdir=-1;
                
                switch(rand()&7)
                {
                case 0:
                    jx-=32;
                    jy-=32;
                    jdir=15;
                    break;
                    
                case 1:
                    jx+=32;
                    jy-=32;
                    jdir=9;
                    break;
                    
                case 2:
                    jx+=32;
                    jy+=32;
                    jdir=11;
                    break;
                    
                case 3:
                    jx-=32;
                    jy+=32;
                    jdir=13;
                    break;
                }
                
                if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
                {
                    misc=3;
                    clk3=32;
                    dir=jdir;
                    break;
                }
            }
            
            case 3:
                dir&=3;
                misc=0;
                
            case 0:
                wizzrobe_newdir(64);
                
            default:
                if(!canmove(dir,(fix)1,spw_door))
                {
                    if(canmove(dir,(fix)15,spw_wizzrobe))
                    {
                        misc=1;
                        clk3=16;
                    }
                    else
                    {
                        wizzrobe_newdir(64);
                        misc=0;
                        clk3=32;
                    }
                }
                else
                {
                    clk3=32;
                }
                
                break;
            }
            
            if(misc<0)
                ++misc;
        }
        
        --clk3;
        
        switch(misc)
        {
        case 1:
        case 3:
            step=1.0;
            break;
            
        case 2:
            step=0;
            break;
            
        default:
            step=0.5;
            break;
            
        }
        
        move(step);
        
    //  if(d->misc1 && misc<=0 && clk3==28)
        if(dmisc1 && misc<=0 && clk3==28)
        {
            if(dmisc2 != 1)
            {
                if(lined_up(8,false) == dir)
                {
    //        addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
    //        sfx(WAV_WAND,pan(int(x)));
                    wizzrobe_attack_for_real();
                    fclk=30;
                }
            }
            else
            {
                if((rand()%500)>=400)
                {
                    wizzrobe_attack_for_real();
                    fclk=30;
                }
            }
        }
        
        if(misc==0 && (rand()&127)==0)
            misc=2;
            
        if(misc==2 && clk3==4)
            fix_coords();
            
        if(!(charging||firing))                               //should never be charging or firing for these wizzrobes
        {
            if(fclk>0)
            {
                --fclk;
            }
        }
        
    }

    guys.cpp is about 14,000 lines, and that's far from the worst of it.

    We can't keep all of this code as it is. It's an absolute nightmare to make any substantial changes, and it depends on a lot of infrastructure that's just as bad.

    But we can't rewrite it, either. I don't just mean that we're not capable of doing so, although that may well be true (I've tried and failed more than once). Rather, if we rewrite everything, we'll break a lot of quests. We've had many problems with this already - some quest depends on a bug, or the exact pixel where a collision is checked, or some other obscure quirk, and so a seemingly innocuous change breaks it. ZScript makes matters worse. It has direct access to a bunch of variables and would see changes in how they're used, so rewriting things without breaking existing scripts is virtually impossible.

    The plan, then, is that the existing code will be converted from C++ to AngelScript with minimal changes. The behavior won't change at all, ZScript won't see any difference, and all we have to do to keep it working in the future is continue to provide the same script interface. This will be implemented invisibly in 2.60. From 3.0 on, these scripts will only be used for backward compatibility; new quests will use a separate set of scripts written from scratch.

    Why switch to AngelScript for this instead of continuing to work on ZScript? Quite simply, it would be a lot more work with no added benefit. ZScript would need a complete overhaul to be capable of doing what we need, and the end result would be about as big a change from the current language.

    Why not update ZScript so it can work alongside AngelScript? Again, a lot of work for little benefit. But more than that, keeping existing scripts working is a major design consideration, which would entail keeping a lot of the issues we want to get away from. Partial compatibility might be less work, but it's also harder to justify the effort in the first place, and it and would create confusion regarding what works and what doesn't.

    Does this mean you'll have to learn a whole new language from scratch? Not really, no. AngelScript and ZScript are both based on C++, so their syntax and behavior are generally very similar. There will certainly be some differences, but if you already know ZScript, you won't have to learn everything all over again. You can see some examples from other programs here, here, and here.


    I felt this was a big enough change to warrant a public announcement, but I want to emphasize that it's more an implementation detail than a radical new direction. If you're not a scripter, all of this barely affects you. If you are, the changes are comparable to what they would have been anyway. There are a lot of details still to be worked out, but I'll answer any questions as best I can.
    Last edited by Tamamo; 01-23-2016 at 11:00 AM.
    [téknolŕiz]

    ffcscript.zh 1.1.1 - Updated 2014-08-19
    ghost.zh 2.8.1 - Updated 2016-09-16
    tango.zh 1.2.0 - Updated 2016-09-16

  2. #2
    ZC Ambassador Tamamo's Avatar
    Join Date
    May 2011
    Location
    Kyoto
    Age
    28
    Posts
    760
    Mentioned
    82 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    4,857
    Level
    21
    vBActivity - Bars
    Lv. Percent
    88.1%
    Daily Activity
    112.11%
    Weekly Activity
    51.82%
    Monthly Activity
    55.19%
    Sounds like a plan, only thing missing is ffcs.
    How are we gonna handle that monster?
    Last edited by Tamamo; 01-20-2016 at 04:45 PM.

  3. #3
    Developer ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,623
    Mentioned
    212 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,172
    Level
    32
    vBActivity - Bars
    Lv. Percent
    39.91%
    Daily Activity
    0%
    Weekly Activity
    10.24%
    Monthly Activity
    42.91%
    I see there now a fixed class for scripts.. ;_( Can't we just get rid of it once and for all?

    Quote Originally Posted by Tamamo View Post
    Sounds like a plan, only thing missing is ffcs.
    How are we gonna handle that monster?
    Burn them with lighter fluid. :)
    This post contains the official Gleeok™ seal of approval. Look for these and other posts in an area near you.

  4. #4
    Mad, Mad, Author ZoriaRPG's Avatar
    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    787
    Mentioned
    71 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    2,984
    Level
    17
    vBActivity - Bars
    Lv. Percent
    69.66%
    Daily Activity
    0%
    Weekly Activity
    103.01%
    Monthly Activity
    81.91%
    I'll say this, the effort in making a ZScript scripting interface for AngelScript, to me, seems worthwhile, and I might even be conned, or forced into making that a thing. I'll lose my sanity bonus to Spellcraft in the process, but my madness modifier will potentially compensate. In short, I would prefer to see the existing syntax preserved, as a user option, allowing for ZScript expansion in the process, or the users already accustomed to it. .


    Featured Scripts & Headers: RPG.zh ( v. a0.97.1 ) ( RPG.zh Thread ) | Zelda 3 Thief's Town Treasure Chest Minigame (ffc) | Bobomb (enemy)
    ZScript & ZC-Related Pastebin | Quests and ZScript Repository | ZC Dev & Betas | Latest ZC 2.54 Beta | YouTube Channel
    All of the code that I create and publish here is free for use, modification and distribution under the GPL v2.0, or v3.0 where applicable..

  5. #5
    Developer ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,623
    Mentioned
    212 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,172
    Level
    32
    vBActivity - Bars
    Lv. Percent
    39.91%
    Daily Activity
    0%
    Weekly Activity
    10.24%
    Monthly Activity
    42.91%
    I could start a ZScript to angelscript conversion utility. Not sure what the total coverage would be but it's doable. Maybe just have it read from a text file containing all the tokens to replace? ..not sure. Most of the syntax is the same anyhoo.
    This post contains the official Gleeok™ seal of approval. Look for these and other posts in an area near you.

  6. #6
    ZC Ambassador Tamamo's Avatar
    Join Date
    May 2011
    Location
    Kyoto
    Age
    28
    Posts
    760
    Mentioned
    82 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    4,857
    Level
    21
    vBActivity - Bars
    Lv. Percent
    88.1%
    Daily Activity
    112.11%
    Weekly Activity
    51.82%
    Monthly Activity
    55.19%
    Quote Originally Posted by Gleeok View Post
    Burn them with lighter fluid. :)
    I completely agree. Let's just burn them.

  7. #7
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    34
    Posts
    3,292
    Mentioned
    141 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    5,841
    Level
    23
    vBActivity - Bars
    Lv. Percent
    69.54%
    Daily Activity
    0%
    Weekly Activity
    19.83%
    Monthly Activity
    7.51%
    Quote Originally Posted by Gleeok View Post
    I see there now a fixed class for scripts.. ;_( Can't we just get rid of it once and for all?
    I don't think we can; things are just too fragile. We can separate it from Allegro, though, and I don't intend for it to be part of the interface for new scripts at all.
    [téknolŕiz]

    ffcscript.zh 1.1.1 - Updated 2014-08-19
    ghost.zh 2.8.1 - Updated 2016-09-16
    tango.zh 1.2.0 - Updated 2016-09-16

  8. #8
    ZC Ambassador Tamamo's Avatar
    Join Date
    May 2011
    Location
    Kyoto
    Age
    28
    Posts
    760
    Mentioned
    82 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    4,857
    Level
    21
    vBActivity - Bars
    Lv. Percent
    88.1%
    Daily Activity
    112.11%
    Weekly Activity
    51.82%
    Monthly Activity
    55.19%
    Someone forgot the glue. *Fixed*
    Anyways, I've been reading up on the documentation for angelscript. Looks pretty snappy guys!
    @Gleeok @Saffith
    Also this is just volunteer work, but I'm willing to rewrite guys.h if need be.
    Last edited by Tamamo; 01-23-2016 at 11:22 AM.

  9. #9
    Mad, Mad, Author ZoriaRPG's Avatar
    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    787
    Mentioned
    71 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    2,984
    Level
    17
    vBActivity - Bars
    Lv. Percent
    69.66%
    Daily Activity
    0%
    Weekly Activity
    103.01%
    Monthly Activity
    81.91%
    Quote Originally Posted by Gleeok View Post
    I could start a ZScript to angelscript conversion utility. Not sure what the total coverage would be but it's doable. Maybe just have it read from a text file containing all the tokens to replace? ..not sure. Most of the syntax is the same anyhoo.

    This is what I was thinking. Just scan ZScript like the lexer does, seek tokens, and identifiers, and make new code as a cross-compiling operation. AngelScript supports whatever language interface you'd want, via plug-ins, so this sould be possible. Even arrays, and strings should convert: Just look for the correct tokens, and change them to a declaration as needed.

    What I worry about, is type conversions. TBH, I abuse the ZScript typecasting to death, and not having that will break more than 50% of what I made to date. It would be nice to add some automated typecasting to AngelScript, to preserve this ZScript feature; as from what can tell, it doesn't already have anything like that.

    Actually, we could probably rewrite the output of the present lexer, to make AngelScript, instead of ZASM.


    Featured Scripts & Headers: RPG.zh ( v. a0.97.1 ) ( RPG.zh Thread ) | Zelda 3 Thief's Town Treasure Chest Minigame (ffc) | Bobomb (enemy)
    ZScript & ZC-Related Pastebin | Quests and ZScript Repository | ZC Dev & Betas | Latest ZC 2.54 Beta | YouTube Channel
    All of the code that I create and publish here is free for use, modification and distribution under the GPL v2.0, or v3.0 where applicable..

  10. #10
    Developer ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,623
    Mentioned
    212 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,172
    Level
    32
    vBActivity - Bars
    Lv. Percent
    39.91%
    Daily Activity
    0%
    Weekly Activity
    10.24%
    Monthly Activity
    42.91%
    Do we plan on supporting waitframes()? I just realized if waitframes aren't a thing then there may not be a compelling reason to pool script contexts.
    This post contains the official Gleeok™ seal of approval. Look for these and other posts in an area near you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social