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
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,430
    Level
    24
    vBActivity - Bars
    Lv. Percent
    69.57%

    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.

  2. #2
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%
    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
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,815
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,933
    Level
    33
    vBActivity - Bars
    Lv. Percent
    23.44%
    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
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    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. .

  5. #5
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,815
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,933
    Level
    33
    vBActivity - Bars
    Lv. Percent
    23.44%
    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
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%
    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
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,430
    Level
    24
    vBActivity - Bars
    Lv. Percent
    69.57%
    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.

  8. #8
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%
    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
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    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.

  10. #10
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,815
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,933
    Level
    33
    vBActivity - Bars
    Lv. Percent
    23.44%
    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