Jump to content

Photo

Updated Minecart Script


  • Please log in to reply
9 replies to this topic

#1 ywkls

ywkls

    Master

  • Members

Posted 20 June 2015 - 10:17 PM

I'm working in the latest version of Zelda Classic (2.50.1, I believe), using the Dance of Remembrance (Hybrid) tileset and if you haven't guessed by now; I'm trying to give my game a minecart (and failing miserably).

 

The latest script I found was by Mr. Z, courtesy of MoscowModder.(There is another more recent one, but I wasn't able to puzzle out how it works.) If anybody want's to look at those scripts for ideas, here are links to them.

 

Requested by Rastael- I don't understand this one enough to figure out if it would do what I want.

http://www.purezc.ne...art#entry855530

 

Requested by Mr. Z- This one doesn't seem to work right and I don't think it was ever finished.

http://www.purezc.ne...art#entry840195

 

I've tried a few versions of my own.

 

One attempt tried to give my character a special MIneCart item that replaces the raft when they step on the ffc, so while rafting you look like you're riding the Mine Cart. When I used this method, the game acted as if I had lost the raft altogether. (Though if I approached the dock with either the raft or Minecart item in my inventory and the ffc wasn't there, you went down the path just like normal.)

 

Another tried to make it when my character touched the MineCart ffc, it would follow him and overlay itself; while hitting another would turn those off and stop it from following him. Unfortunately, even when the ending ffc was not the same ffc number; the overlay, carryover and following effect didn't stop.

 

I'm just about out of ideas for this, except for the one I'm about to suggest. There are two scripts that I already have that I think could be combined to create an effective Mine Cart script.

 

The first is this Moving Platform script, created by Moosh.

 

Spoiler

 

The second is this script, which creates an ffc that follows link.

 

Spoiler

 

The moving platform script doesn't work very well when crossing to a new room, but the follow link script does. With the moving platform, you can set changers that will alter your direction or the id of the ffc that hits them, making the moving platform change direction and appearance.

 

There may be other methods which would do the same thing, but so far I haven't been able to puzzle any of them out. Another feature that both of these script lack is a way to make them stop at a certain point, like when you encounter a certain ComboType or ComboFlag. My thanks in advance to anyone who can provide me with some assistance!

 



#2 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 21 June 2015 - 05:35 PM

Unless your script works as a simple modification of the rafting graphics, it would need to have a global component. Otherwise nothing would be drawn during screen scrolling. This thread has info on how to do that. I think a single global variable would be the easiest way to do this. If that variable is set to true and you change screen (with the usual method of detecting that), it would immediately snap an FFC to Link's position on the new screen and continue the movement. You'd probably need to store the FFC's velocity to a local variable in the global script to transfer that to the new screen also. Directional changes on the track could be handled with changers like you suggested. An FFC script could serve as the start and end points. You'd need a couple loops consisting of just Waitframe(); at the start of that script, to handle the conditions for getting on/off the cart. And if you want Link to be able to swing his sword and use items like the Oracle games minecarts, that's another can of worms.
  • ywkls likes this

#3 ywkls

ywkls

    Master

  • Members

Posted 21 June 2015 - 07:20 PM

The main problem I have with my attempts is transferring information between ffcs, which is why I thought of using a global loop like you suggested. As I imagine it, I'd need an ffc script made so that when you encounter that ffc and aren't moving it begins to follow Link but doesn't carryover. Instead, because it has set the bool to true (let's call this OnCart for simplicity) the global runs the function CartMove. While running that, if you transited the screen; it would pull an ffc to your location and make it display the right graphics while you were onscreen. When you got to the end, because the bool was true, it would then be set to false and you would stop moving.

 

The difficulty i've been having is this. Making it stop and start properly. I can make the cart start following you; even follow you from room to room. But when I reach the end, even though I've encountered the ffc there; it doesn't stop. It keeps following you indefinitely. Perhaps I should have changers at the end that alter it's velocity to zero.

 

Or maybe make a script that says this.

const int MINE_CART_COMBO = 30344;// Combo used for minecart.

ffc script MineCart{
    void run(){
         while(true){
               if(Link->Action == LA_RAFTING){//Would this work? Just place the ffc anywhere on screen and if you enter that screen while rafting it makes it look like a mine cart.
                   this->X = Link->X;
                   this->Y = Link->Y+12;
                   this->Flags[FFCF_OVERLAY] = true;
                   //This code make the combo change to match you direction and actually works.
                   if(Link->Dir == DIR_UP || Link->Dir == DIR_DOWN)this->Data = MINE_CART_COMBO;
                   else{
                        this->Data = MINE_CART_COMBO+1;
                   }
               }
               Waitframe();
         }
    }
}                  

This idea is completely untested. In fact, I'm going to run and try it out now! I'll let you know how it works.

 

(Spends several minutes testing and debugging it...)

 

And for the most part, it works! The only glitch I can see is that the raft is still partially visible. Is there a way to temporarily make an item invisible or change its graphics?


Edited by ywkls, 21 June 2015 - 07:20 PM.


#4 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 21 June 2015 - 07:58 PM

If you don't have a real raft in your game, you can just blank out its item tile, since that's what rafting uses. If you want to do it on a temporary basis, you'll have to mess around with CopyTile and ClearTile.

#5 ywkls

ywkls

    Master

  • Members

Posted 22 June 2015 - 12:19 AM

@Lejes- I've been looking through my notes on scripting (most of which I've posted in another topic) and I haven't been able to find any information on those CopyTile and ClearTile commands you mentioned. Are they functions, or commands you would use like Screen->DrawCombo? If they are functions, what header includes them? Can you give me an example of how they are used, with a breakdown of what each argument is supposed to represent?



#6 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 22 June 2015 - 12:59 AM

They're in zscript.txt. Not a part of any header, nor are they under any namespace or pointer. They alter the tile sheet itself while the quest is loaded, so resetting ZC will undo any tiles they've altered. What you could do is blank out the raft tile with ClearTile, then use CopyTile to copy over a duplicate raft tile (which you would set up beforehand in ZQuest) onto the spot you blanked out when the minecart is done.
 

//begin minecarting
ClearTile(TILE_RAFT);

//minecarting in progress

//end minecarting
CopyTile(TILE_RAFT_ALT, TILE_RAFT);


#7 ywkls

ywkls

    Master

  • Members

Posted 22 June 2015 - 09:46 AM

It boggles my mind sometimes how many strange and mysterious things can happen while constructing a script. I'm pretty sure that what I managed to put together is about 90% done but there's still a flaw that I need help pinning down.

 

Here's my current code.

 

Minecart Script

When you start the mine cart and there's only one everything is fine. When there is more than one, only the one you collide with follows you. When you enter a room riding a cart and there is more than one, a cart follows you. However, the other one may also follow you because it disappears.

 

I think that the problem is with the int CartHandler. It is supposed to only activate when you're already on the cart, but it apparently activating at any time. I'll probably mull over this for a while and see if I can work out a solution; but right now I can't think of one. Any suggestions would be appreciated.


Edited by ywkls, 05 October 2015 - 11:13 AM.


#8 ywkls

ywkls

    Master

  • Members

Posted 22 June 2015 - 03:03 PM

Okay, I've refined this code to a point that it will do what I want for it to, although there are still a lot of limits to what it can accomplish. Unless a way around those can be devised; I'm stuck with this version which makes the Mine Cart work but requires a particular setup of multiple carts in the room to work.

 

Here's the code.

 

Minecart Script

I've tested it out and it works. Simply place an ffc on the screen where you want the mine cart effect to appear with the proper script in its slot. If you start using it on that screen, the best place would be where the mine cart is supposed to stop. If you have more than one mine cart on screen, make sure that none of them exit the same side of the screen and place one at each staring point. That's it!


Edited by ywkls, 05 October 2015 - 11:12 AM.


#9 ywkls

ywkls

    Master

  • Members

Posted 05 October 2015 - 11:12 AM

Okay, this script has a really, really annoying bug. I've tried multiple ways of correcting it but I can't seem to figure out what I'm doing wrong. So, I'm reviving this topic in the hope of getting some advice on correcting the problems that it has been having.
 
First, the script.

 

Minecart Script

 

Now, for the bugs that it has...

 

When there are multiple carts in the room and you're riding one of them, the others become invisilble whether they are supposed to be or not.

 

When you enter the correct side of the room, the cart is not always moved to your location and it doesn't always set the flags for overlay to true and changer to false.

 

I've tried multiple ways of making this work and I'm getting really frustrated with it. So, I'd appreciate some feedback on how to fix this script. I can post an example quest to show the behavior if that helps.



#10 ywkls

ywkls

    Master

  • Members

Posted 07 October 2015 - 10:20 AM

I finally came up with a method of getting each cart to appear properly. It's not pretty, but it works. Here's the code.

 

Mine Cart Script

 

With the tracks as inherently flagged combos, changing the course of the cart shouldn't be too hard. The trouble is as Lejes said earlier; using items while on the cart. i don't need to do this at this point, but maybe someday...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users