User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19

Thread: Playtime-based scripts?

  1. #1
    Aerstalfos En Passant's Avatar
    Join Date
    May 2014
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    412
    Level
    7
    vBActivity - Bars
    Lv. Percent
    35.48%

    Playtime-based scripts?

    I know that there's a Quest Rule that will show the playtime on the subscreen, which means it can be tracked, so I was wondering if it's possible to make scripts that activate once the clock hits a certain value. The biggest use for this would be creating an automatic day-night cycle that would change the CSet or palette (and maybe the music too?) at set intervals.

  2. #2
    Octorok CaRmAgE's Avatar
    Join Date
    Oct 2008
    Location
    Historia
    Age
    35
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,354
    Level
    12
    vBActivity - Bars
    Lv. Percent
    50.49%
    Do you want your script to activate after set intervals from the beginning of the game, or set intervals since loading/DMap change?

  3. #3
    Aerstalfos En Passant's Avatar
    Join Date
    May 2014
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    412
    Level
    7
    vBActivity - Bars
    Lv. Percent
    35.48%
    From the beginning of the game. Time waits for no one, after all.

  4. #4
    Octorok CaRmAgE's Avatar
    Join Date
    Oct 2008
    Location
    Historia
    Age
    35
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,354
    Level
    12
    vBActivity - Bars
    Lv. Percent
    50.49%
    CODE: Show
    int startTime = 0; // Game->Time when last event was triggered

    global script Time{
    void run(){
    bool timeValid = Game->TimeValid; // Make sure the time quest rule is enabled
    while(true){
    if(timeValid && (Game->Time-startTime)*500/3 >= 300){ // Time converted to seconds; trigger event after 300 seconds elapse
    startTime = Game->Time; // Set startTime for the next interval
    // Do stuff here...
    }
    Waitframe();
    }
    }
    }


    Some notes:

    1. That timeValid check is just a sanity check. If you don't think you'll ever disable that time quest rule, you can safely delete that part of the check.
    2. If you want to measure time in minutes, use the fraction 25/9 instead of 500/3.
    3. The global script does not run while the subscreen is open. That is the reason for the >=, so if the interval is passed while the subscreen is open, the inner script will trigger as soon as the subscreen closes. If you want a timer that only counts while the subscreen is closed, let me know and I'll write a script up for that.

    Also, I have zero scripting experience with combos and csets, so if you also want help with a day/night script, you'll have to wait for someone else to reply.

    P.S. The ZC Wiki is deceptive. The Time entry is written as if a Game->Time of 1 is equal to 1/60 seconds, when, in reality, a Game->Time of 0.0001 is equal to 1/60 seconds. That's why it took me so long, so sorry about the wait.

  5. #5
    Aerstalfos En Passant's Avatar
    Join Date
    May 2014
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    412
    Level
    7
    vBActivity - Bars
    Lv. Percent
    35.48%
    Wow, thanks! Admittedly, the script is kind of simple so I'm a bit sad that I hadn't thought of it myself. Oh well, maybe I'll take a try at the day/night switches.
    EDIT: Duh, changing the DMap would cover the color and music changes. Unfortunately, there's no SetCurDMap command, so I'm not sure how to go about doing that.
    Last edited by En Passant; 08-05-2014 at 09:25 PM.

  6. #6
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    36
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,640
    Level
    25
    vBActivity - Bars
    Lv. Percent
    4.39%
    You could record the player's position on screen and then pit warp to the same screen, but with a different DMap (or if you like, a similar screen with a different DMap, depending on how much day/night difference you want). I know there's a way to warp the player (I don't have the specific command on hand) so that would be one way to change the DMap.

    Depending on how different you want day and night to be, you could have one timed warp change dmap but not screen (Dawn/dusk) and another timed warp change the map screen (say from day to night, switching enemies to undead or something and locking doors).

  7. #7
    Aerstalfos En Passant's Avatar
    Join Date
    May 2014
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    412
    Level
    7
    vBActivity - Bars
    Lv. Percent
    35.48%
    How do you warp to the same screen with a different DMap? I was planning on having the cycle be purely aesthetic, as otherwise I'd have to make at least 5 more maps just for minimal changes.

  8. #8
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    36
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,640
    Level
    25
    vBActivity - Bars
    Lv. Percent
    4.39%
    Two DMaps can point to the same Map in the same way. If you build your DMaps correctly, you can switch DMaps using a warp without actually switching screens.

    Code:
    int thisDMapScreen = Game->GetCurDMapScreen();
    int targetDMap = Game->GetCurDMap()+ DUSK;
    Link->PitWarp(targetDMap, thisDMapScreen);
    Essentially, you'll be setting up four constants: DUSK, NIGHT, DAWN, and DAY
    Code:
    const int DUSK = 1;
    const int NIGHT = 2;
    const int DAWN = 3;
    const int DAY = -3
    Then, you make sure every area you make has four DMaps, in order, starting with the Day palette. Day, Dusk, Night, Dawn. By setting up all DMaps in this order you can easily trigger a time shift by adding to or subtracting from the current DMap.
    Essentially, the goal is to trigger a DMap shift without actually triggering a screen shift. Thus, you warp to the screen of the different DMap, but since they all point to the same Map you end up unmoved, with the different palettes/music/item restrictions.


    We have to do it this way as there is no code that lets you directly set a DMap, you have to go through some manner of warp.

  9. #9
    Admiral Zim's Avatar
    Join Date
    Oct 2012
    Posts
    388
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    1,721
    Level
    13
    vBActivity - Bars
    Lv. Percent
    90.74%
    Just use a draw rectangle over the whole screen with transparency. Search in the forums for and play with zim.qst for an example if you like. I wrote my own clock, time based events, nighttime, clouds, and rain scripts. There is even a lantern that works like lttp in there but it is slightly buggy only because I didn't bother to make special overhead tiles that stay dark because Link is under them at night.

    Making extra dmaps is very impractical because then you'd have to write extra scripts that trigger secrets on every map when triggered on one, which is suitable, but so is making a black transparency rectangle over the whole screen.

    Search YouTube for Zim Zelda Classic Nighttime for a short video.
    Last edited by Zim; 08-09-2014 at 02:22 PM.

  10. #10
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    36
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,640
    Level
    25
    vBActivity - Bars
    Lv. Percent
    4.39%
    Quote Originally Posted by Zim View Post
    Making extra dmaps is very impractical because then you'd have to write extra scripts that trigger secrets on every map when triggered on one, which is suitable, but so is making a black transparency rectangle over the whole screen.
    Wait... I thought secrets were by Map screen, not DMap screen. So if you have two DMap screens pointing to the same Map screen, the secret state is not carried over from one to the other?

    I'll have to play around with that.

    You're right though, if you want to do a lamp that cuts through darkness then drawing a transparent rectangle with interpolated fading rule set is the best way to do so. I was actually picturing something completely different from darkness (a dungeon with variable heat levels that becomes increasingly orange as the time counter goes on. At the harshest temperature DMap, the player's PASSIVE_Heat Heart Ring is made an active item, causing gradual damage on each screen. I know that's not what Dry Paratroopa was after, but I was thinking setup would be the same.

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