The Dawn Of Time
The Official Forums for the Dawn Of Time Mud Codebase
 
Log in Register FAQ Memberlist Search The Dawn Of Time Forum Index Goto the Official Dawn Website

Random Weapon Loader

 
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Snippets
View previous topic :: View next topic  
Author Message
mmoritz80



Joined: 21 Sep 2018
Posts: 21
Location: Ohio

PostPosted: Thu Mar 07, 2019 3:26 am    Post subject: Random Weapon Loader Reply with quote

This snippet will allow you to have mobs load up a random weapon through use of a MUDprog like this:

Code:
mob random_weapon
wield all


weapons.cpp
Code:
// *** Random Weapon Generator ***********************************************                                           
// This is part of a series of random item generators designed to load armor,*
// weapons, treasure, and pickpocket loot on sentient humanoid NPCs for      *
// Lands of Oneiro.  LoO is based on Dawn of Time version S beta 6.          *
// *************************************************** Melissa Moritz 2019 ***
#include "include.h" // dawn standard includes
#include "olc.h"
#include "nanny.h"
#include "tables.h"

void do_random_weapon( char_data *ch, char * ){
   OBJ_DATA *rand_weapon;      // the random weapon we'll be creating
   int class_dice;            // which type of weapon is it?
   int special_dice;         // did we score a magical weapon?
   int total_mod = 0;         // add up all the modification factors
    char buf[MSL];
   
   // security check to prevent players from creating free loot
    if (!IS_NPC(ch)){
      ch->println("Only NPCs may create random weapons.");
      return;
   }
      
   
   // if the template item is does not exist, full stop.
   if ( get_obj_index(OBJ_VNUM_OUTFIT_MACE) == NULL )  {
      ch->println("Error, missing OUTFIT_MACE! Submit bug report.");
      return;
   }
   
   // load the newbie outfit_mace vnum 400 as our template then modify it.
   rand_weapon = create_object(get_obj_index(OBJ_VNUM_OUTFIT_MACE));
   rand_weapon->item_type      = ITEM_WEAPON;
   rand_weapon->wear_flags      = OBJWEAR_TAKE + OBJWEAR_WIELD;
   rand_weapon->level         = ch->level;                        // make item the NPC's level
   rand_weapon->relative_size   = ch->size;                           // sized to fit the NPC
    rand_weapon->cost         = ( ch->level * 25 );                  // base item cost
   rand_weapon->extra_flags   = OBJEXTRA_NO_DEGRADE;
   
   //  choose a random Weapon Class [V0]
   class_dice = dice(1,11);
   switch (class_dice) {
   case 1:
      rand_weapon->name        = str_dup( "axe" );
      rand_weapon->value[0] = WEAPON_AXE;
      rand_weapon->value[3] = DAM_SLASH;
      total_mod = 3;
      break;
   case 2:
      rand_weapon->name        = str_dup( "dagger" );
      rand_weapon->value[0] = WEAPON_DAGGER;
      rand_weapon->value[3] = DAM_PIERCE;
      total_mod = -8;
      break;
   case 3:
      rand_weapon->name        = str_dup( "flail" );
      rand_weapon->value[0] = WEAPON_FLAIL;
      rand_weapon->value[3] = DAM_BASH;
      total_mod = -2;
      break;
   case 4:
      rand_weapon->name        = str_dup( "mace" );
      rand_weapon->value[0] = WEAPON_MACE;
      rand_weapon->value[3] = DAM_BASH;
      total_mod = 6;
      break;
   case 5:
      rand_weapon->name        = str_dup( "polearm" );
      rand_weapon->value[0] = WEAPON_POLEARM;
      rand_weapon->value[3] = DAM_SLASH;
      total_mod =  8;
      break;
   case 6:
      rand_weapon->name        = str_dup( "sickle" );
      rand_weapon->value[0] = WEAPON_SICKLE;
      rand_weapon->value[3] = DAM_SLASH;
      total_mod = 9;
      break;
   case 7:
      rand_weapon->name        = str_dup( "spear" );
      rand_weapon->value[0] = WEAPON_SPEAR;
      rand_weapon->value[3] = DAM_PIERCE;
      total_mod = 3;
      break;
   case 8:
      rand_weapon->name        = str_dup( "staff" );
      rand_weapon->value[0] = WEAPON_STAFF;
      rand_weapon->value[3] = DAM_BASH;
      total_mod = 3;
      break;
   case 9:
      rand_weapon->name        = str_dup( "sword" );
      rand_weapon->value[0] = WEAPON_SWORD;
      rand_weapon->value[3] = DAM_SLASH;
      total_mod = 6;
      break;
   case 11:
      rand_weapon->name        = str_dup( "whip" );
      rand_weapon->value[0] = WEAPON_WHIP;
      rand_weapon->value[3] = DAM_SLASH;
      total_mod = -3;
      break;
   }
   
   // roll to see if we got a SPECIAL WEAPONTYPE [V4]
   special_dice = dice(1,40);
   switch (special_dice) {
   case 32:
       if ( !str_cmp( rand_weapon->name, "staff" ) || !str_cmp( rand_weapon->name, "spear" )
       || !str_cmp( rand_weapon->name, "mace" ) || !str_cmp( rand_weapon->name, "flail" )
       || !str_cmp( rand_weapon->name, "whip" ) ){
          rand_weapon->value[4] = WEAPON_ANNEALED;
          total_mod = -3;
       }
        else{
          rand_weapon->value[4] = WEAPON_SHARP; }
          total_mod = -3;
      break;
   case 33:
       rand_weapon->extra_flags   = OBJEXTRA_NO_DEGRADE + OBJEXTRA_MAGIC;
        rand_weapon->value[4] = WEAPON_POISON;
        total_mod = -4;
      break;
   case 34:
       rand_weapon->extra_flags   = OBJEXTRA_NO_DEGRADE + OBJEXTRA_MAGIC;
        rand_weapon->value[4] = WEAPON_FLAMING;
        total_mod = -4;
        break;       
   case 35:
       rand_weapon->extra_flags   = OBJEXTRA_NO_DEGRADE + OBJEXTRA_MAGIC;
        rand_weapon->value[4] = WEAPON_FROST;
        total_mod = -4;
      break;
   case 36:
       rand_weapon->extra_flags   = OBJEXTRA_NO_DEGRADE + OBJEXTRA_MAGIC;
        rand_weapon->value[4] = WEAPON_VAMPIRIC;
        total_mod = -4;
      break;      
   case 37:
       rand_weapon->extra_flags   = OBJEXTRA_NO_DEGRADE + OBJEXTRA_MAGIC;
        rand_weapon->value[4] = WEAPON_VAMPIRIC;
        total_mod = -4;
      break;   
   case 38:
       rand_weapon->extra_flags   = OBJEXTRA_NO_DEGRADE + OBJEXTRA_MAGIC;
        rand_weapon->value[4] = WEAPON_VORPAL;
        total_mod = -4;
      break;   
   case 39:
       rand_weapon->extra_flags   = OBJEXTRA_NO_DEGRADE + OBJEXTRA_MAGIC;
        rand_weapon->value[4] = WEAPON_SHOCKING;
        total_mod = -4;
      break;   
   case 40:
       rand_weapon->extra_flags   = OBJEXTRA_NO_DEGRADE + OBJEXTRA_MAGIC;
        rand_weapon->value[4] = WEAPON_ENERVATE;
        total_mod = -4;
        break;
   }
      
   // change the item level based on the modifiers
   total_mod = (rand_weapon->level + total_mod);
   
   // calculate the weapon dice based on total_mod
   if (total_mod < 1 ){ rand_weapon->value[1] = 1;   rand_weapon->value[2] = 4;   }
   if (total_mod == 1){ rand_weapon->value[1] = 1;   rand_weapon->value[2] = 6;   }
   if (total_mod == 2){ rand_weapon->value[1] = 2;   rand_weapon->value[2] = 3;   }
   if (total_mod == 3){ rand_weapon->value[1] = 1;   rand_weapon->value[2] = 8;   }
   if (total_mod == 4){ rand_weapon->value[1] = 2;   rand_weapon->value[2] = 4;    }
   if (total_mod == 5){ rand_weapon->value[1] = 1;   rand_weapon->value[2] = 10; }
   if (total_mod == 6){ rand_weapon->value[1] = 3;   rand_weapon->value[2] = 3;    }
   if (total_mod == 7){ rand_weapon->value[1] = 1;   rand_weapon->value[2] = 12; }
   if (total_mod == 8){ rand_weapon->value[1] = 2;   rand_weapon->value[2] = 6;    }
   if (total_mod == 9){ rand_weapon->value[1] = 3;   rand_weapon->value[2] = 4;    }
   if (total_mod == 10){ rand_weapon->value[1] = 2;   rand_weapon->value[2] = 7;    }
   
   if (total_mod == 11){ rand_weapon->value[1] = 4;    rand_weapon->value[2] = 3;    }
   if (total_mod == 12){ rand_weapon->value[1] = 2;    rand_weapon->value[2] = 8;    }
   if (total_mod == 13){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 4;    }
   if (total_mod == 14){ rand_weapon->value[1] = 5;    rand_weapon->value[2] = 3;    }
   if (total_mod == 15){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 6;    }
   if (total_mod == 16){ rand_weapon->value[1] = 2;    rand_weapon->value[2] = 10; }
   if (total_mod == 17){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 7;    }
   if (total_mod == 18){ rand_weapon->value[1] = 6;    rand_weapon->value[2] = 3;    }
   if (total_mod == 19){ rand_weapon->value[1] = 5;    rand_weapon->value[2] = 4;    }
   if (total_mod == 20){ rand_weapon->value[1] = 2;    rand_weapon->value[2] = 12; }
   
   if (total_mod == 21){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 8;    }
   if (total_mod == 22){ rand_weapon->value[1] = 4;    rand_weapon->value[2] = 6;    }
   if (total_mod == 23){ rand_weapon->value[1] = 7;    rand_weapon->value[2] = 3;    }
   if (total_mod == 24){ rand_weapon->value[1] = 5;    rand_weapon->value[2] = 5;    }
   if (total_mod == 25){ rand_weapon->value[1] = 6;    rand_weapon->value[2] = 4;    }
   if (total_mod == 26){ rand_weapon->value[1] = 4;    rand_weapon->value[2] = 7;    }
   if (total_mod == 27){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 10; }
   if (total_mod == 28){ rand_weapon->value[1] = 2;    rand_weapon->value[2] = 16; }
   if (total_mod == 29){ rand_weapon->value[1] = 7;    rand_weapon->value[2] = 4;    }
   if (total_mod == 30){ rand_weapon->value[1] = 6;    rand_weapon->value[2] = 5;    }
   
   if (total_mod == 31){ rand_weapon->value[1] = 9;    rand_weapon->value[2] = 3;    }
   if (total_mod == 32){ rand_weapon->value[1] = 2;    rand_weapon->value[2] = 18; }
   if (total_mod == 33){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 12; }
   if (total_mod == 34){ rand_weapon->value[1] = 8;    rand_weapon->value[2] = 4;    }
   if (total_mod == 35){ rand_weapon->value[1] = 10;    rand_weapon->value[2] = 3;    }
   if (total_mod == 36){ rand_weapon->value[1] = 6;    rand_weapon->value[2] = 6;    }
   if (total_mod == 37){ rand_weapon->value[1] = 7;    rand_weapon->value[2] = 5;    }
   if (total_mod == 38){ rand_weapon->value[1] = 11;    rand_weapon->value[2] = 3;    }
   if (total_mod == 39){ rand_weapon->value[1] = 9;    rand_weapon->value[2] = 4;    }
   if (total_mod == 40){ rand_weapon->value[1] = 2;    rand_weapon->value[2] = 22; }

   if (total_mod == 41){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 15; }
   if (total_mod == 42){ rand_weapon->value[1] = 12;    rand_weapon->value[2] = 3;    }
   if (total_mod == 43){ rand_weapon->value[1] = 7;    rand_weapon->value[2] = 6;    }
   if (total_mod == 44){ rand_weapon->value[1] = 10;    rand_weapon->value[2] = 4;    }
   if (total_mod == 45){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 16; }
   if (total_mod == 46){ rand_weapon->value[1] = 4;    rand_weapon->value[2] = 12; }
   if (total_mod == 47){ rand_weapon->value[1] = 13;    rand_weapon->value[2] = 3;    }
   if (total_mod == 48){ rand_weapon->value[1] = 9;    rand_weapon->value[2] = 5;    }
   if (total_mod == 49){ rand_weapon->value[1] = 11;    rand_weapon->value[2] = 4;    }
   if (total_mod == 50){ rand_weapon->value[1] = 14;    rand_weapon->value[2] = 3;    }

   if (total_mod == 51){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 18;   }
   if (total_mod == 52){ rand_weapon->value[1] = 4;    rand_weapon->value[2] = 14;   }
   if (total_mod == 53){ rand_weapon->value[1] = 2;    rand_weapon->value[2] = 29;   }
   if (total_mod == 54){ rand_weapon->value[1] = 10;    rand_weapon->value[2] = 5;   }
   if (total_mod == 55){ rand_weapon->value[1] = 15;    rand_weapon->value[2] = 3;   }
   if (total_mod == 56){ rand_weapon->value[1] = 2;    rand_weapon->value[2] = 30;   }
   if (total_mod == 57){ rand_weapon->value[1] = 9;    rand_weapon->value[2] = 6;   }
   if (total_mod == 58){ rand_weapon->value[1] = 16;    rand_weapon->value[2] = 3;   }
   if (total_mod == 59){ rand_weapon->value[1] = 13;    rand_weapon->value[2] = 4;   }
   if (total_mod == 60){ rand_weapon->value[1] = 6;    rand_weapon->value[2] = 10;   }

   if (total_mod == 61){ rand_weapon->value[1] = 11;    rand_weapon->value[2] = 5;   }
   if (total_mod == 62){ rand_weapon->value[1] = 27;    rand_weapon->value[2] = 3;   }
   if (total_mod == 63){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 22;   }
   if (total_mod == 64){ rand_weapon->value[1] = 10;    rand_weapon->value[2] = 6;   }
   if (total_mod == 65){ rand_weapon->value[1] = 14;    rand_weapon->value[2] = 4;   }
   if (total_mod == 66){ rand_weapon->value[1] = 12;    rand_weapon->value[2] = 5;   }
   if (total_mod == 67){ rand_weapon->value[1] = 18;    rand_weapon->value[2] = 3;   }
   if (total_mod == 68){ rand_weapon->value[1] = 5;    rand_weapon->value[2] = 14;   }
   if (total_mod == 69){ rand_weapon->value[1] = 15;    rand_weapon->value[2] = 4;   }
   if (total_mod == 70){ rand_weapon->value[1] = 19;    rand_weapon->value[2] = 3;   }

   if (total_mod == 71){ rand_weapon->value[1] = 11;    rand_weapon->value[2] = 6;   }
   if (total_mod == 72){ rand_weapon->value[1] = 6;    rand_weapon->value[2] = 12;   }
   if (total_mod == 73){ rand_weapon->value[1] = 13;    rand_weapon->value[2] = 5;   }
   if (total_mod == 74){ rand_weapon->value[1] = 20;    rand_weapon->value[2] = 3;   }
   if (total_mod == 75){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 26;   }
   if (total_mod == 76){ rand_weapon->value[1] = 9;    rand_weapon->value[2] = 8;   }
   if (total_mod == 77){ rand_weapon->value[1] = 15;    rand_weapon->value[2] = 5;   }
   if (total_mod == 78){ rand_weapon->value[1] = 21;    rand_weapon->value[2] = 3;   }
   if (total_mod == 79){ rand_weapon->value[1] = 5;    rand_weapon->value[2] = 16;   }
   if (total_mod == 80){ rand_weapon->value[1] = 17;    rand_weapon->value[2] = 4;   }

   if (total_mod == 81){ rand_weapon->value[1] = 3;    rand_weapon->value[2] = 28;   }
   if (total_mod == 82){ rand_weapon->value[1] = 11;    rand_weapon->value[2] = 7;   }
   if (total_mod == 83){ rand_weapon->value[1] = 22;    rand_weapon->value[2] = 3;   }
   if (total_mod == 84){ rand_weapon->value[1] = 18;    rand_weapon->value[2] = 4;   }
   if (total_mod == 85){ rand_weapon->value[1] = 13;    rand_weapon->value[2] = 6;   }
   if (total_mod == 86){ rand_weapon->value[1] = 4;    rand_weapon->value[2] = 22;   }
   if (total_mod == 87){ rand_weapon->value[1] = 23;    rand_weapon->value[2] = 3;   }
   if (total_mod == 88){ rand_weapon->value[1] = 5;    rand_weapon->value[2] = 18;   }
   if (total_mod == 89){ rand_weapon->value[1] = 19;    rand_weapon->value[2] = 4;   }
   if (total_mod == 90){ rand_weapon->value[1] = 16;    rand_weapon->value[2] = 5;   }

   if (total_mod == 91){ rand_weapon->value[1] = 24;    rand_weapon->value[2] = 3;   }
   if (total_mod == 92){ rand_weapon->value[1] = 14;    rand_weapon->value[2] = 6;   }
   if (total_mod == 93){ rand_weapon->value[1] = 22;    rand_weapon->value[2] = 9;   }
   if (total_mod == 94){ rand_weapon->value[1] = 20;    rand_weapon->value[2] = 4;   }
   if (total_mod == 95){ rand_weapon->value[1] = 25;    rand_weapon->value[2] = 3;   }
   if (total_mod == 96){ rand_weapon->value[1] = 6;    rand_weapon->value[2] = 16;   }
   if (total_mod == 97){ rand_weapon->value[1] = 17;    rand_weapon->value[2] = 5;   }
   if (total_mod == 98){ rand_weapon->value[1] = 26;    rand_weapon->value[2] = 3;   }
   if (total_mod == 99){ rand_weapon->value[1] = 15;    rand_weapon->value[2] = 6;   }
   if (total_mod > 99 ){ rand_weapon->value[1] = 21;    rand_weapon->value[2] = 4;   }


   // LEATHER MATERIALS
   if ( !str_cmp( rand_weapon->name, "whip" ) ){
      if (total_mod > 100){rand_weapon->material = str_dup( "cosmic dragonscale" );}
      if (total_mod < 101){rand_weapon->material = str_dup( "radianthide" );}
      if (total_mod < 96){rand_weapon->material = str_dup( "phantasmal leather" );}      
      if (total_mod < 91){rand_weapon->material = str_dup( "nightmare hide" );}
      if (total_mod < 86){rand_weapon->material = str_dup( "fatescale" );}
      if (total_mod < 81){rand_weapon->material = str_dup( "spectral leather" );}
      if (total_mod < 76){rand_weapon->material = str_dup( "chronohide" );}
      if (total_mod < 71){rand_weapon->material = str_dup( "demonhide" );}
      if (total_mod < 66){rand_weapon->material = str_dup( "shadowhide" );}
      if (total_mod < 61){rand_weapon->material = str_dup( "ghoulskin" );}
      if (total_mod < 56){rand_weapon->material = str_dup( "dragonscale" );}
      if (total_mod < 51){rand_weapon->material = str_dup( "wyrmhide" );}
      if (total_mod < 46){rand_weapon->material = str_dup( "alligator leather" );}
      if (total_mod < 41){rand_weapon->material = str_dup( "crocodile skin" );}
      if (total_mod < 36){rand_weapon->material = str_dup( "snakeskin" );}
      if (total_mod < 31){rand_weapon->material = str_dup( "lizardskin" );}
      if (total_mod < 26){rand_weapon->material = str_dup( "braided leather" );}
      if (total_mod < 21){rand_weapon->material = str_dup( "boiled leather" );}
      if (total_mod < 16){rand_weapon->material = str_dup( "thick leather" );}
      if (total_mod < 11){rand_weapon->material = str_dup( "soft leather" );}
      if (total_mod < 6){rand_weapon->material = str_dup( "doeskin" );}
   }

   // WOOD MATERIALS
   if ( !str_cmp( rand_weapon->name, "staff" ) || !str_cmp( rand_weapon->name, "spear" ) ){
      if (total_mod > 100){rand_weapon->material = str_dup( "lightheart" );}
      if (total_mod < 101){rand_weapon->material = str_dup( "shadow elm" );}
      if (total_mod < 96){rand_weapon->material = str_dup( "manawood" );}      
      if (total_mod < 91){rand_weapon->material = str_dup( "lifethorne" );}
      if (total_mod < 86){rand_weapon->material = str_dup( "greenheart" );}
      if (total_mod < 81){rand_weapon->material = str_dup( "memory willow" );}
      if (total_mod < 76){rand_weapon->material = str_dup( "black locust" );}
      if (total_mod < 71){rand_weapon->material = str_dup( "cherrywood" );}
      if (total_mod < 66){rand_weapon->material = str_dup( "maple" );}
      if (total_mod < 61){rand_weapon->material = str_dup( "hickory" );}
      if (total_mod < 56){rand_weapon->material = str_dup( "hedge apple" );}
      if (total_mod < 51){rand_weapon->material = str_dup( "ebony" );}
      if (total_mod < 46){rand_weapon->material = str_dup( "birch" );}
      if (total_mod < 41){rand_weapon->material = str_dup( "white ash" );}
      if (total_mod < 36){rand_weapon->material = str_dup( "rosewood" );}
      if (total_mod < 31){rand_weapon->material = str_dup( "white oak" );}
      if (total_mod < 26){rand_weapon->material = str_dup( "ironwood" );}
      if (total_mod < 21){rand_weapon->material = str_dup( "purpleheart" );}
      if (total_mod < 16){rand_weapon->material = str_dup( "hawthorn" );}
      if (total_mod < 11){rand_weapon->material = str_dup( "red oak" );}
      if (total_mod < 6){rand_weapon->material = str_dup( "northern pine" );}
   }

   // METAL MATERIALS
   if ( str_cmp( rand_weapon->name, "staff" ) && str_cmp( rand_weapon->name, "spear" ) && str_cmp( rand_weapon->name, "whip" )){
      if (total_mod > 100){rand_weapon->material = str_dup( "luminous aetherite" );}
      if (total_mod < 101){rand_weapon->material = str_dup( "veiled aetherite" );}
      if (total_mod < 96){rand_weapon->material = str_dup( "celestial bronze" );}      
      if (total_mod < 91){rand_weapon->material = str_dup( "pandemonite" );}
      if (total_mod < 86){rand_weapon->material = str_dup( "glomsteel" );}
      if (total_mod < 81){rand_weapon->material = str_dup( "imperial gold" );}
      if (total_mod < 76){rand_weapon->material = str_dup( "star iron" );}
      if (total_mod < 71){rand_weapon->material = str_dup( "coronium" );}
      if (total_mod < 66){rand_weapon->material = str_dup( "orichalcum" );}
      if (total_mod < 61){rand_weapon->material = str_dup( "adamantine" );}
      if (total_mod < 56){rand_weapon->material = str_dup( "mithril" );}
      if (total_mod < 51){rand_weapon->material = str_dup( "recondite" );}
      if (total_mod < 46){rand_weapon->material = str_dup( "titanium" );}
      if (total_mod < 41){rand_weapon->material = str_dup( "steel" );}
      if (total_mod < 36){rand_weapon->material = str_dup( "cold iron" );}
      if (total_mod < 31){rand_weapon->material = str_dup( "iron" );}
      if (total_mod < 26){rand_weapon->material = str_dup( "silver" );}
      if (total_mod < 21){rand_weapon->material = str_dup( "bronze" );}
      if (total_mod < 16){rand_weapon->material = str_dup( "brass" );}
      if (total_mod < 11){rand_weapon->material = str_dup( "tin" );}
      if (total_mod < 6){rand_weapon->material = str_dup( "copper" );}
   }
    // check if the material begins with a vowel and choose appropriate article
    if ( !str_cmp( rand_weapon->material, "ironwood" ) || !str_cmp( rand_weapon->material, "ebony" )       
    || !str_cmp( rand_weapon->material, "imperial gold" ) || !str_cmp( rand_weapon->material, "orichalcum" )
    || !str_cmp( rand_weapon->material, "admantine" ) || !str_cmp( rand_weapon->material, "iron" ) )
    {
      sprintf ( buf, "an %s %s", (rand_weapon->material), rand_weapon->name);
      rand_weapon->short_descr = str_dup( buf );
       
    }else{
      sprintf ( buf, "a %s %s", rand_weapon->material, rand_weapon->name );
      rand_weapon->short_descr = str_dup( buf );   
   }

   ch->println( "You have created a random weapon!" );
   obj_to_char(rand_weapon,ch);
   return;
}


weapons.h
Code:
// *** Random Weapon Generator ***********************************************                                           
// This is part of a series of random item generators designed to load armor,*
// weapons, treasure, and pickpocket loot on sentient humanoid NPCs for      *
// Lands of Oneiro.  LoO is based on Dawn of Time version S beta 6.          *
// *************************************************** Melissa Moritz 2019 ***
#ifndef WEAPONS_H
#define WEAPONS_H

DECLARE_DO_FUN(do_random_weapon);

#endif // WEAPONS_H


Add to interp.cpp:
Code:
 { "random_weapon",      do_random_weapon,       POS_DEAD,      0,       LOG_NORMAL,     1 },


Add to interp.h:
Code:
DECLARE_DO_FUN( do_random_weapon       );


Add to mp_commands near the top:
Code:
DECLARE_DO_FUN( do_random_weapon );


Add to mp_commands near the other commands:
Code:
{"random_weapon",do_random_weapon,"Generates and loads a level appropriate weapon."},


Add weapons.o to the makefile.

I am not sure why the nice indenting/spacing from notepad++ doesn't paste well. My aplogoizes for the appearnce here.

If you use this or test it out, please let me know. I spent the last three days writing and testing it but having another set of eyes on it would be beneficial.



_________________
Lands of Oneiro pre-alpha development phase

Melissa's Game Dev Blog
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Snippets All times are GMT + 13 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2005 phpBB Group
Theme created by Vjacheslav Trushkin