User Tag List

Results 1 to 7 of 7

Thread: Bomb Refill Script help

  1. #1
    Gel
    Join Date
    Jan 2007
    Age
    38
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    713
    Level
    9
    vBActivity - Bars
    Lv. Percent
    41.22%

    Unhappy Bomb Refill Script help

    At the beginning of my game, bombs are a bit crucial and I wanted to make sure the character could get a refill without continuing to load up to the max infinitely. I also wanted to try my hand at scripting, this is my first script.

    Code:
    import "std.zh"
    ffc script bomb_refill {
        void run() {
        itemclass bombclass = LoadItemClass(IC_BOMB);
            if ( (Link->X - this->X) <= 16 ) {
                if( 0 <= (Link->X - this->X) ) {
                    if ( (Link->Y - this->Y) <= 16 ) {
                        if ( 0 <= (Link->Y - this->Y) ) {
                            if (Link->Item[3]) {
                                Link->Item[3]=true;
                                bombclass->Counter[CR_BOMBS]=4;
                            }        
                            else {
                                if (bombclass->Counter[CR_BOMBS]<4) {
                                    bombclass->Counter[CR_BOMBS]=4;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    However, when I try to compile this, it tells me the signature doesn't match for LoadItemClass(float). I've tried using the const from std.zh, as above; I've tried just typing in 27; and because it mentions it as float, I've also tried typing 0.0027. All return the same error. I've also tried just putting LoadItemClass in everywhere I used 'bombclass', but then it told me it wasn't expecting the arrow. What am I doing wrong? I've looked at some code on the forums, I've read the documentation from the stickied thread, but I don't think I've seen an example specifically of LoadItemClass being used. Although CDawg's enemy HP modifier had similar syntax...

    I'd just like to know what I'm missing. I've already gone through a lot correcting errors, and learning all the while. But this one has me stumped.

  2. #2
    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,433
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.17%

    Re: Bomb Refill Script help

    This should fix that problem:
    Code:
    itemclass bombclass = Game->LoadItemClass(IC_BOMB);
    One other simple thing I see: I believe you meant to use if (!Link->Item[3]) { on line 9.

    There are a couple of trickier problems that would undoubtedly be quite frustrating.
    After you change the function call above, the compiler will complain about how itemclass->Counter isn't an array. That isn't what you should be using, anyway; the number of bombs is stored in Game->Counter[CR_BOMBS]. itemclass->Counter just gives you the array index for Game->Counter (that is to say, bombclass->Counter is CR_BOMBS). So, you don't actually need to load up bombclass at all.

    Especially important: you need to wrap everything in while(true) { /* ... */ Waitframe(); }. Otherwise, it'll only run for the first frame the FFC is on the screen. If Link's not in the proper range immediately, it'll never have any effect.




    The script, with those revisions:
    Code:
    import "std.zh"
    ffc script bomb_refill {
        void run() {
            while(true) {
                if ( (Link->X - this->X) <= 16 ) {
                    if( 0 <= (Link->X - this->X) ) {
                        if ( (Link->Y - this->Y) <= 16 ) {
                            if ( 0 <= (Link->Y - this->Y) ) {
                                if (!Link->Item[3]) {
                                    Link->Item[3]=true;
                                    Game->Counter[CR_BOMBS]=4;
                                }        
                                else {
                                    if (Game->Counter[CR_BOMBS]<4) {
                                        Game->Counter[CR_BOMBS]=4;
                                    }
                                }
                            }
                        }
                    }
                }
            Waitframe();
            }
        }
    }

  3. #3
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,612
    Level
    24
    vBActivity - Bars
    Lv. Percent
    100%

    Re: Bomb Refill Script help

    I'm very happy someone coded this. I've been intending to code up an arrow refilling script for some time now, and have not got around to it. Thanks!

  4. #4
    Gel
    Join Date
    Jan 2007
    Age
    38
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    713
    Level
    9
    vBActivity - Bars
    Lv. Percent
    41.22%

    Re: Bomb Refill Script help

    Thanks for all the help, Saffith!

    Yeah, exactly how to use Counter[] and itemclass->Counter was confusing me a bit. I'm glad to understand it better.

    EDIT: I asked about the !, but then I looked again at WHERE it is, and figured it out. Silly me. Thank you!

    And, thanks, C-Dawg! I'm glad just posting it for help makes it useful.

    Also, it looks like it still didn't update yesterday, but if a mod could delete that other topic of mine...I thought I'd changed the name and contents to ask so, too. My 'net cut out right when I was trying to post, and I wasn't seeing any of the forum's changes until well after they occurred once I got it back anyways, so I thought my post hadn't gone through.

    I'll try changing the name and contents again.

    EDIT #2:

    Alright! Compiled, tested...I wanted it to play the item sound effect, so I added that in too, and also, my position checking was a bit off. Now I've tested and fixed it, and it's perfect.

    Code:
    import "std.zh"
    ffc script bomb_refill {
        void run() {
            while(true) {
                if ( (Link->X - this->X) <= 16 ) {
                    if( Link->X >= this->X ) {
                        if ( (Link->Y - this->Y) <= 16 ) {
                            if ( Link->Y >= this->Y ) {
                                if (!Link->Item[3]) {
                                    Link->Item[3]=true;
                                    Game->Counter[CR_BOMBS]=4;
                                    Game->PlaySound(25);
                                }        
                                else {
                                    if (Game->Counter[CR_BOMBS]<4) {
                                        Game->Counter[CR_BOMBS]=4;
                                        Game->PlaySound(25);
                                    }
                                }
                            }
                        }
                    }
                }
            Waitframe();
            }
        }
    }

    Here's an image of it working, too. (Some of the graphics are messed up since I moved tiles around and haven't fixed it yet.)

    I didn't use the SFX_ values because the quest file this is built off of is the old newfirst.qst, which doesn't have all the newer SFX. 25 is, at least in that one, the sound for picking up an item. :)

    I'm thinking I'll maybe have it delete the FFC on contact as well, only to pop back up when you re-enter the room...I'm also thinking of disabling the use of weapons on that DMAP, since it's afterall a house. But right now, I like being able to bomb the table and then refill. :)

    Thanks for all your help, Saffith!

    Sidenote: They said the raft thing was fixed in beta 16, but it isn't! I'll have fun playing with scripts in the mean time, but my quest is on hold right near the beginning waiting for the raft back. Maybe I'll do a script for that, too, although I'd have to basically duplicate the exact workings of the raft (down to following raft flags) for my raft mini-game to work properly...

  5. #5
    Developer
    ZC Developer
    jman2050's Avatar
    Join Date
    Jun 2001
    Location
    Do you really need to know
    Age
    37
    Posts
    3,883
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    5,710
    Level
    23
    vBActivity - Bars
    Lv. Percent
    46.28%

    Re: Bomb Refill Script help

    I tested the raft myself. It worked properly for me O_o
    AGN's Resident Zelda Classic Developer and Sonic the Hedgehog Fanboy

  6. #6
    Gel
    Join Date
    Jan 2007
    Age
    38
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    713
    Level
    9
    vBActivity - Bars
    Lv. Percent
    41.22%

    Re: Bomb Refill Script help

    Really?

    Maybe it's just 'cause my quest was started in b15...

    I'll try some things. Importing an unencoded, and such.

    If it works I'll continue, but I've started this quest over so many many times in the past, I don't want to do it again just to get it to work with the current beta.

    Though technically, even if unencoded doesn't work, I can import a zgp, the maps, strings, and music...

    Music's another thing. Since 2.10 I haven't had use of MIDI in either Zquest or Zelda. I've read various fixes on the forum, mainly, change your device in Sounds & Audio Devices. But all I've got is Microsoft Wavetable SW Synth. I also downloaded the old agsetup.exe and played with that, that used to work a long time ago, but no luck.

    Oh well, that's probably something to report somewhere else. I know a number of people have reported it before, though, but I don't think I've seen an answer yet that's worked. But if I can get sound working on another computer, I can set up my MIDIs there. I'll just be happy knowing others can hear it and it loops properly.

    EDIT!: Looking back through the Open ZC bug forum, I DID find a solution that, funny enough, works! Playing a particular MIDI (in Media Player or whatever you have) resets something, and ZC plays music again! I swear, that thread should be stickied or something for the people with this problem. The person that found it said you have to listen to the song all the way through. I did so, I haven't tried without doing so, so about that I don't know. But the song is here: http://www.vgmusic.com/music/console...irror_boss.mid

    I don't know why it works, but it does. That makes me happy.

    EDIT, on the raft: Hm, nope. Unencoded quest didn't change anything. Also, the B button's broken, I'd forgotten to mention. I tried importing everything separately, but it couldn't import the maps: Incomplete Data. Tried complete, Prefer Original, and Prefer Import. All had the same response.

    Sooo I'll be waiting a bit and learning more about scripting, in the mean time. :)

  7. #7
    Gel
    Join Date
    Jan 2007
    Age
    38
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    713
    Level
    9
    vBActivity - Bars
    Lv. Percent
    41.22%

    Re: Bomb Refill Script help

    Well, good news! My music's working (as long as I leave media player open after playing that file), I got the raft working again, that bomb script works great, and now I'm almost finished with a raft mini-game script.

    The issue my quest was having with the raft was, I forgot I'd tried putting an inherent raft flag on the dock. When I removed that and put a regular flag there, it worked fine. ^_^

    I may end up posting the raft script soon. It's working almost perfectly now, except that for some reason a number of rupees I create never leave 0,0 even though I tell them to, and it's in a while(true) { Waitframe(); } loop, and everything! (It's also in a while(NumItems() < number_I_want) loop)

    About three to four (it's rather random) of the items stay in place even when I tell them to move. I reference them with a variable, curritem, that I cast in the outermost scope and increment at the end of the NumItems loop IF it's on a combo where a raft flag is placed. Yet some still don't move, and I don't understand. I'll post the code soon. In the mean time, I've just upped the number of items it creates and made the ffc the same water combo that's beneath it and 'draw over'. ^_^

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