Browse Source

fix for rune application

lakebane-new
FatBoy-DOTC 4 months ago
parent
commit
78118a1ac1
  1. 171
      src/engine/net/client/msg/ApplyRuneMsg.java

171
src/engine/net/client/msg/ApplyRuneMsg.java

@ -10,6 +10,7 @@
package engine.net.client.msg; package engine.net.client.msg;
import engine.Enum; import engine.Enum;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.net.*; import engine.net.*;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
@ -70,55 +71,86 @@ public class ApplyRuneMsg extends ClientNetMsg {
} }
public static boolean applyRune(int runeID, ClientConnection origin, PlayerCharacter playerCharacter) { public static boolean applyRune(int runeID, ClientConnection origin, PlayerCharacter playerCharacter) {
RuneBase rb = RuneBase.getRuneBase(runeID); RuneBase rb = RuneBase.getRuneBase(runeID);
Dispatch dispatch; Dispatch dispatch;
if (playerCharacter == null || origin == null || rb == null) { if (playerCharacter == null || origin == null || rb == null) {
return false; return false;
} }
int raceID = playerCharacter.getRaceID();
boolean valid;
//Check race is met //Check race is met
if (rb.getRace() != null && rb.getRace().size() > 0) { ConcurrentHashMap<Integer, Boolean> races = rb.getRace();
int raceID = playerCharacter.getRaceID(); if(runeID != 3007 && runeID != 3014) {//bounty hunter and huntsman
valid = !rb.getRace().containsKey(raceID); if (races.size() > 0) {
if (rb.getRace().containsKey(raceID)) boolean valid = false;
valid = rb.getRace().get(raceID); for (int validID : races.keySet()) {
} else{ if (validID == raceID) {
valid = true; valid = true;
} break;
}
if (!valid) }
return false; if(runeID == 3040)
valid = true;
//Check base class is met if(runeID == 2514 && raceID == 1999)
if (rb.getBaseClass() != null && rb.getBaseClass().size() > 0) { valid = true;
int baseID = playerCharacter.getBaseClassID(); if(runeID == 3036 && raceID == 1999)
valid = !rb.getBaseClass().containsKey(baseID); valid = true;
if (rb.getBaseClass().containsKey(baseID)) if(runeID == 3033 && raceID == 1999)
valid = rb.getRace().get(baseID); valid = true;
} else{ if (!valid) {
valid = true; return false;
} }
}
if (!valid) //Check base class is met
return false; ConcurrentHashMap<Integer, Boolean> baseClasses = rb.getBaseClass();
if (baseClasses.size() > 0) {
//Check promotion class is met int baseClassID = playerCharacter.getBaseClassID();
if (rb.getPromotionClass() != null && rb.getPromotionClass().size() > 0) { boolean valid = false;
int promotionClassID = playerCharacter.getPromotionClassID(); for (int validID : baseClasses.keySet()) {
valid = !rb.getPromotionClass().containsKey(promotionClassID); if (validID == baseClassID) {
if (rb.getPromotionClass().containsKey(promotionClassID)) valid = true;
valid = rb.getPromotionClass().get(promotionClassID); break;
}
}
if(runeID == 3040)
valid = true;
if(runeID == 3036 && raceID == 1999)
valid = true;
if(runeID == 3033 && raceID == 1999)
valid = true;
if(runeID == 3035 && baseClassID == 2501)
valid = true;
if (!valid) {
return false;
}
}
//Check promotion class is met
ConcurrentHashMap<Integer, Boolean> promotionClasses = rb.getPromotionClass();
if (promotionClasses.size() > 0) {
int promotionClassID = playerCharacter.getPromotionClassID();
boolean valid = false;
for (int validID : promotionClasses.keySet()) {
if (validID == promotionClassID) {
valid = true;
break;
}
}
if(runeID == 3040)
valid = true;
if(runeID == 3004 && (playerCharacter.getPromotionClassID() == 2505 || playerCharacter.getPromotionClassID() == 2510))
valid = true;
if(runeID == 3036 && raceID == 1999)
valid = true;
if(runeID == 3033 && raceID == 1999)
valid = true;
if (!valid) {
return false;
}
}
} else{ } else{
valid = true; if(playerCharacter.getPromotionClassID() == 2519){//priest
return false;
}
} }
if (!valid)
return false;
//Check disciplines are met //Check disciplines are met
ArrayList<CharacterRune> runes = playerCharacter.getRunes(); ArrayList<CharacterRune> runes = playerCharacter.getRunes();
ConcurrentHashMap<Integer, Boolean> disciplines = rb.getDiscipline(); ConcurrentHashMap<Integer, Boolean> disciplines = rb.getDiscipline();
@ -132,7 +164,6 @@ public class ApplyRuneMsg extends ClientNetMsg {
} }
} }
} }
int discCount = 0; int discCount = 0;
for (CharacterRune cr : runes) { for (CharacterRune cr : runes) {
int runeBaseID = cr.getRuneBaseID(); int runeBaseID = cr.getRuneBaseID();
@ -145,28 +176,32 @@ public class ApplyRuneMsg extends ClientNetMsg {
return false; return false;
} }
} }
//Check level is met //Check level is met
if (playerCharacter.getLevel() < rb.getLevelRequired()) { if (playerCharacter.getLevel() < rb.getLevelRequired()) {
return false; return false;
} }
int strTotal = 0; int strTotal = 0;
int dexTotal = 0; int dexTotal = 0;
int conTotal = 0; int conTotal = 0;
int intTotal = 0; int intTotal = 0;
int spiTotal = 0; int spiTotal = 0;
int cost = 0; int cost = 0;
//Check any attributes are met //Check any attributes are met
ArrayList<RuneBaseAttribute> attrs = rb.getAttrs(); ArrayList<RuneBaseAttribute> attrs = rb.getAttrs();
if (rb.getAttrs() != null) if (rb.getAttrs() != null)
for (RuneBaseAttribute rba : attrs) { for (RuneBaseAttribute rba : attrs) {
int attrID = rba.getAttributeID(); int attrID = rba.getAttributeID();
int mod = rba.getModValue(); int mod = rba.getModValue();
switch (attrID) { switch (attrID) {
case MBServerStatics.RUNE_COST_ATTRIBUTE_ID: case MBServerStatics.RUNE_COST_ATTRIBUTE_ID:
switch (rb.getName()) {
case "Born of the Ethyri":
case "Born of the Taripontor":
case "Born of the Gwendannen":
case "Born of the Invorri":
case "Born of the Irydnu":
mod = 0;
}
if (mod > playerCharacter.getUnusedStatPoints()) { if (mod > playerCharacter.getUnusedStatPoints()) {
return false; return false;
} }
@ -219,14 +254,33 @@ public class ApplyRuneMsg extends ClientNetMsg {
break; break;
} }
} }
//Check if max number runes already reached //Check if max number runes already reached
if (runes.size() > 12) { if (runes.size() > 12) {
return false; return false;
} }
switch (rb.getName()) {
case "Born of the Ethyri":
case "Born of the Taripontor":
case "Born of the Gwendannen":
case "Born of the Invorri":
case "Born of the Irydnu":
for (CharacterRune charRune : playerCharacter.getRunes()) {
RuneBase rb2 = charRune.getRuneBase();
switch (rb2.getName()) {
case "Born of the Ethyri":
case "Born of the Taripontor":
case "Born of the Gwendannen":
case "Born of the Invorri":
case "Born of the Irydnu":
ChatManager.chatSystemError(playerCharacter, "You Have Already Applied A Blood Rune");
return false;
}
}
}
//if discipline, check number applied //if discipline, check number applied
if (isDiscipline(runeID)) { if (isDiscipline(runeID)) {
//if(playerCharacter.getLevel() == 80)
discCount -= 1; // level 80 characters get an extra disc rune
if (playerCharacter.getLevel() < 70) { if (playerCharacter.getLevel() < 70) {
if (discCount > 2) { if (discCount > 2) {
return false; return false;
@ -237,7 +291,6 @@ public class ApplyRuneMsg extends ClientNetMsg {
} }
} }
} }
//Everything succeeded. Let's apply the rune //Everything succeeded. Let's apply the rune
//Attempt add rune to database //Attempt add rune to database
CharacterRune runeWithoutID = new CharacterRune(rb, playerCharacter.getObjectUUID()); CharacterRune runeWithoutID = new CharacterRune(rb, playerCharacter.getObjectUUID());
@ -251,7 +304,6 @@ public class ApplyRuneMsg extends ClientNetMsg {
if (cr == null) { if (cr == null) {
return false; return false;
} }
//remove any overridden runes from player //remove any overridden runes from player
ArrayList<Integer> overwrite = rb.getOverwrite(); ArrayList<Integer> overwrite = rb.getOverwrite();
CharacterRune toRemove = null; CharacterRune toRemove = null;
@ -260,13 +312,10 @@ public class ApplyRuneMsg extends ClientNetMsg {
toRemove = playerCharacter.removeRune(overwriteID); toRemove = playerCharacter.removeRune(overwriteID);
} }
} }
//add rune to player //add rune to player
playerCharacter.addRune(cr); playerCharacter.addRune(cr);
// recalculate all bonuses/formulas/skills/powers // recalculate all bonuses/formulas/skills/powers
playerCharacter.recalculate(); playerCharacter.recalculate();
//if overwriting a stat rune, add any amount granted from previous rune. //if overwriting a stat rune, add any amount granted from previous rune.
if (toRemove != null) { if (toRemove != null) {
RuneBase rbs = toRemove.getRuneBase(); RuneBase rbs = toRemove.getRuneBase();
@ -292,30 +341,32 @@ public class ApplyRuneMsg extends ClientNetMsg {
if (dif > 0 && spiTotal < (int) playerCharacter.statSpiMax) { if (dif > 0 && spiTotal < (int) playerCharacter.statSpiMax) {
playerCharacter.addSpi(dif); playerCharacter.addSpi(dif);
} }
// recalculate all bonuses/formulas/skills/powers // recalculate all bonuses/formulas/skills/powers
playerCharacter.recalculate(); playerCharacter.recalculate();
} }
} }
switch (rb.getName()) {
case "Born of the Ethyri":
case "Born of the Taripontor":
case "Born of the Gwendannen":
case "Born of the Invorri":
case "Born of the Irydnu":
cost = 0;
break;
}
if (cost > 0) { if (cost > 0) {
ModifyStatMsg msm = new ModifyStatMsg((0 - cost), 0, 3); ModifyStatMsg msm = new ModifyStatMsg((0 - cost), 0, 3);
dispatch = Dispatch.borrow(playerCharacter, msm); dispatch = Dispatch.borrow(playerCharacter, msm);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
} }
//send apply rune message to client //send apply rune message to client
ApplyRuneMsg arm = new ApplyRuneMsg(playerCharacter.getObjectType().ordinal(), playerCharacter.getObjectUUID(), runeID, cr.getObjectType().ordinal(), cr.getObjectUUID(), false); ApplyRuneMsg arm = new ApplyRuneMsg(playerCharacter.getObjectType().ordinal(), playerCharacter.getObjectUUID(), runeID, cr.getObjectType().ordinal(), cr.getObjectUUID(), false);
dispatch = Dispatch.borrow(playerCharacter, arm); dispatch = Dispatch.borrow(playerCharacter, arm);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
//alert them of success //alert them of success
ErrorPopupMsg.sendErrorPopup(playerCharacter, 160); ErrorPopupMsg.sendErrorPopup(playerCharacter, 160);
//reapply bonuses //reapply bonuses
playerCharacter.applyBonuses(); playerCharacter.applyBonuses();
return true; return true;
} }

Loading…
Cancel
Save