Jump to content

Photo

Removing a set list if items from Link's inventory upon continuing


  • Please log in to reply
21 replies to this topic

#1 Anthus

Anthus

    Don't look at me, lady

  • Members
  • Pronouns:He / Him
  • Location:Ohio

Posted 24 February 2015 - 12:59 AM

What I'm looking for is a script that runs upon continuing, and it has a list of set item IDs that are removed from your inventory when you continue (or die).

 

It can list individual item IDs or a range of items (00-14 for example, or 2, 4, 19, 35, etc. if that makes sense). I don't expect the script maker to know the item IDs, but as long as it is commented on where I can put the IDs within the script, I should be able to figure it out :heh:. If Link had any of these item IDs in his inventory (rented items) he loses them. The script would need to run each time the player dies and restarts. This quest is going to use save spots, so the continue save screen will be disabled. I'm not sure if that matters or not, but thought it was worth mentioning. If you want to do this, and have any other questions, please ask away! Thanks in advance. :D

 

I would be really thankful to anyone who did this. I don't know enough about scripting to feel comfortable doing this myself yet.



#2 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 24 February 2015 - 01:08 AM

Oh, this one's easy.

const int NumRentalItems = x;
int RentalItems[NumRentalItems] = {1,2};

global script slot_2
	void run(){
		for(int i = 0; i<NumRentalItems; i++){
			Link->Item[RentalItems[i]] = false;
		}
		while(true){
			//All your global script stuff goes here
			Waitframe();
		}
	}
}
The variable called NumRentalItems needs to be set to the total number of items that can be lost on death in the quest. The array below needs to be filled with those items. For instances, let's say I want three rentable items in the quest, with IDs 6, 7, and 42. Those lines would look like this:

const int NumRentalItems = 3;
int RentalItems[NumRentalItems] = {6,7,42};
Whenever the quest is continued, the global script will remove all of those items from Link's inventory before moving in to the normal global loop, where you'd put all the global stuff like normal. It's that easy.

#3 Anthus

Anthus

    Don't look at me, lady

  • Members
  • Pronouns:He / Him
  • Location:Ohio

Posted 24 February 2015 - 01:20 AM

Russ, you are a gentleman, and a scholar! Thanks so much :D

 

What if this is currently my only global script?



#4 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 24 February 2015 - 01:44 AM

No problem!

If it's currently your only global script, then feel free to remove these lines from it:
 
		while(true){
			//All your global script stuff goes here
			Waitframe();
		}
Most global scripts have to run every frame, and thus go in a global loop like that, but if you're not using any than you really don't need that.

#5 Anthus

Anthus

    Don't look at me, lady

  • Members
  • Pronouns:He / Him
  • Location:Ohio

Posted 24 February 2015 - 11:12 AM

Ah ok. So if I leave it in and wanted to add other global scripts later, I'd put it between that while loop, right? This is all I need for the time being though. The only other global scripts I see myself using are the pit/ lava, and bottle system scripts. Thanks again :)



#6 justin

justin

    Adept

  • Members

Posted 24 February 2015 - 11:48 AM

Didn't think you could use a constant or variable to initialize the size of an array.
It's also kinda redundant if you're just gonna initialize all the array elements in the same statement, no?

Edit: anthus, did you want me to make that ffc script for the permanent purchases? Or were you going to use some other method?

Edited by justin, 24 February 2015 - 11:52 AM.


#7 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 24 February 2015 - 01:14 PM

Ah ok. So if I leave it in and wanted to add other global scripts later, I'd put it between that while loop, right? This is all I need for the time being though. The only other global scripts I see myself using are the pit/ lava, and bottle system scripts. Thanks again :)

Yes and no. It's slightly more complicated than that, but that's the gist of it. There are threads on combining global scripts, or I can help you out with it later.

Worth noting that autocorrect thought jelly was an acceptable replacement for help. If you need me to jelly you out, I can do that too according to my phone.

Didn't think you could use a constant or variable to initialize the size of an array.
It's also kinda redundant if you're just gonna initialize all the array elements in the same statement, no?

No, because this way I can make sure the for loop runs through exactly the right amount of iterations. That's the purpose of having the extra variable. That and ease of setup for the end user.
  • Anthus likes this

#8 justin

justin

    Adept

  • Members

Posted 24 February 2015 - 01:36 PM

No, because this way I can make sure the for loop runs through exactly the right amount of iterations. That's the purpose of having the extra variable. That and ease of setup for the end user.

 

except that this way (using a constant to initialize an array) doesn't compile.  i just tried.  and you can just use SizeOfArray for the right amount of interations.

 

(and you were missing a { before the void run )

 

int RentalItems[] = {1,2};

global script slot_2{
    void run(){
        for(int i = SizeOfArray(RentalItems)-1; i>=0; i--){
            Link->Item[RentalItems[i]] = false;
        }
        while(true){
            //All your global script stuff goes here
            Waitframe();
        }
    }
}


#9 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 24 February 2015 - 01:43 PM

Using a constant for an array doesn't compile? Huh... My understanding is that the compiler treats a const int as a number, so it seems like it should work. Huh... Well. Whatever. Your way seems to work fine, so thanks for catching my mistake.

#10 justin

justin

    Adept

  • Members

Posted 24 February 2015 - 01:54 PM

it must be an order of operations thing.  like the first pass of the compiler creates the memory locations of the global variables, and the next pass parses the constants into numbers.

http://www.purezc.ne...=65589#section2



#11 Anthus

Anthus

    Don't look at me, lady

  • Members
  • Pronouns:He / Him
  • Location:Ohio

Posted 27 February 2015 - 11:10 AM

Thanks again guys. I haven't been able to test this out yet, since I've been working, but after my shift today, I'll have a few days off, so I can mess around with this. As far as the FFCs combo, justin, I'm not sure yet if I will need it. I'm hoping to put together a test area and get used to using this script.



#12 SUCCESSOR

SUCCESSOR

    Apprentice

  • Banned
  • Real Name:TJ

Posted 27 February 2015 - 11:21 PM

Late to this convo. justin's edit of Russ' script looks like it will do the trick. I have a question though. Did you only want the items removed if Link dies? Russ' script will run ever single time the quest starts. That way the player might save the game and come back later and their rented items will be gone.

 

Also if you ever want the items to become permanent you are basically left creating duplicate items, which isn't that bad.

 

When i first read your original post I thought of another way of doing it. Using item pick up scripts to set the items to be removed. (Which does mean the items have to actually be picked up.)  Saves you changing and recompiling the script when you want to add a new rental item. If you ever want the item to be permanently in the inventory you just have to give it to link in a manner that the pickup script won't run.

 

This script removes the items only if Link dies.

int RentalItems[25];//a sufficiently large number

global script slot_2 {
	void run(){
		for(int i = 0; i<25; i++){
			if(!RentalItems[i]) break; //found a 0 stop
			if(RentalItems[i] < 0 || RentalItems[i] > 255){ //skip invalid item IDs
				RentalItems[i] = 0; //reset index
				continue; //skip index
			}
			Link->Item[RentalItems[i]] = false;
			RentalItems[i] = 0;
		}
		while(true){
			if (Link->HP <= 0 && !RentalItems[0]) //check if Link died and first index of our array is 0
				RentalItems[0] = -1; //any nonzero number that isn't a valid item ID will do really
		Waitframe();
		}
	}
}

item script Rental //pickup script, requires link to pickup item
	void run(){
		for(int i = 1; i<25; i++){
			if (RentalItems[i]) continue; //not a empty spot
			else {
				RentalItems[i] = this->ID; //save this item for removal at death
				break; //we're done here
			}
		}
	}
}

Obviously, if Russ' script works for you just ignore this post completely. I am just bored.



#13 Anthus

Anthus

    Don't look at me, lady

  • Members
  • Pronouns:He / Him
  • Location:Ohio

Posted 28 February 2015 - 03:16 PM



Late to this convo. justin's edit of Russ' script looks like it will do the trick. I have a question though. Did you only want the items removed if Link dies? Russ' script will run ever single time the quest starts. That way the player might save the game and come back later and their rented items will be gone.

 

Also if you ever want the items to become permanent you are basically left creating duplicate items, which isn't that bad.

 

When i first read your original post I thought of another way of doing it. Using item pick up scripts to set the items to be removed. (Which does mean the items have to actually be picked up.)  Saves you changing and recompiling the script when you want to add a new rental item. If you ever want the item to be permanently in the inventory you just have to give it to link in a manner that the pickup script won't run.

 

This script removes the items only if Link dies.

 

 

Thanks for pointing that out. Yeah, I only want him to lose the items upon death. The item pick-up way sounds interesting, but it would still require making duplicate items (I think). Another way to circumvent this, and even do it without scripts is to just have Link always continue on a screen with a string that takes away the items. I'm not exactly sure though if this can be set up so Link only continues here if he dies, and not every time the player starts the quest.

 

Thanks for the fix though, I'm glad you pointed that out, and saved me the time of figuring it out the hard way :P

 

 

 

Also if you ever want the items to become permanent you are basically left creating duplicate items, which isn't that bad.

 

Yeah, I was prepared to do that. Have all 11-13 or so rental items be copies of the real item, but that ID would be on the list, and removed, while the real one would not, and will remain in Link's inventory for all time. Setting up the items will take some time cause there is no way to directly copy them, and you actually do have to go in, and remake all of them, but I still feel like this is the cleanest way to do it.

 

 

EDIT: My first post was worded poorly. It does sound like I mean when you continue and die, but I think it's unfair, and annoying to take them when you quit.



#14 SUCCESSOR

SUCCESSOR

    Apprentice

  • Banned
  • Real Name:TJ

Posted 01 March 2015 - 05:41 AM



Thanks for pointing that out. Yeah, I only want him to lose the items upon death. The item pick-up way sounds interesting, but it would still require making duplicate items (I think).

With my script you don't need duplicate items. You just have to give link the items in a manner in which teh pickup script won't run such as String Control Codes, Setting Link->Item[], or some other way I can't think of right now. If Link doesn't actually pick up the item then the item script doesn't run and the item script never sets up the item to be removed.


Edited by SUCCESSOR, 01 March 2015 - 05:41 AM.


#15 Anthus

Anthus

    Don't look at me, lady

  • Members
  • Pronouns:He / Him
  • Location:Ohio

Posted 01 March 2015 - 06:09 PM

With your version of the script, does the number of items have to match the amount defined at the beginning of the script? I don't see where I put the individual item numbers, if that's the case. It looks slightly different than Russ', and it looks like it is only checking for items within that range. If that's the case, does the first item that Link doesn't lose have to be higher than 25?

 

I may seem stubborn in this regard, but I think I still am going to use the duplicate item method. This way, the stores can still be set up as regular, non-scripted 3-item shops (well, six, including the other room for real items). Unlike ALBW, there will be four different item shops, instead of one central one. I'm going to try to compile the script, and see how it works.

 

 

EDIT: The more I think about it, and work out ideas in my head, I'm starting to ask myself if such an idea would even be fun in ZC. The difficulty would have to be balanced really well, and it might end up being way too easy to eliminate constant deaths, and rupee grinding. It could still be fun, but maybe with only a few items, and not all of Link's items. Alternately the player could grind for rupees, and get all the items really early. This is a hard idea to plan out. 




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users