Posted by
| Robert Powell
Australia (367 posts) Bio
|
Message
| Ok i have read through this peice of code a number of times and still dont make sence of where the damage values are comming from, tho i hazzard a guess that this is is what is happening,
if ( !wield ) /* dice formula fixed by Thoric */
dam = proj_bonus;
else
dam = number_range(wield->value[1], wield->value[2]) + (proj_bonus / 10);
that if the MOB is shot by the projectile then the damage done is the values from the projectile, otherways if your wacking the MOB over the head with your ranged weapon then the damage done is the values from the ranged weapon + some from the projectile??
Im not much of a coder, but just need to work out how its working so i can work out some sort of game balance for ranged weapons when i add in new types for guns, rocket launchers and the like.
If anyone can help me decifer this would be greatly apreciated.
/*
* Hit one guy with a projectile.
* Handles use of missile weapons (wield = missile weapon)
* or thrown items/weapons
*/
ch_ret projectile_hit( CHAR_DATA *ch, CHAR_DATA *victim, OBJ_DATA *wield,
OBJ_DATA *projectile, sh_int dist )
{
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int plusris;
int dam;
int diceroll;
int prof_bonus;
int prof_gsn = -1;
int proj_bonus;
int dt;
ch_ret retcode;
if ( !projectile )
return rNONE;
if ( projectile->item_type == ITEM_PROJECTILE
|| projectile->item_type == ITEM_WEAPON )
{
dt = TYPE_HIT + projectile->value[3];
proj_bonus = number_range(projectile->value[1], projectile->value[2]);
}
else
{
dt = TYPE_UNDEFINED;
proj_bonus = number_range(1, URANGE(2, get_obj_weight(projectile), 100) );
}
/*
* Can't beat a dead char!
*/
if ( victim->position == POS_DEAD || char_died(victim) )
{
extract_obj(projectile);
return rVICT_DIED;
}
if ( wield )
prof_bonus = weapon_prof_bonus_check( ch, wield, &prof_gsn );
else
prof_bonus = 0;
if ( dt == TYPE_UNDEFINED )
{
dt = TYPE_HIT;
if ( wield && wield->item_type == ITEM_MISSILE_WEAPON )
dt += wield->value[3];
}
/*
* Calculate to-hit-armor-class-0 versus armor.
*/
if ( IS_NPC(ch) )
{
thac0_00 = ch->mobthac0;
thac0_32 = 0;
}
else
{
thac0_00 = class_table[ch->class]->thac0_00;
thac0_32 = class_table[ch->class]->thac0_32;
}
thac0 = interpolate( ch->level, thac0_00, thac0_32 ) - GET_HITROLL(ch) + (dist*2);
victim_ac = UMAX( -19, (int) (GET_AC(victim) / 10) );
/* if you can't see what's coming... */
if ( !can_see_obj( victim, projectile) )
victim_ac += 1;
if ( !can_see( ch, victim ) )
victim_ac -= 4;
/* Weapon proficiency bonus */
victim_ac += prof_bonus;
/*
* The moment of excitement!
*/
while ( ( diceroll = number_bits( 5 ) ) >= 20 )
;
if ( diceroll == 0
|| ( diceroll != 19 && diceroll < thac0 - victim_ac ) )
{
/* Miss. */
if ( prof_gsn != -1 )
learn_from_failure( ch, prof_gsn );
/* Do something with the projectile */
if ( number_percent() < 50 )
extract_obj(projectile);
else
{
if ( projectile->in_obj )
obj_from_obj(projectile);
if ( projectile->carried_by )
obj_from_char(projectile);
obj_to_room(projectile, victim->in_room);
}
damage( ch, victim, 0, dt );
tail_chain( );
return rNONE;
}
/*
* Hit.
* Calc damage.
*/
if ( !wield ) /* dice formula fixed by Thoric */
dam = proj_bonus;
else
dam = number_range(wield->value[1], wield->value[2]) + (proj_bonus / 10);
/*
* Bonuses.
*/
dam += GET_DAMROLL(ch);
if ( prof_bonus )
dam += prof_bonus / 4;
/*
* Calculate Damage Modifiers from Victim's Fighting Style
*/
if ( victim->position == POS_BERSERK )
dam = 1.2 * dam;
else if ( victim->position == POS_AGGRESSIVE )
dam = 1.1 * dam;
else if ( victim->position == POS_DEFENSIVE )
dam = .85 * dam;
else if ( victim->position == POS_EVASIVE )
dam = .8 * dam;
if ( !IS_NPC(ch) && ch->pcdata->learned[gsn_enhanced_damage] > 0 )
{
dam += (int) (dam * LEARNED(ch, gsn_enhanced_damage) / 120);
learn_from_success( ch, gsn_enhanced_damage );
}
if ( !IS_AWAKE(victim) )
dam *= 2;
if ( dam <= 0 )
dam = 1;
plusris = 0;
if ( IS_OBJ_STAT(projectile, ITEM_MAGIC) )
dam = ris_damage( victim, dam, RIS_MAGIC );
else
dam = ris_damage( victim, dam, RIS_NONMAGIC );
/*
* Handle PLUS1 - PLUS6 ris bits vs. weapon hitroll -Thoric
*/
if ( wield )
plusris = obj_hitroll( wield );
removed code here that related to weaponspells resist and immune to reduce post size
|
Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated. | Top |
|