The Dawn Of Time
The Official Forums for the Dawn Of Time Mud Codebase
 
Log in Register FAQ Memberlist Search The Dawn Of Time Forum Index Goto the Official Dawn Website

Counter

 
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Migration/Porting
View previous topic :: View next topic  
Author Message
Deisel



Joined: 31 Jul 2007
Posts: 84
Location: SC

PostPosted: Sat Sep 08, 2007 12:30 am    Post subject: Counter Reply with quote

So I am at work and was asked to add counter as a skill. I found a snippet and I --think-- I ported it over properly. I just don't know if it will work because I don't know if hand to hand is considered a weapon skill? If it is, great, I think it will work fine. If it's not, I will put this skill on hold and make a new weapon type called 'gloves' or something.

Anyway, not my snippet but need to post it somewhere as I am not allowed to use email at work, so this is an easy way for me to grab it when I get home and well...it is a port. Razz

Quote:
/* -------------------------------------------
* Counter Skill for ROM24, 1.02 - 3/30/98
* -------------------------------------------
* The counter skill is an advanced defensive
* fighting technique that allows a skilled
* fighter to reverse his opponents attack and
* actually hit him back with it.
*
* As with all else, please email me if you use
* this code so I know my time is not going
* to waste. Smile And also, with this one I could
* really use some suggesstions for improvement!
*
* Brian Babey (aka Varen)
* [bribe@erols.com]
* ------------------------------------------- */

/* ----------------------------------------------
* In fight.c, in the local function declarations,
* insert this line. */

bool check_counter args( ( char_data *ch, char_data *victim, int dam, int dt ) );


/* ---------------------------------------------
* In fight.c, insert this function wherever
* it belongs alphabetically (or wherever you'd
* like it to be - it really doesn't matter) */

bool check_counter( char_data *ch, char_data *victim, int dam, int dt)
{
int chance;
int dam_type;
OBJ_DATA *wield;

if ( !IS_AWAKE(victim) ) ||
( !can_see(victim,ch) ) ||
( get_skill(victim,gsn_counter) < 1 )
return false;

wield = get_eq_char(victim,WEAR_WIELD);

chance = get_skill(victim,gsn_counter) / 6;
chance += ( victim->level - ch->level ) / 2;
chance += 2 * (victim,STAT_QU) - (ch,STAT_QU);
chance += get_weapon_skill(victim,get_weapon_sn(victim)) - get_weapon_skill(ch,get_weapon_sn(ch));
chance += (victim,STAT_ST) - (ch,STAT_ST);

if ( number_percent( ) >= chance )
return false;

dt = gsn_counter;

if ( dt == TYPE_UNDEFINED )
{
dt = TYPE_HIT;
if ( wield != NULL && wield->item_type == ITEM_WEAPON )
dt += wield->value[3];
else
dt += ch->dam_type;
}

if (dt < TYPE_HIT)
if (wield != NULL)
dam_type = attack_table[wield->value[3]].damage;
else
dam_type = attack_table[ch->dam_type].damage;
else
dam_type = attack_table[dt - TYPE_HIT].damage;

if (dam_type == -1)
dam_type = DAM_BASH;
check_improve(victim,gsn_counter,true,6);
act( "You reverse $n's attack and counter with your own!", ch, NULL, victim, TO_VICT );
act( "$N reverses your attack!", ch, NULL, victim, TO_CHAR );
damage(victim,ch,dam/2, gsn_counter , dam_type ,true );
return true;

}




/* -------------------------------------------
* In fight.c inside the one_hit function, you
* need to put this in to replace the line reading
* result = damage ( ch, victim, dam, dt, da... etc. */

if ( !check_counter( ch, victim, dam, dt ) )
result = damage( ch, victim, dam, dt, dam_type, true );

else return;



_________________
The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair.
Douglas Adams
Back to top
View user's profile Send private message
Deisel



Joined: 31 Jul 2007
Posts: 84
Location: SC

PostPosted: Sat Sep 08, 2007 1:27 pm    Post subject: Reply with quote

Heh, I wasn't too far off. Razz

Been testing it a while now and nothing is asploding on me so I am guessing it's working now. Had to make a few changes.

I made a sweepkick skill as well, so would I put that here or in snippets?

Code:
bool check_counter( char_data *ch, char_data *victim, int dam, int dt)
{
   int chance;
   int dam_type;
   OBJ_DATA *wield;

    if ( !IS_AWAKE(victim) ){
     return false;
   }   
    if ( !can_see(victim,ch) ){
    return false;
   }
    if ( get_skill(victim,gsn_counter) < 1 ){
    return false;
   }
   wield = get_eq_char(victim,WEAR_WIELD);

    chance = get_skill(victim, gsn_counter) / 6;
    chance += ( victim->level - ch->level ) ;
    chance += 5 + (victim->modifiers[STAT_QU] - ch->modifiers[STAT_QU]);
    chance += get_weapon_skill(victim, get_weapon_sn(victim)) - get_weapon_skill(ch,get_weapon_sn(ch)); 
    chance += 5 + (victim->modifiers[STAT_ST] - ch->modifiers[STAT_ST]);

    if ( number_percent( ) >= chance )
    return false;
   
    dt = gsn_counter;

    if ( dt == TYPE_UNDEFINED )
    {
    dt = TYPE_HIT;
     if ( wield != NULL && wield->item_type == ITEM_WEAPON )
    dt += wield->value[3];
   else
    dt += ch->dam_type;
    }
   
   if (dt < TYPE_HIT)
    if (wield != NULL)
    dam_type = attack_table[wield->value[3]].damage;
   else
    dam_type = attack_table[ch->dam_type].damage;
   else
    dam_type = attack_table[dt - TYPE_HIT].damage;
   
   
   if (dam_type == -1)
    dam_type = DAM_BASH;
    check_improve(victim,gsn_counter,true,6);
     act( "You reverse $n's attack and counter with your own!", ch, NULL, victim, TO_VICT );
     act( "$N reverses your attack!", ch, NULL, victim, TO_CHAR );

    damage(victim,ch,dam/2, gsn_counter , dam_type ,true );

   return true;

}



_________________
The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair.
Douglas Adams
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Migration/Porting All times are GMT + 13 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2005 phpBB Group
Theme created by Vjacheslav Trushkin