Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Google

Members: 0
Guests: 6
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SWFOTE FUSS » BUG: Lightsaber slash/whirlwi...
Forum Rules | Mark all | Recent Posts

BUG: Lightsaber slash/whirlwind drops hp into negatives but don't kill.
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2 next >>
Post is unread #1 Apr 6, 2009, 11:06 pm   Last edited Apr 6, 2009, 11:10 pm by ayuri
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

When using fskill slash or whirlwind, for some reason the damage done can drop a npc or pc into the negatives.

Example oinv a lightsaber, set it to do some uber damage. 1000 is fine. Minv a citizen. Now, lets slash a citizen and peace before the next round so you don't kill him.

Mstat shows: -35/115

Now, when the next round of combat starts, and you land a normal attack (blaster, kick, punch whatever) he's dead.

Here's the full function of the code so you all don't have to go and download it to view.
void fskill_slash(CHAR_DATA *ch, char *argument)
{
    FORCE_SKILL *fskill;
    OBJ_DATA *wield;
    CHAR_DATA *victim;
    int dam;
    fskill = force_test_skill_use("slash",ch,FORCE_COMBAT);
    if(fskill == NULL)
        return;
    if(!ch->fighting)
    {
        if ( ( wield = get_eq_char( ch, WEAR_WIELD ) ) == NULL || ( ( wield->value[3] != WEAPON_LIGHTSABER ) && (wield->value[3] != WEAPON_DUAL_LIGHTSABER) ))
        {
            if ( ( wield = get_eq_char( ch, WEAR_DUAL_WIELD ) ) == NULL || (( wield->value[3] != WEAPON_LIGHTSABER ) && (wield->value[3] != WEAPON_DUAL_LIGHTSABER) ))
            {
                send_to_char("You must be wielding a lightsaber to use this skill.\r\n",ch);
                return;
            }
        }
        if ( ( victim = get_char_room( ch, argument ) ) == NULL )
        {
            send_to_char( "They aren't here.\n\r", ch );
            return;
        }

        if ( IS_SET( ch->in_room->room_flags, ROOM_SAFE ) )
        {
            send_to_char( "You must go elsewhere to do that.\n\r", ch );
            return;
        }
        ch_printf(ch, "You swing your lightsaber at %s!\n\r", PERS(victim, ch));
        ch_printf(victim, "%s swings their lightsaber at you!\n\r", PERS(ch, victim));
        act(AT_WHITE, "$n swings their lightsaber at $N!\n\r", ch, NULL, victim, TO_NOTVICT);

        if(number_range(0,4) != 0 && number_range(0,100) > URANGE(1,ch->force_skill[FORCE_SKILL_STRIKE],60))
        {
            ch_printf(ch, "Your lightsaber cuts the air inches away from them.\n\r";);
            ch_printf(victim,"Their lightsaber cuts the air inches away from your midsection.\n\r";);
            act(AT_WHITE, "$n's slash barely misses $N.", ch, NULL, victim, TO_NOTVICT);
            if(wield->value[3] == WEAPON_DUAL_LIGHTSABER) secondslash(ch, victim);
            force_learn_from_failure(ch,fskill);
            return;
        }
        if(check_parry(ch,victim))
        {
            ch_printf(ch, "%s quickly parries your attack.\n\r", PERS(victim, ch));
            ch_printf(ch, "You quickly parry the attack.\n\r", PERS(ch, victim));
            act(AT_WHITE, "$N quickly parries $n's attack.", ch, NULL, victim, TO_NOTVICT);
            if(wield->value[3] == WEAPON_DUAL_LIGHTSABER) secondslash(ch, victim);
            force_learn_from_failure(ch,fskill);
            return;
        }
        ch_printf(ch, "Your attack cleanly slices across their midsection!\n\r";);
        ch_printf(victim, "Their attack cleanly slices across your midsection!\n\r";);
        act(AT_WHITE, "$N grimaces as $n's lightsaber slices into them!", ch, NULL, victim, TO_NOTVICT);

        dam = URANGE(20,(ch->force_skill[FORCE_SKILL_STRIKE] * ch->force_control) / (40 * (5-ch->force_level_status)),150);
        if(IS_AFFECTED(victim, AFF_SANCTUARY))
            dam /= 2;
        dam= ris_damage (victim, dam, RIS_SLASH);
        victim->hit-=dam*1.8;
        if(wield->value[3] == WEAPON_DUAL_LIGHTSABER) secondslash(ch, victim);
        set_fighting(victim, ch);
        force_learn_from_success(ch,fskill);
        return;
    }

    victim = ch->fighting->who;
    if ( ( wield = get_eq_char( ch, WEAR_WIELD ) ) == NULL || (( wield->value[3] != WEAPON_LIGHTSABER ) && (wield->value[3] != WEAPON_DUAL_LIGHTSABER)) )
    {
        if ( ( wield = get_eq_char( ch, WEAR_DUAL_WIELD ) ) == NULL || (( wield->value[3] != WEAPON_LIGHTSABER ) && (wield->value[3] != WEAPON_DUAL_LIGHTSABER)))
        {
            send_to_char("You must be wielding a lightsaber to use this skill.\r\n",ch);
            return;
        }
    }
    send_to_char(force_parse_string(ch,victim,fskill->ch_effect[0]),ch);
    send_to_char(force_parse_string(ch,victim,fskill->victim_effect[0]),victim);
    force_send_to_room(ch,victim,force_parse_string(ch,victim,fskill->room_effect[0]));
    if(number_range(0,4) != 0 && number_range(0,100) > URANGE(1,ch->force_skill[FORCE_SKILL_STRIKE],75))
    {
        send_to_char(force_parse_string(ch,victim,fskill->ch_effect[4]),ch);
        send_to_char(force_parse_string(ch,victim,fskill->victim_effect[4]),victim);
        force_send_to_room(ch,victim,force_parse_string(ch,victim,fskill->room_effect[4]));
        if(wield->value[3] == WEAPON_DUAL_LIGHTSABER) secondslash(ch, victim);
        force_learn_from_failure(ch,fskill);
        return;
    }
    if(check_parry(ch,victim))
    {
        send_to_char(force_parse_string(ch,victim,fskill->ch_effect[2]),ch);
        send_to_char(force_parse_string(ch,victim,fskill->victim_effect[2]),victim);
        force_send_to_room(ch,victim,force_parse_string(ch,victim,fskill->room_effect[2]));
        if(wield->value[3] == WEAPON_DUAL_LIGHTSABER) secondslash(ch, victim);
        force_learn_from_failure(ch,fskill);
        return;
    }

    send_to_char(force_parse_string(ch,victim,fskill->ch_effect[1]),ch);
    send_to_char(force_parse_string(ch,victim,fskill->victim_effect[1]),victim);
    force_send_to_room(ch,victim,force_parse_string(ch,victim,fskill->room_effect[1]));
    dam = URANGE(40,number_range(0,ch->force_skill[FORCE_SKILL_STRIKE] * ch->force_control / (20 * (4-ch->force_level_status))),100);
    if(IS_AFFECTED(victim, AFF_SANCTUARY))
        dam /= 2;
    dam= ris_damage (victim, dam, RIS_SLASH);
    victim->hit-=dam*1.2;
    if(wield->value[3] == WEAPON_DUAL_LIGHTSABER) secondslash(ch, victim);
    force_learn_from_success(ch,fskill);
    return;
}

**EDIT** I think part of the problem is how victim->hit is being set. But, I'm unsure of the correct way to go about fixing.
Just something annoying.
ayuri
       
Post is unread #2 Apr 7, 2009, 7:26 am
Go to the top of the page
Go to the bottom of the page

tphegley
Magician
GroupMembers
Posts176
JoinedMay 21, 2006

Does it even need the victim->hit?

Have you tried commenting those out and seeing what happens?
       
Post is unread #3 Apr 7, 2009, 7:49 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

It should probably be calling damage( ) instead of modifying the hitpoints itself. But I'm not familiar enough with the code to make a call on that.
       
Post is unread #4 Apr 7, 2009, 8:38 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

In general, nobody should ever modify hit points directly without going through the damage function, which takes care of various things among which are actually dying when HP go negative. :wink:
       
Post is unread #5 Apr 7, 2009, 8:41 am
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

tphegley said:

Does it even need the victim->hit?

Have you tried commenting those out and seeing what happens?

Yes, thats where it the damage done. Pretty sure anyhow, cause I don't see anywhere else were damage is dealt.

Kayle said:

It should probably be calling damage( ) instead of modifying the hitpoints itself. But I'm not familiar enough with the code to make a call on that.

I agree that it should be calling damage( ) in some way.

From swskills.c function punch:
    if ( IS_NPC(ch) || number_percent( ) < ch->pcdata->learned[gsn_punch] )
    {
        learn_from_success( ch, gsn_punch );
        if ( IS_NPC(ch) )
        {
            global_retcode = damage( ch, victim, number_range( 20, ((20+ch->skill_level[COMBAT_ABILITY])*2) ), gsn_punch );
        }
        else
        {
            global_retcode = damage( ch, victim, number_range( ch->pcdata->learned[gsn_punch],(ch->pcdata->learned[gsn_punch])*2 ), gsn_punch );
        }
        ch->move -= 15;
        return;
    }
    else
    {
        learn_from_failure( ch, gsn_punch );
        global_retcode = damage( ch, victim, number_range( ch->pcdata->learned[gsn_punch],(ch->pcdata->learned[gsn_punch])*2 ), gsn_punch );
    }


Now, normal attacks if your weapons is a lightsaber is a slash.
Your slash *** ANNIHILATES *** A male corellian! You do 843 points of damage.
With a violent twisting motion, A male corellian falls to the ground and ceases
to move!

^uber lightsaber for testing^

I'm not very versed with how exactly the fight code works.
Thanks,
ayuri
       
Post is unread #6 Apr 7, 2009, 8:42 am
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008


DavidHaley said:

In general, nobody should ever modify hit points directly without going through the damage function, which takes care of various things among which are actually dying when HP go negative. :wink:

So true, so true. Or you end up with zombies. And I don't know about you, but I don't really like zombies. They stink.

ayuri
       
Post is unread #7 Apr 7, 2009, 10:10 am
Go to the top of the page
Go to the bottom of the page

tphegley
Magician
GroupMembers
Posts176
JoinedMay 21, 2006

So instead of victim->hit -= dam

it should probably be:

damage(ch, victim, dam, gsn_lightsaber)

or whatever the gsn is called. Something along those lines.
       
Post is unread #8 Apr 7, 2009, 10:48 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Incidentally, going through 'damage' also means that things like damage resistance can be applied.
       
Post is unread #9 Apr 7, 2009, 10:56 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

This is something Keb is going to need to look at since it's from FotE and that's his department. But a good chunk near the end of that second will probably need redone a bit if it gets switched to use damage( )
       
Post is unread #10 Apr 7, 2009, 3:46 pm
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

I would also venture a guess to say this bug is in SWRFUSS also. I'll check when I get a few moments after I get home tonight.
ayuri
       
Post is unread #11 Apr 8, 2009, 2:59 am
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

I would also venture a guess to say this bug is in SWRFUSS also. I'll check when I get a few moments after I get home tonight.


SWRFUSS and SWR codebases in general use a different force system, so I don't think the bug exists there.

I'm not sure on this but you might be abe to get away with leaving it as is, if you throw in an update_pos call after taking away the hit points

    dam= ris_damage (victim, dam, RIS_SLASH);
    victim->hit-=dam*1.2;
    update_pos( victim );
    if(wield->value[3] == WEAPON_DUAL_LIGHTSABER) secondslash(ch, victim);


If that doesn't work I can look at it more throughly over the weekend, for now I'm working a lot so I won't be doing much til the weekends at least.
       
Post is unread #12 Apr 8, 2009, 8:19 am   Last edited Apr 8, 2009, 8:19 am by ayuri
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

Keberus said:


SWRFUSS and SWR codebases in general use a different force system, so I don't think the bug exists there.

Ya, I totaly forgot about that. Just so much between the two are the same. Heh.
I'll try the update_pos( victim ) when I get a moment.
ayuri
       
Post is unread #13 Apr 8, 2009, 9:23 am
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

Ok, so I tried adding in update_pos( victim ); within two spots for slash, and no dice. He went to -84/336.
ayuri
       
Post is unread #14 Apr 8, 2009, 10:20 am
Go to the top of the page
Go to the bottom of the page

tphegley
Magician
GroupMembers
Posts176
JoinedMay 21, 2006


ayuri said:

Ok, so I tried adding in update_pos( victim ); within two spots for slash, and no dice. He went to -84/336.
ayuri


Maybe just add in an if check to see if hp is below 0 and then do a raw_kill?
       
Post is unread #15 Apr 8, 2009, 12:29 pm   Last edited Apr 8, 2009, 12:35 pm by ayuri
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

tphegley said:


Maybe just add in an if check to see if hp is below 0 and then do a raw_kill?

A raw_kill would be bad if used against PC. Right now, if your hp goes under 0 your stunned. In stock it is -500 you die. In my current game we gave it to -1500. A raw_kill wouldn't let someone toss a pair of binders and ship em off to jail.
**EDIT to correct values of stock vs my game
ayuri
       
Post is unread #16 Apr 8, 2009, 12:34 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Sorry if I missed it, but why not just use damage? (there might be a reason not to that I'm not aware of, I don't know the SW bases too well)
       
Post is unread #17 Apr 8, 2009, 12:41 pm
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

I think we'll/I'll have to wait for Keb.
I'm not that great with C and need someone to hold my hand from time to time.
Thank you all for taking an interest.
ayuri
       
Post is unread #18 Apr 8, 2009, 4:22 pm
Go to the top of the page
Go to the bottom of the page

tphegley
Magician
GroupMembers
Posts176
JoinedMay 21, 2006


ayuri said:

tphegley said:


Maybe just add in an if check to see if hp is below 0 and then do a raw_kill?

A raw_kill would be bad if used against PC. Right now, if your hp goes under 0 your stunned. In stock it is -500 you die. In my current game we gave it to -1500. A raw_kill wouldn't let someone toss a pair of binders and ship em off to jail.
**EDIT to correct values of stock vs my game
ayuri


So put in a NPC check and kill the npc and not the pc
       
Post is unread #19 Apr 8, 2009, 11:36 pm   Last edited Apr 8, 2009, 11:37 pm by ayuri
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

That could work, but when it would come to arena combat, that could tip the balance into favor of the person who just got put into the negatives. Especially if it was a very close fight.
ayuri
       
Post is unread #20 Apr 9, 2009, 6:33 am   Last edited Apr 9, 2009, 7:09 am by tphegley
Go to the top of the page
Go to the bottom of the page

tphegley
Magician
GroupMembers
Posts176
JoinedMay 21, 2006

So put in an arena if check...

Why can't you just go with damage like david said?

**EDIT**

Ok, so I had some time and this seemed to work.

      if( IS_AFFECTED( victim, AFF_SANCTUARY ) )
         dam /= 2;
//      victim->hit -= dam * 1.5;
      global_retcode = damage(ch, victim, dam, gsn_lightsabers);
      if( wield->value[3] == WEAPON_DUAL_LIGHTSABER )
         secondslash( ch, victim );
      //set_fighting( victim, ch );
      force_learn_from_success( ch, fskill );
      return;


I commented out victim->hit and set_fighting and added the damage. I set a citizen to 5 hp and slashed him and he died. You could probably do the same with whirlwind as well. It seems like all the fskills do victim->hit instead of damage so change as needed.

You swing your lightsaber at a male citizen of Tatooine!
Your attack cleanly slices across their midsection!
Your  *** ANNIHILATES *** a male citizen of Tatooine! You do 17 points of damage.
A male citizen of Tatooine is DEAD!
You receive 1501 combat experience.
The corpse of a male citizen of Tatooine contains:
     Nothing.


The only thing I can see wrong now is that it's not calling the attack_table.
       
Pages:<< prev 1, 2 next >>