[Chistopher Herringshaw's example function]
>/* control the fights going on */
>void perform_violence(void)
>{
> struct char_data *ch;
>
> for (ch = combat_list; ch; ch = combat_next_dude) {
> combat_next_dude = ch->next_fighting;
> assert(ch->specials.fighting);
>
> /* every creatures god given right to attack once a round */
> if (AWAKE(ch) && (ch->in_room == ch->specials.fighting->in_room)) {
> hit(ch, ch->specials.fighting, TYPE_UNDEFINED);
* } else { /* Not in same room */
* stop_fighting(ch);
> }
>
> /* See if the character gets a second attack */
> if (AWAKE(ch) && (ch->in_room == ch->specials.fighting->in_room) &&\
> <some formula to determine if gets second attack goes here>) {
> hit(ch, ch->specials.fighting, TYPE_UNDEFINED);
* } else { /* Not in same room */
* stop_fighting(ch);
> }
>
.......
>
> }
>}
>
Just want to point out one thing about the code quoted above that
I suspect is an oversight on Chris's part. Given the logic used
in the if statement for the second, third, and fourth attacks,
a player will actually stop fighting if the formula that
determines the extra attack returns false, since it will then fall
through to the else { stop_fighting... } part. That check
is, I think, just to make sure the person isn't fighting somebody
who isn't in the same room. I think better logic for the second,
third, and fourth if statements might be:
if (AWAKE(ch) && <some formula...>) hit(ch, ch->.....);
If there's a flaw in my logic on this, please point it out so nobody
uses my example if they shouldn't. ;)
--
-Mathue Moyer
-mathue@ucsd.edu
This archive was generated by hypermail 2b30 : 12/07/00 PST