Combat system tweaks

Posted by Valna on Mon 05 Apr 2004 04:35 AM — 5 posts, 22,130 views.

#0
Ok i'm working on a little bit of code here to set an "offensive strength" relative to weapon type being
wielded. I intend to add more variables before it's all said and done but this is the basic prototype. However
when i compile i have no problems, but when i execute the code it returns 0. The only way this is possible is if get_curr_str(ch) could be returning 0. or the initial test is invalid hence it does not execute at all. Any insights?

void do_os( CHAR_DATA * ch, char *argument)
{
        OBJ_DATA *wield;
        int os = 0;

        wield = get_eq_char( ch, WEAR_WIELD );
        if ( !IS_NPC(ch) && wield )
        {
                if ( wield->value[3] == WEAPON_AXE )
                os = ((get_curr_str(ch) * 2) + get_curr_dex(ch) + get_curr_con(ch));
                else if ( wield->value[3] == WEAPON_DAGGER )
                os = ((get_curr_dex(ch) * 2) + get_curr_str(ch) + get_curr_ref(ch));
                else if ( wield->value[3] == WEAPON_SWORD )
                os = ((get_curr_str(ch) * 2) + get_curr_dex(ch) + get_curr_ref(ch));
                else
                os = ((get_curr_str(ch) * 10));
                ch->os = os;
        }
        ch_printf( ch, "Ok this is here to test: OS = %d\n\r", os );
}


thanks.
Amended on Mon 05 Apr 2004 04:36 AM by Valna
Australia Forum Administrator #1
Can't see anything wrong with it - try some debugging, eg.


wield = get_eq_char( ch, WEAR_WIELD );
if (wield)
  ch_printf( ch, "wield->value[3] = %i\n\r", wield->value[3] );
else
  ch_printf( ch, "Not wielding a weapon\n\r");

USA #2
Interesting thing, I just grepped my admittedly stock smaug source code for the weapon_type flags you're checking against and came up with no matches. Might be something to look into.
#3
I changed the weapon types. They are functional and affect
the applicable skills as they should. The flags have been
referrenced in other code. I'll throw that debugging code
in there that you suggested Nick.
#4
Yeah apparently one of the possible issues is the problem it's returning no weapon wielded. Any idea why?
I've seen this get_eq_char( ch, WEAR_WIELD ) function called successfully in fight.c. Ok i think i figured out
the problem... I had changed the wear locations around.
As far as i could tell the flag was the same only the bit
had changed. once I put get_eq_char( ch, 18 ) 18 = wear_loc wield.
It returned a value as it should.