Am I missing something? (food items)

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).

Pages

AuthorTopic: Am I missing something? (food items)
Shock Trooper
Member # 4180
Profile #0
Is there an easy way to check if the party has any food items and take one away? Without checking for each individual type of food item, that is.

-spyderbytes

--------------------
-spyderbytes
Posts: 200 | Registered: Wednesday, March 31 2004 08:00
Infiltrator
Member # 154
Profile #1
Food Items never really get taken by the player - when a player takes a food item, it adds some food to the food count and erases the item. Same with gold.

--------------------
Apparently still annoying.
Posts: 612 | Registered: Saturday, October 13 2001 07:00
Shock Trooper
Member # 4180
Profile #2
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

--------------------
-spyderbytes
Posts: 200 | Registered: Wednesday, March 31 2004 08:00
Warrior
Member # 1505
Profile #3
You have to give all food items in your scenario a special class (using the it_special_class item property). Then, when the player comes to the NPC, use the has_item_of_class() function.

Snuff ling kin, I think you are thinking of BoE.

[ Tuesday, April 06, 2004 13:18: Message edited by: Newtfeet ]

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Apprentice
Member # 4127
Profile #4
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

// Give Bread special class 0
begindefineitem 450;
import = 4;
begindefineitem 4;
import = 450;
it_special_class = 0;

// Give Mushrooms special class 0
begindefineitem 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.

[ Tuesday, April 06, 2004 13:27: Message edited by: Walker White ]
Posts: 48 | Registered: Saturday, March 20 2004 08:00
Warrior
Member # 1505
Profile #5
What is that begindefinecreature bit in there? What does that have to do with items?

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Warrior
Member # 1505
Profile #6
Remind me why we have those "begindefineitem 450" and "import = 450" lines in there.

Edit: And crap, I double posted.

[ Tuesday, April 06, 2004 13:37: Message edited by: Newtfeet ]

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Apprentice
Member # 4127
Profile #7
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.
Posts: 48 | Registered: Saturday, March 20 2004 08:00
Triad Mage
Member # 7
Profile Homepage #8
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.

--------------------
"At times discretion should be thrown aside, and with the foolish we should play the fool." - Menander
====
Drakefyre's Demesne - Happy Happy Joy Joy
Encyclopedia Ermariana - Trapped in the Closet
====
You can take my Mac when you pry my cold, dead fingers off the mouse!
Posts: 9436 | Registered: Wednesday, September 19 2001 07:00
Apprentice
Member # 4127
Profile #9
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.
Posts: 48 | Registered: Saturday, March 20 2004 08:00
Warrior
Member # 1505
Profile #10
Then why can't we just say:
begindefineitem 4;
import = 4;
And then why do we have clear if saying begindefineitem already clears?

Edit: Oh, wait; it's because it would import the empty item 4, right?

[ Tuesday, April 06, 2004 13:45: Message edited by: Newtfeet ]

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Triad Mage
Member # 7
Profile Homepage #11
We need to say 'clear' because the calls automatically import the last defined creature.

--------------------
"At times discretion should be thrown aside, and with the foolish we should play the fool." - Menander
====
Drakefyre's Demesne - Happy Happy Joy Joy
Encyclopedia Ermariana - Trapped in the Closet
====
You can take my Mac when you pry my cold, dead fingers off the mouse!
Posts: 9436 | Registered: Wednesday, September 19 2001 07:00
Shock Trooper
Member # 4180
Profile #12
Yikes! That's way more work than the importance of this exchange to my scenario. :) I'll either figure out something different or make the NPC picky about what he eats. ;)

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. :)

-spyderbytes

--------------------
-spyderbytes
Posts: 200 | Registered: Wednesday, March 31 2004 08:00
Warrior
Member # 1505
Profile #13
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 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.
// Bread
begindefineitem 498;
import = 4;
begindefineitem 4;
import = 498;
it_special_class = 0;

// Mushrooms
begindefineitem 498;
import = 5;
begindefineitem 5;
import = 498;
it_special_class = 0;

// Greens
begindefineitem 498;
import = 6;
begindefineitem 6;
import = 498;
it_special_class = 0;

// Steak
begindefineitem 498;
import = 7;
begindefineitem 7;
import = 498;
it_special_class = 0;

// Dried Meat
begindefineitem 498;
import = 8;
begindefineitem 8;
import = 498;
it_special_class = 0;

// Wierd Meat
begindefineitem 498;
import = 9;
begindefineitem 9;
import = 498;
it_special_class = 0;

// Lizard Haunch
begindefineitem 498;
import = 10;
begindefineitem 10;
import = 498;
it_special_class = 0;

// Fish
begindefineitem 498;
import = 11;
begindefineitem 11;
import = 498;
it_special_class = 0;

// Deli Sandwich
begindefineitem 498;
import = 12;
begindefineitem 12;
import = 498;
it_special_class = 0;


[ Tuesday, April 06, 2004 14:35: Message edited by: Newtfeet ]

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Apprentice
Member # 4127
Profile #14
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 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.
Posts: 48 | Registered: Saturday, March 20 2004 08:00
Apprentice
Member # 4127
Profile #15
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.

[ Tuesday, April 06, 2004 14:51: Message edited by: Walker White ]
Posts: 48 | Registered: Saturday, March 20 2004 08:00
Warrior
Member # 1505
Profile #16
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.

[ Tuesday, April 06, 2004 14:54: Message edited by: Newtfeet ]

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Apprentice
Member # 4127
Profile #17
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.
Posts: 48 | Registered: Saturday, March 20 2004 08:00
Warrior
Member # 1505
Profile #18
quote:
Originally written by Walker White:

I didn't mean any insult by it.
And neither did I. I'm just pointing out that it doesn't really make any difference what you call it; it means the same thing.

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Shock Trooper
Member # 4180
Profile #19
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 ;) ) 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. :( 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. :)

-spyderbytes

--------------------
-spyderbytes
Posts: 200 | Registered: Wednesday, March 31 2004 08:00
Warrior
Member # 1505
Profile #20
No problem. It took about 30 seconds.

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Triad Mage
Member # 7
Profile Homepage #21
There is a problem with doing this, however. Any food from other scenarios will not have the special class.

--------------------
"At times discretion should be thrown aside, and with the foolish we should play the fool." - Menander
====
Drakefyre's Demesne - Happy Happy Joy Joy
Encyclopedia Ermariana - Trapped in the Closet
====
You can take my Mac when you pry my cold, dead fingers off the mouse!
Posts: 9436 | Registered: Wednesday, September 19 2001 07:00
Shock Trooper
Member # 4180
Profile #22
quote:
Originally written by Drakefyre:

Any food from other scenarios will not have the special class.
Good point... and YA reason we need has_item_of_variety() to supplement has_item_of_class(). :)

--------------------
-spyderbytes
Posts: 200 | Registered: Wednesday, March 31 2004 08:00
Warrior
Member # 4202
Profile Homepage #23
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:

//in variables section
short i, j, k;

//main code
i = 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.

--------------------
Creator of the 3D Blades of Avernum Editor for Mac. Get it at Ingenious Isaac's Illusion, my web page. Better yet, get Battle for Wesnoth, a wonderful free TBS game.
Posts: 192 | Registered: Sunday, April 4 2004 08:00
Warrior
Member # 4202
Profile Homepage #24
quote:
Originally written by spyderbytes:

Good point... and YA reason we need has_item_of_variety() to supplement has_item_of_class(). :)
Do we? It's not in the BoA Editor Docs Appendices, unless I'm missing something.

--------------------
Creator of the 3D Blades of Avernum Editor for Mac. Get it at Ingenious Isaac's Illusion, my web page. Better yet, get Battle for Wesnoth, a wonderful free TBS game.
Posts: 192 | Registered: Sunday, April 4 2004 08:00

Pages