Mailing List
Home
Forum Home
MUD Dev - Discussion of MUD system design, development, and implementation
Mac Game - Mac game development
Rivers of MUD - a Diku and Merc based multiuser dungeon
SMAUG
Subjects
Getting UDP through NAT/firewalls/whatever for a game
Getting UDP through NAT/firewalls/whatever for a game
QuickTime errors
Python script as stand alone MUD server
Various sound problems
Fragment Shaders & GL TEXTURE RECTANGLE EXT
Timers and global variables
Re: Language and platform for Text MUD server
Apparent acquisition of Yantis (mysupersales) by IDE
HID keyboard
Getting UDP through NAT/firewalls/whatever for a game
Microsoft Sparkle
Director MX
Congratulations Horizons
Yet more problems fullscreen mode
Apple Dev Kitchen Them 's tasty vittles, Maw!
NSOpenGLContext, Pbuffers, and drawables
More DCR "theft " naughtiness
dynamic sprite creation and imaging lingo
Re: Find stuff in Flash array?
Effects of skill imbalances?
QuickTime errors
Rom 2 4/Quickmud Enhancement/Bug fix
Working with XML files/CFURL
smooth scrolling/subpixel tweening
RE: (Ron help me?) Flash text
Flash Racing
MudDev FAQ 2
Browser based games
Installing GLUT
Special character in Flash XML
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Problem with combat

Problem with combat

2003-12-11       - By Sarix

 Back
Reply:     1     2  

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
ROM@(protected)
http://www.rom.org/cgi-bin/mailman/listinfo/rom

Earn $52 per hosting referral at Lunarpages.