Ranger Stuff

Alertness   : intelligence
Appetite    : craving time
Brutality   : weapon class
Development : age/time to grow
Eluding     : to_hit modifier (from attacks)
Energy      : constitution
Evasion     : dodging
Ferocity    : damage bonus (to attacks)
Fortitude   : health points
Insight     : learning chance
Might       : strength
Nimbleness  : dexterity
Patience    : wisdom
Procreation : litter size & pregnancy chance
Sufficiency : max stuffing
Targeting   : to_hit bonus (to attacks)
Toughness   : to_damage modifier (from attacks)
Random Puppy Code:

#include "/w/paldin/com/paldin.h"
#include <daemons.h>
#include "/w/paldin/project/puppies/puppies.h"

inherit COM;

#ifdef TESTMUD
#define SAVEPATH "/w/paldin/project/wolf/savetest"
#else
#define SAVEPATH "/w/paldin/project/wolf/save"
#endif

int Str;
int Dex;
int Con;
int Int;
int Wis;
int max_hp;
int level;

int loyalty;
int total_extra_stuff;
int bonus_hp;
int strength_learn_count;
int dexterity_learn_count;

string *abilities_names;
string *abilities_values;
string formername;
string race;
int trained_age;
int primary_coat;
int secondary_coat;
int primary_eye;
int colour_segment;
int eye_segment;
string coat_length;
string mark_type;
string feature;
string master;
int shushed;
int sedated;
int gender;
int time_var;
int time_exp_var;
string nickname;
int age;
string intensity;

int light_food; // The light side of food
int dark_food;  // The sith food

int add_wis;
int add_int;

int version;

static mixed intense_colours;
static string *colours;
static string *coat_segments;
static string *coat_marks;
static string *coat_lengths;
static string *coat_features;
static string *eye_colours;
static string *eye_segments;

// Puppy additions
mapping genetic_traits;
mapping colour_map;
int wolfnum;

main(str) {
  mapping info;
  object ob,wf;
  string *names;
  string *ind;
  string savefile;
  int i,j;

  if (!check(this_player()->query_real_name())) return;

  if (!str) {
    notify_fail("Showwolf <who>\n");
    return 0;
  }
  master = str;

  coat_lengths = ({"","","short ", "furry ", "neat ", "straggly ", "shaggy ", "long ", "thick "});

  colour_map = ([]);
  genetic_traits = ([]);
  restore_object(savefile);

  if (!version) {
    colours = ({ "ivory","white",
                 "cream","almond",
                 "golden","tan",
                 "silver","light grey",
                 "red","sienna",
                 "brown","brindle",
                 "steel","dark grey",
                 "charcoal","black"});

    coat_segments =
               ({ ({"light",
                    "dark"}),
                  ({"light",
                    "pale",
                    "dirty",
                    "dark"}),
                  ({"off-white",
                    "beige",
                    "orange",
                    "smokey",
                    "reddish",
                    "chocolate",
                    "metallic",
                    "ebony"})
                 });

  intense_colours = ({ ({ }) });


  } else {
    colours = ({ "ivory","alabaster",
                 "snowy","white",
                 "cream","pearl",
                 "almond","wheat",
                 "golden","honey",
                 "tan","cinnamon",
                 "silver","marble",
                 "light grey","merle grey",
                 "red","russet",
                 "sienna","fawn",
                 "chocolate","brown",
                 "brindle","bronze",
                 "steel","slate grey",
                 "dim grey","dark grey",
                 "charcoal","ebony",
                 "black","sable"});

    coat_segments =
               ({ ({"light",
                    "dark"}),
                  ({"light",
                    "pale",
                    "dirty",
                    "dark"}),
                  ({"off-white",
                    "drab",
                    "sandy",
                   "smokey",
                    "dusky",
                    "muddy",
                    "metallic",
                    "sooty"}),
                  ({"yellow-white",
                    "pale white",
                    "creamy",
                    "beige",
                    "straw",
                    "hazel",
                    "silvery",
                    "ash",
                    "reddish",
                    "sepia",
                    "earthy",
                    "umber",
                    "steely",
                    "marble",
                    "swarthy",
                    "inky",
                   })
                 });

    intense_colours = ({ ({"light ","deep "}), // ivory
                         ({"pearly "}), // alabaster
                         ({}), // snowy
                         ({"mist ","ghost ","bone ","frost "}), // white
                         ({"light ","deep "}),//cream
                         ({}), //pearl
                         ({"bitter ","frosted ","blanched "}),// almond
                         ({"golden ","dappled "}),//wheat
                         ({"deep ","bright "}),// golden
                         ({"tawned "}), // honey
                         ({"dark "}), // tan
                         ({}), // cinnamon
                         ({"light ","frosted "}), // silver
                         ({}), // marble
                         ({"mist "}), // light grey
                         ({}), // merle grey
                         ({}), // red
                         ({"deep "}), // russet
                         ({"burnt ","dark "}), // sienna
                        ({}), // fawn
                         ({"spice ","cinnamon "}),//brown
                         ({"dark "}), //chocolate
                         ({}), // brindle
                         ({}), // bronze
                         ({"smoky ","burnished "}), // steel
                         ({}), // slate grey
                         ({}), // dim grey
                         ({"deep ","shadowy ","smoky "}), // dark grey
                         ({"smoky ","shadowy "}), // charcoal
                         ({}), // ebony
                         ({"deep ","smoky ","ink ","pitch "}), // black
                         ({}) // sable
                      });
  }

  coat_marks = ({"patches", "marks", "stripes", "streaks"});

  coat_features = ({"star on the forehead",
                    "pair of socks on both forepaws",
                    "pair of socks on both hind legs",
                    "set of socks on all paws",
                    "right ear",
                    "left ear",
                    "muzzle",
                    "tip on the tail",
                    "underside",
                    "line down the spine"});

  eye_colours = ({ "silver","light grey",
                   "golden","coppery",
                   "amber","crimson",
                   "turquoise","indigo",
                   "blue","dark blue",
                   "turquoise","emerald green",
                   "brown","dark brown",
                   "charcoal","glossy black"});

  eye_segments = ({ ({ "light","dark" }),
                    ({ "light","plum",
                       "teal","dark"}),
                    ({ "cloudy","yellow",
                        "reddish","bluish",
                       "blue","greenish",
                       "brownish","ebony" })
                  });

  coat_lengths = ({"","","short ", "furry ", "neat ", "straggly ", "shaggy ", "long ", "thick "});

  ob = find_player(master);
  if (ob) {
    wf = present("RangerClassObj",ob);
    if (wf) {
      wf = wf->query_tame();
      if (wf) {
         trained_age = wf->query_trained_age();
         age = wf->query_age();
         Str = wf->query_str();
         Wis = wf->query_wis();
         Int = wf->query_int();
         Con = wf->query_con();
         Dex = wf->query_dex();
         loyalty = wf->query_loyalty();
         bonus_hp = wf->query_bonus_hp();
      }
    }
  }

  write(capitalize(race)+" name : "+nickname+" ["+wolfnum+"]\n");
  show_long();
  write("Level: "+level+"\tLoyalty: "+loyalty+"\n");
  i = max_hp - bonus_hp;
  write("MaxHp: "+i+" / "+max_hp+" ("+bonus_hp+")    L/D: ("+light_food+"/"+dark_food+")\n");
  write("Stats: S:"+Str+" ("+strength_learn_count+"/"+check_str()+")\n");
  write("       D:"+Dex+" ("+dexterity_learn_count+"/"+check_dex()+")\n");
  write("       C:"+Con+" ("+total_extra_stuff+"/"+check_con()+"/"+bonus_hp_check()+")\n");
  write("       W:"+Wis+" ("+add_wis+")\n");
  write("       I:"+Int+" ("+add_int+")\n");
  i = member_array("carrying",abilities_names);
  if (i >=0 && i < sizeof(abilities_values))
    write("Carrying : "+abilities_values[i]+"\n");
  i = member_array("guarding",abilities_names);
  if (i >=0 && i < sizeof(abilities_values))
    write("Guarding : "+abilities_values[i]+"\n");
  i = member_array("dodging",abilities_names);
  if (i >=0 && i < sizeof(abilities_values))
    write("Dodging  : "+abilities_values[i]+"\n");
  i = member_array("rescue",abilities_names);
  if (i >=0 && i < sizeof(abilities_values))
    write("Rescue   : "+abilities_values[i]+"\n");
  info = RANGER_DAEMON->query_info(master);
  write("Ranger save info: \n");
  ind = m_indices(info);
  j = sizeof(ind);
  for(i=0;i<j;i+=2) {
    if (i+1<j)
      printf(" %15s : %3d     %15s : %3d\n",ind[i],info[ind[i]], ind[i+1],info[ind[i+1]]);
    else
      printf(" %15s : %3d\n",ind[i],info[ind[i]]);
  }

  if (genetic_traits) {
    write("Traits : \n");
    names = m_indices(genetic_traits);
    names = sort_array(names, #'>);
    j = 0;
    for(i=0;i<sizeof(names);i+=2) {
      if (i+1>=sizeof(names)) {
        j += genetic_traits[names[i]];
        write(sprintf("%15s : %3d\n",names[i],genetic_traits[names[i]]));
      } else{
        j += genetic_traits[names[i]] + genetic_traits[names[i+1]];
        write(sprintf("%15s : %3d     %15s : %3d\n",names[i],genetic_traits[names[i]],names[i+1],genetic_traits[names[i+1]]));
      }
    }
    write(sprintf("%15s : %3d\n","Total",j));
  }

  write(sprintf("%-5s is    : %-20s old\n",race,show_age(age)));
  write(sprintf("Trained age : %-20s\n",show_age(trained_age)));

  if (wf) {
    i = wf->check_trained_age(0) - trained_age;
  } else {
    i = check_trained_age(0) - trained_age;
  }
  if (i > 0)
  write("Till next level: "+show_age(i)+"\n");
  else
  write(capitalize(race)+" will level at next reset.\n");
  write("Vars T :"+time_var+"/300  E: "+time_exp_var+"/125\n");

  return 1;
}

show_age(s) {
  int i,j;
  string ret;
  ret = "";
  i = s/43200;
  j = s*2;
  if (i) {
    ret += i+" days ";
  }
  j -= i*86400;
  i = j/3600;
  ret += i+" hours ";
  j -= i*3600;
  i = j/60;
  ret += i+" mins ";
  j -= i*60;
  ret += j+" seconds";
  return ret;
}

check(str) {
  return str=="ixnay";
}


show_long() {
  string lg,el;
  if (master) {
     if (colour_segment) {
        lg = "This "+race+" seems to be the lifelong companion of a ranger. ";
        if ((!version && colour_segment < 4) ||
            (version && colour_segment < 5) ) {
          if (primary_coat != secondary_coat) {
            lg += "This furry canine has "+a_an((string)coat_segments[colour_segment-1][primary_coat])+" coloured coat with some "+
                  (primary_coat > secondary_coat?"lighter":"darker")+
                  " marks. ";
          } else {
            lg += "This furry canine has "+a_an((string)coat_segments[colour_segment-1][primary_coat])+" coloured coat. ";
          }
          lg += capitalize(query_possessive())+" coat seems to be shedding. ";
        } else {
          if (primary_coat != secondary_coat) {
            lg += "This furry canine has "+a_an(coat_length+intensity+colours[primary_coat])+" coat with";
            if (mark_type != "") {
               lg += " "+colours[secondary_coat]+" "+mark_type;
               if (feature != "")
                  lg +=" and";
            }
            if (feature != "")
              lg += " "+a_an(colours[secondary_coat])+" "+feature;
            lg += ". ";
          } else {
            lg += "This furry canine has a "+coat_length+"pure "+intensity+colours[primary_coat]+
                  " coat. ";
          }
        }
        if (eye_segment) {
          switch((Int+Wis)) {
            case 1..7   : el = "look around vacantly";break;
            case 8..14  : el = "look around curiously";break;
            case 15..21 : el = "survey "+query_possessive()+" surroundings cautiously";break;
            case 22..28 : el = "scan the surroundings with interest";break;
            case 29..35 : el = "observe the area alertly";break;
            case 36..42 : el = "seem to watch your every movement";break;
            default: el = "seem uninterested in everything";break;
          }
          if (eye_segment < 4) {
            lg += capitalize(query_possessive())+" "+eye_segments[eye_segment-1][primary_eye]+
                                   " eyes "+el+".";
          } else {
            lg += capitalize(query_possessive())+" "+eye_colours[primary_eye]+
                                   " eyes "+el+".";
          }
        }
        lg += "\n";
        writef(lg);

     } else {
        // Change desc once it has saved so ppl will know when its safe to quit
        if (file_size(SAVEPATH+"/"+master[0..0]+"/"+master+".o") > 0) {
          writef("This young and impressionable canine appears to have bonded "+                 "to a ranger and is now a life-long companion.\n");
        } else {
          writef("This furry canine, formerly "+formername+", appears to have "+                 "been tamed and well-trained as a ranger's companion.\n");
        }
     }
     if(shushed) writef(capitalize(this_object()->query_pronoun())+" is being very quiet.");

//     if (is_master()) {
//        wag();
//     }

  } else if (sedated) {
    writef("This furry canine, formerly "+formername+
             ", looks docile and well-fed.");
  } else {
    writef("This furry canine looks like "+this_object()->query_pronoun()+" was formerly tame, but "+
             "has gone feral after much neglect.  It looks thin and its "+
             "ribs poke out.");
  }
}

query_possessive() {
 if (gender==1) return "his";
 if (gender==2) return "her";
 return "its";
}

query_objective() {
  if (gender==1) return "him";
  if (gender==2) return "her";
  return "it";
}

query_pronoun() {
  if (gender==1) return "he";
  if (gender==2) return "she";
  return "it";
}

string a_an(string str) {
 string l;   
 if (!str) return "a";
 l = lower_case(str[0..0]);
 if (l == "a" || l == "e" || l == "i" || l=="o" || l == "u") {
    return "an "+str;
 } else {
    return "a "+str;
 }
}

int check_trained_age(int x) {
   int a;
   a = 900;
   if (level+x >= 15) a += 5 * (level+1+x) * (level+1+x) * (level+1+x);
   return a + (1750+time_var) * (level+x) + (475+time_exp_var) * (level+1+x)* (level+1+x);
}

int check_dex() {
   return Dex * Dex * 3 + 10 * Dex + 30;
}
int check_str() {
   return (Str+2) * (Str+2) * 12 + 32 * (Str+1) + 40;
}
int check_con() {
   return Con * Con * 3 + 8 * Con + 15;
}
int bonus_hp_check() {
   return 18*bonus_hp + 10* Con + 6*Con*Con;
}