Re: [Circle] [Code] falling_char

From: Christopher M. Ryan (drizzt@visi.net)
Date: 11/14/96


> Hi Guys-
> 
> I finally got around to finishing up my fly code and everything is done 
> except for the wearing off part. I now have it so that in affect_update, 
> when they affect is removed and if it is SPELL_FLY, a function called 
> falling_char is called (sorry I stole the name whoever gave it to me :-)
> 
> Anyway, the function looks like it should work except I'm having a 
> problem setting up the for loop that cycles through the rooms below until

> it gets to one that doesn't have an exit downward. It's supposed to stop 
> there then issue the damage. Here's the entire function:
> 
> 
> void fall_char(struct char_data *ch) {
> 
> int rooms_fallen, down_room, dam;
> 
> rooms_fallen = 1; /* Falling in the same room is considered 1 room */
> down_room = world[ch->in_room].dir_option[5]->to_room;
> 
/* for( init var(s); conditional(s); incriment) */
> for (ch->in_room; !down_room; down_room) {
/*       ^^^^ not quite   ^^^^ that works  ^^^ huh? */
/* try this instead */
for( /*alread done with down_room above (leave blank) */;
	down_room != -1; /* i could be wrong here not to famil with directions */
	/* nothing to do here, we'll do this later */ ) {
>   rooms_fallen ++;
>   send_to_char("You fall!\r\n", ch);
/* i would also send a message to the room like so and so plumets to the
ground.*/
/* not sure but you may nned to extract character first! */
>   char_to_room(ch, down_room);
/* here you want to incriment the to the next down room. */
down_room = world[ch->in_room].dir_option[5]->to_room;
> }
> 
> switch(rooms_fallen) {
>   case 1: dam = GET_MAX_HIT(ch) * .2;
>   case 2: dam = GET_MAX_HIT(ch) * .3;
>   case 3: dam = GET_MAX_HIT(ch) * .66;
>   case 4: dam = GET_MAX_HIT(ch) * .9;
>   default: dam = GET_MAX_HIT(ch);  /* ouch */
> }
> 
> GET_HIT(ch) = dam;
> send_to_char("You hit the ground with a loud THUD!\r\n", ch);
> act("$n falls onto the ground with a THUD!", FALSE, ch, 0, 0, TO_ROOM);
> }
> 
> I do it this way so that everyone has the same chance of survivng a fall 
> based on how healthy they are at the time (again thanks for the idea). If

> anyone can help me with that for loop, it would be greatly appreciated.
> 
> Thanks,
> 
>   -Brian

	Looks good to me! You need to practice on the for loops though. At least
you gave it a try ;) Have fun. I am glad that my psuedo code could help you
out too. I don't mind that took any name either after all that is why i
told the list to help someone out! Have fun and when you get the fall
working let me know the address of you mud so i can try it out ;>

Christopher M. Ryan
drizzt@visi.net
http://www.visi.net/~drizzt/index.html
http://www.visi.net/~drizzt/quake/index.html


+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



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