Jump to content

Am I missing something? (food items)


Recommended Posts

Umm... that doesn't answer my question (perhaps I asked it badly?). Food items do show up in inventory. What I'm wanting to do is to give the player a choice to give a (generic) food item to a NPC.

 

Obviously, the option should only come up in dialog if someone in the party actually has a food item. But I don't care WHAT particular food item (fish, bread, steak, whatever) it might be.

 

So... do I have to check for each food item the party MIGHT have individually (until I find one or work through every possible food item), or is there an easy way?

 

-spdyerbytes

Link to comment
Share on other sites

Quote:
Originally written by spyderbytes:
Obviously, the option should only come up in dialog if someone in the party actually has a food item. But I don't care WHAT particular food item (fish, bread, steak, whatever) it might be.

So... do I have to check for each food item the party MIGHT have individually (until I find one or work through every possible food item), or is there an easy way?

-spdyerbytes
You will have to change food and give it a special class (say 0). To do this, in your scenario data file, do things like this

Code:
// Give Bread special class 0begindefineitem 450;	import = 4;begindefineitem 4;	import = 450;	it_special_class = 0;// Give Mushrooms special class 0begindefineitem 450;	import = 5;begindefineitem 5;	import = 450;	it_special_class = 0;
and so on. If you do this for all the foods, you can use the item_of_class functions everywhere to query for food.

Edit: Newtfeet beat me to the post.
Link to comment
Share on other sites

Quote:
Originally written by Newtfeet:
What is that begindefinecreature bit in there? What does that have to do with items?
Heh. The danger of not reading before I post. This was a mistake and I editted while you posted.

I copied the example from the Chitrach level bump in VoDT (which is creature, not item). I forgot to make definecreature as defineitem everywhere.
Link to comment
Share on other sites

Quote:
Originally written by Newtfeet:
Remind me why we have those "begindefineitem 450" and "import = 450" lines in there.

Edit: And crap, I double posted.
It's because we just want to edit item 4, instead of completely replacing it. Starting with begindefineitem 4; will just erase that item.
Link to comment
Share on other sites

Quote:
Originally written by Newtfeet:
Remind me why we have those "begindefineitem 450" and "import = 450" lines in there.

Edit: And crap, I double posted and the first post is complete nonsense.
Simple. I copied Bread into slot 450 which is the first empty item slot. I then cleared slot 4 (you can redefine ANY item slot you want) so that I could alter it. I loaded in all the data for Bread (which is now in slot 450) and added the extra definition to give it a special class.

Rinse, lather, repeat.

You cannot just say begindefineitem 4 as that will erase all the old Bread information. And I did not want to leave Bread as item 450, as then I would have two different types of Bread.
Link to comment
Share on other sites

Yikes! That's way more work than the importance of this exchange to my scenario. smile I'll either figure out something different or make the NPC picky about what he eats. wink

 

I would have thought there would be a simple single call for this, since Jeff is most likely grouping all food together somewhere internally (to facilitate taking some when the party sleeps or enters certain terrain types or whatever). I mean, if all food has the same value for 'variety', he's bound to have some way to query inventory by variety, I would think. It's likely just not public.

 

Thanks for explaining how to do it, though. smile

 

-spyderbytes

Link to comment
Share on other sites

Ok, so let me set this all out.

 

clear: Obvious. Sets all the values for the object currently being edited to their defaults.

property = new_value: Also obvious. Sets the value "property" to "new_value" for the object currently being edited.

import = which_object: Replaces all the values for the object currently being edited to the values for "which_object". If "which_object" was already edited in this same script, it imports that. If it hasn't been, it imports from the core data.

begindefine{object} which_object: Sets the object currently being edited to "which_object". Copies the data from the object that was edited before this statement over the data of "which_object".

 

Is that right?

 

Oh, and spyderbytes: It's not that hard; just use this. It should work.

Code:
// Breadbegindefineitem 498;     import = 4;begindefineitem 4;     import = 498;     it_special_class = 0;// Mushroomsbegindefineitem 498;     import = 5;begindefineitem 5;     import = 498;     it_special_class = 0;// Greensbegindefineitem 498;     import = 6;begindefineitem 6;     import = 498;     it_special_class = 0;// Steakbegindefineitem 498;     import = 7;begindefineitem 7;     import = 498;     it_special_class = 0;// Dried Meatbegindefineitem 498;     import = 8;begindefineitem 8;     import = 498;     it_special_class = 0;// Wierd Meatbegindefineitem 498;     import = 9;begindefineitem 9;     import = 498;     it_special_class = 0;// Lizard Haunchbegindefineitem 498;     import = 10;begindefineitem 10;     import = 498;     it_special_class = 0;// Fishbegindefineitem 498;     import = 11;begindefineitem 11;     import = 498;     it_special_class = 0;// Deli Sandwichbegindefineitem 498;     import = 12;begindefineitem 12;     import = 498;     it_special_class = 0;
Link to comment
Share on other sites

Quote:
Originally written by Newtfeet:
Ok, so let me set this all out.

clear: Obvious. Sets all the values for the object currently being edited to their defaults.
property = new_value: Also obvious. Sets the value "property" to "new_value" for the object currently being edited.
import = which_object: Replaces all the values for the object currently being edited to the values for "which_object". If "which_object" was already edited in this same script, it imports that. If it hasn't been, it imports from the core data.
begindefine{object} which_object: Sets the object currently being edited to "which_object". Copies the data from the object that was edited before this statement over the data of "which_object".

Is that right?
Yes.
Link to comment
Share on other sites

Quote:
Originally written by spyderbytes:
I mean, if all food has the same value for 'variety', he's bound to have some way to query inventory by variety, I would think. It's likely just not public.
It's more than not just public; it is not in the scripting language. He has functions in his engine for doing it. Those are C++ calls. The way scripts work, however, is part of the engine reads in the script text file (the thing doing the reader is called the interpreter) and converts it to C++ calls. If the interpreter does not know to translate calls about item variety into the existing C++ calls, then you can never use them in a script, whether you know their name or not.

This is the big deal in the "Calls We Wish Existed Thread". If those calls already exist in C++ form in the engine, it is very easy for him to add them to AvernumScript; he could do it in a few minutes. If they don't, it is much harder to add them, and not necessarily advisable to do so, as it could break the engine.

It's like the difference between needing a word in French for which the language translator does not know the correct word, and when there is no such word in French at all.
Link to comment
Share on other sites

Quote:
Originally written by Walker White:
It's more than not just public; it is not in the scripting language. He has functions in his engine for doing it. Those are C++ calls. The way scripts work, however, is part of the engine reads in the script text file (the thing doing the reader is called the interpreter) and converts it to C++ calls. If the interpreter does not know to translate calls about item variety into the existing C++ calls, then you can never use them in a script, whether you know their name or not.
I think that's what spyderbytes meant. "Public" means about the same thing as "known by the interpreter".

Oh, and I'm glad I finally got those custom objects straightened out.
Link to comment
Share on other sites

Quote:
Originally written by Newtfeet:
"Public" means about the same thing as "known by the interpreter".
If you are a Microsoft programmer "not public" means "it is there and usable by anyone, but Microsoft won't tell me what it is so their Office programs can be better than mine." That's why I assumed that interpretation.

I didn't mean any insult by it.
Link to comment
Share on other sites

Thanks for the list, Newtfeet! I already decided it would be better if my NPC wanted a particular food item in this instance, however. Especially since the NPC is a talking dog (who would obviously prefer meat of some sort--it's a comical scenario so I can get by with such things wink ) and if I add food items (and I'm sure I will) I'd have to ensure my lists stay in synch. The "any food" was just a compromise I was willing to make if there was a simple way to do it. Sorry you went to the effort and I'm not using it. frown Maybe it will help someone who comes along after me, though.

 

And yes, I'm well aware of the distinction in interpreted and precompiled languages, and probably should have worded my post better. Still, there's no public call to access JV's private function, regardless of whether one is an apple and the other is an orange. smile

 

-spyderbytes

Link to comment
Share on other sites

Certain items which stack in the inventory, including food, when you bring them into the new scenario will change into items of the same type in the new scenario. This is so stacking works properly. It also means that giving food a special class works (unless another scenario designer made a custom food item).

 

If you want a totally foolproof mechanism, you'll have to use Advanced Item Management Calls:

 

Code:
//in variables sectionshort i, j, k;//main codei = 0;while(i < 4) {  //dead or nonexistant characters can't have items  if(char_ok(i)) {    //only check inventory, not equipment (you can't equip food)    j = 12;    while(j < 40) {      k = item_type_in_slot(i,j);      //check if an item exists in that slot      if(k != -1) {        //check if it's food        if(get_item_variety(k) == 4) {          destroy_char_item(i,j);          //do whatever you want to do here if the party had food          end();          }        }      j = j + 1;      }    i = i + 1;    }  }//do whatever you want to do here if the party didn't have food
Actually, I'm not totally sure that would work. I'm not sure what item_type_in_slot returns when it checks a custom item from another scenario.
Link to comment
Share on other sites

In the "Item, Special Item and Gold Calls" section we have:

 

short has_item_of_class(short which_class,short take_item)

 

I'm saying that JV needs to add a complimentary call like this:

 

short has_item_of_variety(short which_variety,short take_item)

 

so that we can just directly check for food (or weapons, or armor, or whatever), without all the special class rigamarole or the expensive item by item check to see if there's anything that matches.

 

-spyderbytes

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...