|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
09-30-2007, 07:25 PM
|
Sarnak
|
|
Join Date: Sep 2005
Posts: 34
|
|
No gains for illegially equipped items
First a fix to support Frogloks and Berserkers
Code:
bool ItemInst::IsEquipable(int16 race, int16 class_) const
{
if (!m_item)
return false;
bool israce = false;
bool isclass = false;
if (m_item->Slots == 0) {
return false;
}
uint32 classes_ = m_item->Classes;
uint32 races_ = m_item->Races;
int32 race_ = 0;
#ifndef PACKETCOLLECTOR
race_ = GetArrayRace(race);
race_ = (race_==17? 15 : race_);
#endif
// @merth: can this be optimized? i.e., will (race & common->Races) suffice?
for (int cur_class = 1; cur_class<=16; cur_class++) {
if (classes_ % 2 == 1) {
if (cur_class == class_) {
isclass = true;
}
}
classes_ >>= 1;
}
for (unsigned int cur_race = 1; cur_race <= 15; cur_race++) {
if (races_ % 2 == 1) {
if (cur_race == race_) {
israce = true;
}
}
races_ >>= 1;
}
if (!isclass){printf("CLASS FAILED:%i ",class_);}
if (!israce){printf("RACE FAILED:%i ",race_);}
return (israce && isclass);
}
Update to allow new aug bool used in function
Code:
void AddItemBonuses(const ItemInst *inst, StatBonuses* newbon, bool isaug = false);
function now makes a return if player does not meet level requirement, class requirement, race requirement, or if a non-augment item is inserted into an augment slot. Slot check is currently commented due to GetCurrentSlot() returning bad values.
Please excuse the return functions not being combined, left them separate while i was testing each part.
Code:
void Client::AddItemBonuses(const ItemInst *inst, StatBonuses* newbon, bool isaug) {
if(!inst || !inst->IsType(ItemClassCommon))
{
return;
}
if (GetLevel() < inst->GetItem()->ReqLevel)
{
//printf("LEVEL FAILED:%i < %i ",GetLevel(),inst->GetItem()->ReqLevel);
return;
}
if (!inst->IsEquipable(GetBaseRace(),GetClass()))
{
return;
}
if(inst->GetAugmentType()==0 && isaug == TRUE)
{
//printf("AUG FAILED:%i ",inst->GetAugmentType());
return;
}
//if(!inst->IsEquipable(inst->GetCurrentSlot()))
//{
// printf("SLOT FAILED:%i ",inst->GetCurrentSlot());
//}
const Item_Struct *item = inst->GetItem();
if( GetLevel() >= item->RecLevel)
{
newbon->AC += item->AC;
newbon->HP += item->HP;
newbon->Mana += item->Mana;
newbon->Endurance += item->Endur;
newbon->STR += item->AStr;
newbon->STA += item->ASta;
newbon->DEX += item->ADex;
newbon->AGI += item->AAgi;
newbon->INT += item->AInt;
newbon->WIS += item->AWis;
newbon->CHA += item->ACha;
newbon->MR += item->MR;
newbon->FR += item->FR;
newbon->CR += item->CR;
newbon->PR += item->PR;
newbon->DR += item->DR;
}
else
{
int lvl = GetLevel();
int reclvl = item->RecLevel;
newbon->AC += CalcRecommendedLevelBonus( lvl, reclvl, item->AC );
newbon->HP += CalcRecommendedLevelBonus( lvl, reclvl, item->HP );
newbon->Mana += CalcRecommendedLevelBonus( lvl, reclvl, item->Mana );
newbon->Endurance += CalcRecommendedLevelBonus( lvl, reclvl, item->Endur );
newbon->STR += CalcRecommendedLevelBonus( lvl, reclvl, item->AStr );
newbon->STA += CalcRecommendedLevelBonus( lvl, reclvl, item->ASta );
newbon->DEX += CalcRecommendedLevelBonus( lvl, reclvl, item->ADex );
newbon->AGI += CalcRecommendedLevelBonus( lvl, reclvl, item->AAgi );
newbon->INT += CalcRecommendedLevelBonus( lvl, reclvl, item->AInt );
newbon->WIS += CalcRecommendedLevelBonus( lvl, reclvl, item->AWis );
newbon->CHA += CalcRecommendedLevelBonus( lvl, reclvl, item->ACha );
newbon->MR += CalcRecommendedLevelBonus( lvl, reclvl, item->MR );
newbon->FR += CalcRecommendedLevelBonus( lvl, reclvl, item->FR );
newbon->CR += CalcRecommendedLevelBonus( lvl, reclvl, item->CR );
newbon->PR += CalcRecommendedLevelBonus( lvl, reclvl, item->PR );
newbon->DR += CalcRecommendedLevelBonus( lvl, reclvl, item->DR );
}
//FatherNitwit: New style haste, shields, and regens
if(newbon->haste < (sint8)item->Haste) {
newbon->haste = item->Haste;
}
if(item->Regen > 0) {
newbon->HPRegen += item->Regen;
}
if(item->ManaRegen > 0) {
newbon->ManaRegen += item->ManaRegen;
}
if(item->EnduranceRegen > 0){
newbon->EnduranceRegen += item->EnduranceRegen;
}
if(item->DamageShield > 0) {
newbon->DamageShield += item->DamageShield;
}
if(item->SpellShield > 0) {
newbon->SpellDamageShield += item->SpellShield;
}
if(item->Shielding > 0) {
newbon->MeleeMitigation += item->Shielding;
}
if(item->StunResist > 0) {
newbon->StunResist += item->StunResist;
}
if(item->StrikeThrough > 0) {
newbon->StrikeThrough += item->StrikeThrough;
}
if(item->Avoidance > 0) {
newbon->AvoidMeleeChance += item->Avoidance;
}
if(item->Accuracy > 0) {
newbon->HitChance += item->Accuracy;
}
if(item->CombatEffects > 0) {
newbon->ProcChance += item->CombatEffects;
}
if (item->Worn.Effect>0 && (item->Worn.Type == ET_WornEffect)) { // latent effects
//printf("WORN EFFECT???");
ApplySpellsBonuses(item->Worn.Effect, item->Worn.Level, newbon);
}
switch(item->BardType)
{
case 51: /* All (e.g. Singing Short Sword) */
{
if(item->BardValue > newbon->singingMod)
newbon->singingMod = item->BardValue;
if(item->BardValue > newbon->brassMod)
newbon->brassMod = item->BardValue;
if(item->BardValue > newbon->stringedMod)
newbon->stringedMod = item->BardValue;
if(item->BardValue > newbon->percussionMod)
newbon->percussionMod = item->BardValue;
if(item->BardValue > newbon->windMod)
newbon->windMod = item->BardValue;
break;
}
case 50: /* Singing */
{
if(item->BardValue > newbon->singingMod)
newbon->singingMod = item->BardValue;
break;
}
case 23: /* Wind */
{
if(item->BardValue > newbon->windMod)
newbon->windMod = item->BardValue;
break;
}
case 24: /* stringed */
{
if(item->BardValue > newbon->stringedMod)
newbon->stringedMod = item->BardValue;
break;
}
case 25: /* brass */
{
if(item->BardValue > newbon->brassMod)
newbon->brassMod = item->BardValue;
break;
}
case 26: /* Percussion */
{
if(item->BardValue > newbon->percussionMod)
newbon->percussionMod = item->BardValue;
break;
}
}
if (item->SkillModValue != 0 && item->SkillModType < HIGHEST_SKILL){
if (newbon->skillmod[item->SkillModType] < item->SkillModValue)
newbon->skillmod[item->SkillModType] = (sint8)item->SkillModValue;
}
int i;
for(i = 0; i < MAX_AUGMENT_SLOTS; i++) {
AddItemBonuses(inst->GetAugment(i),newbon,TRUE);
}
}
insert this where convienient in
int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item)
currently have it at the bottom; prevents illegally equipped weapons from doing damage
Code:
if(weapon_item){
if(weapon_item->GetItem() && GetLevel() < weapon_item->GetItem()->ReqLevel && weapon_item->IsEquipable(GetBaseRace(),GetClass()))
{
dmg = 0;
}
}
|
|
|
|
10-01-2007, 10:19 AM
|
Sarnak
|
|
Join Date: Sep 2005
Posts: 34
|
|
Disregard that last code block, noticed the logic was wrong, here is the correct code:
Code:
if(weapon_item){
if(weapon_item->GetItem() && ( GetLevel() < weapon_item->GetItem()->ReqLevel || !weapon_item->IsEquipable(GetBaseRace(),GetClass())))
{
dmg = 0;
}
}
|
10-02-2007, 08:36 AM
|
Discordant
|
|
Join Date: Aug 2006
Posts: 394
|
|
This looks very very good. I know that the server code can definitely use some more hardening against exploits of this type. That being said, I hope this makes it into the tree.
Thank you!
__________________
--
Keelyeh
Owner, ServerOp and Developer
Jest 4 Server
Linux (Jest3 runs on Fedora, our Dev servers usually run on Ubuntu and/or Gentoo), OC-12 Connection = Hella Fast
|
10-04-2007, 06:47 PM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
I'm guessing it will, I'll have some free time this weekend to look over this.
|
10-04-2007, 07:43 PM
|
Sarnak
|
|
Join Date: Sep 2005
Posts: 34
|
|
Just make sure to comment all my printf functions, they get pretty spammy in the console at times. Been running this on my test server for almost 2 weeks now, haven't had any crashes related to it. Sadly all my MacroQuest Players quit.... wonder why? ^^
|
10-05-2007, 02:00 AM
|
|
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
Quote:
Originally Posted by AiliaMorisato
Sadly all my MacroQuest Players quit.... wonder why? ^^
|
Oh that's just a shame...
|
10-05-2007, 03:33 PM
|
Discordant
|
|
Join Date: Aug 2006
Posts: 394
|
|
Quote:
Originally Posted by KLS
I'm guessing it will, I'll have some free time this weekend to look over this.
|
It's appreciated as always, KLS!
__________________
--
Keelyeh
Owner, ServerOp and Developer
Jest 4 Server
Linux (Jest3 runs on Fedora, our Dev servers usually run on Ubuntu and/or Gentoo), OC-12 Connection = Hella Fast
|
10-08-2007, 04:36 PM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
I got a little backed up but I still wanna get to this within a few days. Just fyi.
|
10-08-2007, 05:34 PM
|
Discordant
|
|
Join Date: Aug 2006
Posts: 394
|
|
Believe me, it's all good =)
Thank you!
__________________
--
Keelyeh
Owner, ServerOp and Developer
Jest 4 Server
Linux (Jest3 runs on Fedora, our Dev servers usually run on Ubuntu and/or Gentoo), OC-12 Connection = Hella Fast
|
10-11-2007, 01:34 PM
|
Discordant
|
|
Join Date: Aug 2006
Posts: 394
|
|
Just saw it hit CVS a bit ago!
Awesome!
__________________
--
Keelyeh
Owner, ServerOp and Developer
Jest 4 Server
Linux (Jest3 runs on Fedora, our Dev servers usually run on Ubuntu and/or Gentoo), OC-12 Connection = Hella Fast
|
10-11-2007, 03:11 PM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
mhm
Code:
race_ = (race_==17? 15 : race_);
is kinda hackish but we'll see what we can do with it.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 01:35 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|