Esempio n. 1
0
mapping save()
{
	ACCESS_CHECK(GAME());

	return ([
		"archetypes": query_archetypes(),
		"capacity": query_capacity(),
		"density": query_density(),
		"environment": query_environment(),
		"flexible": query_flexible(),
		"id": query_id(),
		"inventory": query_inventory(),
		"mass": query_mass(),
		"max_mass": query_max_mass(),
		"name": query_object_name(),
		"properties": query_local_properties(),
		"virtual": query_virtual()
	]);
}
Esempio n. 2
0
varargs int wear_armour(int silent) {
   object owner = environment(this_object());
   object obj;
   int tlayer = 0;
   set_target(this_object());
   if (worn) {
      if (!silent)
         msg("You are already wearing ~targ!");
      return 0;
   }
   if (!owner->query_is_living())
      return 0;
   if (!owner->query_has_bp(query_body_parts())) {
      if (!silent)
         msg("You lack the required appendages to wear ~targ!");
      return 0;
   }

   // returns non-zero if base requirements are not met
   if (this_object()->query_requirements_met(this_player()) != 0)
      return 0;

   if (this_object()->query_broken()) {
      if (!silent)
         msg("You can't wear ~targ, it's broken!");
      return 0;
   }
   //debug("size = "+query_size()+", flex = "+query_flexible());
   // check if they're wearing anything already
   foreach ( obj : all_inventory(owner) ) {
      if (obj->query_is_apparel() && obj->query_worn()) {
         if (obj->query_body_parts() & query_body_parts()) {
            int osize = obj->query_size();
            int oflex = obj->query_flexible();
            int ocloth = obj->query_cloth();
            int small;

            if (ocloth) {
               if (oflex && osize > query_size()) {
                  // flexible cloth
                  small = 1;
            } else if (!oflex && osize > query_size() - 3) {
                  // rigid cloth
                  small = 1;
               }
            } else {
               if (oflex && osize > query_size() - 5) {
                  // flexible metal (example: chainmail)
                  small = 1;
               }

               // can't wear rigid clothing over other rigid clothing.
               if (!oflex && !query_flexible()) {
                  small = 1;
               }
            }
            if (small) {
               msg("You can't wear ~targ over your "+obj->query_name()+".");
               return 0;
            }
            if (obj->query_layer() > tlayer)
               tlayer = obj->query_layer();
         }
      }
   }
   layer = tlayer + 1;
   // returns true if on_wear() has been defined, so false means we need
   // to manually wear the item for them
   if (this_object()->on_wear() == 0) {
      if (!silent) {
         owner->msg_local("~Name ~verbwear ~targ.");
      }
      set_worn(1);
      owner->recalc();
      return 1;
   }
}