Converted back to gradle maybe or something, cleared out old in progress code from item bonuses, giving up on unique skill bonuses, will likely just use skillid to check if its like religion or fighting and not bonus those

This commit is contained in:
mstoppelli
2018-12-07 00:49:46 -05:00
parent 5b9fa72644
commit 41a5b19c79
16 changed files with 104 additions and 54 deletions

2
.idea/compiler.xml generated
View File

@@ -3,6 +3,8 @@
<component name="CompilerConfiguration">
<bytecodeTargetLevel>
<module name="WyvernMods_main" target="1.8" />
<module name="wyvernmods_main" target="1.8" />
<module name="wyvernmods_test" target="1.8" />
<module name="WyvernMods_test" target="1.8" />
</bytecodeTargetLevel>
</component>

View File

@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="Gradle: com.github.Sindusk:sindusklibrary:v1.0">
<CLASSES>
<root url="jar://$USER_HOME$/wurm_modding/mods/SinduskLibrary/SinduskLibrary.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="Gradle: org.gotti.wurmunlimited:common:2613165">
<CLASSES>
<root url="jar://$USER_HOME$/wurm_modding/common.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="Gradle: org.gotti.wurmunlimited:server:2613165">
<CLASSES>
<root url="jar://$USER_HOME$/wurm_modding/server.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="Gradle: org.gotti.wurmunlimited:server-modlauncher:0.33-beta1">
<CLASSES>
<root url="jar://$USER_HOME$/wurm_modding/modlauncher.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -1,9 +1,11 @@
<component name="libraryTable">
<library name="Gradle: org.javassist:javassist:3.20.0-GA">
<CLASSES>
<root url="jar://$USER_HOME$/wurm_modding/javassist.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.javassist/javassist/3.20.0-GA/a9cbcdfb7e9f86fbc74d3afae65f2248bfbf82a0/javassist-3.20.0-GA.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.javassist/javassist/3.20.0-GA/d8fdc08a455bc0b28bc0bed1f0d032d935cee8e1/javassist-3.20.0-GA-sources.jar!/" />
</SOURCES>
</library>
</component>

7
.idea/modules.xml generated
View File

@@ -3,8 +3,11 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/WyvernMods.iml" filepath="$PROJECT_DIR$/WyvernMods.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/WyvernMods_main.iml" filepath="$PROJECT_DIR$/.idea/modules/WyvernMods_main.iml" group="WyvernMods" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/WyvernMods_test.iml" filepath="$PROJECT_DIR$/.idea/modules/WyvernMods_test.iml" group="WyvernMods" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/WyvernMods_main.iml" filepath="$PROJECT_DIR$/.idea/modules/WyvernMods_main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/WyvernMods_test.iml" filepath="$PROJECT_DIR$/.idea/modules/WyvernMods_test.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/wyvernmods.iml" filepath="$PROJECT_DIR$/.idea/modules/wyvernmods.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/wyvernmods_main.iml" filepath="$PROJECT_DIR$/.idea/modules/wyvernmods_main.iml" group="wyvernmods" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/wyvernmods_test.iml" filepath="$PROJECT_DIR$/.idea/modules/wyvernmods_test.iml" group="wyvernmods" />
</modules>
</component>
</project>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="WyvernMods:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="mod.sin" external.system.module.type="sourceSet" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<module external.system.module.type="sourceSet" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/../../out/production/classes" />
<exclude-output />

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="WyvernMods:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="mod.sin" external.system.module.type="sourceSet" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<module external.system.module.type="sourceSet" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output-test url="file://$MODULE_DIR$/../../out/test/classes" />
<exclude-output />

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="WyvernMods" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="mod.sin" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">

View File

@@ -28,7 +28,6 @@ public class AddSubGroupAction implements ModAction {
public AddSubGroupAction() {
logger.log(Level.WARNING, "AddSubGroupAction()");
actionId = (short) ModActions.getNextActionId();
actionEntry = ActionEntry.createEntry(
actionId,

View File

@@ -37,7 +37,7 @@ public class WoodEssenceAction implements ModAction, BehaviourProvider, ActionPe
actionId,
"Imbue",
"imbuing",
new int[] { 6 }
new int[0]
//new int[] { 6 /* ACTION_TYPE_NOMOVE */ } // 6 /* ACTION_TYPE_NOMOVE */, 48 /* ACTION_TYPE_ENEMY_ALWAYS */, 36 /* ACTION_TYPE_ALWAYS_USE_ACTIVE_ITEM */
);
ModActions.registerAction(actionEntry);
@@ -75,11 +75,12 @@ public class WoodEssenceAction implements ModAction, BehaviourProvider, ActionPe
act.setTimeLeft(time);
performer.sendActionControl("Infusing", true, act.getTimeLeft());
}
else if(counter * 10 > performer.getCurrentAction().getTimeLeft()) {
else if(counter * 10.0f > performer.getCurrentAction().getTimeLeft()) {
performer.getCommunicator().sendNormalServerMessage("You finish imbuing " + target.getName() + " with the properties of another tree. It's damaged in the process.");
target.setMaterial(source.getMaterial());
target.sendUpdate();
Items.destroyItem(source.getWurmId());
source.setDamage(20f);
target.setDamage(20f);
return true;
}
return false;
@@ -93,6 +94,6 @@ public class WoodEssenceAction implements ModAction, BehaviourProvider, ActionPe
@Override
public short getActionId() {
return 0;
return actionId;
}
}

View File

@@ -21,7 +21,8 @@ public class WoodEssence implements ItemTypes, MiscConstants {
ItemTypes.ITEM_TYPE_FULLPRICE,
ItemTypes.ITEM_TYPE_NOSELLBACK,
ItemTypes.ITEM_TYPE_ALWAYS_BANKABLE,
ItemTypes.ITEM_TYPE_WOOD
ItemTypes.ITEM_TYPE_WOOD,
ItemTypes.ITEM_TYPE_NAMED
});
itemBuilder.imageNumber((short) 859);
itemBuilder.behaviourType((short) 1);
@@ -31,8 +32,8 @@ public class WoodEssence implements ItemTypes, MiscConstants {
itemBuilder.primarySkill((int) NOID);
itemBuilder.bodySpaces(MiscConstants.EMPTY_BYTE_PRIMITIVE_ARRAY);
itemBuilder.modelName("model.valrei.");
itemBuilder.difficulty(300.0f);
itemBuilder.weightGrams(4500);
itemBuilder.difficulty(80.0f);
itemBuilder.weightGrams(1);
itemBuilder.material(Materials.MATERIAL_WOOD_BIRCH);
itemBuilder.value(1);
itemBuilder.isTraded(true);
@@ -45,7 +46,9 @@ public class WoodEssence implements ItemTypes, MiscConstants {
public void initCreationEntry() {
logger.info("initCreationEntry()");
if(templateId > 0) {
CreationEntryCreator.createSimpleEntry(SkillList.ALCHEMY_NATURAL, ItemList.sourceSalt, ItemList.log, templateId, true, true, 0.0f, true, false, CreationCategories.RESOURCES);
CreationEntryCreator.createAdvancedEntry(SkillList.ALCHEMY_NATURAL, ItemList.sourceSalt, ItemList.log, templateId, true,
true, 0.0f, true, false, CreationCategories.RESOURCES);
//CreationEntryCreator.createSimpleEntry(SkillList.ALCHEMY_NATURAL, ItemList.sourceSalt, ItemList.log, templateId, true, true, 0.0f, false, false, CreationCategories.RESOURCES);
}
else{
logger.info("woodEssence does not have a template ID on creation entry.");

View File

@@ -1,17 +1,24 @@
package mod.sin.wyvern.bonusoverhaul;
import com.wurmonline.server.creatures.Creature;
import com.wurmonline.server.creatures.SpellEffectsEnum;
import com.wurmonline.server.items.*;
import com.wurmonline.server.players.ItemBonus;
import com.wurmonline.server.skills.NoSuchSkillException;
import com.wurmonline.server.skills.Skill;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.NotFoundException;
import javassist.bytecode.Descriptor;
import mod.sin.armour.GlimmerscaleVest;
import mod.sin.lib.Util;
import mod.sin.wyvern.MiscChanges;
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
import org.gotti.wurmunlimited.modloader.classhooks.HookException;
import org.gotti.wurmunlimited.modloader.classhooks.HookManager;
import org.gotti.wurmunlimited.modloader.interfaces.PreInitable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
@@ -19,6 +26,7 @@ import java.util.logging.Logger;
public class ItemBonusOverhaul {
private static List<ItemBonusWrapper> itemBonuses = new ArrayList<>();
private static Logger logger = Logger.getLogger(ItemBonusOverhaul.class.getName());
private static final float SKILLGAIN_BONUS_SCALE = .01f;
/**
* Called to add all itemBonusWrapper objects to the itemBonuses list to be called upon later.
@@ -75,6 +83,40 @@ public class ItemBonusOverhaul {
return null;
}
public static float getNewSkillBonus(Creature creature, int skillid) {
try {
ItemBonusWrapper wrapper;
CtClass[] params1 = {
CtClass.longType,
CtClass.intType
};
String desc = Descriptor.ofMethod(CtClass.floatType, params1);
float bonus = ReflectionUtil.callPrivateMethod(ItemBonus.class, ReflectionUtil.getMethod(ItemBonus.class, "getBonus"), creature.getWurmId(), SpellEffectsEnum.ITEM_RING_SKILLGAIN.getTypeId());
for(Item item:creature.getBody().getContainersAndWornItems()) {
wrapper = matchTemplateidToWrapper(item.getTemplateId());
if(wrapper != null) {
if(!checkItemBonusForSkill(wrapper, skillid) && wrapper.getEffect() == SpellEffectsEnum.ITEM_RING_SKILLGAIN) {
bonus -= wrapper.getValue() * item.getCurrentQualityLevel() * .01f;
}
}
}
return bonus;
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
return 0.0f;
}
}
public static boolean checkItemBonusForSkill(ItemBonusWrapper wrapper, int skillid) {
if(wrapper.getEffect() != SpellEffectsEnum.ITEM_RING_SKILLGAIN) {
return false;
}
if(wrapper.isSkillRestricted() && wrapper.getRestrictedSkill() == skillid) {
return true;
}
return !wrapper.isSkillRestricted();
}
public static void preInit() {
try {
ClassPool classPool = HookManager.getInstance().getClassPool();
@@ -95,6 +137,10 @@ public class ItemBonusOverhaul {
replace = "{ return " + ItemBonusOverhaul.class.getName() + ".getNewTimed($1); }";
Util.setBodyDeclared(thisClass, itemBonus, "isTimed", replace);
Util.setReason("Overwrite default check for bonus skillgain");
replace = "{ return " + ItemBonusOverhaul.class.getName() + ".getNewSkillBonus($1, $2); }";
Util.setBodyDeclared(thisClass, itemBonus, "getSkillGainBonus", replace);
Util.setReason("Overwrite default item spell effect lookup with one checking the custom list.");
replace = "{ return " + ItemBonusOverhaul.class.getName() + ".getNewEffectForTemplateId($1, $2); }";
Util.setBodyDeclared(thisClass, ctSpellEffectsEnum, "getEnumForItemTemplateId", replace);

View File

@@ -1,6 +1,7 @@
package mod.sin.wyvern.bonusoverhaul;
import com.wurmonline.server.creatures.SpellEffectsEnum;
import com.wurmonline.server.skills.Skill;
public class ItemBonusWrapper {
private int templateid;
@@ -8,6 +9,8 @@ public class ItemBonusWrapper {
private boolean stackable;
private float value;
private boolean timed;
private boolean skillRestricted;
private int restrictedSkill;
public ItemBonusWrapper(int templateid, SpellEffectsEnum effect, boolean stackable, float value, boolean timed) {
this.templateid = templateid;
@@ -15,6 +18,17 @@ public class ItemBonusWrapper {
this.stackable = stackable;
this.value = value;
this.timed = timed;
this.skillRestricted = false;
}
public ItemBonusWrapper(int templateid, SpellEffectsEnum effect, boolean stackable, float value, boolean timed, boolean skillRestricted, int restrictedSkill) {
this.templateid = templateid;
this.effect = effect;
this.stackable = stackable;
this.value = value;
this.timed = timed;
this.skillRestricted = skillRestricted;
this.restrictedSkill = restrictedSkill;
}
public int getTemplateid() {
@@ -56,4 +70,20 @@ public class ItemBonusWrapper {
public void setTimed(boolean timed) {
this.timed = timed;
}
public boolean isSkillRestricted() {
return skillRestricted;
}
public void setSkillRestricted(boolean skillRestricted) {
this.skillRestricted = skillRestricted;
}
public int getRestrictedSkill() {
return restrictedSkill;
}
public void setRestrictedSkill(int restrictedSkill) {
this.restrictedSkill = restrictedSkill;
}
}

View File

@@ -119,8 +119,8 @@ public class PlayerBounty {
try {
double fightskill = player.getFightingSkill().getKnowledge();
int quality = random.nextInt((int)fightskill);
Item crystal = ItemFactory.createItem(TreasureBox.templateId, quality, (random.nextInt((int)fightskill) < 20 ? (byte)0:(byte)1), "");
player.getInventory().insertItem(crystal);
Item treasure = ItemFactory.createItem(TreasureBox.templateId, quality, "");
player.getInventory().insertItem(treasure);
player.getCommunicator().sendNormalServerMessage("You find something in your inventory!");
} catch (FailedException | NoSuchTemplateException e) {
e.printStackTrace();