ROFL ok ok so I am a little complicated, and I promise I have been toning
down the complication in this code. I know their using the right pointer.
Cause the combats been working sound. When the problem started is I noticed
that some of the mobs weren't get new attack objects when they were fighting
new mobs. So I had it in stop_fighting clear out that pointer so to insure
they would get new ones. And I double check all of this with is_fighting
checks is they are fighting they have to have gone through time_to_kill and
that gives them an attack data. After that if the fight is ever stoped
is_fighting should achnowlage that and stop it. So I'm confused but I'll
show you mob_hit (I belive I left it mostly stock:

void fight_type::mob_hit (CHAR_DATA *ch)
{
    int number;
    CHAR_DATA *vch, *vch_next, *victim = ch->Fighting();
    OBJ_DATA *wield;


 if (!IS_VALID(victim) || !IS_VALID(ch))
  return;

    /* now for the skills */
    number = number_range(0,8);

    switch(number)
    {
     case (0) :
  if (ch->OffFlagged(OFF_BASH))
       do_function(ch, &do_bash, "");
  break;

     case (1) :
  if (ch->OffFlagged(OFF_BERSERK) && !IS_AFFECTED(ch,AFF_BERSERK))
       do_function(ch, &do_berserk, "");
  break;


     case (2) :
  if (ch->OffFlagged(OFF_DISARM)
  || (get_weapon_sn(ch) != gsn_hand_to_hand
  && (ch->MobFlagged(ACT_WARRIOR) || ch->MobFlagged(ACT_THIEF))))
       do_function(ch, &do_disarm, "");
  break;

     case (3) :
  if (ch->OffFlagged(OFF_KICK))
       do_function(ch, &do_kick, "");
  break;

     case (4) :
  if (ch->OffFlagged(OFF_KICK_DIRT))
       do_function(ch, &do_dirt, "");
  break;

     case (5) :
  if (ch->OffFlagged(OFF_TAIL))
  {
       do_function(ch, &do_tail, "");
  }
  break;

     case (6) :
  if (ch->OffFlagged(OFF_TRIP))
       do_function(ch, &do_trip, "");
  break;

     case (7) :
  if (ch->OffFlagged(OFF_CRUSH))
  {
     /* do_function(ch, &do_crush, "") */ ;
  }
  break;
     case (8) :
  if (ch->OffFlagged(OFF_BACKSTAB))
  {
//     do_function(ch, &do_backstab, "");
  }
    }

    if (!ch->is_fighting())
     return;

    if (ch->attack_obj == NULL)
     return;

 if ((wield = get_eq_char(ch, WEAR_WIELD)) == NULL)
  this->hit_hand_to_hand(ch);
 else if (wield->value[0] != WEAPON_BOW)
  this->hit_melee_weapon(ch, wield);
 else
  this->hit_ranged_weapon(ch, wield);

    if (!ch->is_fighting())
     return;

 if ((wield = get_eq_char(ch, WEAR_SECONDARY)) != NULL && ch->Fighting() !=
NULL)
  this->hit_melee_weapon(ch, wield);

     if (!ch->is_fighting())
      return;

    /* Area attack -- BALLS nasty! */
     if ( ch->OffFlagged(OFF_AREA_ATTACK))
     {
   for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
   {
       if (!IS_VALID(ch)) // incase it died?
        return;

    vch_next = vch->next;
       if ((vch != victim && vch->Fighting() != ch))
       {
        ch->change_fighting(vch);

     if ((wield = get_eq_char(ch, WEAR_WIELD)) == NULL)
      this->hit_hand_to_hand(ch);
     else if (wield->value[0] != WEAPON_BOW)
      this->hit_melee_weapon(ch, wield);
     else
      this->hit_ranged_weapon(ch, wield);
    }
   }
     }

    return;
}

And to mabye clear somethings up:

void fight_type::hit_hand_to_hand(CHAR_DATA *ch)
{
 int dam, skill, dt;
 OBJ_DATA *gloves;

     if (!ch->is_fighting() || !IS_SAME_ROOM(ch, ch->Fighting()))
      return;

 if (!IS_NPC(ch))
 {
  skill = get_skill(ch, gsn_hand_to_hand);

  dam = number_range( 1 + 4 * skill/100, UMAX(10, 2 * ch->level/3 *
skill/100));

  dam += (get_curr_stat(ch, STAT_STR) /* * 2*/); //thinking about this, or
maybe just using the GET_DAMROLL

  if ((gloves = get_eq_char(ch, WEAR_HANDS)) != NULL)
  {
   if (material_table[gloves->material].beats >= 8) // meaning it's a metal
of sorts
    dam *= (material_table[gloves->material].beats / 4);
  }

      dam += GET_DAMROLL(ch) * UMIN(100,skill) /100;
 }
 else
  dam = dice(ch->damage[DICE_NUMBER], ch->damage[DICE_TYPE]) +
ch->damage[DICE_BONUS];

 dt = IS_NPC(ch) ? attack_table[ch->dam_type].damage : DAM_BASH;

 ch->attack_obj->dam = dam;
 ch->attack_obj->dt = dt;
 ch->attack_obj->range_type = ATTACK_MELEE;
 ch->attack_obj->sn_type = SKILL_TYPE_SKILL;
 ch->attack_obj->sn = gsn_hand_to_hand;



     ch->Fighting()->attacked(ch, ch->attack_obj, NULL);
     return;
}

With that setting of the attack_obj at the bottem. I was thinking of maybe
making a nother function (smirks) That would set the object see if it's NULL
and allocate one. That I know would clean up the problem. The only problem I
see with that is thats hacking a fix to me, and I hate hacking fixs when
things should technicaly be working :P

----- Original Message ----- 
From: "Davion Kalhen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 11, 2003 3:26 PM
Subject: RE: Problem with combat


> C++, heh. Jeeze man! Show us mob_hit, and make sure your not using like
> this-> instead of ch. Or your using the right ch pointer. But, that all
> looks sound. But, maybe check around for another call for mob_hit or
> something. I duno, thats just weird. Also, checkout hit_hand_to_hand, and
> make sure its using the right pointer. its probably something silly like
> that, you seem like a compitant coder.
>
> Davion
>
>
> >From: "Sarix" <[EMAIL PROTECTED]>
> >To: <[email protected]>
> >Subject: Problem with combat
> >Date: Thu, 11 Dec 2003 11:43:41 -0700
> >
> >Ok a while ago I redid our combat system to fit with more on how we
wanted
> >it to work. And so far it's been working good but lattly I've been having
> >this problem, and IDK how it's a problem because it shouldn't be
according
> >to how it all works. I'll show you what it's doing and what I mean. When
> >someone goes to start an attack the time_to_kill function is called, that
> >top part of it looks like this:
> >
> >void fight_type::time_to_kill(CHAR_DATA *ch)
> >{
> >  OBJ_DATA *wield, *secondary;
> >
> >      if (ch->AffFlagged(AFF_PARALIZE))
> >       return;
> >
> >      if (!ch->is_fighting())
> >       return;
> >
> >      if (IS_VALID(ch->attack_obj))
> >       free_attack_data(ch->attack_obj);
> >
> >      ch->attack_obj = new_attack_data();
> >
> >      ch->attack_obj->ch = ch;
> >      ch->attack_obj->victim = ch->Fighting();
> >
> >      if (IS_NPC(ch))
> >      {
> >       this->mob_hit(ch);
> >    this->end_player_attack(ch);
> >    return;
> >      }
> >      else
> >      {
> >
> >K now the problem I'm having is with mobs attacking. I'll show the core:
> >
> >#0  0x080cb949 in fight_type::hit_hand_to_hand (this=0x82e7c14,
> >ch=0x40fda410)
> >     at fight.cc:451
> >451             ch->attack_obj->dam = dam;
> >(gdb) print ch->attack_obj
> >$1 = (ATTACK_DATA *) 0x0
> >(gdb) bt
> >#0  0x080cb949 in fight_type::hit_hand_to_hand (this=0x82e7c14,
> >ch=0x40fda410)
> >     at fight.cc:451
> >#1  0x080cc374 in fight_type::mob_hit (this=0x82e7c14, ch=0x40fda410)
> >     at fight.cc:663
> >#2  0x080cb5de in fight_type::time_to_kill (this=0x82e7c14,
ch=0x40fda410)
> >     at fight.cc:396
> >#3  0x080d008c in char_data::attack (this=0x40fda410) at fight.cc:1800
> >#4  0x080d0443 in char_data::init_fight (this=0x40fda410,
> >victim=0x40fd9e28)
> >     at fight.cc:1907
> >#5  0x080d031d in char_data::change_fighting (this=0x40fd9e28,
> >     victim=0x40fda410) at fight.cc:1875
> >#6  0x080cc348 in fight_type::mob_hit (this=0x82e7c14, ch=0x40fd9e28)
> >     at fight.cc:660
> >#7  0x080cb5de in fight_type::time_to_kill (this=0x82e7c14,
ch=0x40fd9e28)
> >     at fight.cc:396
> >#8  0x080d008c in char_data::attack (this=0x40fd9e28) at fight.cc:1800
> >#9  0x080d0443 in char_data::init_fight (this=0x40fd9e28,
> >victim=0x40f9aeb0)
> >     at fight.cc:1907
> >#10 0x080d031d in char_data::change_fighting (this=0x40f9aeb0,
> >     victim=0x40fd9e28) at fight.cc:1875
> >#11 0x080cc348 in fight_type::mob_hit (this=0x82e7c14, ch=0x40f9aeb0)
> >     at fight.cc:660
> >#12 0x080cb5de in fight_type::time_to_kill (this=0x82e7c14,
ch=0x40f9aeb0)
> >     at fight.cc:396
> >---Type <return> to continue, or q <return> to quit---
> >#13 0x080d008c in char_data::attack (this=0x40f9aeb0) at fight.cc:1800
> >#14 0x080d0443 in char_data::init_fight (this=0x40f9aeb0,
> >victim=0x40b43144)
> >     at fight.cc:1907
> >#15 0x080d031d in char_data::change_fighting (this=0x40b43144,
> >     victim=0x40f9aeb0) at fight.cc:1875
> >#16 0x080cc348 in fight_type::mob_hit (this=0x82e7c14, ch=0x40b43144)
> >     at fight.cc:660
> >#17 0x080cb5de in fight_type::time_to_kill (this=0x82e7c14,
ch=0x40b43144)
> >     at fight.cc:396
> >#18 0x080d008c in char_data::attack (this=0x40b43144) at fight.cc:1800
> >#19 0x080d0443 in char_data::init_fight (this=0x40b43144,
> >victim=0x40f9c744)
> >     at fight.cc:1907
> >#20 0x080d0435 in char_data::init_fight (this=0x40f9c744,
> >victim=0x40b43144)
> >     at fight.cc:1905
> >#21 0x080d7c66 in do_kill (ch=0x40f9c744, argument=0x40fca773 "q")
> >     at fight.cc:4749
> >#22 0x080fed0e in interpret (ch=0x40f9c744, argument=0x40fca773 "q")
> >     at interp.cc:788
> >#23 0x0809cf56 in substitute_alias (d=0x40fc8754, argument=0x40fca771 "k
> >q")
> >     at alias.cc:58
> >#24 0x080adc6a in game_loop_unix (control=4, control2=5) at comm.cc:1252
> >#25 0x080ad43b in main (argc=4, argv=0xbffff714) at comm.cc:828
> >#26 0x400711c4 in __libc_start_main () from /lib/libc.so.6
> >(gdb) fram 21
> >#21 0x080d7c66 in do_kill (ch=0x40f9c744, argument=0x40fca773 "q")
> >     at fight.cc:4749
> >4749        ch->init_fight(victim);
> >(gdb) print ch->name
> >$2 = 0x40f9c978 "Corellon"
> >(gdb) print victim->name
> >$3 = 0x4024e33d "black queen"
> >(gdb) down
> >#20 0x080d0435 in char_data::init_fight (this=0x40f9c744,
> >victim=0x40b43144)
> >     at fight.cc:1905
> >1905                    victim->init_fight(this);
> >(gdb) print victim->name
> >$4 = 0x4024e33d "black queen"
> >(gdb) print this->name
> >$5 = 0x40f9c978 "Corellon"
> >(gdb) down
> >#19 0x080d0443 in char_data::init_fight (this=0x40b43144,
> >victim=0x40f9c744)
> >     at fight.cc:1907
> >1907            this->attack();
> >(gdb) print this->name
> >$6 = 0x4024e33d "black queen"
> >(gdb) down
> >#18 0x080d008c in char_data::attack (this=0x40b43144) at fight.cc:1800
> >1800            fight_handler.time_to_kill(this);
> >(gdb) down
> >#17 0x080cb5de in fight_type::time_to_kill (this=0x82e7c14,
ch=0x40b43144)
> >     at fight.cc:396
> >396                     this->mob_hit(ch);
> >(gdb) print ch->name
> >$7 = 0x4024e33d "black queen"
> >(gdb) print ch->attack_obj
> >$8 = (ATTACK_DATA *) 0x0
> >(gdb)
> >
> >My problem is at the top of time_to_kill it's making sure the person has
a
> >valid attack_obj but for some reason by the time it gets to the mob_hit
> >call
> >which is like what 4 lines away. The characters pointer to it's
attack_obj
> >is NULL. How could it not be allocating this? Also this is how I handle
> >getting new and freeing attack_obj's
> >
> >ATTACK_DATA *attack_free;
> >
> >ATTACK_DATA *new_attack_data()
> >{
> >  static ATTACK_DATA attack_zero;
> >  ATTACK_DATA *attack;
> >
> >  if ( !attack_free )
> >   attack = (ATTACK_DATA *)alloc_perm(sizeof(*attack));
> >  else
> >  {
> >   attack = attack_free;
> >   attack_free = attack_free->next;
> >  }
> >  *attack = attack_zero;
> >  VALIDATE(attack);
> >
> >  return attack;
> >}
> >
> >
> >void free_attack_data(ATTACK_DATA *attack)
> >{
> >
> >  if (!attack)
> >   return;
> >
> >  INVALIDATE(attack);
> >  attack->next = attack_free;
> >  attack_free = attack;
> >}
> >
> >So if you can see that I missed anything please point it out to me this
is
> >becoming a pain.
> >
> >
> >--
> >ROM mailing list
> >[email protected]
> >http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
> _________________________________________________________________
> MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
>
http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
>
>


Reply via email to