Yes I would like to point out a ery good leason I learned from this issue.

When you get a corefile, READ THE STUPID THING. My problem lied in mob_hit
yes but not at the first time it called melee_hand_to_hand but at the bottom
the second time it called it down where if the mob is an area_attack_mob.
Now had I read the corefile and went to the line number it hand told me. I
would have found this issue much quicker. So it is always wise to fully read
something rathern then to quickly skim it :P

----- Original Message ----- 
From: "Sarix" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, December 11, 2003 11:43 AM
Subject: Problem with combat


> 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
>


Reply via email to