Re: Hiya folks...

From: Herbert Kremser (kremser@flinux.tu-graz.ac.at)
Date: 08/15/95


On Mon, 14 Aug 1995, MUD Programmer wrote:

> > > 5) Can you PLEASE take the "hits <target> extremely hard" etc. output 
> > > from fight.c and put it into the misc text area?!  We had to work a tad 
> > > with fight.c (mostly cut & replace) to customize it.
> > > 
> > It would take an nigh-complete rewrite of fight.c to do this.
> 
> Hence we need a programmer :)  But that will wait until 3.1

Having a programmer never seems to be a bad idea.  :-)

But actually what you want should rather be easy, if you really want
that.
Just don't define the constant dam_weapons in fight.c, but make a small
routine which loads that info from a file, on boot-up time.
You can easily do this with line by line (use fgets) and copy it
to the place where you want it (with strdup). You may want to add
an entry for max_dam, if you want to keep it more flexible. This of course
would need slight update on the procedure dam_message too, but thats all.

To give your coders some ideas, you can use something like,
static struct dam_weapon_type
{
  char *to_room;
  char *to_char;
  char *to_victim;
  int max_dam;
};

dam_weapons = NULL;
fl = fopen(DAMFILE, "r");
i=0;
while(fgets(buf, 255, fl))
  {
  i++;
  if (dam_weapons)
    CREATE(dam_weapons, struct dam_weapon_type, i);
  else
    RECREATE(dam_weapons, struct dam_weapon_type, i);
  buf[strlen(buf)-1] = '\0';
  dam_weapons->to_room = strdup(buf);
  fgets(buf, 255, fl);
  buf[strlen(buf)-1] = '\0';
  dam_weapons->to_char = strdup(buf);
  fgets(buf, 255, fl);
  buf[strlen(buf)-1] = '\0';
  dam_weapons->to_victim = strdup(buf);
  fgets(buf, 255, fl);
  sscanf(buf, "%i", &(dam_weapons->max_dam));
  }
fclose(fl);


Of course these are just quick ideas, and it's always good to add
some error checks etc. etc.

Herbert

[on public request 12 lines of signature deleted]  *snip* ;)



This archive was generated by hypermail 2b30 : 12/18/00 PST