Jump to content

Photo

Inventory system and Goron Tunic


  • Please log in to reply
9 replies to this topic

#1 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Gender:Male
  • Location:Palm Desert, CA

Posted 20 April 2017 - 04:00 PM

Okay, so, people have explained to me how to use arrays about a billion times and I still just don't get it, so here's what I need:

 

Check if Link has I_ADULTLINK or I_CHILDLINK (item IDs 143 and 144, respectively)

Record items in Link's inventory as they're collected, as well as the value of CR_ARROWS to separate arrays, one for child Link and one for adult Link.

Remove child items and reset CR_ARROWS if Link->Item[I_ADULTLINK] == true

Add items from the adult array and set the value of CR_ARROWS to what is stored in the adult array if Link->Item[I_ADULTLINK] == true

Remove adult items and reset CR_ARROWS if Link->Item[I_CHILDLINK] == true

Add items from the child array and set the value of CR_ARROWS to what is stored in the child array if Link->Item[I_CHILDLINK] == true

I'm about 95% certain I can handle the character switching aspect, myself since I plan to recycle the script I used in another quest.

 

Items to be placed in the arrays

 

All of the other items are shared between the two, so they won't need to be part of the script (The gold ring is placed via item override, the red ring will be used separately, below). 

 

EDIT: I could just use dummy items like I did for my last character switching script, but it uses a LOT of item slots, and it's pretty messy; plus I wouldn't be able to keep track of the arrow counter so that I don't have to script a separate bow and arrow for adult Link. An array is just much cleaner.

 

As for the other request, I'm using Mero's hot room script:
 

Hot Room Script

And I need it to give Link I_RING2 if he is in a hot room and take it away if he's not, but I'm not sure where to add the Link->Item[I_RING2] = true; and Link->Item[I_RING2] = false; lines, so it's not really a request, I just need a little advice

 

EDIT: It occurs to me I forgot to say please. That wasn't very polite of me.


Edited by Binx, 20 April 2017 - 08:48 PM.


#2 Dimentio

Dimentio

    Edgy unwanted opinions

  • Members
  • Real Name:Joshua
  • Gender:Male
  • Location:America's Hat.

Posted 21 April 2017 - 05:25 AM

Okay, so, people have explained to me how to use arrays about a billion times and I still just don't get it, so here's what I need:

 

Check if Link has I_ADULTLINK or I_CHILDLINK (item IDs 143 and 144, respectively)

Record items in Link's inventory as they're collected, as well as the value of CR_ARROWS to separate arrays, one for child Link and one for adult Link.

Remove child items and reset CR_ARROWS if Link->Item[I_ADULTLINK] == true

Add items from the adult array and set the value of CR_ARROWS to what is stored in the adult array if Link->Item[I_ADULTLINK] == true

Remove adult items and reset CR_ARROWS if Link->Item[I_CHILDLINK] == true

Add items from the child array and set the value of CR_ARROWS to what is stored in the child array if Link->Item[I_CHILDLINK] == true

I'm about 95% certain I can handle the character switching aspect, myself since I plan to recycle the script I used in another quest.

 

Items to be placed in the arrays

 

All of the other items are shared between the two, so they won't need to be part of the script (The gold ring is placed via item override, the red ring will be used separately, below). 

 

EDIT: I could just use dummy items like I did for my last character switching script, but it uses a LOT of item slots, and it's pretty messy; plus I wouldn't be able to keep track of the arrow counter so that I don't have to script a separate bow and arrow for adult Link. An array is just much cleaner.

 

As for the other request, I'm using Mero's hot room script:
 

Hot Room Script


For the first question: Arrays are basically multiple variables with the same name. They are declared by putting square brackets at the end of the variable's name when creating the variable (no spaces between the end of the name and the start of the brackets), with a number inside the brackets representing how many indexes (or, how many variables) you want inside the array.

bool ChildItems[6];

Arrays indexes start from 0. So, Index 1 would be ChildItems[0], Index 2 would be ChildItems[1], etc. The last index would be ChildItems[5]. Some things count from 1 instead of 0, but you shouldn't need to worry about that at this point.

Anyways, if you can keep track of which number responds to which item, it should be fairly simple to keep track:

ChildItems[0] = true; //Child Link now has the bow item.
ChildItems[1] = false; //Child Link no longer has bullet item.
ChildItems[2] = true; //Child Link now has Child Link item
if (ChildItems[3] == true) DoSomething(); //Do Something if Child Link has boomerang

//etc

For your second question, I edited in where it should go inside your code bracket, along with the appropriate if/else statement.
  • ShadowTiger likes this

#3 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Gender:Male
  • Location:Palm Desert, CA

Posted 21 April 2017 - 08:53 AM

Yeah... I still don't get it. Like I said, it's been explained a billion times, and you could explain it a billion more and I will never understand. Sorry, but that's why I placed this in the request forum, rather than Scripting Discussion. This code would work:

Overly messy character switching script

The problem is that the dummy items take up 24 slots that I'd rather not have to use, and it causes MASSIVE slowdown, plus, I can't figure out how to reset the Game->MCounter[CR_ARROWS] and Game->Counter[CR_ARROWS] values to 0 without also changing the values of BULLETMAX, ARROWMAX, BULLETS, and ARROWS, because I need those variables in order to set the values of the counters to the appropriate amounts for child and adult Link. So, all I need is to turn that code into an array format, and telling me how to do it isn't helping because I just don't understand, and I will never understand. I know no one is required to do this, but I'd really appreciate it if someone could fix the code so it will work without dummy items and without causing ZC to run at a snail's pace.

 

As for the hot room script, I seem to be having a slight problem integrating it into my global, the part after the waitframe goes in fine, but when I try to add the part before the waitframe I get an error saying it's missing a semicolon at line 27, but I've checked, and I'm not missing any semicolons, so I'm not sure what's going on. Here's the full global script, as it currently stands:

https://pastebin.com/BheDcBe0


Edited by Binx, 23 April 2017 - 02:24 PM.


#4 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Gender:Male
  • Location:I wish I knew

Posted 21 April 2017 - 09:44 AM

So if I understand this correctly you want the script to change the items you currently carry depending if your an adult or child.

Do you use two different subscreens for each age? Are Dmaps for each age the same or different?

You might not need a script to get away with what your after but I'll have to test a few things first to tell you.

#5 Dimentio

Dimentio

    Edgy unwanted opinions

  • Members
  • Real Name:Joshua
  • Gender:Male
  • Location:America's Hat.

Posted 21 April 2017 - 10:13 AM

Yeah... I still don't get it. Like I said, it's been explained a billion times, and you could explain it a billion more and I will never understand. Sorry, but that's why I placed this in the request forum, rather than Scripting Discussion. This code would work:

Overly messy character switching script

The problem is that the dummy items take up 24 slots that I'd rather not have to use, and it causes MASSIVE slowdown, plus, I can't figure out how to reset the Game->MCounter[CR_ARROWS] and Game->Counter[CR_ARROWS] values to 0 without also changing the values of BULLETMAX, ARROWMAX, BULLETS, and ARROWS, because I need those variables in order to set the values of the counters to the appropriate amounts for child and adult Link. So, all I need is to turn that code into an array format, and telling me how to do it isn't helping because I just don't understand, and I will never understand. I know no one is required to do this, but I'd really appreciate it if someone could fix the code so it will work without dummy items and without causing ZC to run at a snail's pace.

 

As for the hot room script, I seem to be having a slight problem integrating it into my global, the part after the waitframe goes in fine, but when I try to add the part before the waitframe I get an error saying it's missing a semicolon at line 27, but I've checked, and I'm not missing any semicolons, so I'm not sure what's going on. Here's the full global script, as it currently stands:

https://pastebin.com/BheDcBe0


What is with the brackets around Update_HotRoom();?



#6 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Gender:Male
  • Location:Palm Desert, CA

Posted 21 April 2017 - 10:29 AM

So if I understand this correctly you want the script to change the items you currently carry depending if your an adult or child.

Do you use two different subscreens for each age? Are Dmaps for each age the same or different?

You might not need a script to get away with what your after but I'll have to test a few things first to tell you.

The DMaps are different, and, but using separate subscreens won't solve the problem, as a number of the items are passive equipment (boots, tunics, flippers, rings, quivers, bows, shields, swords), so I have to be able to take those items away and give them back, which is what the dummy items in my script are for; and besides, using a single subscreen is much cleaner and looks nicer; I will most likely be using a handful of dummy items, but only to display the items Link has collected and can't use in grey, since checking for them in the script seems to be what causes the system to lag. Plus, it wouldn't solve the arrow problem. If it wasn't explained well, I need to be able to, when Link becomes an adult or a child, reset the arrow counter and it's maximum value to 0, then set the max to whichever quiver item he has in that form and the arrows to how many he had the last time he was in that form. As an example, if Link has a slingshot (bow 1) and a bullet bag (Quiver 1 or 2) and becomes an adult, I need to record how many arrows he had as a child, and how many arrows he could carry, reset the counter and maximum allowable arrows to 0, take away his slingshot and bullet bag, and then Adult Link will have to get his own quiver (Quiver 3 or 4, which have the same max values as 1 and 2) and bow (bow 2). But when he becomes a kid again, I need to record how many arrows adult Link can carry, how many he has, reset the counter and maximum carry amount BACK to 0, set the maximum arrows back to what child Link could carry, and set the counter to the number of bullets he had before he became an adult the last time; and then when he switches again, reset the counters to what Adult Link was/could carry. So, if Child Link pulls the Master Sword with 20 bullets out of a maximum of 30, when he becomes an adult for the first time, he will have 0 arrows, and won't be able to carry any, until he gets his own quiver and bow, but if he has 30 arrows out of a possible 60 when he becomes a child again, he will be reset back to 20 bullets out of a maximum 30 (I'm doing this so I don't have to script a new bow and arrow weapon, since neither will be able to use the other's bow and arrow, anyways, but I want to keep their totals separate, as it was in the original OoT).
 


What is with the brackets around Update_HotRoom();?

Eh, they were there in the original script. do I not need them? Oh, I don't need them. Cool, thank you.


Oh, and also, because I completely forgot to mention it, I need to be able to respawn the character switching item every time Link enters the Master Sword room in the Temple of Time, so that he can change between the two consistently, but only in that specific place (otherwise I'd use it as an action script instead of pickup, like I did in Sunday Funeral: Destiny's Song).


Edited by Binx, 21 April 2017 - 11:46 AM.

  • Dimentio likes this

#7 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Gender:Male
  • Location:Palm Desert, CA

Posted 21 April 2017 - 11:59 AM

Something weird happened when I put in the global script. Link now has a whirlwind over his head at all times. I think the placement of the hot room script is interfering with the Farore's Wind global (since that uses the whirlwind in the code). Here are all the scripts I'm using:

 

Main Buffer file (OoTClassic.z):
https://pastebin.com/J8eSFwT8

 

Constants (OoTConstants.z):

https://pastebin.com/0FWVVUi1

 

Slot 2 Global (OoTGlobal.z):

https://pastebin.com/E9PnN5pX

 

FFCs (OoTFFC.z):

https://pastebin.com/T7e0ebXt

 

Items (OoTItems.z):

https://pastebin.com/XQxTKb3Q

 

EDIT: The Farore's Wind script doesn't use the whirlwind sprite, I was mistaken. I have no clue why it's spawning a whirlwind over his head.


Edited by Binx, 21 April 2017 - 01:11 PM.


#8 Dimentio

Dimentio

    Edgy unwanted opinions

  • Members
  • Real Name:Joshua
  • Gender:Male
  • Location:America's Hat.

Posted 21 April 2017 - 01:23 PM

Something weird happened when I put in the global script. Link now has a whirlwind over his head at all times. I think the placement of the hot room script is interfering with the Farore's Wind global (since that uses the whirlwind in the code). Here are all the scripts I'm using:

 

Main Buffer file (OoTClassic.z):
https://pastebin.com/J8eSFwT8

 

Constants (OoTConstants.z):

https://pastebin.com/0FWVVUi1

 

Slot 2 Global (OoTGlobal.z):

https://pastebin.com/E9PnN5pX

 

FFCs (OoTFFC.z):

https://pastebin.com/T7e0ebXt

 

Items (OoTItems.z):

https://pastebin.com/XQxTKb3Q

 

EDIT: The Farore's Wind script doesn't use the whirlwind sprite, I was mistaken. I have no clue why it's spawning a whirlwind over his head.

Did you delete your save file and make a new one? Existing save files break when you add in global variables, which I think the hot room script has.



#9 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Gender:Male
  • Location:Palm Desert, CA

Posted 21 April 2017 - 01:30 PM

Oh, duh. Yeah, that was the problem. Ok, that's one down, 3 to go, and I'll be completely done with the scripting, and I can focus solely on mapmaking.



#10 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Gender:Male
  • Location:Palm Desert, CA

Posted 23 April 2017 - 02:05 PM

I just had an idea! If I make 120 different types of arrow ammo drops, then I could keep track of the number of arrows by assigning the value ARROWS or BULLETS to whatever the Link's current ammo total is, depending on if he's an adult or child, then reset the counters as above, and just drop an ammo bundle on them correlating to BULLETS/ARROWS. So, if Link has 30 bullets on him when he becomes an adult, it'll drop a 30 bullet bundle on top of him after it resets his arrow total. The only problem which occurs to me is making sure it doesn't update the the ammo value after it resets but before it gives you the bundle. Other than that, I could drop the quivers directly on Link's head instead of passively adding them to his inventory (since passively adding it doesn't update your max carryable), and then just keep track of the passive items with the script. Then it's just a matter of making two subscreens which just don't have the unselectable items since they will always be on different DMaps. I'd also have to find a way to make it only happen when you switch from adult to child. Before I needed to be able to switch on the fly, I might just be able to work it all into the item script, right? That would certainly solve the lag issue.

 

EDIT Maybe if I make it reset the counter before I make it switch the items between adult and child, so you're still an adult when you lose the arrows becoming a child and vice versa? Wait, no... then you'd still have one of the variables being reset to 0, it would just be the other one. Wait... here's an idea, have it take away the adult/child item, then run the item switching code while neither counter variable is being updated (since each only gets updated while you have either the child or adult item),  drop the appropriate bundle and quivers on Link, then give the child/adult item?


Edited by Binx, 23 April 2017 - 02:24 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users