L2JMobius

Public Development => General Discussion => Topic started by: klz on March 01, 2025, 03:28:18 AM

Title: Surrenders and Resistances
Post by: klz on March 01, 2025, 03:28:18 AM
Hello guys, I have a question for you. Is there any configuration file to enable the surrender/resistance system according to the element?

Thank you very much in advance!
Title: Re: Surrenders and Resistances
Post by: klz on March 04, 2025, 06:40:49 PM
Ok, didn't find anything related so i'm sharing here how i'm starting to implement this. This is way too early beta as I'm hard-coding all the values just to  check if based on resistances, damage gets modified.

Sorry for the code style, i'm a noob to programming and particularly noob to Java.

Hope this helps someone :)

Code: [Select]
public static double calcAttributeBonus(Creature attacker, Creature target, Skill skill)
{
int attackAttribute;
if (skill != null)
{
// if ((skill.getElement() == -1) || (attacker.getAttackElement() != skill.getElement()))
if ((skill.getElement() == -1))
{
return 0;
}
attackAttribute = attacker.getAttackElementValue(attacker.getAttackElement()) + skill.getElementPower();
}
else
{
attackAttribute = attacker.getAttackElementValue(attacker.getAttackElement());
if (attackAttribute == 0)
{
return 0;
}
}

double result = 0;

if (skill != null)
{
if (skill.getElement() != -1)
{
// debuffs
final boolean isAffectedBySurrenderToWater = target.isAffectedBySkill(1071);
final boolean isAffectedBySurrenderToFire = target.isAffectedBySkill(1083);
final boolean isAffectedBySurrenderToWind = target.isAffectedBySkill(1074);
final boolean isAffectedByIceVortex = target.isAffectedBySkill(1340);
final boolean isAffectedByLightVortex = target.isAffectedBySkill(1342);
final boolean isAffectedByFireVortex = target.isAffectedBySkill(1339);
final boolean isAffectedByWindVortex = target.isAffectedBySkill(1341);
final boolean isAffectedByDarkVortex = target.isAffectedBySkill(1343);

// resistances
final boolean hasResistAqua = target.isAffectedBySkill(1182);
final boolean hasResistFire = target.isAffectedBySkill(1191);
final boolean hasResistWind = target.isAffectedBySkill(1189);
final boolean hasAquaGuard = target.isAffectedBySkill(307);
final boolean hasFlameGuard = target.isAffectedBySkill(306);
final boolean hasStormGuard = target.isAffectedBySkill(308);
final boolean hasInvocation = target.isAffectedBySkill(270);
final boolean hasElementalProtection = target.isAffectedBySkill(1352);
final boolean hasHolyResistance = target.isAffectedBySkill(1392);
final boolean hasUnholyResistance = target.isAffectedBySkill(1393);
final boolean hasDivineProtection = target.isAffectedBySkill(1353);

final int FIRE = 0;
final int WATER = 1;
final int WIND = 2;
final int HOLY = 4;
final int DARK = 5;

if (isAffectedByIceVortex && (skill.getElement() == WATER))
{
result += 350;
}

if (isAffectedBySurrenderToWater && (skill.getElement() == WATER))
{
result += 350;
}

if (isAffectedBySurrenderToFire && (skill.getElement() == FIRE))
{
result += 350;
}

if (isAffectedBySurrenderToWind && (skill.getElement() == WIND))
{
result += 350;
}

if (isAffectedByLightVortex && (skill.getElement() == HOLY))
{
result += 700;
}

if (isAffectedByFireVortex && (skill.getElement() == FIRE))
{
result += 350;
}

if (isAffectedByWindVortex && (skill.getElement() == WIND))
{
result += 350;
}

if (isAffectedByDarkVortex && (skill.getElement() == DARK))
{
result += 350;
}

// water

if (hasResistAqua && (skill.getElement() == WATER))
{
result -= 50;
}

if (hasAquaGuard && (skill.getElement() == WATER))
{
result -= 150;
}

// fire

if (hasResistFire && (skill.getElement() == FIRE))
{
result -= 50;
}

if (hasFlameGuard && (skill.getElement() == FIRE))
{
result -= 150;
}

// wind
if (hasResistWind && (skill.getElement() == WIND))
{
result -= 150;
}

if (hasStormGuard && (skill.getElement() == WIND))
{
result -= 150;
}

// all elements

if (hasElementalProtection && ((skill.getElement() == WATER) || (skill.getElement() == FIRE) || (skill.getElement() == WIND)))
{
result -= 150;
}

// holy
if (hasHolyResistance && (skill.getElement() == HOLY))
{
result -= 150;
}

// dark
if (hasUnholyResistance && (skill.getElement() == DARK))
{
result -= 150;
}

if (hasInvocation && (skill.getElement() == DARK))
{
result -= 150;
}

// holy & dark
if (hasDivineProtection && ((skill.getElement() == DARK) || (skill.getElement() == HOLY)))
{
result -= 100;
}
}
}

return result;
}