Morphing Spell [by BoxBoy]
Snippet Posted Monday, March 26th @ 12:39:12 PM, by Brandon Brown in the Skills dept.
BoxBoy supplies a snippet allowing for a temporary player transformation into an beast.
Disclaimer: Using this code doesn't make me resposible for the damage
            it will (erm might *grin*) do.

I was emailed asking if I had a morph spell. To which I answered, nope.
But I was asked to add one, so here is a basic spell, and checks.
You might have to change the values in the spell, I have 200 levels
and you can build up your stats at level 200 (so you can eventually
get 20,000,000 mana, but thats unlikey).

The spell changes your race depending on lvl/mana. There are five
things u can change into: rabbit, dog, wolf, bear, demon.

(note from bbrown: be sure to add the required definitions and declarations
as you would for a normal manual spell throughout the code)

Wells here goes..

******* in spells.c *************
 at the end add:

ASPELL(spell_morph)
{
     int thing, i;

  if (victim == NULL)
    return;

  if (PLR_FLAGGED(victim, PLR_RABBIT) ||
     PLR_FLAGGED(victim, PLR_DOG) ||
     PLR_FLAGGED(victim, PLR_WOLF) ||
     PLR_FLAGGED(victim, PLR_BEAR) ||
     PLR_FLAGGED(victim, PLR_DEMON)){
     return;
  }

  for (i = 0; i < NUM_WEARS; i++)
  if (GET_EQ(victim, i)){
     send_to_char("The target cannot be wearing anything!\r\n", ch);
     return;
  }

  thing = number(GET_LEVEL(ch)/2, GET_LEVEL(ch));
  thing += GET_MAX_MANA(ch)/100;

  if (thing <= 75) {
     sprintf(buf, "rabbit");
     SET_BIT(PLR_FLAGS(victim), PLR_RABBIT);
  } else if (thing <= 100) {
     sprintf(buf, "dog");
     SET_BIT(PLR_FLAGS(victim), PLR_DOG);
  } else if (thing <= 125) {
     sprintf(buf, "wolf");
     SET_BIT(PLR_FLAGS(victim), PLR_WOLF);
  } else if (thing <= 150) {
     sprintf(buf, "bear");
     SET_BIT(PLR_FLAGS(victim), PLR_BEAR);
  } else {
     sprintf(buf, "demon");
     SET_BIT(PLR_FLAGS(victim), PLR_DEMON);
  }
  //Tell them what they won
  sprintf(buf2, "You turn into a %s!", buf);
  send_to_char(buf, victim);
  sprintf(buf2, "%s turns into a %s!", GET_NAME(victim), buf);
  act(buf2, FALSE, victim, 0, 0, TO_ROOM);
}

************ in spell_parser.c ***********
find:
  if ((spellnum < 1) || (spellnum > MAX_SPELLS)) {
    send_to_char("Cast what?!?\r\n", ch);
    return;
  }

and below it add:

  //Morph Spell
  if (PLR_FLAGGED(ch, PLR_RABBIT) ||
     PLR_FLAGGED(ch, PLR_DOG) ||
     PLR_FLAGGED(ch, PLR_WOLF) ||
     PLR_FLAGGED(ch, PLR_BEAR) ||
     PLR_FLAGGED(ch, PLR_DEMON)){
     send_to_char("You feel too beastly to cast spells.\r\n", ch);
     return;
  }

*********** act.infomative.c *********
find:

  if (!ch->desc)
    return;

  else if (i->player.description)
    send_to_char(i->player.description, ch);
  else
    act("&3You see nothing special about $m.&0", FALSE, i, 0, ch, TO_VICT);

act("You see nothing special about $m.", FALSE, i, 0, ch, TO_VICT);

above it add:

  if (PLR_FLAGGED(i, PLR_RABBIT)) {
    send_to_char("A cute little rabbit, with few teeth. It has a cute little tail and it's nose twitches from side to side.\r\n", ch);
    return;
  }
  if (PLR_FLAGGED(i, PLR_DOG)) {
    send_to_char("Some kind of hunting dog, with sharp teeth and a thick set of fur.\r\n", ch);
    return;
  }
  if (PLR_FLAGGED(i, PLR_WOLF)) {
    send_to_char("A bushy tailed timber wolf with deep red gums and crystal white fangs.\r\n", ch);
    return;
  }
  if (PLR_FLAGGED(i, PLR_BEAR)) {
    send_to_char("An eight foot grizzy bear, with long sharp claws and teeth. If doesn't look like it is going to cause any trouble though.\r\n", ch);
    return;
  }
  if (PLR_FLAGGED(i, PLR_DEMON)) {
    send_to_char("A ten foot demon with red skin an black horns, yellow talon like claws. This demon looks very tame, and doesn't appear dangerous.\r\n", ch);
    return;
  }

then look for:

    sprintf(buf, "%s", i->player.name);

  if (AFF_FLAGGED(i, AFF_INVISIBLE))
    strcat(buf, " (invisible)");
  if (AFF_FLAGGED(i, AFF_HIDE))
    strcat(buf, " (hidden)");

above it add:

  //Morph
  if (PLR_FLAGGED(i, PLR_RABBIT))  {
   strcpy(buf, CCCYN(ch, C_NRM));
   strcat(buf, "A cute little rabbit wiggles it's nose and tail.");
  } else if (PLR_FLAGGED(i, PLR_DOG))  {
   strcpy(buf, CCCYN(ch, C_NRM));
   strcat(buf, "A hunting dog trots along on all fours.");
  } else if (PLR_FLAGGED(i, PLR_WOLF))  {
   strcpy(buf, CCCYN(ch, C_NRM));
   strcat(buf, "A fearsome looking timber wolf walks about on all fours.");
  } else if (PLR_FLAGGED(i, PLR_BEAR))  {
   strcpy(buf, CCCYN(ch, C_NRM));
   strcat(buf, "An eight foot tall grizzy bear stands here on hinds legs.");
  } else if (PLR_FLAGGED(i, PLR_DEMON))  {
   strcpy(buf, CCCYN(ch, C_NRM));
   strcat(buf, "A ten foot, red skin demon stands here, grinning.");
  } else

******* act.item.c ************
find:


  /* first, make sure that the wear position is valid. */
  if (!CAN_WEAR(obj, wear_bitvectors[where]) && where != WEAR_DUALWIELD) {
    act("You can't wear $p there.", FALSE, ch, obj, 0, TO_CHAR);
    return;
  }

and above it add:

  //Check to see if morphed
  if (PLR_FLAGGED(ch, PLR_RABBIT) ||
     PLR_FLAGGED(ch, PLR_DOG) ||
     PLR_FLAGGED(ch, PLR_WOLF) ||
     PLR_FLAGGED(ch, PLR_BEAR) ||
     PLR_FLAGGED(ch, PLR_DEMON)){
     send_to_char("Animals don't need to wear clothes.\r\n", ch);
     return;
  }

********** fight.c **********
in int damage()
find:

/* peaceful rooms */

above it add:

  //Check to see if morphed
  if (PLR_FLAGGED(ch, PLR_RABBIT) ||
     PLR_FLAGGED(ch, PLR_DOG) ||
     PLR_FLAGGED(ch, PLR_WOLF) ||
     PLR_FLAGGED(ch, PLR_BEAR) ||
     PLR_FLAGGED(ch, PLR_DEMON) && !FIGHTING(ch)){
     send_to_char("Your ability to fight is much lower whilst morphed.\r\n", ch);
     return (0);
  }

******** mobact.c *********
find:

     if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
     continue;

and below it add:

  if (!PLR_FLAGGED(vict, PLR_RABBIT) ||
     !PLR_FLAGGED(vict, PLR_DOG) ||
     !PLR_FLAGGED(vict, PLR_WOLF) ||
     !PLR_FLAGGED(vict, PLR_BEAR) ||
     !PLR_FLAGGED(vict, PLR_DEMON))
     continue;

*****************************

And thats it....
Basically it makes u look like an animal, stops you from
using anything and from attacking anyone. It stops you
being attacked by aggro mobs, but still lets you fight
anything if it attacks you.

As others say,
like it, lump it, burn it, whatever takes ur fancy.
BoxBoy...

<< FTP Uploads 2001/03/25 | Reply | Threaded | FTP Uploads 2001/04/01 >>

 


Related Links
  BoxBoy
Related Articles
More by bbrown
 
 

Quick Links
 
The CircleMUD FAQ
The CircleMUD home page
Alex's Snippets
Wintermute Snippets
CircleMUD Bug Reporting or Help
CircleMUD List Archives
CircleMUD Resources
Death Gate's Scripts
(Author of C conversion)
Sammy's code site
Erwin S. Andreasen's page
(Author of mudFTP and other goodies)
Death's Gate Scripting site
Help for CircleMUD in Windows
The OasisOLC Maintenance Effort
George's Random Stuff
Imaginary Realities
MUD Dictionary
 
 


I think this don't quite work...
by BoxBoy (boruki@as-if.com) on Monday, April 9th @ 11:54:30 PM
http://
I have removed this from my mud, well actually I just didn't put it back in when I started over. I was wondering...when the spell wears off..do you lose the plr_flags? I doubt it, but can't think of how to do this..Then again, this spell doesn't actually wear off does it?

perhaps a command which puts you back into human form?

Oh well...dense little me.
Boruki (BoxBoy)
[ Reply to this comment ]

Re: I think this don't quite work...
by D. Tyler Barnes () on Saturday, April 14th @ 04:42:07 PM
http://
plr_flags are not modified when spells wear off.. actually plr_flag probably wasn't the best place to store it.. or any bitvector for that matter seeing as you shouldn't be able to set more than one of those states at a time.. perhaps a "form" ubyte somewhere in your char data instead? if 0, normal, if 1 rabbit, if 2 bear, etc..

Or if you're stuck on using flags, maybe the aff_x bivector, though that's quite a few bits to be wasting on one spell.
Just random thoughts.
[ Reply to this comment ]

Re: I think this don't quite work...
by BoxBoy (boruki@as-if.com) on Saturday, June 23rd @ 01:38:54 AM
http://
Ok this was badly done, in some ways..mainly cause I have no spare aff_'s free and I can't be bothered to convert upto the 128 bit. I have however had a nice idea which came to me recently.
Using the affect_by_spell(ch, SPELL_MORPH) as a check, you can actually tell it to remove the PLR_FLAGS in the unaffect section.

I'll hopefully get on and do this soon.

BoxBoy
[ Reply to this comment ]

My final solution to a hacky piece of code
by BoxBoy (boruki@as-if.com) on Saturday, June 23rd @ 01:59:02 AM
http://
** magic.c **
in affect_update at the top add:

struct obj_data *fur;

then find :

if (*spell_wear_off_msg[af->type]) {
send_to_char(spell_wear_off_msg[af->type], i);
send_to_char(" ", i);
}

and below it add:
if (af->type == SPELL_MORPH) {
if (PLR_FLAGGED(i, PLR_RABBIT)){
REMOVE_BIT(PLR_FLAGS(i), PLR_RABBIT);
send_to_char("You feel yourself growing, and your ears shrinking. You no longer feel like a rabbit. ", i);
}
else if (PLR_FLAGGED(i, PLR_DOG)) {
REMOVE_BIT(PLR_FLAGS(i), PLR_DOG);
send_to_char("Your fur sheds itself and your nose beings to shrink. You no longer feel like a dog. ", i);
//BoxBoy: The hair on the ground
fur = create_obj();
fur->item_number = NOTHING;
fur->in_room = NOWHERE;
fur->name = str_dup("fur");
fur->description = str_dup("The shed fur of some animal is scattered across the floor.");
fur->short_description = str_dup("some animal fur");

GET_OBJ_TYPE(fur) = ITEM_TRASH;
GET_OBJ_WEAR(fur) = ITEM_WEAR_TAKE;
GET_OBJ_EXTRA(fur) = ITEM_NODONATE;
}
else if (PLR_FLAGGED(i, PLR_WOLF)) {
REMOVE_BIT(PLR_FLAGS(i), PLR_WOLF);
send_to_char("You feel your your fur shed and your teeth shrink. You no longer feel like a wolf. ", i);
//BoxBoy: The hair on the ground
fur = create_obj();
fur->item_number = NOTHING;
fur->in_room = NOWHERE;
fur->name = str_dup("fur");
fur->description = str_dup("Some white and grey fur is scattered across the floor.");
fur->short_description = str_dup("some white and grey fur");

GET_OBJ_TYPE(fur) = ITEM_TRASH;
GET_OBJ_WEAR(fur) = ITEM_WEAR_TAKE;
GET_OBJ_EXTRA(fur) = ITEM_NODONATE;
}
else if (PLR_FLAGGED(i, PLR_BEAR)) {
REMOVE_BIT(PLR_FLAGS(i), PLR_BEAR);
send_to_char("Your talons shrink as does the rest of your body. You no longer feel like a bear. ", i);
send_to_char("Your fur sheds itself and your nose beings to shrink. You no longer feel like a dog. ", i);
//BoxBoy: The hair on the ground
fur = create_obj();
fur->item_number = NOTHING;
fur->in_room = NOWHERE;
fur->name = str_dup("fur");
fur->description = str_dup("The dark fur of a large animal lays on the floor.");
fur->short_description = str_dup("some animal fur");

GET_OBJ_TYPE(fur) = ITEM_TRASH;
GET_OBJ_WEAR(fur) = ITEM_WEAR_TAKE;
GET_OBJ_EXTRA(fur) = ITEM_NODONATE;
}
else if (PLR_FLAGGED(i, PLR_DEMON)){
REMOVE_BIT(PLR_FLAGS(i), PLR_DEMON);
send_to_char("Your horns fade away and you claws disappear. Your demonic skin changes back to normal. ", i);
}
}

if you dont want the fur on the ground then don't put the struct obj_data *fur; at the top and remove all the fur related stuff, otherwise enjoy :)

BoxBoy
[ Reply to this comment ]