18 Feb, 2010, boblinski wrote in the 1st comment:
Votes: 0
What I'm trying to do is have an ITEM_QUIVER that acts like a normal ITEM_CONTAINER except that the quivers will only be able to hold ITEM_MISSILE's..

I've added my quiver and missile item types.. and I've modified do_put so that you can only put missiles into quivers… but the last thing I want it to do is make it so only the -same- type of missiles will be able to go into a quiver..

This is my do_put() thus far:
void do_put (CHAR_DATA * ch, char *argument)
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
OBJ_DATA *container;
OBJ_DATA *obj;
OBJ_DATA *obj_next;

argument = one_argument (argument, arg1);
argument = one_argument (argument, arg2);

if (!str_cmp (arg2, "in") || !str_cmp (arg2, "on"))
argument = one_argument (argument, arg2);

if (arg1[0] == '\0' || arg2[0] == '\0')
{
send_to_char ("Put what in what?\n\r", ch);
return;
}

if (!str_cmp (arg2, "all") || !str_prefix ("all.", arg2))
{
send_to_char ("You can't do that.\n\r", ch);
return;
}

if ((container = get_obj_here (ch, arg2)) == NULL)
{
act ("I see no $T here.", ch, NULL, arg2, TO_CHAR);
return;
}

if (container->item_type != ITEM_CONTAINER && container->item_type != ITEM_QUIVER)
{
send_to_char ("That's not a container.\n\r", ch);
return;
}

if (IS_SET (container->value[1], CONT_CLOSED))
{
act ("The $d is closed.", ch, NULL, container->name, TO_CHAR);
return;
}



if (str_cmp (arg1, "all") && str_prefix ("all.", arg1))
{
/* 'put obj container' */
if ((obj = get_obj_carry (ch, arg1, ch)) == NULL)
{
send_to_char ("You do not have that item.\n\r", ch);
return;
}

if (obj == container)
{
send_to_char ("You can't fold it into itself.\n\r", ch);
return;
}

//QUIVER & BOW stuff.
if (container->item_type == ITEM_QUIVER)
{
if (obj->item_type != ITEM_MISSILE)
{
act ("You can only put projectiles into the $d.", ch, NULL, container->name, TO_CHAR);
return;
}
}


if (!can_drop_obj (ch, obj))
{
send_to_char ("You can't let go of it.\n\r", ch);
return;
}

if (WEIGHT_MULT (obj) != 100)
{
send_to_char ("You have a feeling that would be a bad idea.\n\r",
ch);
return;
}

if (get_obj_weight (obj) + get_true_weight (container)
> (container->value[0] * 10)
|| get_obj_weight (obj) > (container->value[3] * 10))
{
send_to_char ("It won't fit.\n\r", ch);
return;
}

if (container->pIndexData->vnum == OBJ_VNUM_PIT
&& !CAN_WEAR (container, ITEM_TAKE))
{
if (obj->timer)
SET_BIT (obj->extra_flags, ITEM_HAD_TIMER);
else
obj->timer = number_range (100, 200);
}

obj_from_char (obj);
obj_to_obj (obj, container);

if (IS_SET (container->value[1], CONT_PUT_ON))
{
act ("$n puts $p on $P.", ch, obj, container, TO_ROOM);
act ("You put $p on $P.", ch, obj, container, TO_CHAR);
}
else
{
act ("$n puts $p in $P.", ch, obj, container, TO_ROOM);
act ("You put $p in $P.", ch, obj, container, TO_CHAR);
}
}
else
{
/* 'put all container' or 'put all.obj container' */
for (obj = ch->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;

if ((arg1[3] == '\0' || is_name (&arg1[4], obj->name))
&& can_see_obj (ch, obj)
&& WEIGHT_MULT (obj) == 100
&& obj->wear_loc == WEAR_NONE
&& obj != container && can_drop_obj (ch, obj)
&& get_obj_weight (obj) + get_true_weight (container)
<= (container->value[0] * 10)
&& get_obj_weight (obj) < (container->value[3] * 10))
{
if (container->pIndexData->vnum == OBJ_VNUM_PIT
&& !CAN_WEAR (obj, ITEM_TAKE))
{
if (obj->timer)
SET_BIT (obj->extra_flags, ITEM_HAD_TIMER);
else
obj->timer = number_range (100, 200);
}

obj_from_char (obj);
obj_to_obj (obj, container);

if (IS_SET (container->value[1], CONT_PUT_ON))
{
act ("$n puts $p on $P.", ch, obj, container, TO_ROOM);
act ("You put $p on $P.", ch, obj, container, TO_CHAR);
}
else
{
act ("$n puts $p in $P.", ch, obj, container, TO_ROOM);
act ("You put $p in $P.", ch, obj, container, TO_CHAR);
}
}
}
}

return;
}


I'm not sure how to write it.. but it needs to do something like…

look in the quiver..
if no items don't worry
otherwise.. if the first item in the container isn't the same as the one I'm trying to put in… fail..
if it is the same.. continue..

Also.. I'm not sure how on earth I will add all this to the "/* 'put all container' or 'put all.obj container' */" section.

Any help?

Thanks,
Bob.
18 Feb, 2010, Skol wrote in the 2nd comment:
Votes: 0
Bob, you might do something a little different, simply have an if check for if (is_name (container->name, "quiver") && item_type != ITEM_MISSILE) send_to_char ("That won't fit in this quiver.\r\n", ch); etc.

Rather than having to make a unique item type for Quiver, simply let it check names etc.
18 Feb, 2010, Davion wrote in the 3rd comment:
Votes: 0
Skol said:
Bob, you might do something a little different, simply have an if check for if (is_name (container->name, "quiver") && item_type != ITEM_MISSILE) send_to_char ("That won't fit in this quiver.\r\n", ch); etc.

Rather than having to make a unique item type for Quiver, simply let it check names etc.


–You grab a picture of a man holding a quiver.
–You put a missile in the picture of a man holding a quiver.
–*snicker* No one ever suspects the painting!
18 Feb, 2010, jurdendurden wrote in the 4th comment:
Votes: 0
Since you want only the same type of missiles in the quiver, you will need to write something like:

(Ok object is what you're trying to put in the quiver. You might set up a "missile_type" somewhere and assign to all of your
missiles (arrows, bullets, blow darts, whatev.) )

OBJ_DATA *object;
OBJ_DATA *missile = NULL;
OBJ_DATA *missile_next = NULL;

//Some code for validating 'object' exists.

if (object->item_type != ITEM_MISSILE && container->item_type == ITEM_QUIVER)
{
send_to_char ("That's not a missile.\r\n",ch);
return;
}

for (missile = container->contains; missile != NULL; missile = missile_next)
{
missile_next = missile->next_content;
//it found something in the container and it's also a missile… may be a redundant check on the second part.
if (missile && missile->item_type == ITEM_MISSILE)
{
if (missile->missile_type != object->missile_type)
{
send_to_char ("It must be the same type of missile.\r\n",ch);
return;
}
else
{
//Throw it in the bag ;)
return;
}
break;
}
}
18 Feb, 2010, jurdendurden wrote in the 5th comment:
Votes: 0
Oooh or even better yet instead of missile_type being it's own thing just attach it to v0/v1/v2/v3 of item_type ITEM_MISSILE and have it compare the v's of each item.
18 Feb, 2010, Runter wrote in the 6th comment:
Votes: 0
Also might consider making IS_QUIVER just a toggle flag associated with a container. Makes more sense than a new item type that is essentially a container.

You don't even have to change the code surrounding placing and getting objects from a quiver. It makes sense that arrows would be able to be in other containers—Just that only quivers can be worn and taken advantage of for loosing arrows quicker.
18 Feb, 2010, David Haley wrote in the 7th comment:
Votes: 0
When I implemented quivers, I simply had the ammo type as an object value on the container, so that checking if the missile was of an appropriate type was just a matter of comparing the missile's ammo type against the quiver's ammo type. (Of course, this meant that ammo type was added to missiles as well.)
18 Feb, 2010, jurdendurden wrote in the 8th comment:
Votes: 0
Good thinking Runter, this is much easier… So in the code above you'd simply replace

if (container->item_type == ITEM_QUIVER)


with,

if (IS_SET(container, ITEM_QUIVER))


I think I'll be using this approach when I create ranged combat on my mud :lol:
18 Feb, 2010, jurdendurden wrote in the 9th comment:
Votes: 0
David Haley said:
When I implemented quivers, I simply had the ammo type as an object value on the container, so that checking if the missile was of an appropriate type was just a matter of comparing the missile's ammo type against the quiver's ammo type. (Of course, this meant that ammo type was added to missiles as well.)


That's exactly what I meant by the v0/v1/v2 theory, I just couldn't word it properly. :P Object values is what I meant to say. But didn't think about setting it on the container itself as well. That would save the whole looping through the items in the quiver bit, heh.
18 Feb, 2010, David Haley wrote in the 10th comment:
Votes: 0
Well, also, there's no reason why an arrow quiver would become a stone pouch just because you happened to put stones into it before arrows. That's why I had it as a container property, and not just a check on what was there before.
18 Feb, 2010, Koron wrote in the 11th comment:
Votes: 0
Yeah, I probably would've just opted for adding a "Quiver" eq slot, but I suppose then other PCs would be able to see what type of ammunition you were using, which might be something you're trying to avoid (for some reason? They'll see it as soon as it's used, at least).
19 Feb, 2010, Skol wrote in the 12th comment:
Votes: 0
Rofl Davion, you're right heh, it was late ;).
I'd do a container flag yeah. Closeable etc, add quiver (might add a few others while you're there if you want to have containers act uniquely).

My original thoughts on containers were:

Bags:
small bag, medium bag, large bag, rucksack, bag of holding

Boxes, Crates and Chests:
Normal: tiny box, medium box, crate, large crate, massive crate
Locking: jewelry box, coffer, small chest, large chest, massive chest

Pouches:
coin purse, small pouch, belt purse, small backpack, large backpack

Furniture type Containers:
desk, cabinet, cubby hole

Misc:
vial, jar,
small basket, medium basket, large basket
map case/scroll case,
pit

So maybe in that case I'd have more like IS_BAG, IS_CRATE, IS_CHEST etc, and have that determine things like how large of items I can put into them, what types etc. Also ambient noises or 'how' it opens due to the type.
0.0/12