Contents

  1. Introduction to weapons
  2. How Do I Make a Weapon
  3. Advanced Features
  4. Special Attack

  1. Introduction to Weapons


        
        All weapons must include the following lines:
    
       inherit DAGGER;
    
        void setup() {
        }
    
        The line    inherit DAGGER;
        is the base for your weapon. It gives you the ability to set descriptions, 
        bonuses, etc. You can inherit a number of weapon inherits, 
        the list can be found in /std/inherits/weapons/
        
             Examples are:
    
                inherit DAGGER;
                inherit WHIP;
                inherit SHORT_SWORD;
                inherit STAFF;
    
    
        Your weapon must contain at least one inherit.
        Pick the one most appropriate for your weapon if there is not an
        exact match.
    
        Most, if not all, of your weapon's code will go inside the {}s
        of the setup() function.
    
        Make your code as clean as possible. Indent! (The 'I' command
        within ed does indentation).
    

  2. How do I make a Weapon


    
        The most basic weapon file is like this:
    
         inherit LONG_SWORD;
    
         void setup() {
    
             set_id( "broadsword", "sword" );
             set_adj( "mighty" );
             set_in_room_desc( "A mighty broadsword" );
             set_long( "The sword is made of black iron.\n");
             set_size(30);
             set_mass(22);
             set_quality(5);
             set_magic_level(0);
    }
    

    set_id()

    USAGE: set_id(primary id, secondary id,...) This is what the players use to identify the weapon. It should be in all lower case. The set_id() should be the most logical name for the weapon, any noun used in the desc of the item should most likely be included as an id. Notice you can pass multiple ids to set_id(). The first one passed will be considered the "primary id" and will be joined with the 'primary adj' to form the primary name of the item. set_id("broadsword","sword");

    set_adj()

    English 101 - Adjectives are any word that describes a noun. Ugly dog, fat dog, young dog, pretty dog, innocent dog, lustful dog, crazy dog, etc. are all examples of an adjective and its noun (in this case, "dog"). As with set_id(), set_adj() can take a list of adjectives. Again, the first one specified is the 'primary' adjective. This gets combined with the primary id to form the 'primary name'. If your weapon has an adjective in its description, you should include adjective in set_adj() for it. This allows a player to type "wield mighty broadsword" and have the mud know what they are referring to. set_adj("mighty");

    set_in_room_desc()

    USAGE: set_in_room_desc(string) This gives a description to the weapon if it is found in a room. see also: set_untouched_desc() set_in_room_desc("A mighty sword lies here collecting dirt.");

    set_long

    USAGE: set_long(long desc) When a player looks at the weapon, this is what he will see This helps the player to visualize the weapon, so don't be skimpy on the description (like this example is)! set_long( "The sword is made of black iron.\n" );

    set_size()

    USAGE: set_size(number) This defines the size of the weapon in inches. This particular weapon is 2 feet and 6 inches long (12 inches per foot). Setting this parameter is NOT mandatory, if you do not set it yourself it will use the default value linked to the inherit you used (so if you used DAGGER it'll be fairly small, if you used LONG_SWORD like here, it'll be quite long). Size of a weapon affects its weapon class since big weapons hit harder. set_size(30);

    set_mass()

    This defines the weight of the weapon, expressed in pounds. This has an important effect on the weapon class of the item. As with size, you do not have to set this parameter if you want it to be just the default weight for the inherit. set_mass(22)

    set_quality()

    This defines the quality of the making/forging of the weapon. It goes from 0 to 10 (if you use smaller values it will be 0, and bigger ones will be dealt as 10). This also affects the weapon damage in melee. The default quality of a weapon is 4 which is considered average. set_quality(5)

    set_magic_level()

    This represents whether the weapon was enchanted to be more efficient in battle. The parameter ranges from 0 (default value) to 10. A weapon with a 10 magic level should be a very powerful one and restricted to equipment obtained from tough monsters. If the weapon is to be wielded by a monster, you have to be careful to check if the monster can wield it or not. Monsters of low levels have limits to which weapons they can wield. Big ones can wield about anything.

  3. Advanced Features


    Well, right now the weapon is functional, but pretty basic. The 
    following functions can be used to spice it up a bit.
    
    
        

    set_light

    USAGE: set_light This function makes it so that the weapon actually emits light, light that will effect everyone in the room. Positive numbers give light while negative numbers make the object absorb light.

    add_stat_bonus

    USAGE: add_stat_bonus(stat,amount) This function allows to give bonuses to the weapon. See current guidelines (help eqstats) to check limits of such bonuses. Valid additions to this function are usual statistics (str, con, dex, int, wis, sta), regeneration(sp_regen, hp_regen, ep_regen) and special stats like all_skills, all_spells, damage, avoid_hits.

    add_resist_bonus()

    USAGE: add_resist_bonus(resistance,percent) Adds a magical bonus to a resistance to the weapon. First argument has to be a valid damage type. Second argument is the value of the resistance. add_resist_bonus("physical", 2);

    set_wield_message()

    USAGE: set_wield_msg(string) Defines a special message that is displayed to the player when he wields the weapon. Message can be based off the messages module. set_wield_msg("$N $vfeel a surge of power as $n $vwield the famous " "sword of power.\n");

    set_unwield_msg()

    USAGE: set_unwield_msg(string) Defines a special message that is displayed to the player when he unwields the weapon. Message can be based off the messages module. set_unwield_msg("$N $vfeel weak as $n $vunwield the sword.\n");

    set_magical_damage_type()

    USAGE: set_magical_damage_type(string | mapping ) This functions allow the weapon to do damage types other than physical in melee (physical is the default damage). There are two options, the first one is to set a string (which was the original way for it to work) and in that case the weapon will do half physical damage and half fire damage (in our example, you can use any allowed damage type). set_magical_damage_type("fire"); The two other examples use a mapping as the argument to the function, and in that case the mapping must be a list of valid damage types which are affected values that represent percentages. The sum of the values must therefore never go over 100. If the sum is inferior to 100, the remaining damage is attributed to physical damage type. So in the two examples given, first one the weapon will do 75% fire and 25% physical, while in the second the weapon will do 10% magical, 10% acid and 80% physical. set_magical_damage_type( ([ "fire" : 75 ]) ); set_magical_damage_type( ([ "magical" : 10, "acid": 10 ]) );

  4. Special Attack


    With some weapons, you are going to want to add special abilities 
    that are not included in the standard weapon code. The most common is
    to give a weapon a special hit. 
    
    The following example does not cover all of the possibilities, by any
    means. If you can imagine it, odds are it can be done.
    
    

    The following code should be located outside the void setup() {}


    void special_attack(object target) { object attacker = this_object()->query_wielded_by(); if (random(4)) return; attacker->combat_targetted_action( "$P mighty broadsword slips past $p1 defenses and strikes "+ "home!\n", target); target->hit_me(random(150), "physical", attacker); }
    This function is called once per round. Since random(4) is true 75% of the time (true meaning non zero here), it means the attack will occur one round out of 4. Combat_targetted_action is a special messenging function that takes into account the flag for combat silent. If you don't understand any part of this code, please feel free to ask another wizard to clarify.