Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Event_Processor_Commands.cs
- // Discard Item
- private bool command_item_discard()
- {
- // Value[0] = id is for a unit, or for an actor
- // Value[1] = id
- // Value[2] = item index (-1 for discard everything, -2 to discard a specific item)
- // Value[3] = item type
- // Value[4] = item id
- Game_Actor actor;
- get_actor(command.Value[0], command.Value[1], out actor);
- int item_index = process_number(command.Value[2]);
- if (actor != null)
- {
- if (item_index == -1)
- {
- // Discard all items
- while (actor.num_items > 0)
- actor.discard_item(0);
- }
- else if (item_index == -2) // Skitty
- {
- {
- int result = 0;
- var itemData = new Item_Data(process_number(command.Value[3]),
- process_number(command.Value[4]));
- result = actor.FindItem(itemData);
- if (result != -1)
- actor.discard_item(result);
- //else
- // Print.message(
- // "Item not found in inventory.\n" +
- // "Check to make sure you have the\n" +
- // "correct item/weapon id.");
- }
- }
- else
- actor.discard_item(item_index);
- }
- Index++;
- return true;
- }
- // Game_Actor.cs
- public bool HasItem(Item_Data itemData)
- {
- Maybe<int> index;
- return HasItem(itemData, out index);
- }
- private bool HasItem(Item_Data itemData, out Maybe<int> index)
- {
- index = Maybe<int>.Nothing;
- for (int i = 0; i < Items.Count; i++)
- {
- if (itemData.same_item(Items[i]) && !Items[i].out_of_uses)
- {
- index = i;
- return true;
- }
- }
- return false;
- }
- public int FindItem(Item_Data itemData)
- {
- Maybe<int> index;
- return FindItem(itemData, out index);
- }
- private int FindItem(Item_Data itemData, out Maybe<int> index)
- {
- index = Maybe<int>.Nothing;
- for (int i = 0; i < Items.Count; i++)
- {
- if (itemData.same_item(Items[i]) && !Items[i].out_of_uses)
- {
- return i;
- }
- }
- return -1;
- }
- // placed above discard_item(int)
Advertisement
Add Comment
Please, Sign In to add comment