PDA

View Full Version : Shield Block Working


takatok
06-10-2009, 01:15 PM
The following code was mostly written by trevius I just tracked down a small logic error that was making it not work. Tested on my server with and w/o a shield andis blocking 10% as intended.

In attack.cpp Line 561
REPLACE

/* Trying to add Shield Block AA, but this isn't working yet
if(damage > 0 && GetAA(aaShieldBlock) && (!other->BehindMob(this, other->GetX(), other->GetY()))) {
bool equiped = CastToClient()->m_inv.GetItem(14);
if(equiped) {
uint8 shield = CastToClient()->m_inv.GetItem(14)->GetItem()->ItemType;

if(shield == ItemTypeShield) {
switch(GetAA(aaShieldBlock)) {
case 1:
RollTable[1] = RollTable[0] + 2.50;
break;
case 2:
RollTable[1] = RollTable[0] + 5.00;
break;
case 3:
RollTable[1] = RollTable[0] + 10.00;
break;
}
}
}
}
*/
if (damage > 0 && CanThisClassBlock() && (!other->BehindMob(this, other->GetX(), other->GetY()) || bBlockFromRear)) {
skill = CastToClient()->GetSkill(BLOCKSKILL);
if (IsClient()) {
if (!other->IsClient() && GetLevelCon(other->GetLevel()) != CON_GREEN)
this->CastToClient()->CheckIncreaseSkill(BLOCKSKILL, -10);
}

if (!ghit) { //if they are not using a garunteed hit discipline
bonus = 2.0 + skill/35.0 + (GetDEX()/200);
RollTable[1] = RollTable[0] + bonus;
}
}
else{
RollTable[1] = RollTable[0];
}


WITH

if (damage > 0 && CanThisClassBlock() && (!other->BehindMob(this, other->GetX(), other->GetY()) || bBlockFromRear)) {
skill = CastToClient()->GetSkill(BLOCKSKILL);
if (IsClient()) {
if (!other->IsClient() && GetLevelCon(other->GetLevel()) != CON_GREEN)
this->CastToClient()->CheckIncreaseSkill(BLOCKSKILL, -10);
}

if (!ghit) { //if they are not using a garunteed hit discipline
bonus = 2.0 + skill/35.0 + (GetDEX()/200);
RollTable[1] = RollTable[0] + bonus;
}
}
else{
RollTable[1] = RollTable[0];
}


if(damage > 0 && GetAA(aaShieldBlock) && (!other->BehindMob(this, other->GetX(), other->GetY()))) {
bool equiped = CastToClient()->m_inv.GetItem(14);
if(equiped) {
uint8 shield = CastToClient()->m_inv.GetItem(14)->GetItem()->ItemType;

if(shield == ItemTypeShield) {
switch(GetAA(aaShieldBlock)) {
case 1:
RollTable[1] = RollTable[0] + 2.50;
break;
case 2:
RollTable[1] = RollTable[0] + 5.00;
break;
case 3:
RollTable[1] = RollTable[0] + 10.00;
break;
}
}
}
}


Basically just swaps twi blocks of code to avoid shield block % from being overwritten.

Whats the policy for items AAs and the SQL to enable them. Since this is a database specific thing to enable the shield block, is that something you just want individual DBs to handle? And just have the code read in the server for when they want to enable it.

Tony

cavedude
06-19-2009, 05:21 PM
Normally, any SQL changes you want to post with the code. At which point it'll be up to the server op whether they want to use it or not :)

trevius
06-22-2009, 05:59 AM
This has now been added to Revision 702 on the SVN and SQL is included.