Latest Updates.
This commit is contained in:
118
src/main/java/mod/sin/actions/CreatureReportAction.java
Normal file
118
src/main/java/mod/sin/actions/CreatureReportAction.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package mod.sin.actions;
|
||||
|
||||
import com.wurmonline.server.behaviours.Action;
|
||||
import com.wurmonline.server.behaviours.ActionEntry;
|
||||
import com.wurmonline.server.creatures.*;
|
||||
import com.wurmonline.server.items.Item;
|
||||
import com.wurmonline.server.items.ItemList;
|
||||
import com.wurmonline.server.players.Player;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ActionPerformer;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.BehaviourProvider;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModAction;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModActions;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CreatureReportAction implements ModAction {
|
||||
private static Logger logger = Logger.getLogger(CreatureReportAction.class.getName());
|
||||
|
||||
private final short actionId;
|
||||
private final ActionEntry actionEntry;
|
||||
|
||||
public CreatureReportAction() {
|
||||
logger.log(Level.WARNING, "CreatureReportAction()");
|
||||
|
||||
actionId = (short) ModActions.getNextActionId();
|
||||
actionEntry = ActionEntry.createEntry(
|
||||
actionId,
|
||||
"Creature Report",
|
||||
"reporting",
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BehaviourProvider getBehaviourProvider()
|
||||
{
|
||||
return new BehaviourProvider() {
|
||||
// Menu with activated object
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, Item source, Item object)
|
||||
{
|
||||
return this.getBehavioursFor(performer, object);
|
||||
}
|
||||
|
||||
// Menu without activated object
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, Item object)
|
||||
{
|
||||
if(performer instanceof Player && object != null && (object.getTemplateId() == ItemList.bodyBody || object.getTemplateId() == ItemList.bodyHand) && performer.getPower() >= 5) {
|
||||
return Collections.singletonList(actionEntry);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
private static void creatureReport(Communicator comm) {
|
||||
HashMap<CreatureTemplate, Integer> counts = new HashMap<>();
|
||||
Arrays.stream(CreatureTemplateFactory.getInstance().getTemplates()).forEach(ct -> counts.put(ct, 0));
|
||||
Arrays.stream(Creatures.getInstance().getCreatures()).forEach(cr -> counts.put(cr.getTemplate(), counts.get(cr.getTemplate()) + 1));
|
||||
Map<Boolean, List<Map.Entry<CreatureTemplate, Integer>>> tmp = counts.entrySet().stream().collect(Collectors.partitioningBy(e -> e.getKey().isMonster() || e.getKey().isAggHuman()));
|
||||
List<Map.Entry<CreatureTemplate, Integer>> aggro = tmp.get(true);
|
||||
List<Map.Entry<CreatureTemplate, Integer>> passive = tmp.get(false);
|
||||
aggro.sort((o1, o2) -> -Integer.compare(o1.getValue(), o2.getValue()));
|
||||
passive.sort((o1, o2) -> -Integer.compare(o1.getValue(), o2.getValue()));
|
||||
int aggroTotal = aggro.stream().mapToInt(Map.Entry::getValue).sum();
|
||||
int passiveTotal = passive.stream().mapToInt(Map.Entry::getValue).sum();
|
||||
int sum = aggroTotal + passiveTotal;
|
||||
comm.sendSystemMessage(String.format("Passive: %d (%.1f) Aggro: %d (%.1f) Total: %d", passiveTotal, 100.0 * passiveTotal / sum, aggroTotal, 100.0 * aggroTotal / sum, sum));
|
||||
comm.sendSystemMessage("== Aggressive ==");
|
||||
aggro.forEach(e -> comm.sendSystemMessage(String.format("%s: %d (%.1f)", e.getKey().getName(), e.getValue(), 100.0 * e.getValue() / aggroTotal)));
|
||||
comm.sendSystemMessage("== Passive ==");
|
||||
passive.forEach(e -> comm.sendSystemMessage(String.format("%s: %d (%.1f)", e.getKey().getName(), e.getValue(), 100.0 * e.getValue() / passiveTotal)));
|
||||
comm.sendSystemMessage("=============");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionPerformer getActionPerformer()
|
||||
{
|
||||
return new ActionPerformer() {
|
||||
|
||||
@Override
|
||||
public short getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
// Without activated object
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Item target, short action, float counter)
|
||||
{
|
||||
if(performer instanceof Player){
|
||||
if(performer.getPower() < 5){
|
||||
performer.getCommunicator().sendNormalServerMessage("You do not have permission to do that.");
|
||||
return true;
|
||||
}
|
||||
creatureReport(performer.getCommunicator());
|
||||
}else{
|
||||
logger.info("Somehow a non-player activated an Affinity Orb...");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Item source, Item target, short action, float counter)
|
||||
{
|
||||
return this.action(act, performer, target, action, counter);
|
||||
}
|
||||
|
||||
|
||||
}; // ActionPerformer
|
||||
}
|
||||
}
|
||||
323
src/main/java/mod/sin/actions/SmoothTerrainAction.java
Normal file
323
src/main/java/mod/sin/actions/SmoothTerrainAction.java
Normal file
@@ -0,0 +1,323 @@
|
||||
package mod.sin.actions;
|
||||
|
||||
import com.wurmonline.mesh.MeshIO;
|
||||
import com.wurmonline.mesh.Tiles;
|
||||
import com.wurmonline.server.Constants;
|
||||
import com.wurmonline.server.Players;
|
||||
import com.wurmonline.server.Server;
|
||||
import com.wurmonline.server.Servers;
|
||||
import com.wurmonline.server.behaviours.Action;
|
||||
import com.wurmonline.server.behaviours.ActionEntry;
|
||||
import com.wurmonline.server.behaviours.Actions;
|
||||
import com.wurmonline.server.behaviours.Terraforming;
|
||||
import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.items.Item;
|
||||
import com.wurmonline.server.players.Player;
|
||||
import com.wurmonline.server.structures.Structure;
|
||||
import com.wurmonline.server.structures.Structures;
|
||||
import com.wurmonline.server.villages.Village;
|
||||
import com.wurmonline.server.villages.Villages;
|
||||
import com.wurmonline.server.zones.NoSuchZoneException;
|
||||
import com.wurmonline.server.zones.Zone;
|
||||
import com.wurmonline.server.zones.Zones;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ActionPerformer;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.BehaviourProvider;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModAction;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModActions;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class SmoothTerrainAction implements ModAction {
|
||||
private static Logger logger = Logger.getLogger(SmoothTerrainAction.class.getName());
|
||||
|
||||
private final short actionId;
|
||||
private final ActionEntry actionEntry;
|
||||
|
||||
public SmoothTerrainAction() {
|
||||
logger.log(Level.WARNING, "SmoothTerrainAction()");
|
||||
|
||||
actionId = (short) ModActions.getNextActionId();
|
||||
actionEntry = ActionEntry.createEntry(
|
||||
actionId,
|
||||
"Smooth Terrain",
|
||||
"smoothing",
|
||||
new int[] {
|
||||
Actions.ACTION_TYPE_QUICK,
|
||||
Actions.ACTION_TYPE_IGNORERANGE
|
||||
}
|
||||
//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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BehaviourProvider getBehaviourProvider()
|
||||
{
|
||||
return new BehaviourProvider() {
|
||||
// Menu with activated object
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, Item source, int tilex, int tiley, boolean onSurface, boolean corner, int tile, int heightOffset) {
|
||||
return this.getBehavioursFor(performer, tilex, tiley, onSurface, corner, tile, heightOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, int tilex, int tiley, boolean onSurface, boolean corner, int tile, int heightOffset) {
|
||||
if(performer instanceof Player && performer.getPower() >= 5){
|
||||
return Collections.singletonList(actionEntry);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static boolean isValidSmoothTile(byte type){
|
||||
return Tiles.isTree(type) || Tiles.isBush(type) || type == Tiles.Tile.TILE_SAND.id || type == Tiles.Tile.TILE_GRASS.id || type == Tiles.Tile.TILE_TUNDRA.id || type == Tiles.Tile.TILE_STEPPE.id || type == Tiles.Tile.TILE_SNOW.id;
|
||||
}
|
||||
/*static boolean isImmutableTile(byte type) {
|
||||
return Tiles.isTree(type) || Tiles.isBush(type) || type == Tiles.Tile.TILE_CLAY.id || type == Tiles.Tile.TILE_MARSH.id || type == Tiles.Tile.TILE_PEAT.id || type == Tiles.Tile.TILE_TAR.id || type == Tiles.Tile.TILE_HOLE.id || type == Tiles.Tile.TILE_MOSS.id || type == Tiles.Tile.TILE_LAVA.id || Tiles.isMineDoor(type);
|
||||
}
|
||||
static boolean isRockTile(byte type) {
|
||||
return Tiles.isSolidCave(type) || type == Tiles.Tile.TILE_CAVE.id || type == Tiles.Tile.TILE_CAVE_EXIT.id || type == Tiles.Tile.TILE_CLIFF.id || type == Tiles.Tile.TILE_ROCK.id || type == Tiles.Tile.TILE_CAVE_FLOOR_REINFORCED.id;
|
||||
}*/
|
||||
|
||||
public static void smooth(int tilex, int tiley, MeshIO mesh) {
|
||||
int currentTileRock;
|
||||
short currentRockHeight;
|
||||
boolean insta;
|
||||
if(tilex < 50 || tiley < 50 || tilex > Server.surfaceMesh.getSize()-50 || tiley > Server.surfaceMesh.getSize()-50){
|
||||
return;
|
||||
}
|
||||
if (tilex > 1 << Constants.meshSize || tiley > 1 << Constants.meshSize) {
|
||||
return;
|
||||
}
|
||||
int digTile = mesh.getTile(tilex, tiley);
|
||||
byte digTileType = Tiles.decodeType(digTile);
|
||||
if(!isValidSmoothTile(digTileType)){
|
||||
return;
|
||||
}
|
||||
short digTileHeight = Tiles.decodeHeight(digTile);
|
||||
if (digTileHeight <= Tiles.decodeHeight(Server.rockMesh.getTile(tilex, tiley))) {
|
||||
return;
|
||||
}
|
||||
Village village = Villages.getVillageWithPerimeterAt(tilex, tiley, true);
|
||||
if(village != null){
|
||||
return;
|
||||
}
|
||||
Structure structure = Structures.getStructureForTile(tilex, tiley, true);
|
||||
if(structure != null){
|
||||
return;
|
||||
}
|
||||
short minHeight = -300;
|
||||
short maxHeight = 20000;
|
||||
|
||||
// Check for slopes nearby
|
||||
int minDiff = -5;
|
||||
int xMinDiff = 0;
|
||||
int yMinDiff = 0;
|
||||
int lNewTile = mesh.getTile(tilex, tiley - 1);
|
||||
short height = Tiles.decodeHeight(lNewTile);
|
||||
int difference = height - digTileHeight;
|
||||
int northDiff = difference;
|
||||
if(northDiff < minDiff){
|
||||
minDiff = northDiff;
|
||||
xMinDiff = 0;
|
||||
yMinDiff = -1;
|
||||
}
|
||||
|
||||
lNewTile = mesh.getTile(tilex + 1, tiley);
|
||||
height = Tiles.decodeHeight(lNewTile);
|
||||
difference = height - digTileHeight;
|
||||
int eastDiff = difference;
|
||||
if(eastDiff < minDiff){
|
||||
minDiff = eastDiff;
|
||||
xMinDiff = 1;
|
||||
yMinDiff = 0;
|
||||
}
|
||||
|
||||
lNewTile = mesh.getTile(tilex, tiley + 1);
|
||||
height = Tiles.decodeHeight(lNewTile);
|
||||
difference = height - digTileHeight;
|
||||
int southDiff = difference;
|
||||
if(southDiff < minDiff){
|
||||
minDiff = southDiff;
|
||||
xMinDiff = 0;
|
||||
yMinDiff = 1;
|
||||
}
|
||||
|
||||
lNewTile = mesh.getTile(tilex - 1, tiley);
|
||||
height = Tiles.decodeHeight(lNewTile);
|
||||
difference = height - digTileHeight;
|
||||
int westDiff = difference;
|
||||
if(westDiff < minDiff){
|
||||
//minDiff = westDiff;
|
||||
xMinDiff = -1;
|
||||
yMinDiff = 0;
|
||||
}
|
||||
|
||||
boolean bump = false;
|
||||
boolean pit = false;
|
||||
boolean slanted = false;
|
||||
if(westDiff < 0 && eastDiff < 0){
|
||||
bump = true;
|
||||
}else if(westDiff > 0 && eastDiff > 0){
|
||||
pit = true;
|
||||
}else if(northDiff < 0 && southDiff < 0){
|
||||
bump = true;
|
||||
}else if(northDiff > 0 && southDiff > 0){
|
||||
pit = true;
|
||||
}
|
||||
if(pit){
|
||||
return;
|
||||
}
|
||||
if(!bump){
|
||||
if(westDiff + eastDiff > 10 || westDiff + eastDiff < -10){
|
||||
slanted = true;
|
||||
}else if(northDiff + southDiff > 10 || northDiff + southDiff < -10){
|
||||
slanted = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!bump && !slanted){
|
||||
return;
|
||||
}
|
||||
|
||||
for(int x = tilex-2; x < tilex+2; x++){
|
||||
for(int y = tiley-2; y < tiley+2; y++){
|
||||
lNewTile = mesh.getTile(x, y);
|
||||
byte lNewTileType = Tiles.decodeType(lNewTile);
|
||||
if(!isValidSmoothTile(lNewTileType)){
|
||||
return;
|
||||
}
|
||||
structure = Structures.getStructureForTile(x, y, true);
|
||||
if(structure != null){
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (digTileHeight > minHeight && digTileHeight < maxHeight) {
|
||||
short maxdifference = 0;
|
||||
boolean hitRock = false;
|
||||
boolean allCornersRock;
|
||||
for (int x = 1; x >= -1; --x) {
|
||||
for (int y = 1; y >= -1; --y) {
|
||||
boolean lChanged = false;
|
||||
lNewTile = mesh.getTile(tilex + x, tiley + y);
|
||||
byte type = Tiles.decodeType(lNewTile);
|
||||
short newTileHeight = Tiles.decodeHeight(lNewTile);
|
||||
int rockTile = Server.rockMesh.getTile(tilex + x, tiley + y);
|
||||
short rockHeight = Tiles.decodeHeight(rockTile);
|
||||
if (x == xMinDiff && y == yMinDiff){
|
||||
lChanged = true;
|
||||
newTileHeight = (short)Math.max(newTileHeight + 1, rockHeight);
|
||||
//logger.info("Tile " + (tilex + x) + ", " + (tiley + y) + " now at " + newTileHeight + ", rock at " + rockHeight + ".");
|
||||
mesh.setTile(tilex + x, tiley + y, Tiles.encode(newTileHeight, type, Tiles.decodeData(lNewTile)));
|
||||
}
|
||||
if (x == 0 && y == 0) {
|
||||
if (newTileHeight > rockHeight) {
|
||||
lChanged = true;
|
||||
newTileHeight = (short)Math.max(newTileHeight - 1, rockHeight);
|
||||
//logger.info("Tile " + (tilex + x) + ", " + (tiley + y) + " now at " + newTileHeight + ", rock at " + rockHeight + ".");
|
||||
mesh.setTile(tilex + x, tiley + y, Tiles.encode(newTileHeight, type, Tiles.decodeData(lNewTile)));
|
||||
}
|
||||
}
|
||||
allCornersRock = Terraforming.allCornersAtRockLevel(tilex + x, tiley + y, mesh);
|
||||
if(allCornersRock) {
|
||||
int theTile = mesh.getTile(tilex + x, tiley + y);
|
||||
float oldTileHeight = Tiles.decodeHeightAsFloat(theTile);
|
||||
Server.modifyFlagsByTileType(tilex + x, tiley + y, Tiles.Tile.TILE_ROCK.id);
|
||||
mesh.setTile(tilex + x, tiley + y, Tiles.encode(oldTileHeight, Tiles.Tile.TILE_ROCK.id, (byte) 0));
|
||||
Players.getInstance().sendChangedTile(tilex + x, tiley + y, true, true);
|
||||
}else if(type == Tiles.TILE_TYPE_ROCK){
|
||||
int theTile = mesh.getTile(tilex + x, tiley + y);
|
||||
float oldTileHeight = Tiles.decodeHeightAsFloat(theTile);
|
||||
Server.modifyFlagsByTileType(tilex + x, tiley + y, Tiles.Tile.TILE_DIRT.id);
|
||||
mesh.setTile(tilex + x, tiley + y, Tiles.encode(oldTileHeight, Tiles.Tile.TILE_DIRT.id, (byte) 0));
|
||||
Players.getInstance().sendChangedTile(tilex + x, tiley + y, true, true);
|
||||
}
|
||||
if (lChanged) {
|
||||
Players.getInstance().sendChangedTile(tilex + x, tiley + y, true, true);
|
||||
try {
|
||||
Zone toCheckForChange = Zones.getZone(tilex + x, tiley + y, true);
|
||||
toCheckForChange.changeTile(tilex + x, tiley + y);
|
||||
}
|
||||
catch (NoSuchZoneException nsz) {
|
||||
logger.log(Level.INFO, "no such zone?: " + tilex + ", " + tiley, nsz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void smoothArea(int tilex, int tiley){
|
||||
long start = System.currentTimeMillis();
|
||||
int x = tilex-10;
|
||||
int y;
|
||||
while(x < tilex+10){
|
||||
y = tiley-10;
|
||||
while(y < tiley+10){
|
||||
SmoothTerrainAction.smooth(x, y, Server.surfaceMesh);
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
if(System.currentTimeMillis()-start > 500) {
|
||||
logger.info(String.format("Smoothing terrain at [%s, %s] took %s milliseconds.", tilex, tiley, System.currentTimeMillis() - start));
|
||||
}
|
||||
}
|
||||
public static void onServerPoll(){
|
||||
if(Servers.localServer.PVPSERVER){
|
||||
return;
|
||||
}
|
||||
smoothArea(Server.rand.nextInt(Server.surfaceMesh.getSize()), Server.rand.nextInt(Server.surfaceMesh.getSize()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionPerformer getActionPerformer()
|
||||
{
|
||||
return new ActionPerformer() {
|
||||
|
||||
@Override
|
||||
public short getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
// Without activated object
|
||||
@Override
|
||||
public boolean action(Action action, Creature performer, Item source, int tilex, int tiley, boolean onSurface, boolean corner, int tile, int heightOffset, short num, float counter)
|
||||
{
|
||||
return this.action(action, performer, tilex, tiley, onSurface, corner, tile, heightOffset, num, counter);
|
||||
}
|
||||
|
||||
// Without activated object
|
||||
@Override
|
||||
public boolean action(Action action, Creature performer, int tilex, int tiley, boolean onSurface, boolean corner, int tile, int heightOffset, short num, float counter)
|
||||
{
|
||||
if(performer instanceof Player){
|
||||
if(performer.getPower() < 5){
|
||||
performer.getCommunicator().sendNormalServerMessage("You do not have permission to do that.");
|
||||
return true;
|
||||
}
|
||||
smoothArea(tilex, tiley);
|
||||
//SmoothTerrainAction.smooth(tilex, tiley, Server.surfaceMesh);
|
||||
}else{
|
||||
logger.info("Somehow a non-player activated an Affinity Orb...");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Item source, Item target, short action, float counter)
|
||||
{
|
||||
return this.action(act, performer, target, action, counter);
|
||||
}
|
||||
|
||||
|
||||
}; // ActionPerformer
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package mod.sin.actions.items;
|
||||
|
||||
import com.wurmonline.server.behaviours.Action;
|
||||
import com.wurmonline.server.behaviours.ActionEntry;
|
||||
import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.items.Item;
|
||||
import com.wurmonline.server.players.Player;
|
||||
import com.wurmonline.server.skills.Affinities;
|
||||
import com.wurmonline.server.skills.Affinity;
|
||||
import com.wurmonline.server.skills.Skill;
|
||||
import com.wurmonline.server.skills.SkillSystem;
|
||||
import mod.sin.items.AffinityCatcher;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ActionPerformer;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.BehaviourProvider;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModAction;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModActions;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AffinityCatcherCaptureAction implements ModAction {
|
||||
private static Logger logger = Logger.getLogger(AffinityCatcherCaptureAction.class.getName());
|
||||
|
||||
private final short actionId;
|
||||
private final ActionEntry actionEntry;
|
||||
|
||||
public AffinityCatcherCaptureAction() {
|
||||
logger.log(Level.WARNING, "AffinityCatcherCaptureAction()");
|
||||
|
||||
actionId = (short) ModActions.getNextActionId();
|
||||
actionEntry = ActionEntry.createEntry(
|
||||
actionId,
|
||||
"Capture affinity",
|
||||
"capturing",
|
||||
new int[] { 0 /* ACTION_TYPE_NOMOVE */ } // 6 /* ACTION_TYPE_NOMOVE */, 48 /* ACTION_TYPE_ENEMY_ALWAYS */, 36 /* ACTION_TYPE_ALWAYS_USE_ACTIVE_ITEM */
|
||||
);
|
||||
ModActions.registerAction(actionEntry);
|
||||
}
|
||||
|
||||
public static boolean hasAffinityCatcher(Creature performer){
|
||||
logger.info("Checking if creature has affinity catcher.");
|
||||
for(Item i : performer.getInventory().getItems()){
|
||||
if(i.getTemplateId() == AffinityCatcher.templateId){
|
||||
logger.info("Has affinity catcher.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
logger.info("No affinity catcher found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BehaviourProvider getBehaviourProvider()
|
||||
{
|
||||
return new BehaviourProvider() {
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, Skill skill) {
|
||||
if(performer instanceof Player && skill.affinity > 0 && hasAffinityCatcher(performer)) {
|
||||
return Collections.singletonList(actionEntry);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Never called
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, Item source, Skill skill) {
|
||||
if(performer instanceof Player && source != null && source.getTemplateId() == AffinityCatcher.templateId && source.getData() == 0) {
|
||||
return Collections.singletonList(actionEntry);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionPerformer getActionPerformer()
|
||||
{
|
||||
return new ActionPerformer() {
|
||||
|
||||
@Override
|
||||
public short getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Skill skill, short action, float counter) {
|
||||
performer.getCommunicator().sendNormalServerMessage("Activate your affinity catcher to capture the affinity.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Without activated object
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Item source, Skill skill, short action, float counter) {
|
||||
logger.info("Action with item.");
|
||||
if(performer instanceof Player){
|
||||
Player player = (Player) performer;
|
||||
if (source.getTemplate().getTemplateId() != AffinityCatcher.templateId){
|
||||
player.getCommunicator().sendSafeServerMessage("You must use an Affinity Catcher to capture an affinity.");
|
||||
return true;
|
||||
}
|
||||
if(source.getData() > 0){
|
||||
player.getCommunicator().sendSafeServerMessage("The catcher already has an affinity captured.");
|
||||
return true;
|
||||
}
|
||||
int skillNum = skill.getNumber();
|
||||
Affinity[] affs = Affinities.getAffinities(player.getWurmId());
|
||||
int affinityCount = 0;
|
||||
for (Affinity affinity : affs) {
|
||||
if(affinity.getNumber() > 0){
|
||||
logger.info("Adding "+affinity.getNumber()+" affinities to total due to skill "+SkillSystem.getNameFor(affinity.getSkillNumber()));
|
||||
affinityCount += affinity.getNumber();
|
||||
}
|
||||
}
|
||||
if(affinityCount < 3){
|
||||
logger.info("Player "+performer.getName()+" does not have enough affinities to utilize an affinity catcher.");
|
||||
performer.getCommunicator().sendNormalServerMessage("You must have at least 3 affinities in total before using an "+source.getName()+".");
|
||||
return true;
|
||||
}
|
||||
for (Affinity affinity : affs) {
|
||||
if (affinity.getSkillNumber() != skillNum) continue;
|
||||
if (affinity.getNumber() < 1){
|
||||
break;
|
||||
}
|
||||
Affinities.setAffinity(player.getWurmId(), skillNum, affinity.getNumber() - 1, false);
|
||||
logger.info("Setting "+source.getName()+" data to "+skillNum);
|
||||
source.setData(skill.getNumber());
|
||||
source.setName("captured "+skill.getName()+" affinity");
|
||||
performer.getCommunicator().sendSafeServerMessage("Your "+skill.getName()+" affinity is captured!");
|
||||
return true;
|
||||
}
|
||||
// Only called if the affinity is not found or it breaks from having less than one.
|
||||
player.getCommunicator().sendNormalServerMessage("You must have an affinity in the skill to capture.");
|
||||
}else{
|
||||
logger.info("Somehow a non-player activated an Affinity Orb...");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Item source, Item target, short action, float counter)
|
||||
{
|
||||
return this.action(act, performer, target, action, counter);
|
||||
}
|
||||
|
||||
|
||||
}; // ActionPerformer
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package mod.sin.actions.items;
|
||||
|
||||
import com.wurmonline.server.Items;
|
||||
import com.wurmonline.server.behaviours.Action;
|
||||
import com.wurmonline.server.behaviours.ActionEntry;
|
||||
import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.items.Item;
|
||||
import com.wurmonline.server.players.Player;
|
||||
import com.wurmonline.server.questions.AffinityOrbQuestion;
|
||||
import com.wurmonline.server.skills.Affinities;
|
||||
import com.wurmonline.server.skills.Affinity;
|
||||
import mod.sin.items.AffinityCatcher;
|
||||
import mod.sin.items.AffinityOrb;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ActionPerformer;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.BehaviourProvider;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModAction;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModActions;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AffinityCatcherConsumeAction implements ModAction {
|
||||
private static Logger logger = Logger.getLogger(AffinityCatcherConsumeAction.class.getName());
|
||||
|
||||
private final short actionId;
|
||||
private final ActionEntry actionEntry;
|
||||
|
||||
public AffinityCatcherConsumeAction() {
|
||||
logger.log(Level.WARNING, "AffinityCatcherConsumeAction()");
|
||||
|
||||
actionId = (short) ModActions.getNextActionId();
|
||||
actionEntry = ActionEntry.createEntry(
|
||||
actionId,
|
||||
"Gain affinity",
|
||||
"infusing",
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BehaviourProvider getBehaviourProvider()
|
||||
{
|
||||
return new BehaviourProvider() {
|
||||
// Menu with activated object
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, Item source, Item object)
|
||||
{
|
||||
return this.getBehavioursFor(performer, object);
|
||||
}
|
||||
|
||||
// Menu without activated object
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, Item object)
|
||||
{
|
||||
if(performer instanceof Player && object != null && object.getTemplateId() == AffinityCatcher.templateId && object.getData() > 0) {
|
||||
return Collections.singletonList(actionEntry);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionPerformer getActionPerformer()
|
||||
{
|
||||
return new ActionPerformer() {
|
||||
|
||||
@Override
|
||||
public short getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
// Without activated object
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Item target, short action, float counter)
|
||||
{
|
||||
if(performer instanceof Player){
|
||||
Player player = (Player) performer;
|
||||
if (target.getTemplate().getTemplateId() != AffinityCatcher.templateId){
|
||||
player.getCommunicator().sendSafeServerMessage("You must use a captured affinity.");
|
||||
return true;
|
||||
}
|
||||
if(target.getData() <= 0){
|
||||
player.getCommunicator().sendSafeServerMessage("The catcher needs to have an affinity captured before being consumed.");
|
||||
return true;
|
||||
}
|
||||
int skillNum = (int) target.getData();
|
||||
Affinity[] affs = Affinities.getAffinities(performer.getWurmId());
|
||||
for (Affinity affinity : affs) {
|
||||
if (affinity.getSkillNumber() != skillNum) continue;
|
||||
if (affinity.getNumber() >= 5){
|
||||
player.getCommunicator().sendSafeServerMessage("You already have the maximum amount of affinities for that skill.");
|
||||
return true;
|
||||
}
|
||||
Affinities.setAffinity(player.getWurmId(), skillNum, affinity.getNumber() + 1, false);
|
||||
Items.destroyItem(target.getWurmId());
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
logger.info("Somehow a non-player activated an Affinity Orb...");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Item source, Item target, short action, float counter)
|
||||
{
|
||||
return this.action(act, performer, target, action, counter);
|
||||
}
|
||||
|
||||
|
||||
}; // ActionPerformer
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
package mod.sin.actions.items;
|
||||
|
||||
import com.wurmonline.server.Items;
|
||||
import com.wurmonline.server.behaviours.Action;
|
||||
import com.wurmonline.server.behaviours.ActionEntry;
|
||||
import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.items.Item;
|
||||
import com.wurmonline.server.players.Player;
|
||||
import com.wurmonline.server.skills.Affinities;
|
||||
import com.wurmonline.server.skills.Affinity;
|
||||
import com.wurmonline.server.skills.SkillSystem;
|
||||
import com.wurmonline.server.questions.AffinityOrbQuestion;
|
||||
import mod.sin.items.AffinityOrb;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ActionPerformer;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.BehaviourProvider;
|
||||
@@ -84,7 +81,9 @@ public class AffinityOrbAction implements ModAction {
|
||||
player.getCommunicator().sendSafeServerMessage("You must use an Affinity Orb to be infused.");
|
||||
return true;
|
||||
}
|
||||
int skillNum = SkillSystem.getRandomSkillNum();
|
||||
AffinityOrbQuestion aoq = new AffinityOrbQuestion(performer, "Affinity Orb", "Which affinity would you like to receive?", performer.getWurmId(), target);
|
||||
aoq.sendQuestion();
|
||||
/*int skillNum = SkillSystem.getRandomSkillNum();
|
||||
Affinity[] affs = Affinities.getAffinities(player.getWurmId());
|
||||
boolean found = false;
|
||||
while (!found) {
|
||||
@@ -108,7 +107,7 @@ public class AffinityOrbAction implements ModAction {
|
||||
found = true;
|
||||
}
|
||||
skillNum = SkillSystem.getRandomSkillNum();
|
||||
}
|
||||
}*/
|
||||
}else{
|
||||
logger.info("Somehow a non-player activated an Affinity Orb...");
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ public class ArenaCacheOpenAction implements ModAction {
|
||||
Server.getInstance().broadCastAction(performer.getName() + " opens "+performer.getHisHerItsString()+" "+target.getName()+".", performer, 5);
|
||||
logger.info("Player "+performer.getName()+" opened arena cache.");
|
||||
// Sorcery fragment.
|
||||
Item sorceryFragment = ItemFactory.createItem(SorceryFragment.templateId, 90f, null);
|
||||
performer.getInventory().insertItem(sorceryFragment, true);
|
||||
/*Item sorceryFragment = ItemFactory.createItem(SorceryFragment.templateId, 90f, null);
|
||||
performer.getInventory().insertItem(sorceryFragment, true);*/
|
||||
SupplyDepots.giveCacheReward(performer);
|
||||
Items.destroyItem(target.getWurmId());
|
||||
return true;
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ChaosCrystalInfuseAction implements ModAction {
|
||||
Items.destroyItem(source.getWurmId());
|
||||
}else if(power > 30){
|
||||
performer.getCommunicator().sendNormalServerMessage("You safely infuse the "+target.getName()+ ", chaotically changing it its weight.");
|
||||
target.setWeight((int) (target.getWeightGrams()*Server.rand.nextFloat()*2f), false);
|
||||
target.setWeight((int) ((target.getWeightGrams()*0.5f)+target.getWeightGrams()*Server.rand.nextFloat()*1.5f), false);
|
||||
Items.destroyItem(source.getWurmId());
|
||||
}else if(power > 0){
|
||||
performer.getCommunicator().sendNormalServerMessage("You barely manage to infuse the "+target.getName()+ ", chaotically changing its quality.");
|
||||
|
||||
@@ -137,7 +137,7 @@ public class EnchantersCrystalInfuseAction implements ModAction {
|
||||
}else if(power > 35){
|
||||
performer.getCommunicator().sendNormalServerMessage("You manage to infuse the "+target.getName()+ ", shifting its magical properties.");
|
||||
for(SpellEffect eff : effs.getEffects()){
|
||||
eff.setPower(eff.getPower()+((eff.getPower()*Server.rand.nextFloat()*0.4f) * (Server.rand.nextBoolean() ? 1 : -1)));
|
||||
eff.setPower(eff.getPower()+((eff.getPower()*Server.rand.nextFloat()*0.3f) * (Server.rand.nextBoolean() ? 1 : -1)));
|
||||
}
|
||||
Items.destroyItem(source.getWurmId());
|
||||
}else if(power > 0){
|
||||
|
||||
@@ -95,6 +95,12 @@ public class EternalOrbAction implements ModAction {
|
||||
player.getCommunicator().sendNormalServerMessage("The "+target.getTemplate().getName()+" has no enchants.");
|
||||
return true;
|
||||
}
|
||||
for(SpellEffect eff : teffs.getEffects()){
|
||||
if(eff.type == 120){
|
||||
player.getCommunicator().sendNormalServerMessage("The "+eff.getName()+" enchant makes this item immune to the effects of the "+source.getName()+".");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Item enchantOrb = ItemFactory.createItem(EnchantOrb.templateId, source.getCurrentQualityLevel(), "");
|
||||
ItemSpellEffects effs = enchantOrb.getSpellEffects();
|
||||
|
||||
119
src/main/java/mod/sin/actions/items/SorcerySplitAction.java
Normal file
119
src/main/java/mod/sin/actions/items/SorcerySplitAction.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package mod.sin.actions.items;
|
||||
|
||||
import com.wurmonline.server.FailedException;
|
||||
import com.wurmonline.server.behaviours.Action;
|
||||
import com.wurmonline.server.behaviours.ActionEntry;
|
||||
import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.items.Item;
|
||||
import com.wurmonline.server.items.ItemFactory;
|
||||
import com.wurmonline.server.items.NoSuchTemplateException;
|
||||
import com.wurmonline.server.players.Player;
|
||||
import com.wurmonline.server.questions.BookConversionQuestion;
|
||||
import mod.sin.items.BookOfConversion;
|
||||
import mod.sin.wyvern.util.ItemUtil;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ActionPerformer;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.BehaviourProvider;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModAction;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModActions;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class SorcerySplitAction implements ModAction {
|
||||
private static Logger logger = Logger.getLogger(SorcerySplitAction.class.getName());
|
||||
|
||||
private final short actionId;
|
||||
private final ActionEntry actionEntry;
|
||||
|
||||
public SorcerySplitAction() {
|
||||
actionId = (short) ModActions.getNextActionId();
|
||||
actionEntry = ActionEntry.createEntry(
|
||||
actionId,
|
||||
"Split sorcery",
|
||||
"splitting",
|
||||
new int[] { 0 /* ACTION_TYPE_NOMOVE */ } // 6 /* ACTION_TYPE_NOMOVE */, 48 /* ACTION_TYPE_ENEMY_ALWAYS */, 36 /* ACTION_TYPE_ALWAYS_USE_ACTIVE_ITEM */
|
||||
);
|
||||
ModActions.registerAction(actionEntry);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BehaviourProvider getBehaviourProvider()
|
||||
{
|
||||
return new BehaviourProvider() {
|
||||
// Menu with activated object
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, Item source, Item object)
|
||||
{
|
||||
return this.getBehavioursFor(performer, object);
|
||||
}
|
||||
|
||||
// Menu without activated object
|
||||
@Override
|
||||
public List<ActionEntry> getBehavioursFor(Creature performer, Item object)
|
||||
{
|
||||
if(performer instanceof Player && object != null && ItemUtil.isSorcery(object) && object.getAuxData() < 2) {
|
||||
return Collections.singletonList(actionEntry);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionPerformer getActionPerformer()
|
||||
{
|
||||
return new ActionPerformer() {
|
||||
|
||||
@Override
|
||||
public short getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
// Without activated object
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Item target, short action, float counter)
|
||||
{
|
||||
if(performer instanceof Player){
|
||||
Player player = (Player) performer;
|
||||
if(!ItemUtil.isSorcery(target)){
|
||||
player.getCommunicator().sendNormalServerMessage("You can only split a sorcery.");
|
||||
return true;
|
||||
}
|
||||
if(target.getAuxData() >= 2){
|
||||
player.getCommunicator().sendNormalServerMessage("The sorcery must have at least two charges to split.");
|
||||
return true;
|
||||
}
|
||||
if(target.getOwnerId() != player.getWurmId()){
|
||||
player.getCommunicator().sendNormalServerMessage("You must be holding the sorcery to split it.");
|
||||
return true;
|
||||
}
|
||||
while(target.getAuxData() < 2){
|
||||
try {
|
||||
Item newSorcery = ItemFactory.createItem(target.getTemplateId(), target.getCurrentQualityLevel(), null);
|
||||
newSorcery.setAuxData((byte) 2);
|
||||
player.getInventory().insertItem(newSorcery, true);
|
||||
target.setAuxData((byte) (target.getAuxData()+1));
|
||||
} catch (FailedException | NoSuchTemplateException e) {
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
logger.info("Somehow a non-player activated a "+target.getName()+"...");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Action act, Creature performer, Item source, Item target, short action, float counter)
|
||||
{
|
||||
return this.action(act, performer, target, action, counter);
|
||||
}
|
||||
|
||||
|
||||
}; // ActionPerformer
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import mod.sin.items.SorceryFragment;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ActionPerformer;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.BehaviourProvider;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModAction;
|
||||
@@ -110,6 +111,8 @@ public class SupplyDepotAction implements ModAction {
|
||||
Item inv = performer.getInventory();
|
||||
Item cache = ItemFactory.createItem(ArenaCache.templateId, 90+(10*Server.rand.nextFloat()), "");
|
||||
inv.insertItem(cache, true);
|
||||
Item fragment = ItemFactory.createItem(SorceryFragment.templateId, 90+(10*Server.rand.nextFloat()), "");
|
||||
inv.insertItem(fragment, true);
|
||||
performer.getCommunicator().sendSafeServerMessage("You have successfully captured the depot!");
|
||||
Server.getInstance().broadCastAction(performer.getName() + " successfully captures the depot!", performer, 50);
|
||||
SupplyDepots.broadcastCapture(performer);
|
||||
|
||||
@@ -68,6 +68,10 @@ public class Charger implements ModCreature, CreatureTypes {
|
||||
builder.denMaterial(Materials.MATERIAL_WOOD_BIRCH);
|
||||
builder.denName("charger lair");
|
||||
builder.maxGroupAttackSize(100);
|
||||
//builder.color(219, 180, 87);
|
||||
//builder.color(255, 0, 0);
|
||||
//builder.sizeModifier(1024, 1024, 1024);
|
||||
//builder.paintMode(2);
|
||||
|
||||
templateId = builder.getTemplateId();
|
||||
return builder;
|
||||
@@ -87,7 +91,7 @@ public class Charger implements ModCreature, CreatureTypes {
|
||||
|
||||
vehicle.createPassengerSeats(0);
|
||||
vehicle.setSeatFightMod(0, 0.8f, 1.1f);
|
||||
vehicle.setSeatOffset(0, 0.0f, 0.0f, 0.0f);
|
||||
vehicle.setSeatOffset(0, 0.0f, 0.0f, 0.5f);
|
||||
vehicle.setCreature(true);
|
||||
vehicle.setSkillNeeded(Servers.localServer.PVPSERVER ? 25.0f : 37.0f);
|
||||
vehicle.setName(creature.getName());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package mod.sin.creatures;
|
||||
|
||||
import com.wurmonline.server.items.ItemList;
|
||||
import com.wurmonline.server.items.Materials;
|
||||
import com.wurmonline.shared.constants.CreatureTypes;
|
||||
import org.gotti.wurmunlimited.modsupport.CreatureTemplateBuilder;
|
||||
import org.gotti.wurmunlimited.modsupport.creatures.ModCreature;
|
||||
@@ -33,7 +35,7 @@ public class Facebreyker implements ModCreature, CreatureTypes {
|
||||
"model.creature.humanoid.ogre.rift", types, (byte) 0, (short) 20, (byte) 0, (short) 350, (short) 100, (short) 60,
|
||||
"sound.death.troll", "sound.death.troll", "sound.combat.hit.troll", "sound.combat.hit.troll",
|
||||
0.05f, 50.0f, 50.0f, 0.0f, 0.0f, 0.0f, 1.6f, 1100,
|
||||
new int[]{867}, 40, 100, (byte) 0);
|
||||
new int[]{ItemList.boneCollar}, 40, 100, Materials.MATERIAL_MEAT_HUMANOID);
|
||||
|
||||
builder.skill(SkillList.BODY_STRENGTH, 90.0f);
|
||||
builder.skill(SkillList.BODY_STAMINA, 90.0f);
|
||||
|
||||
80
src/main/java/mod/sin/creatures/GuardianMagranon.java
Normal file
80
src/main/java/mod/sin/creatures/GuardianMagranon.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package mod.sin.creatures;
|
||||
|
||||
import com.wurmonline.server.bodys.BodyTemplate;
|
||||
import com.wurmonline.server.bodys.Wound;
|
||||
import com.wurmonline.server.combat.ArmourTypes;
|
||||
import com.wurmonline.server.items.ItemList;
|
||||
import com.wurmonline.server.items.Materials;
|
||||
import com.wurmonline.server.skills.SkillList;
|
||||
import com.wurmonline.shared.constants.CreatureTypes;
|
||||
import org.gotti.wurmunlimited.modsupport.CreatureTemplateBuilder;
|
||||
import org.gotti.wurmunlimited.modsupport.creatures.ModCreature;
|
||||
|
||||
public class GuardianMagranon implements ModCreature, CreatureTypes {
|
||||
public static int templateId;
|
||||
|
||||
@Override
|
||||
public CreatureTemplateBuilder createCreateTemplateBuilder() {
|
||||
// {C_TYPE_MOVE_LOCAL, C_TYPE_VEHICLE, C_TYPE_ANIMAL, C_TYPE_LEADABLE, C_TYPE_GRAZER, C_TYPE_OMNIVORE, C_TYPE_DOMINATABLE, C_TYPE_AGG_HUMAN, C_TYPE_NON_NEWBIE, C_TYPE_BURNING}; - Hell Horse
|
||||
// int[] types = new int[]{7, 6, 13, 3, 29, 39, 60, 61}; - Spider
|
||||
int[] types = {
|
||||
CreatureTypes.C_TYPE_MOVE_LOCAL,
|
||||
CreatureTypes.C_TYPE_AGG_HUMAN,
|
||||
CreatureTypes.C_TYPE_HUNTING,
|
||||
CreatureTypes.C_TYPE_MONSTER,
|
||||
CreatureTypes.C_TYPE_CARNIVORE,
|
||||
CreatureTypes.C_TYPE_DETECTINVIS,
|
||||
CreatureTypes.C_TYPE_NON_NEWBIE,
|
||||
CreatureTypes.C_TYPE_NO_REBIRTH
|
||||
};
|
||||
|
||||
//public CreatureTemplateBuilder(final String identifier, final String name, final String description,
|
||||
// final String modelName, final int[] types, final byte bodyType, final short vision, final byte sex, final short centimetersHigh, final short centimetersLong, final short centimetersWide,
|
||||
// final String deathSndMale, final String deathSndFemale, final String hitSndMale, final String hitSndFemale,
|
||||
// final float naturalArmour, final float handDam, final float kickDam, final float biteDam, final float headDam, final float breathDam, final float speed, final int moveRate,
|
||||
// final int[] itemsButchered, final int maxHuntDist, final int aggress) {
|
||||
CreatureTemplateBuilder builder = new CreatureTemplateBuilder("mod.creature.guardian.magranon", "Guardian of Magranon", "A loyal servant of Magranon, bound to defend their master.",
|
||||
"model.creature.humanoid.giant.juggernaut", types, BodyTemplate.TYPE_HUMAN, (short) 5, (byte) 0, (short) 85, (short) 50, (short) 85,
|
||||
"sound.death.magranon.juggernaut", "sound.death.magranon.juggernaut", "sound.combat.hit.magranon.juggernaut", "sound.combat.hit.magranon.juggernaut",
|
||||
0.1f, 12f, 0f, 0f, 0.0f, 0.0f, 1.2f, 500,
|
||||
new int[]{ItemList.charcoal, ItemList.flint, ItemList.heart, ItemList.adamantineOre}, 15, 70, Materials.MATERIAL_MEAT_HUMANOID);
|
||||
|
||||
builder.skill(SkillList.BODY_STRENGTH, 70.0f);
|
||||
builder.skill(SkillList.BODY_STAMINA, 70.0f);
|
||||
builder.skill(SkillList.BODY_CONTROL, 70.0f);
|
||||
builder.skill(SkillList.MIND_LOGICAL, 50.0f);
|
||||
builder.skill(SkillList.MIND_SPEED, 50.0f);
|
||||
builder.skill(SkillList.SOUL_STRENGTH, 50.0f);
|
||||
builder.skill(SkillList.SOUL_DEPTH, 50.0f);
|
||||
builder.skill(SkillList.WEAPONLESS_FIGHTING, 70.0f);
|
||||
builder.skill(SkillList.GROUP_FIGHTING, 90.0f);
|
||||
builder.skill(SkillList.AXE_HUGE, 70.0f);
|
||||
builder.skill(SkillList.AXE_LARGE, 70.0f);
|
||||
builder.skill(SkillList.AXE_SMALL, 70.0f);
|
||||
builder.skill(SkillList.MAUL_LARGE, 70.0f);
|
||||
builder.skill(SkillList.MAUL_MEDIUM, 70.0f);
|
||||
builder.skill(SkillList.MAUL_SMALL, 70.0f);
|
||||
builder.skill(SkillList.SWORD_TWOHANDED, 70.0f);
|
||||
builder.skill(SkillList.SWORD_LONG, 70.0f);
|
||||
builder.skill(SkillList.SWORD_SHORT, 70.0f);
|
||||
|
||||
builder.boundsValues(-0.5f, -1.0f, 0.5f, 1.42f);
|
||||
builder.handDamString("hit");
|
||||
builder.maxAge(100);
|
||||
builder.armourType(ArmourTypes.ARMOUR_LEATHER);
|
||||
builder.baseCombatRating(30.0f);
|
||||
builder.combatDamageType(Wound.TYPE_BURN);
|
||||
builder.maxGroupAttackSize(100);
|
||||
builder.sizeModifier(5, 5, 5);
|
||||
builder.hasHands(true);
|
||||
|
||||
templateId = builder.getTemplateId();
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEncounters() {
|
||||
if (templateId == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class SpiritTroll implements ModCreature, CreatureTypes {
|
||||
"model.creature.humanoid.troll.standard", Servers.localServer.PVPSERVER ? pvpTypes : types, BodyTemplate.TYPE_HUMAN, (short) 5, (byte) 0, (short) 85, (short) 50, (short) 85,
|
||||
"sound.death.troll", "sound.death.troll", "sound.combat.hit.troll", "sound.combat.hit.troll",
|
||||
0.15f, 15f, 17f, 19.0f, 0.0f, 0.0f, 1.2f, 500,
|
||||
new int[]{}, 10, 74, (byte) 82);
|
||||
new int[]{}, 10, 74, Materials.MATERIAL_MEAT_HUMANOID);
|
||||
|
||||
builder.skill(SkillList.BODY_STRENGTH, 45.0f);
|
||||
builder.skill(SkillList.BODY_STAMINA, 40.0f);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mod.sin.creatures;
|
||||
|
||||
import com.wurmonline.server.Servers;
|
||||
import org.gotti.wurmunlimited.modsupport.CreatureTemplateBuilder;
|
||||
import org.gotti.wurmunlimited.modsupport.creatures.EncounterBuilder;
|
||||
import org.gotti.wurmunlimited.modsupport.creatures.ModCreature;
|
||||
@@ -54,7 +55,7 @@ public class Worg implements ModCreature {
|
||||
vehicle.setName(creature.getName());
|
||||
vehicle.setMaxHeightDiff(0.07f);
|
||||
vehicle.setMaxDepth(-1.7f);
|
||||
vehicle.setMaxSpeed(40.0f);
|
||||
vehicle.setMaxSpeed(Servers.localServer.PVPSERVER ? 35.0f : 40.0f);
|
||||
vehicle.setCommandType((byte) 3);
|
||||
vehicle.setCanHaveEquipment(false);
|
||||
}
|
||||
|
||||
45
src/main/java/mod/sin/items/AffinityCatcher.java
Normal file
45
src/main/java/mod/sin/items/AffinityCatcher.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package mod.sin.items;
|
||||
|
||||
import com.wurmonline.server.MiscConstants;
|
||||
import com.wurmonline.server.items.ItemTemplate;
|
||||
import com.wurmonline.server.items.ItemTypes;
|
||||
import com.wurmonline.server.items.Materials;
|
||||
import org.gotti.wurmunlimited.modsupport.ItemTemplateBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AffinityCatcher implements ItemTypes, MiscConstants {
|
||||
public static Logger logger = Logger.getLogger(AffinityCatcher.class.getName());
|
||||
public static int templateId;
|
||||
|
||||
public void createTemplate() throws IOException{
|
||||
String name = "affinity catcher";
|
||||
ItemTemplateBuilder itemBuilder = new ItemTemplateBuilder("mod.item.affinity.catcher");
|
||||
itemBuilder.name(name, "affinity catchers", "A valuable orb that can transfer knowledge from one person to another.");
|
||||
itemBuilder.itemTypes(new short[]{
|
||||
ItemTypes.ITEM_TYPE_MAGIC,
|
||||
ItemTypes.ITEM_TYPE_FULLPRICE,
|
||||
ItemTypes.ITEM_TYPE_HASDATA,
|
||||
ItemTypes.ITEM_TYPE_NOSELLBACK,
|
||||
ItemTypes.ITEM_TYPE_ALWAYS_BANKABLE
|
||||
});
|
||||
itemBuilder.imageNumber((short) 919);
|
||||
itemBuilder.behaviourType((short) 1);
|
||||
itemBuilder.combatDamage(0);
|
||||
itemBuilder.decayTime(Long.MAX_VALUE);
|
||||
itemBuilder.dimensions(1, 1, 1);
|
||||
itemBuilder.primarySkill((int) NOID);
|
||||
itemBuilder.bodySpaces(EMPTY_BYTE_PRIMITIVE_ARRAY);
|
||||
itemBuilder.modelName("model.artifact.orbdoom");
|
||||
itemBuilder.difficulty(5.0f);
|
||||
itemBuilder.weightGrams(500);
|
||||
itemBuilder.material(Materials.MATERIAL_CRYSTAL);
|
||||
itemBuilder.value(100000);
|
||||
itemBuilder.isTraded(true);
|
||||
|
||||
ItemTemplate template = itemBuilder.build();
|
||||
templateId = template.getTemplateId();
|
||||
logger.info(name+" TemplateID: "+templateId);
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class AffinityOrb implements ItemTypes, MiscConstants {
|
||||
itemBuilder.difficulty(5.0f);
|
||||
itemBuilder.weightGrams(500);
|
||||
itemBuilder.material(Materials.MATERIAL_CRYSTAL);
|
||||
itemBuilder.value(1000000);
|
||||
itemBuilder.value(500000);
|
||||
itemBuilder.isTraded(true);
|
||||
|
||||
ItemTemplate template = itemBuilder.build();
|
||||
|
||||
325
src/main/java/mod/sin/wyvern/AchievementChanges.java
Normal file
325
src/main/java/mod/sin/wyvern/AchievementChanges.java
Normal file
@@ -0,0 +1,325 @@
|
||||
package mod.sin.wyvern;
|
||||
|
||||
import com.wurmonline.server.players.Achievement;
|
||||
import com.wurmonline.server.players.AchievementTemplate;
|
||||
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AchievementChanges {
|
||||
private static Logger logger = Logger.getLogger(AchievementChanges.class.getName());
|
||||
public static HashMap<Integer, AchievementTemplate> goodAchievements = new HashMap<>();
|
||||
public static ArrayList<Integer> blacklist = new ArrayList<>();
|
||||
|
||||
protected static int getNumber(String name){
|
||||
AchievementTemplate temp = Achievement.getTemplate(name);
|
||||
if(temp != null){
|
||||
return temp.getNumber();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected static void blacklist(String name){
|
||||
blacklist.add(getNumber(name));
|
||||
}
|
||||
protected static void blacklist(int number){
|
||||
blacklist.add(number);
|
||||
}
|
||||
|
||||
private static AchievementTemplate addAchievement(int id, String name, String description, String requirement, boolean isInvisible, int triggerOn, byte achievementType, boolean playUpdateSound, boolean isOneTimer) {
|
||||
AchievementTemplate ach = new AchievementTemplate(id, name, isInvisible, triggerOn, achievementType, playUpdateSound, isOneTimer, requirement);
|
||||
ach.setDescription(description);
|
||||
try {
|
||||
ReflectionUtil.callPrivateMethod(null, ReflectionUtil.getMethod(Achievement.class, "addTemplate", new Class<?>[]{AchievementTemplate.class}), ach);
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ach;
|
||||
}
|
||||
|
||||
protected static void generateBlacklist(){
|
||||
blacklist("Adulterator");
|
||||
blacklist("All Hell");
|
||||
blacklist("Ambitious");
|
||||
blacklist("Angry Sailor");
|
||||
blacklist("Arachnophile");
|
||||
blacklist("Arch Mage");
|
||||
blacklist("Ascended");
|
||||
blacklist("Backstabber");
|
||||
blacklist("Barbarian");
|
||||
blacklist("Braaains");
|
||||
blacklist(299); // Brilliant!
|
||||
blacklist(364); // Brilliant!
|
||||
blacklist("Bumble Bee");
|
||||
blacklist("Burglar");
|
||||
blacklist("Cap'n");
|
||||
blacklist("Caravel sailor");
|
||||
blacklist("Chief Mate");
|
||||
blacklist("Cog sailor");
|
||||
blacklist("Corbita sailor");
|
||||
blacklist("Cowboy");
|
||||
blacklist("Deforestation");
|
||||
blacklist("Demolition");
|
||||
blacklist("Diabolist");
|
||||
blacklist("Die by the Rift");
|
||||
blacklist("Die by the Rift a gazillion times");
|
||||
blacklist("Drake Spirits");
|
||||
blacklist("Eagle Spirits");
|
||||
blacklist("Environmental Hero");
|
||||
blacklist("Epic finalizer");
|
||||
blacklist(298); // Exquisite Gem
|
||||
blacklist(363); // Exquisite Gem
|
||||
blacklist("Fast Learner");
|
||||
blacklist("Fine titles");
|
||||
blacklist("Fo's Favourite");
|
||||
blacklist("Ghost of the Rift Warmasters");
|
||||
blacklist("Hedgehog");
|
||||
blacklist("High Spirits");
|
||||
blacklist("Hippie");
|
||||
blacklist("Humanss!");
|
||||
blacklist("Hunter Apprentice");
|
||||
blacklist("Incarnated To Hell");
|
||||
blacklist("Investigating the Rift");
|
||||
blacklist("Jackal Hunter");
|
||||
blacklist("Janitor");
|
||||
blacklist("Johnny Appleseed");
|
||||
blacklist("Joyrider");
|
||||
blacklist("Juggernaut's demise");
|
||||
blacklist("Kingdom Assault");
|
||||
blacklist("Knarr sailor");
|
||||
blacklist("Last Rope");
|
||||
blacklist("Lord of War");
|
||||
blacklist("Mage");
|
||||
blacklist("Magician");
|
||||
blacklist("Magus");
|
||||
blacklist("Manifested No More");
|
||||
blacklist("Master Bridgebuilder");
|
||||
blacklist("Master Shipbuilder");
|
||||
blacklist("Master Winemaker");
|
||||
blacklist("Miner on Strike");
|
||||
blacklist("Moby Dick");
|
||||
blacklist("Mountain Goat");
|
||||
blacklist("Moved a Mountain");
|
||||
blacklist("Muffin Maker");
|
||||
blacklist("Mussst kill");
|
||||
blacklist("No Fuel for the Flame Of Udun");
|
||||
blacklist("On the Way to the Moon");
|
||||
blacklist("Out At Sea");
|
||||
blacklist("Out, out, brief candle!");
|
||||
blacklist("Own The Rift");
|
||||
blacklist("Pasta maker");
|
||||
blacklist("Pasta master");
|
||||
blacklist("Peace of Mind");
|
||||
blacklist("Pirate");
|
||||
blacklist("Pizza maker");
|
||||
blacklist("Pizza master");
|
||||
blacklist("Planeswalker");
|
||||
blacklist("Rider of the Apocalypse");
|
||||
blacklist("Rift Beast Nemesis");
|
||||
blacklist("Rift Ogre Hero");
|
||||
blacklist("Rift Opener");
|
||||
blacklist("Rift Specialist");
|
||||
blacklist("Rift Surfer");
|
||||
blacklist("Rowboat sailor");
|
||||
blacklist("Ruler");
|
||||
blacklist("Sailboat sailor");
|
||||
blacklist("Settlement Assault");
|
||||
blacklist("Sisyphos Says Hello");
|
||||
blacklist("Shadow");
|
||||
blacklist("Shadowmage");
|
||||
blacklist("Shutting Down");
|
||||
blacklist("Singing While Eating");
|
||||
blacklist("Sneaky");
|
||||
blacklist("Tastes like Chicken");
|
||||
blacklist("Tears of the Unicorn");
|
||||
blacklist("The Path of Vynora");
|
||||
blacklist("The Smell of Freshly Baked Bread");
|
||||
blacklist("The Smell of Freshly Made Muffins");
|
||||
blacklist("Thin Air");
|
||||
blacklist("Tree Hugger");
|
||||
blacklist("Trucker");
|
||||
blacklist("Truffle Pig");
|
||||
blacklist("Vynora commands you");
|
||||
blacklist("Waller");
|
||||
blacklist("Wanderer");
|
||||
blacklist("Went up a Hill");
|
||||
blacklist("Wet Feet");
|
||||
blacklist("You Beauty");
|
||||
blacklist("You Cannot Pass");
|
||||
blacklist("Zombie Hunter");
|
||||
blacklist("around the world");
|
||||
blacklist("brewed 1000 liters");
|
||||
blacklist("brewed liters");
|
||||
blacklist("distilled 1000 liters");
|
||||
blacklist("distilled liters");
|
||||
}
|
||||
|
||||
protected static void setRequirement(AchievementTemplate temp, String req){
|
||||
try {
|
||||
ReflectionUtil.setPrivateField(temp, ReflectionUtil.getField(temp.getClass(), "requirement"), req);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected static void addRequirements(AchievementTemplate temp){
|
||||
if(temp.getName().equals("Meoww!")){
|
||||
setRequirement(temp, "Kill a Wild Cat");
|
||||
}
|
||||
if(temp.getName().equals("Treasure Hunter")){
|
||||
setRequirement(temp, "Open a treasure chest");
|
||||
}
|
||||
if(temp.getName().equals("Mercykiller")){
|
||||
setRequirement(temp, "Slay a Diseased creature");
|
||||
}
|
||||
if(temp.getName().equals("Slayer of the Meek")){
|
||||
setRequirement(temp, "Slay a Scared creature");
|
||||
}
|
||||
if(temp.getName().equals("Willbreaker")){
|
||||
setRequirement(temp, "Slay a Hardened creature");
|
||||
}
|
||||
if(temp.getName().equals("Crocodiles Killed")){
|
||||
setRequirement(temp, "Kill a Crocodile");
|
||||
}
|
||||
if(temp.getName().equals("Tower Builder")){
|
||||
setRequirement(temp, "Build a Guard Tower");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:UseResStone")){
|
||||
setRequirement(temp, "Use a Resurrection Stone");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:ShakerOrbing")){
|
||||
setRequirement(temp, "Use a Shaker Orb");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:CutTree")){
|
||||
setRequirement(temp, "Cut down a tree");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:CatchFish")){
|
||||
setRequirement(temp, "Catch a fish");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:PlantFlower")){
|
||||
setRequirement(temp, "Plant a flower");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:Planting")){
|
||||
setRequirement(temp, "Plant a tree");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:PickLock")){
|
||||
setRequirement(temp, "Pick a lock");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:Stealth")){
|
||||
setRequirement(temp, "Successfully hide");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:ItemInTrash")){
|
||||
setRequirement(temp, "Trash an item");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:BulkBinDeposit")){
|
||||
setRequirement(temp, "Deposit a bulk item");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:Distancemoved")){
|
||||
setRequirement(temp, "Walk one tile");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:Hedges")){
|
||||
setRequirement(temp, "Plant a hedge or flower bed");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:MeditatingAction")){
|
||||
setRequirement(temp, "Meditate");
|
||||
}
|
||||
if(temp.getName().equals("Invisible:PickMushroom")){
|
||||
setRequirement(temp, "Pick a mushroom");
|
||||
}
|
||||
if(temp.getName().equals("Maintenance")){
|
||||
setRequirement(temp, "Repair a fence, floor, or wall");
|
||||
}
|
||||
if(temp.getName().equals("Be Gentle Please")){
|
||||
setRequirement(temp, "Win a spar");
|
||||
}
|
||||
if(temp.getName().equals("Rarity")){
|
||||
setRequirement(temp, "Make the best quality of an item");
|
||||
}
|
||||
}
|
||||
|
||||
protected static void fixName(AchievementTemplate temp){
|
||||
if(temp.getName().contains("Invisible:")){
|
||||
temp.setName(temp.getName().replaceAll("Invisible:", ""));
|
||||
}
|
||||
if(temp.getName().equals("PlayerkillBow")){
|
||||
temp.setName("Arrow To The Knee");
|
||||
}
|
||||
if(temp.getName().equals("PlayerkillSword")){
|
||||
temp.setName("Pointing The Right Direction");
|
||||
}
|
||||
if(temp.getName().equals("PlayerkillMaul")){
|
||||
temp.setName("Trip To The Maul");
|
||||
}
|
||||
if(temp.getName().equals("PlayerkillAxe")){
|
||||
temp.setName("Can I Axe You A Question?");
|
||||
}
|
||||
if(temp.getName().equals("OuchThatHurt")){
|
||||
temp.setName("Ouch That Hurt");
|
||||
}
|
||||
if(temp.getName().equals("UseResStone")){
|
||||
temp.setName("No Risk No Reward");
|
||||
}
|
||||
if(temp.getName().equals("ShakerOrbing")){
|
||||
temp.setName("This Mine Is Busted");
|
||||
}
|
||||
if(temp.getName().equals("CutTree")){
|
||||
temp.setName("Getting Wood");
|
||||
}
|
||||
if(temp.getName().equals("CatchFish")){
|
||||
temp.setName("Delicious Fish");
|
||||
}
|
||||
if(temp.getName().equals("PlantFlower")){
|
||||
temp.setName("Gardening");
|
||||
}
|
||||
if(temp.getName().equals("Planting")){
|
||||
temp.setName("Forester");
|
||||
}
|
||||
if(temp.getName().equals("PickLock")){
|
||||
temp.setName("Vault Hunter");
|
||||
}
|
||||
if(temp.getName().equals("ItemInTrash")){
|
||||
temp.setName("Another Mans Trash");
|
||||
}
|
||||
if(temp.getName().equals("Stealth")){
|
||||
temp.setName("The Invisible Man");
|
||||
}
|
||||
if(temp.getName().equals("BulkBinDeposit")){
|
||||
temp.setName("Bulk Hoarder");
|
||||
}
|
||||
if(temp.getName().equals("Distancemoved")){
|
||||
temp.setName("Explorer");
|
||||
}
|
||||
if(temp.getName().equals("Hedges")){
|
||||
temp.setName("Hedging Your Bets");
|
||||
}
|
||||
if(temp.getName().equals("MeditatingAction")){
|
||||
temp.setName("One With The World");
|
||||
}
|
||||
if(temp.getName().equals("PickMushroom")){
|
||||
temp.setName("Mushroom Collector");
|
||||
}
|
||||
}
|
||||
|
||||
public static void onServerStarted(){
|
||||
try {
|
||||
ConcurrentHashMap<Integer, AchievementTemplate> templates = ReflectionUtil.getPrivateField(Achievement.class, ReflectionUtil.getField(Achievement.class, "templates"));
|
||||
generateBlacklist();
|
||||
for(int i : templates.keySet()){
|
||||
AchievementTemplate temp = templates.get(i);
|
||||
addRequirements(temp);
|
||||
if(!temp.getRequirement().equals("") && !temp.isForCooking() && !blacklist.contains(i)){
|
||||
fixName(temp);
|
||||
goodAchievements.put(i, temp);
|
||||
logger.info(temp.getNumber()+": "+temp.getName()+" - "+temp.getDescription()+" ("+temp.getRequirement()+")");
|
||||
}
|
||||
}
|
||||
logger.info("Total achievements loaded into system: "+goodAchievements.size());
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.wurmonline.server.items.*;
|
||||
import com.wurmonline.server.players.Player;
|
||||
import com.wurmonline.server.questions.NewSpawnQuestion;
|
||||
import com.wurmonline.server.questions.SpawnQuestion;
|
||||
import com.wurmonline.server.skills.Affinity;
|
||||
import com.wurmonline.server.villages.Citizen;
|
||||
import com.wurmonline.server.villages.Village;
|
||||
import com.wurmonline.server.zones.Zone;
|
||||
@@ -139,14 +140,14 @@ public class Arena {
|
||||
statue.insertItem(sleepPowder, true);
|
||||
}
|
||||
for (x = 0; x < 5; ++x) {
|
||||
lump = ItemFactory.createItem(ItemList.adamantineBar, Math.min(99, 50 + winStreak), null);
|
||||
lump = ItemFactory.createItem(ItemList.adamantineBar, Math.min(99f, 60 + (winStreak*Server.rand.nextFloat()*1.5f)), null);
|
||||
float baseWeight = lump.getWeightGrams();
|
||||
float multiplier = 1f;//+(winStreak*0.4f*Server.rand.nextFloat());
|
||||
lump.setWeight((int) (baseWeight*multiplier), true);
|
||||
statue.insertItem(lump, true);
|
||||
}
|
||||
for (x = 0; x < 5; ++x) {
|
||||
lump = ItemFactory.createItem(ItemList.glimmerSteelBar, Math.min(99, 50 + winStreak), null);
|
||||
lump = ItemFactory.createItem(ItemList.glimmerSteelBar, Math.min(99f, 60 + (winStreak*Server.rand.nextFloat()*1.5f)), null);
|
||||
float baseWeight = lump.getWeightGrams();
|
||||
float multiplier = 1f;//+(winStreak*0.2f*Server.rand.nextFloat());
|
||||
lump.setWeight((int) (baseWeight*multiplier), true);
|
||||
@@ -163,8 +164,8 @@ public class Arena {
|
||||
ArtifactCache.templateId,
|
||||
CrystalCache.templateId, CrystalCache.templateId,
|
||||
DragonCache.templateId, DragonCache.templateId, DragonCache.templateId,
|
||||
GemCache.templateId,
|
||||
RiftCache.templateId, RiftCache.templateId, RiftCache.templateId,
|
||||
ToolCache.templateId,
|
||||
TreasureMapCache.templateId
|
||||
};
|
||||
int i = 5+Server.rand.nextInt(4); // 5-8 caches.
|
||||
@@ -180,9 +181,9 @@ public class Arena {
|
||||
i--;
|
||||
}
|
||||
// Add 3-5 seryll lumps of medium ql
|
||||
i = 3+Server.rand.nextInt(3); // 3-5 caches
|
||||
i = 3+Server.rand.nextInt(3); // 3-5 lumps
|
||||
while(i > 0){
|
||||
Item seryll = ItemFactory.createItem(ItemList.seryllBar, 30f+(40f*Server.rand.nextFloat()), null);
|
||||
Item seryll = ItemFactory.createItem(ItemList.seryllBar, 40f+(60f*Server.rand.nextFloat()), null);
|
||||
statue.insertItem(seryll, true);
|
||||
i--;
|
||||
}
|
||||
@@ -209,6 +210,10 @@ public class Arena {
|
||||
}
|
||||
}
|
||||
|
||||
public static Affinity[] getNullAffinities(){
|
||||
return new Affinity[0];
|
||||
}
|
||||
|
||||
public static void preInit(){
|
||||
try {
|
||||
ClassPool classPool = HookManager.getInstance().getClassPool();
|
||||
@@ -688,13 +693,13 @@ public class Arena {
|
||||
"}";
|
||||
Util.instrumentDeclared(thisClass, ctCreature, "die", "getFavor", replace);
|
||||
|
||||
Util.setReason("Nerf resurrection stones.");
|
||||
/*Util.setReason("Nerf resurrection stones.");
|
||||
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER){" +
|
||||
" $_ = com.wurmonline.server.Server.rand.nextInt(40) > 35;" +
|
||||
"}else{" +
|
||||
" $_ = $proceed($$);" +
|
||||
"}";
|
||||
Util.instrumentDeclared(thisClass, ctCreature, "die", "isDeathProtected", replace);
|
||||
Util.instrumentDeclared(thisClass, ctCreature, "die", "isDeathProtected", replace);*/
|
||||
|
||||
Util.setReason("Adjust spawn question mechanics.");
|
||||
CtClass ctSpawnQuestion = classPool.get("com.wurmonline.server.questions.SpawnQuestion");
|
||||
@@ -770,6 +775,40 @@ public class Arena {
|
||||
replace = "$_ = $0.getAttitude(this) == 1;";
|
||||
Util.instrumentDeclared(thisClass, ctPlayer, "spreadCrownInfluence", "isFriendlyKingdom", replace);
|
||||
|
||||
Util.setReason("Disable item drops from players on Arena.");
|
||||
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER && this.isPlayer()){" +
|
||||
" this.getCommunicator().sendSafeServerMessage(\"You have died on the Arena server and your items are kept safe.\");" +
|
||||
" keepItems = true;" +
|
||||
"}" +
|
||||
"$_ = $proceed($$);";
|
||||
Util.instrumentDeclaredCount(thisClass, ctCreature, "die", "isOnCurrentServer", 1, replace);
|
||||
|
||||
Util.setReason("Disable player skill loss on Arena.");
|
||||
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER && this.isPlayer() && this.isDeathProtected()){" +
|
||||
" this.getCommunicator().sendSafeServerMessage(\"You have died on the Arena server with a Resurrection Stone and your knowledge is kept safe.\");" +
|
||||
" return;" +
|
||||
"}else if(com.wurmonline.server.Servers.localServer.PVPSERVER){" +
|
||||
" this.getCommunicator().sendAlertServerMessage(\"You have died on the Arena server without a Resurrection Stone, resulting in some of your knowledge being lost.\");" +
|
||||
"}";
|
||||
Util.insertBeforeDeclared(thisClass, ctCreature, "punishSkills", replace);
|
||||
|
||||
Util.setReason("Disable player fight skill loss on Arena.");
|
||||
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER && this.isPlayer() && this.isDeathProtected()){" +
|
||||
" $_ = null;" +
|
||||
"}else{" +
|
||||
" $_ = $proceed($$);" +
|
||||
"}";
|
||||
Util.instrumentDeclaredCount(thisClass, ctCreature, "modifyFightSkill", "setKnowledge", 1, replace);
|
||||
|
||||
Util.setReason("Disable player affinity loss on Arena.");
|
||||
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER && this.isPlayer() && this.isDeathProtected()){" +
|
||||
" this.getCommunicator().sendSafeServerMessage(\"Your resurrection stone keeps your affinities safe from your slayers.\");" +
|
||||
" $_ = "+Arena.class.getName()+".getNullAffinities();" +
|
||||
"}else{" +
|
||||
" $_ = $proceed($$);" +
|
||||
"}";
|
||||
Util.instrumentDeclared(thisClass, ctPlayer, "modifyRanking", "getAffinities", replace);
|
||||
|
||||
|
||||
}catch (NotFoundException e) {
|
||||
throw new HookException(e);
|
||||
|
||||
@@ -55,10 +55,10 @@ public class Caches {
|
||||
}
|
||||
|
||||
public static float getBaseQuality(float quality){
|
||||
return quality*0.2f;
|
||||
return quality*0.25f;
|
||||
}
|
||||
public static float getRandomQuality(float quality){
|
||||
return quality*0.5f;
|
||||
return quality*0.6f;
|
||||
}
|
||||
public static float getWeightMultiplier(int templateId, float quality){
|
||||
if(templateId == DragonCache.templateId){
|
||||
@@ -120,6 +120,7 @@ public class Caches {
|
||||
ItemList.axeSmall, ItemList.axeMedium, ItemList.axeHuge,
|
||||
ItemList.maulSmall, ItemList.maulMedium, ItemList.maulLarge,
|
||||
ItemList.spearLong, ItemList.staffSteel, ItemList.halberd,
|
||||
Club.templateId, BattleYoyo.templateId,
|
||||
Knuckles.templateId, Warhammer.templateId
|
||||
};
|
||||
}else if(templateId == CrystalCache.templateId){
|
||||
@@ -174,11 +175,52 @@ public class Caches {
|
||||
ItemList.riftWood,
|
||||
ItemList.riftStone
|
||||
};
|
||||
}else if(templateId == ToolCache.templateId){
|
||||
return new int[]{
|
||||
ItemList.hatchet,
|
||||
ItemList.knifeCarving,
|
||||
ItemList.pickAxe,
|
||||
ItemList.saw,
|
||||
ItemList.shovel,
|
||||
ItemList.rake,
|
||||
ItemList.hammerMetal,
|
||||
ItemList.hammerWood,
|
||||
ItemList.anvilSmall,
|
||||
ItemList.cheeseDrill,
|
||||
ItemList.knifeButchering,
|
||||
ItemList.fishingRodIronHook,
|
||||
ItemList.stoneChisel,
|
||||
ItemList.spindle,
|
||||
ItemList.anvilLarge,
|
||||
ItemList.grindstone,
|
||||
ItemList.needleIron,
|
||||
ItemList.knifeFood,
|
||||
ItemList.sickle,
|
||||
ItemList.scythe,
|
||||
ItemList.file,
|
||||
ItemList.awl,
|
||||
ItemList.leatherKnife,
|
||||
ItemList.scissors,
|
||||
ItemList.clayShaper,
|
||||
ItemList.spatula,
|
||||
ItemList.fruitpress,
|
||||
ItemList.trowel,
|
||||
ItemList.groomingBrush
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void adjustBasicItem(int templateId, float quality, Item item){
|
||||
if(templateId == ArmourCache.templateId){
|
||||
if(Server.rand.nextInt(800) < quality){
|
||||
if(item.getRarity() == 0){
|
||||
if(Server.rand.nextInt(1800) < quality){
|
||||
item.setRarity(MiscConstants.SUPREME);
|
||||
}else{
|
||||
item.setRarity(MiscConstants.RARE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(quality > 50){
|
||||
if(quality > 95 && Server.rand.nextBoolean()){
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_SHARED_PAIN, quality*Server.rand.nextFloat()*0.7f);
|
||||
@@ -218,7 +260,6 @@ public class Caches {
|
||||
Materials.MATERIAL_STEEL
|
||||
};
|
||||
item.setMaterial(materials[Server.rand.nextInt(materials.length)]);
|
||||
item.setQualityLevel(item.getQualityLevel());
|
||||
if(Server.rand.nextInt(400) < quality){
|
||||
if(item.getRarity() == 0){
|
||||
if(Server.rand.nextInt(900) < quality){
|
||||
@@ -233,8 +274,8 @@ public class Caches {
|
||||
Enchants.BUFF_WIND_OF_AGES,
|
||||
Enchants.BUFF_BLESSINGDARK
|
||||
};
|
||||
ItemUtil.applyEnchant(item, enchants[Server.rand.nextInt(enchants.length)], quality*Server.rand.nextFloat()*0.6f);
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_NIMBLENESS, quality*Server.rand.nextFloat()*0.7f);
|
||||
ItemUtil.applyEnchant(item, enchants[Server.rand.nextInt(enchants.length)], quality*0.5f+(quality*0.5f*Server.rand.nextFloat()));
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_NIMBLENESS, quality*0.3f+(quality*0.7f*Server.rand.nextFloat()));
|
||||
}else if(quality > 30){
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_LIFETRANSFER, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
|
||||
}
|
||||
@@ -242,7 +283,54 @@ public class Caches {
|
||||
if(Server.rand.nextInt(500) < quality){
|
||||
item.setRarity(MiscConstants.RARE);
|
||||
}
|
||||
}
|
||||
}else if(templateId == ToolCache.templateId){
|
||||
byte[] materials = {
|
||||
Materials.MATERIAL_SERYLL,
|
||||
Materials.MATERIAL_GLIMMERSTEEL,
|
||||
Materials.MATERIAL_ADAMANTINE,
|
||||
Materials.MATERIAL_STEEL,
|
||||
Materials.MATERIAL_TIN,
|
||||
Materials.MATERIAL_BRONZE,
|
||||
Materials.MATERIAL_BRASS,
|
||||
Materials.MATERIAL_ZINC,
|
||||
Materials.MATERIAL_IRON,
|
||||
Materials.MATERIAL_COPPER,
|
||||
Materials.MATERIAL_GOLD,
|
||||
Materials.MATERIAL_LEAD,
|
||||
Materials.MATERIAL_SILVER
|
||||
};
|
||||
item.setMaterial(materials[Server.rand.nextInt(materials.length)]);
|
||||
if(Server.rand.nextInt(1200) < quality){
|
||||
if(item.getRarity() == 0){
|
||||
if(Server.rand.nextInt(2700) < quality){
|
||||
item.setRarity(MiscConstants.SUPREME);
|
||||
}else{
|
||||
item.setRarity(MiscConstants.RARE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Server.rand.nextInt(200) < quality){
|
||||
byte rune = (byte) (Server.rand.nextInt(78)-128);
|
||||
if(!ItemUtil.isSingleUseRune(rune)){
|
||||
ItemUtil.applyEnchant(item, rune, 50);
|
||||
}
|
||||
}
|
||||
if(quality > 30 && Server.rand.nextInt(250) < quality){
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_WIND_OF_AGES, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
|
||||
}
|
||||
if(quality > 30 && Server.rand.nextInt(250) < quality){
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_CIRCLE_CUNNING, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
|
||||
}
|
||||
if(quality > 50 && Server.rand.nextInt(250) < quality){ // Efficiency
|
||||
ItemUtil.applyEnchant(item, (byte) 114, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
|
||||
}
|
||||
if(quality > 70 && Server.rand.nextInt(350) < quality){
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_BLESSINGDARK, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
|
||||
}
|
||||
if(quality > 90 && Server.rand.nextInt(5000) < quality){ // Titanforged
|
||||
ItemUtil.applyEnchant(item, (byte) 120, quality*0.2f+(quality*0.2f*Server.rand.nextFloat()));
|
||||
}
|
||||
}
|
||||
}
|
||||
public static int getBasicNums(int templateId){
|
||||
if(templateId == CrystalCache.templateId){
|
||||
@@ -439,7 +527,7 @@ public class Caches {
|
||||
TITAN_CACHE.createTemplate();
|
||||
CACHE_IDS.add(TitanCache.templateId);
|
||||
TOOL_CACHE.createTemplate();
|
||||
//CACHE_IDS.add(ToolCache.templateId);
|
||||
CACHE_IDS.add(ToolCache.templateId);
|
||||
TREASUREMAP_CACHE.createTemplate();
|
||||
CACHE_IDS.add(TreasureMapCache.templateId);
|
||||
WEAPON_CACHE.createTemplate();
|
||||
|
||||
@@ -9,21 +9,22 @@ import com.wurmonline.server.creatures.Creatures;
|
||||
import com.wurmonline.server.items.Item;
|
||||
import com.wurmonline.server.players.Player;
|
||||
import com.wurmonline.shared.constants.Enchants;
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
import javassist.NotFoundException;
|
||||
import javassist.*;
|
||||
import javassist.bytecode.*;
|
||||
import javassist.expr.ExprEditor;
|
||||
import javassist.expr.FieldAccess;
|
||||
import mod.sin.lib.Util;
|
||||
import org.gotti.wurmunlimited.modloader.classhooks.HookException;
|
||||
import org.gotti.wurmunlimited.modloader.classhooks.HookManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class CombatChanges {
|
||||
public static Logger logger = Logger.getLogger(CombatChanges.class.getName());
|
||||
|
||||
// Added to CombatHandled
|
||||
public static int getWeaponType(Item weapon){
|
||||
if(weapon.enchantment == Enchants.ACID_DAM){
|
||||
return Wound.TYPE_ACID;
|
||||
@@ -67,6 +68,7 @@ public class CombatChanges {
|
||||
return mult;
|
||||
}
|
||||
|
||||
// Added to CombatHandled
|
||||
public static int getLifeTransferAmountModifier(Wound wound, int initial){
|
||||
byte type = wound.getType();
|
||||
if(type == Wound.TYPE_ACID || type == Wound.TYPE_BURN || type == Wound.TYPE_COLD){
|
||||
@@ -77,6 +79,7 @@ public class CombatChanges {
|
||||
return initial;
|
||||
}
|
||||
|
||||
// Added to CombatHandled
|
||||
public static float getLifeTransferModifier(Creature creature, Creature defender){
|
||||
if(Servers.localServer.PVPSERVER && (defender.isDominated() || defender.isPlayer()) && creature.isPlayer()){
|
||||
return 0.5f;
|
||||
@@ -84,6 +87,7 @@ public class CombatChanges {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
// Added to CombatHandled
|
||||
public static void doLifeTransfer(Creature creature, Creature defender, Item attWeapon, double defdamage, float armourMod){
|
||||
float lifeTransfer = attWeapon.getSpellLifeTransferModifier()*getLifeTransferModifier(creature, defender);
|
||||
Wound[] w;
|
||||
@@ -94,6 +98,7 @@ public class CombatChanges {
|
||||
}
|
||||
}
|
||||
|
||||
// Added (kind of) to CombatHandled
|
||||
public static float getAdjustedOakshell(Creature defender, Item armour, float armourMod){
|
||||
if(defender != null && armour == null){
|
||||
float oakshellPower = defender.getBonusForSpellEffect(Enchants.CRET_OAKSHELL);
|
||||
@@ -139,6 +144,8 @@ public class CombatChanges {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Added to CombatHandled
|
||||
public static boolean canDoDamage(double damage, Creature attacker, Creature defender) {
|
||||
//logger.info(String.format("canDoDamage from %s to %s - %.1f", attacker.getName(), defender.getName(), damage));
|
||||
return damage > 1D;
|
||||
@@ -250,6 +257,18 @@ public class CombatChanges {
|
||||
}
|
||||
}
|
||||
|
||||
// Added to CombatHandled
|
||||
public static void pollCreatureActionStacks(){
|
||||
for(Creature c : Creatures.getInstance().getCreatures()){
|
||||
if(c.isFighting()) {
|
||||
c.getActions().poll(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void goodLog(String str){
|
||||
logger.info(str);
|
||||
}
|
||||
|
||||
public static void preInit(){
|
||||
try{
|
||||
@@ -383,6 +402,55 @@ public class CombatChanges {
|
||||
"}";
|
||||
Util.instrumentDeclared(thisClass, ctCombatHandler, "setDamage", "getSpellPainShare", replace);
|
||||
|
||||
/*Util.setReason("Debug attack method");
|
||||
CtClass ctAction = classPool.get("com.wurmonline.server.behaviours.Action");
|
||||
CtClass[] params4 = {
|
||||
ctCreature,
|
||||
CtClass.intType,
|
||||
CtClass.booleanType,
|
||||
CtClass.floatType,
|
||||
ctAction
|
||||
};
|
||||
String desc4 = Descriptor.ofMethod(CtClass.booleanType, params4);
|
||||
replace = "logger.info(\"opponent = \"+$1.getName()+\", combatCounter = \"+$2+\", opportunity = \"+$3+\", actionCounter = \"+$4);";
|
||||
Util.insertBeforeDescribed(thisClass, ctCombatHandler, "attack", desc4, replace);*/
|
||||
|
||||
/*Util.setReason("Debug CreatureAI Poll");
|
||||
CtClass ctCreatureAI = classPool.get("com.wurmonline.server.creatures.ai.CreatureAI");
|
||||
replace = "if($1.getTemplate().getTemplateId() == 2147483619){" +
|
||||
CombatChanges.class.getName()+".goodLog(\"CreatureAI.pollCreature(\"+$1.getName()+\", \"+$2+\")\");" +
|
||||
"}";
|
||||
Util.insertBeforeDeclared(thisClass, ctCreatureAI, "pollCreature", replace);*/
|
||||
|
||||
/*Util.setReason("Debug VolaTile Poll");
|
||||
CtClass ctVolaTile = classPool.get("com.wurmonline.server.zones.VolaTile");
|
||||
replace = "if($2.getTemplate().getTemplateId() == 2147483619){" +
|
||||
CombatChanges.class.getName()+".goodLog(\"VolaTile.pollOneCreatureOnThisTile(\"+$2.getName()+\")\");" +
|
||||
"}";
|
||||
Util.insertBeforeDeclared(thisClass, ctVolaTile, "pollOneCreatureOnThisTile", replace);*/
|
||||
|
||||
/*Util.setReason("Debug Creature Poll");
|
||||
replace = "if($0.getTemplate().getTemplateId() == 2147483619){" +
|
||||
CombatChanges.class.getName()+".goodLog(\"Creature.poll(\"+$0.getName()+\")\");" +
|
||||
"}";
|
||||
Util.insertBeforeDeclared(thisClass, ctCreature, "poll", replace);*/
|
||||
|
||||
/*Util.setReason("Debug Creatures Poll");
|
||||
CtClass ctCreatures = classPool.get("com.wurmonline.server.creatures.Creatures");
|
||||
replace = CombatChanges.class.getName()+".goodLog(\"Creatures.pollAllCreatures()\");";
|
||||
Util.insertBeforeDeclared(thisClass, ctCreatures, "pollAllCreatures", replace);*/
|
||||
|
||||
// TODO: Enable with new combat rework.
|
||||
/*Util.setReason("Poll creature action stacks on every update.");
|
||||
CtClass ctZones = classPool.get("com.wurmonline.server.zones.Zones");
|
||||
replace = //CombatChanges.class.getName()+".goodLog(\"Zones.pollNextZones(\"+$1+\") [time \"+java.lang.System.currentTimeMillis()+\"]\");" +
|
||||
CombatChanges.class.getName()+".pollCreatureActionStacks();";
|
||||
Util.insertBeforeDeclared(thisClass, ctZones, "pollNextZones", replace);*/
|
||||
|
||||
/*replace = "$_ = $proceed($$);" +
|
||||
CombatChanges.class.getName()+".goodLog(\"Zones.pollNextZones(\"+sleepTime+\") call to Creatures.getInstance().pollAllCreatures(\"+$1+\") [time \"+java.lang.System.currentTimeMillis()+\"]\");";
|
||||
Util.instrumentDeclared(thisClass, ctZones, "pollNextZones", "pollAllCreatures", replace);*/
|
||||
|
||||
patchCombatDamageCheckCombatEngine(classPool);
|
||||
patchCombatDamageCheckCombatHandler(classPool);
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ public class Crystals {
|
||||
Enchants.BUFF_VENOM,
|
||||
Enchants.BUFF_WEBARMOUR,
|
||||
Enchants.BUFF_WIND_OF_AGES,
|
||||
110 // Harden
|
||||
110, // Harden
|
||||
114 // Efficiency
|
||||
//110, 111 // Harden and Phasing
|
||||
};
|
||||
public static byte getNewRandomEnchant(Item target){
|
||||
|
||||
149
src/main/java/mod/sin/wyvern/DatabaseHelper.java
Normal file
149
src/main/java/mod/sin/wyvern/DatabaseHelper.java
Normal file
@@ -0,0 +1,149 @@
|
||||
package mod.sin.wyvern;
|
||||
|
||||
import com.wurmonline.server.players.Player;
|
||||
import org.gotti.wurmunlimited.modsupport.ModSupportDb;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DatabaseHelper {
|
||||
private static Logger logger = Logger.getLogger(DatabaseHelper.class.getName());
|
||||
|
||||
public static void onPlayerLogin(Player p){
|
||||
Connection dbcon;
|
||||
PreparedStatement ps;
|
||||
boolean foundLeaderboardOpt = false;
|
||||
try {
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("SELECT * FROM LeaderboardOpt");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
if (!rs.getString("name").equals(p.getName())) continue;
|
||||
foundLeaderboardOpt = true;
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (!foundLeaderboardOpt) {
|
||||
logger.info("No leaderboard entry for "+p.getName()+". Creating one.");
|
||||
try {
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("INSERT INTO LeaderboardOpt (name) VALUES(\"" + p.getName() + "\")");
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
boolean foundPlayerStats = false;
|
||||
try {
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("SELECT * FROM PlayerStats");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
if (!rs.getString("NAME").equals(p.getName())) continue;
|
||||
foundPlayerStats = true;
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (!foundPlayerStats) {
|
||||
logger.info("No player stats entry for "+p.getName()+". Creating one.");
|
||||
try {
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("INSERT INTO PlayerStats (NAME) VALUES(\"" + p.getName() + "\")");
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void onServerStarted(){
|
||||
try {
|
||||
Connection con = ModSupportDb.getModSupportDb();
|
||||
String sql;
|
||||
String tableName = "LeaderboardOpt";
|
||||
if (!ModSupportDb.hasTable(con, tableName)) {
|
||||
logger.info(tableName+" table not found in ModSupport. Creating table now.");
|
||||
sql = "CREATE TABLE "+tableName+" (name VARCHAR(30) NOT NULL DEFAULT 'Unknown', OPTIN INT NOT NULL DEFAULT 0)";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}
|
||||
tableName = "SteamIdMap";
|
||||
if (!ModSupportDb.hasTable(con, tableName)) {
|
||||
logger.info(tableName+" table not found in ModSupport. Creating table now.");
|
||||
sql = "CREATE TABLE "+tableName+" (NAME VARCHAR(30) NOT NULL DEFAULT 'Unknown', STEAMID LONG NOT NULL DEFAULT 0)";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}
|
||||
tableName = "PlayerStats";
|
||||
if (!ModSupportDb.hasTable(con, tableName)) {
|
||||
logger.info(tableName+" table not found in ModSupport. Creating table now.");
|
||||
sql = "CREATE TABLE "+tableName+" (NAME VARCHAR(30) NOT NULL DEFAULT 'Unknown', KILLS INT NOT NULL DEFAULT 0, DEATHS INT NOT NULL DEFAULT 0, DEPOTS INT NOT NULL DEFAULT 0, HOTAS INT NOT NULL DEFAULT 0, TITANS INT NOT NULL DEFAULT 0, UNIQUES INT NOT NULL DEFAULT 0)";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}else{
|
||||
logger.info("Found "+tableName+". Checking if it has a unique column.");
|
||||
ResultSet rs = con.getMetaData().getColumns(null, null, tableName, "UNIQUES");
|
||||
if(rs.next()){
|
||||
logger.info(tableName+" already has a uniques column.");
|
||||
}else{
|
||||
logger.info("Detected no uniques column in "+tableName);
|
||||
sql = "ALTER TABLE "+tableName+" ADD COLUMN UNIQUES INT NOT NULL DEFAULT 0";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}
|
||||
}
|
||||
tableName = "ObjectiveTimers";
|
||||
if (!ModSupportDb.hasTable(con, tableName)) {
|
||||
logger.info(tableName+" table not found in ModSupport. Creating table now.");
|
||||
sql = "CREATE TABLE "+tableName+" (ID VARCHAR(30) NOT NULL DEFAULT 'Unknown', TIMER LONG NOT NULL DEFAULT 0)";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
try {
|
||||
Connection dbcon;
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("INSERT INTO ObjectiveTimers (ID, TIMER) VALUES(\"DEPOT\", 0)");
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
Connection dbcon;
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("INSERT INTO ObjectiveTimers (ID, TIMER) VALUES(\"TITAN\", 0)");
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
SupplyDepots.initializeDepotTimer();
|
||||
Titans.initializeTitanTimer();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/main/java/mod/sin/wyvern/DeityChanges.java
Normal file
32
src/main/java/mod/sin/wyvern/DeityChanges.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package mod.sin.wyvern;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DeityChanges {
|
||||
public static Logger logger = Logger.getLogger(DeityChanges.class.getName());
|
||||
|
||||
public static void onServerStarted(){
|
||||
/*if(Deities.getDeity(101) != null){ // Edit Breyk player god
|
||||
Deity breyk = Deities.getDeity(101);
|
||||
// Add some defining affinities
|
||||
breyk.repairer = true;
|
||||
breyk.learner = true;
|
||||
breyk.deathProtector = true;
|
||||
breyk.befriendCreature = true;
|
||||
// Remove some affinities
|
||||
breyk.warrior = false;
|
||||
breyk.healer = false;
|
||||
breyk.clayAffinity = false;
|
||||
}*/
|
||||
/*if(Deities.getDeity(102) != null){ // Edit Cyberhusky player god
|
||||
Deity cyberhusky = Deities.getDeity(102);
|
||||
// Add some defining affinities
|
||||
cyberhusky.hateGod = true;
|
||||
cyberhusky.allowsButchering = true;
|
||||
cyberhusky.warrior = true;
|
||||
// Remove some affinities
|
||||
cyberhusky.woodAffinity = false;
|
||||
cyberhusky.befriendCreature = false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package mod.sin.wyvern;
|
||||
|
||||
import com.wurmonline.server.economy.Economy;
|
||||
import com.wurmonline.server.economy.Shop;
|
||||
import com.wurmonline.server.items.Item;
|
||||
import com.wurmonline.server.items.Trade;
|
||||
import com.wurmonline.server.villages.GuardPlan;
|
||||
import com.wurmonline.server.villages.Village;
|
||||
import com.wurmonline.server.villages.Villages;
|
||||
@@ -48,6 +51,36 @@ public class EconomicChanges {
|
||||
return -10;
|
||||
}
|
||||
|
||||
public static long getNewShopDiff(Trade trade, long money, long shopDiff){
|
||||
Shop shop = null;
|
||||
Village citizenVillage = null;
|
||||
if (trade.creatureOne.isNpcTrader()) {
|
||||
shop = Economy.getEconomy().getShop(trade.creatureOne);
|
||||
}
|
||||
if (trade.creatureTwo.isNpcTrader()) {
|
||||
shop = Economy.getEconomy().getShop(trade.creatureTwo);
|
||||
}
|
||||
if(shop == null){
|
||||
logger.info("Something went horribly wrong and the shop is null.");
|
||||
return 0;
|
||||
}
|
||||
logger.info("Money = "+money+", shopDiff = "+shopDiff);
|
||||
if(!shop.isPersonal() && money > 0){
|
||||
logger.info("We're adding money. Testing to see how much difference there is.");
|
||||
if(money + shopDiff > 0){
|
||||
logger.info("Player actually purchased something. Reducing the income.");
|
||||
long newDiff = money + shopDiff;
|
||||
logger.info("Actual difference in currency: "+Economy.getEconomy().getChangeFor(newDiff).getChangeString());
|
||||
newDiff *= 0.2;
|
||||
logger.info("After 80% void: "+Economy.getEconomy().getChangeFor(newDiff).getChangeString());
|
||||
logger.info("Returning the following amount of money to incur the change: "+(-shopDiff+newDiff));
|
||||
return -shopDiff+newDiff;
|
||||
}
|
||||
//return (long) (money*0.2);
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
public static void preInit(){
|
||||
try{
|
||||
ClassPool classPool = HookManager.getInstance().getClassPool();
|
||||
@@ -76,6 +109,11 @@ public class EconomicChanges {
|
||||
replace = "$_ = 1;";
|
||||
Util.instrumentDeclared(thisClass, ctCreature, "removeRandomItems", "nextInt", replace);
|
||||
|
||||
Util.setReason("Void 80% of all currency put into traders.");
|
||||
CtClass ctTrade = classPool.get("com.wurmonline.server.items.Trade");
|
||||
replace = "$1 = "+EconomicChanges.class.getName()+".getNewShopDiff($0, $1, $0.shopDiff);";
|
||||
Util.insertBeforeDeclared(thisClass, ctTrade, "addShopDiff", replace);
|
||||
|
||||
} catch ( NotFoundException | IllegalArgumentException | ClassCastException e) {
|
||||
throw new HookException(e);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.wurmonline.server.Servers;
|
||||
import mod.sin.items.caches.*;
|
||||
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
|
||||
import org.gotti.wurmunlimited.modloader.classhooks.HookManager;
|
||||
import org.gotti.wurmunlimited.modloader.classhooks.InvocationHandlerFactory;
|
||||
@@ -35,7 +36,8 @@ import mod.sin.weapons.titan.*;
|
||||
|
||||
public class ItemMod {
|
||||
public static Logger logger = Logger.getLogger(ItemMod.class.getName());
|
||||
|
||||
|
||||
public static AffinityCatcher AFFINITY_CATCHER = new AffinityCatcher();
|
||||
public static AffinityOrb AFFINITY_ORB = new AffinityOrb();
|
||||
public static ArenaCache ARENA_CACHE = new ArenaCache();
|
||||
public static ArenaSupplyDepot ARENA_SUPPLY_DEPOT = new ArenaSupplyDepot();
|
||||
@@ -100,6 +102,7 @@ public class ItemMod {
|
||||
public static void createItems(){
|
||||
logger.info("createItems()");
|
||||
try{
|
||||
AFFINITY_CATCHER.createTemplate();
|
||||
AFFINITY_ORB.createTemplate();
|
||||
ARENA_CACHE.createTemplate();
|
||||
ARENA_SUPPLY_DEPOT.createTemplate();
|
||||
@@ -166,6 +169,8 @@ public class ItemMod {
|
||||
}
|
||||
|
||||
public static void registerActions(){
|
||||
ModActions.registerAction(new AffinityCatcherCaptureAction());
|
||||
ModActions.registerAction(new AffinityCatcherConsumeAction());
|
||||
ModActions.registerAction(new AffinityOrbAction());
|
||||
ModActions.registerAction(new ArenaCacheOpenAction());
|
||||
ModActions.registerAction(new ArrowPackUnpackAction());
|
||||
@@ -270,6 +275,7 @@ public class ItemMod {
|
||||
new Weapon(Club.templateId, 8.1f, 4.5f, 0.002f, 3, 3, 0.4f, 0.5d);
|
||||
new Weapon(Knuckles.templateId, 3.6f, 2.2f, 0.002f, 1, 1, 0.2f, 0.5d);
|
||||
new Weapon(Warhammer.templateId, 9.40f, 5.6f, 0.008f, 4, 3, 1f, 0d);
|
||||
//new Weapon(ItemList.stoneChisel, 50f, 1f, 0.5f, 8, 1, 3f, -5f);
|
||||
// Titan weaponry
|
||||
new Weapon(MaartensMight.templateId, 11, 5, 0.02f, 4, 4, 1.0f, 0d);
|
||||
new Weapon(RaffehsRage.templateId, 9.5f, 4.25f, 0.02f, 3, 3, 1.0f, 0d);
|
||||
@@ -310,6 +316,15 @@ public class ItemMod {
|
||||
}
|
||||
return -10;
|
||||
}
|
||||
|
||||
private static void setFragments(int templateId, int fragmentCount){
|
||||
try {
|
||||
ItemTemplate item = ItemTemplateFactory.getInstance().getTemplate(templateId);
|
||||
ReflectionUtil.setPrivateField(item, ReflectionUtil.getField(item.getClass(), "fragmentAmount"), fragmentCount);
|
||||
} catch (IllegalAccessException | NoSuchFieldException | NoSuchTemplateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void modifyItems() throws NoSuchTemplateException, IllegalArgumentException, IllegalAccessException, ClassCastException, NoSuchFieldException{
|
||||
// Make leather able to be combined.
|
||||
@@ -383,6 +398,29 @@ public class ItemMod {
|
||||
ReflectionUtil.setPrivateField(marbleKeystone, ReflectionUtil.getField(marbleKeystone.getClass(), "decoration"), true);
|
||||
ItemTemplate skull = ItemTemplateFactory.getInstance().getTemplate(ItemList.skull);
|
||||
ReflectionUtil.setPrivateField(skull, ReflectionUtil.getField(skull.getClass(), "decoration"), true);
|
||||
|
||||
// Modify fragment counts
|
||||
setFragments(ArmourCache.templateId, 18);
|
||||
setFragments(ArtifactCache.templateId, 33);
|
||||
setFragments(CrystalCache.templateId, 11);
|
||||
setFragments(DragonCache.templateId, 19);
|
||||
setFragments(GemCache.templateId, 7);
|
||||
setFragments(MoonCache.templateId, 14);
|
||||
setFragments(PotionCache.templateId, 18);
|
||||
setFragments(RiftCache.templateId, 24);
|
||||
setFragments(TitanCache.templateId, 100);
|
||||
setFragments(ToolCache.templateId, 27);
|
||||
setFragments(TreasureMapCache.templateId, 38);
|
||||
|
||||
setFragments(AffinityOrb.templateId, 20);
|
||||
|
||||
setFragments(ItemList.statueWorg, 40);
|
||||
setFragments(ItemList.statueEagle, 40);
|
||||
|
||||
setFragments(ItemList.statueFo, 50);
|
||||
setFragments(ItemList.statueMagranon, 50);
|
||||
setFragments(ItemList.statueLibila, 50);
|
||||
setFragments(ItemList.statueVynora, 50);
|
||||
|
||||
createCustomWeapons();
|
||||
createCustomArmours();
|
||||
|
||||
@@ -731,11 +731,77 @@ public class MiscChanges {
|
||||
}
|
||||
});
|
||||
|
||||
Util.setReason("Make armour title benefits always occur.");
|
||||
replace = "$_ = improve.getNumber();";
|
||||
Util.instrumentDeclared(thisClass, ctMethodsItems, "improveItem", "getSkillId", replace);
|
||||
Util.instrumentDeclared(thisClass, ctMethodsItems, "polishItem", "getSkillId", replace);
|
||||
|
||||
Util.setReason("Make it so sorceries can be used anywhere with a flat 3x3 altar.");
|
||||
CtClass ctAbilities = classPool.get("com.wurmonline.server.players.Abilities");
|
||||
replace = "$_ = 1;";
|
||||
Util.instrumentDeclared(thisClass, ctAbilities, "isInProperLocation", "getTemplateId", replace);
|
||||
|
||||
/*Util.setReason("Debug Login Handler when creating a new player via an exception.");
|
||||
CtClass ctLoginHandler = classPool.get("com.wurmonline.server.LoginHandler");
|
||||
replace = "$_ = $proceed($$);" +
|
||||
"logger.info(ex.getMessage());";
|
||||
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "doNewPlayer", replace);
|
||||
replace = "$_ = $proceed($$);" +
|
||||
"logger.info(\"addPlayer(\"+$1+\")\");";
|
||||
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "addPlayer", replace);
|
||||
replace = "$_ = $proceed($$);" +
|
||||
"logger.info(\"initialisePlayer(\"+$1+\")\");";
|
||||
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "initialisePlayer", replace);
|
||||
replace = "$_ = $proceed($$);" +
|
||||
"logger.info(\"createBodyParts\");";
|
||||
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "createBodyParts", replace);
|
||||
replace = "logger.info(\"loadSkills\");" +
|
||||
"$_ = $proceed($$);";
|
||||
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "loadSkills", replace);
|
||||
replace = "logger.info(\"loadAllItemsForCreature1(\"+$1+\")\");" +
|
||||
"logger.info(\"loadAllItemsForCreature2(\"+$1.getStatus()+\")\");" +
|
||||
"logger.info(\"loadAllItemsForCreature3(\"+$2+\")\");" +
|
||||
"try{" +
|
||||
" $_ = $proceed($$);" +
|
||||
"}catch(com.wurmonline.server.NoSuchItemException ex){" +
|
||||
" logger.info(ex.getMessage());" +
|
||||
"}";
|
||||
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "loadAllItemsForCreature", replace);
|
||||
|
||||
// -- Items method debugging -- //
|
||||
Util.setReason("Debug Items method loadAllitemsForCreature");
|
||||
CtClass ctItems = classPool.get("com.wurmonline.server.Items");
|
||||
replace = "logger.info(\"creature = \"+$1+\", inventoryId = \"+$2);";
|
||||
Util.insertBeforeDeclared(thisClass, ctItems, "loadAllItemsForCreature", replace);
|
||||
replace = "logger.info(\"loadPossessions(\"+$1+\")\");" +
|
||||
"$_ = $proceed($$);";
|
||||
Util.instrumentDeclared(thisClass, ctItems, "loadAllItemsForCreature", "loadPossessions", replace);
|
||||
|
||||
replace = "logger.info(\"sendMapInfo - Communicator: \"+$0);" +
|
||||
"$_ = $proceed($$);";
|
||||
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "sendMapInfo", replace);
|
||||
replace = "logger.info(\"loadAllPrivatePOIForPlayer(\"+$1+\")\");" +
|
||||
"$_ = $proceed($$);";
|
||||
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "loadAllPrivatePOIForPlayer", replace);
|
||||
replace = "$_ = $proceed($$);" +
|
||||
"logger.info(\"resetLastSentToolbelt\");";
|
||||
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "resetLastSentToolbelt", replace);*/
|
||||
|
||||
Util.setReason("Make drinks less filling.");
|
||||
CtClass[] params13 = {
|
||||
ctAction,
|
||||
ctCreature,
|
||||
ctItem,
|
||||
CtClass.floatType
|
||||
};
|
||||
String desc13 = Descriptor.ofMethod(CtClass.booleanType, params13);
|
||||
replace = "$_ = $proceed($1, $2, $3*5);";
|
||||
Util.instrumentDescribed(thisClass, ctMethodsItems, "drink", desc13, "sendActionControl", replace);
|
||||
replace = "$_ = $proceed($1/5, $2, $3, $4, $5);";
|
||||
Util.instrumentDescribed(thisClass, ctMethodsItems, "drink", desc13, "modifyThirst", replace);
|
||||
|
||||
} catch (CannotCompileException | NotFoundException | IllegalArgumentException | ClassCastException e) {
|
||||
throw new HookException(e);
|
||||
}
|
||||
}
|
||||
public static void logMessage(String message){
|
||||
logger.info(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class MountedChanges {
|
||||
if(creature.isHorse() || creature.isUnicorn()) {
|
||||
factor *= newCalcHorseShoeBonus(creature);
|
||||
}
|
||||
if(creature.isHorse()){
|
||||
/*if(creature.isHorse()){
|
||||
try {
|
||||
Item barding = creature.getArmour(BodyPartConstants.TORSO);
|
||||
if(barding != null){
|
||||
@@ -81,7 +81,7 @@ public class MountedChanges {
|
||||
}
|
||||
} catch (NoArmourException | NoSpaceException ignored) {
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (creature.getBonusForSpellEffect(Enchants.CRET_OAKSHELL) > 0.0f) {
|
||||
factor *= 1f - (0.3f * (creature.getBonusForSpellEffect(Enchants.CRET_OAKSHELL) / 100.0f));
|
||||
}
|
||||
|
||||
144
src/main/java/mod/sin/wyvern/SkillChanges.java
Normal file
144
src/main/java/mod/sin/wyvern/SkillChanges.java
Normal file
@@ -0,0 +1,144 @@
|
||||
package mod.sin.wyvern;
|
||||
|
||||
import com.wurmonline.server.Server;
|
||||
import com.wurmonline.server.TimeConstants;
|
||||
import com.wurmonline.server.skills.*;
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.NotFoundException;
|
||||
import mod.sin.lib.Util;
|
||||
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
|
||||
import org.gotti.wurmunlimited.modloader.classhooks.HookException;
|
||||
import org.gotti.wurmunlimited.modloader.classhooks.HookManager;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class SkillChanges {
|
||||
public static Logger logger = Logger.getLogger(SkillChanges.class.getName());
|
||||
|
||||
public static double newDoSkillGainNew(Skill skill, double check, double power, double learnMod, float times, double skillDivider) {
|
||||
double bonus = 1.0;
|
||||
double diff = Math.abs(check - skill.getKnowledge());
|
||||
short sType = SkillSystem.getTypeFor(skill.getNumber());
|
||||
boolean awardBonus = true;
|
||||
if (sType == 1 || sType == 0) {
|
||||
awardBonus = false;
|
||||
}
|
||||
if (diff <= 15.0 && awardBonus) {
|
||||
bonus = 1.0 + (0.1 * (diff / 15.0));
|
||||
}
|
||||
/*if (power < 0.0) {
|
||||
if (this.knowledge < 20.0) {
|
||||
this.alterSkill((100.0 - this.knowledge) / (this.getDifficulty(this.parent.priest) * this.knowledge * this.knowledge) * learnMod * bonus, false, times, true, skillDivider);
|
||||
}
|
||||
} else {
|
||||
this.alterSkill((100.0 - this.knowledge) / (this.getDifficulty(this.parent.priest) * this.knowledge * this.knowledge) * learnMod * bonus, false, times, true, skillDivider);
|
||||
}*/
|
||||
try {
|
||||
Skills parent = ReflectionUtil.getPrivateField(skill, ReflectionUtil.getField(skill.getClass(), "parent"));
|
||||
double advanceMultiplicator = (100.0 - skill.getKnowledge()) / (skill.getDifficulty(parent.priest) * skill.getKnowledge() * skill.getKnowledge()) * learnMod * bonus;
|
||||
double p = 5;
|
||||
double q = 3;
|
||||
//advanceMultiplicator *= Math.pow(2, ((2-Math.pow((100/(100+power)), p))*(100-power)/100));
|
||||
double mult = Math.pow(2, (2-Math.pow(100/(100+power), p))*Math.pow((100-power)*0.01, q));
|
||||
if(mult < 0.5 && skill.getKnowledge() < 20){
|
||||
advanceMultiplicator *= 0.5+(Server.rand.nextDouble()*0.5);
|
||||
}else if(skill.getNumber() == SkillList.MEDITATING || skill.getNumber() == SkillList.LOCKPICKING){
|
||||
advanceMultiplicator *= Math.max(mult, 0.8d);
|
||||
}else if(mult > 0.0001) {
|
||||
advanceMultiplicator *= mult*0.95d;
|
||||
}else{
|
||||
advanceMultiplicator = 0;
|
||||
}
|
||||
/*if(skill.getType() > 3) {
|
||||
logger.info(String.format("Power of %.2f on skill %s gives multiplier of %.2f.", power, skill.getName(), mult));
|
||||
}*/
|
||||
return advanceMultiplicator;
|
||||
//ReflectionUtil.callPrivateMethod(skill, ReflectionUtil.getMethod(skill.getClass(), "alterSkill"), advanceMultiplicator, false, times, true, skillDivider);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void onServerStarted(){
|
||||
/*SkillTemplate exorcism = SkillSystem.templates.get(SkillList.EXORCISM);
|
||||
int[] deps = {SkillList.GROUP_ALCHEMY};
|
||||
try {
|
||||
String newName = "Crystal handling";
|
||||
ReflectionUtil.setPrivateField(exorcism, ReflectionUtil.getField(exorcism.getClass(), "name"), newName);
|
||||
SkillSystem.skillNames.put(exorcism.getNumber(), newName);
|
||||
SkillSystem.namesToSkill.put(newName, exorcism.getNumber());
|
||||
ReflectionUtil.setPrivateField(exorcism, ReflectionUtil.getField(exorcism.getClass(), "dependencies"), deps);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to rename exorcism!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
SkillTemplate ballistae = SkillSystem.templates.get(SkillList.BALLISTA);
|
||||
int[] deps2 = {SkillList.GROUP_ALCHEMY};
|
||||
try {
|
||||
String newName = "Mystic components";
|
||||
ReflectionUtil.setPrivateField(ballistae, ReflectionUtil.getField(ballistae.getClass(), "name"), newName);
|
||||
SkillSystem.skillNames.put(ballistae.getNumber(), newName);
|
||||
SkillSystem.namesToSkill.put(newName, ballistae.getNumber());
|
||||
ReflectionUtil.setPrivateField(ballistae, ReflectionUtil.getField(ballistae.getClass(), "dependencies"), deps2);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to rename ballistae!");
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
SkillTemplate preaching = SkillSystem.templates.get(SkillList.PREACHING);
|
||||
int[] deps3 = {SkillList.MASONRY};
|
||||
try {
|
||||
String newName = "Gem augmentation";
|
||||
ReflectionUtil.setPrivateField(preaching, ReflectionUtil.getField(preaching.getClass(), "name"), newName);
|
||||
SkillSystem.skillNames.put(preaching.getNumber(), newName);
|
||||
SkillSystem.namesToSkill.put(newName, preaching.getNumber());
|
||||
ReflectionUtil.setPrivateField(preaching, ReflectionUtil.getField(preaching.getClass(), "dependencies"), deps3);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to rename preaching!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
SkillTemplate stealing = SkillSystem.templates.get(SkillList.STEALING);
|
||||
try {
|
||||
ReflectionUtil.setPrivateField(stealing, ReflectionUtil.getField(stealing.getClass(), "tickTime"), 0);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to set tickTime for stealing!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
SkillTemplate meditating = SkillSystem.templates.get(SkillList.MEDITATING);
|
||||
try {
|
||||
ReflectionUtil.setPrivateField(meditating, ReflectionUtil.getField(meditating.getClass(), "tickTime"), TimeConstants.HOUR_MILLIS);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to set tickTime for meditating!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
meditating.setDifficulty(300f);
|
||||
|
||||
// Set mining difficulty down to be equivalent to digging.
|
||||
SkillTemplate mining = SkillSystem.templates.get(SkillList.MINING);
|
||||
mining.setDifficulty(3000f);
|
||||
// Triple lockpicking skill
|
||||
SkillTemplate lockpicking = SkillSystem.templates.get(SkillList.LOCKPICKING);
|
||||
lockpicking.setDifficulty(700f);
|
||||
}
|
||||
|
||||
public static void preInit(){
|
||||
try{
|
||||
ClassPool classPool = HookManager.getInstance().getClassPool();
|
||||
final Class<SkillChanges> thisClass = SkillChanges.class;
|
||||
String replace;
|
||||
|
||||
Util.setReason("Allow skill check failures to add skill gain.");
|
||||
CtClass ctSkill = classPool.get("com.wurmonline.server.skills.Skill");
|
||||
replace = "{" +
|
||||
" double advanceMultiplicator = "+SkillChanges.class.getName()+".newDoSkillGainNew($0, $1, $2, $3, $4, $5);" +
|
||||
" $0.alterSkill(advanceMultiplicator, false, $4, true, $5);" +
|
||||
"}";
|
||||
Util.setBodyDeclared(thisClass, ctSkill, "doSkillGainNew", replace);
|
||||
|
||||
} catch ( NotFoundException | IllegalArgumentException | ClassCastException e) {
|
||||
throw new HookException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,6 +198,7 @@ public class SupplyDepots {
|
||||
MiscChanges.sendServerTabMessage("arena", "The next Arena depot will appear in 5 minutes!", 255, 128, 0);
|
||||
}else if(minutesLeft == 19){
|
||||
MiscChanges.sendServerTabMessage("arena", "The next Arena depot will appear in 20 minutes!", 255, 128, 0);
|
||||
MiscChanges.sendGlobalFreedomChat(host, "The next Arena depot will appear in 20 minutes!", 255, 128, 0);
|
||||
}else if(minutesLeft == 59){
|
||||
MiscChanges.sendServerTabMessage("arena", "The next Arena depot will appear in 60 minutes!", 255, 128, 0);
|
||||
MiscChanges.sendGlobalFreedomChat(host, "The next Arena depot will appear in 60 minutes!", 255, 128, 0);
|
||||
@@ -251,14 +252,12 @@ public class SupplyDepots {
|
||||
inv.insertItem(token, true);
|
||||
i--;
|
||||
}
|
||||
// Seryll or sleep powder
|
||||
if(Server.rand.nextBoolean()){
|
||||
Item seryll = ItemFactory.createItem(ItemList.seryllBar, 70+(30*Server.rand.nextFloat()), null);
|
||||
inv.insertItem(seryll, true);
|
||||
}else{
|
||||
Item sleepPowder = ItemFactory.createItem(ItemList.sleepPowder, 99f, null);
|
||||
inv.insertItem(sleepPowder, true);
|
||||
}
|
||||
// High quality seryll
|
||||
Item seryll = ItemFactory.createItem(ItemList.seryllBar, 80+(20*Server.rand.nextFloat()), null);
|
||||
inv.insertItem(seryll, true);
|
||||
// Sleep powder
|
||||
Item sleepPowder = ItemFactory.createItem(ItemList.sleepPowder, 99f, null);
|
||||
inv.insertItem(sleepPowder, true);
|
||||
// Very low chance for a HotA statue.
|
||||
if(Server.rand.nextFloat()*100f <= 1f){
|
||||
Item hotaStatue = ItemFactory.createItem(ItemList.statueHota, 80f+(20f*Server.rand.nextFloat()), "");
|
||||
|
||||
@@ -3,6 +3,7 @@ package mod.sin.wyvern;
|
||||
import com.wurmonline.mesh.Tiles;
|
||||
import com.wurmonline.server.*;
|
||||
import com.wurmonline.server.bodys.Wound;
|
||||
import com.wurmonline.server.bodys.Wounds;
|
||||
import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.creatures.Creatures;
|
||||
import com.wurmonline.server.creatures.MineDoorPermission;
|
||||
@@ -675,6 +676,23 @@ public class Titans {
|
||||
}
|
||||
titanDamage.put(titan, currentDamage);
|
||||
}
|
||||
public static void pollTitanRegeneration(){
|
||||
if(!titans.isEmpty()) {
|
||||
for (Creature cret : titans) {
|
||||
if (cret.getBody().isWounded()) {
|
||||
Wounds tWounds = cret.getBody().getWounds();
|
||||
int toHeal = 2;
|
||||
Wound w = tWounds.getWounds()[Server.rand.nextInt(tWounds.getWounds().length)];
|
||||
if (w.getSeverity() > toHeal) {
|
||||
w.modifySeverity(-toHeal);
|
||||
break;
|
||||
} else {
|
||||
w.heal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void pollTitan(Creature titan){
|
||||
if(titanDamage.containsKey(titan)){
|
||||
int prevDamage = titanDamage.get(titan);
|
||||
@@ -687,6 +705,14 @@ public class Titans {
|
||||
titanDamage.put(titan, titan.getStatus().damage);
|
||||
}
|
||||
}
|
||||
public static void pollTitans(){
|
||||
for(Creature c : titans){
|
||||
if(isTitan(c)){
|
||||
pollTitan(c);
|
||||
}
|
||||
}
|
||||
pollTitanRegeneration();
|
||||
}
|
||||
|
||||
public static ArrayList<Creature> titans = new ArrayList<>();
|
||||
public static long lastPolledTitanSpawn = 0;
|
||||
@@ -764,7 +790,7 @@ public class Titans {
|
||||
int tiley = (int) (minY+(minY*2*Server.rand.nextFloat()))*4;*/
|
||||
int[] titanTemplates = {Lilith.templateId, Ifrit.templateId};
|
||||
try {
|
||||
Creature.doNew(titanTemplates[Server.rand.nextInt(titanTemplates.length)], spawnX, spawnY, 360f*Server.rand.nextFloat(), 1, "", (byte)0);
|
||||
Creature.doNew(titanTemplates[Server.rand.nextInt(titanTemplates.length)], spawnX, spawnY, 360f*Server.rand.nextFloat(), 0, "", (byte)0);
|
||||
lastSpawnedTitan = System.currentTimeMillis();
|
||||
updateLastSpawnedTitan();
|
||||
} catch (Exception e) {
|
||||
@@ -779,13 +805,6 @@ public class Titans {
|
||||
lastPolledTitanSpawn = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
public static void pollTitans(){
|
||||
for(Creature c : titans){
|
||||
if(isTitan(c)){
|
||||
pollTitan(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void preInit(){
|
||||
try {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.creatures.CreatureTemplate;
|
||||
import com.wurmonline.server.creatures.CreatureTemplateFactory;
|
||||
import com.wurmonline.server.items.*;
|
||||
import mod.sin.actions.items.SorcerySplitAction;
|
||||
import mod.sin.lib.Util;
|
||||
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
|
||||
import org.gotti.wurmunlimited.modloader.classhooks.HookException;
|
||||
@@ -112,9 +113,9 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
}
|
||||
}
|
||||
|
||||
/*public static void handleExamine(Creature performer, Item target) {
|
||||
public static void handleExamine(Creature performer, Item target) {
|
||||
// Im just not a smart man.
|
||||
if(target.isContainerLiquid()){
|
||||
/*if(target.isContainerLiquid()){
|
||||
boolean found = false;
|
||||
for(Item i : Items.getAllItems()){
|
||||
if(i == target){
|
||||
@@ -126,8 +127,8 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
}else{
|
||||
logger.info("Item not found.");
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}*/
|
||||
}
|
||||
|
||||
public void preInit() {
|
||||
logger.info("Pre-Initializing.");
|
||||
@@ -144,6 +145,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
MethodsBestiary.preInit();
|
||||
MissionCreator.preInit();
|
||||
CombatChanges.preInit();
|
||||
SkillChanges.preInit();
|
||||
MeditationPerks.preInit();
|
||||
MountedChanges.preInit();
|
||||
EconomicChanges.preInit();
|
||||
@@ -157,10 +159,10 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
Class<WyvernMods> thisClass = WyvernMods.class;
|
||||
ClassPool classPool = HookManager.getInstance().getClassPool();
|
||||
|
||||
/*Util.setReason("Insert examine method.");
|
||||
Util.setReason("Insert examine method.");
|
||||
CtClass ctItemBehaviour = classPool.get("com.wurmonline.server.behaviours.ItemBehaviour");
|
||||
String replace = WyvernMods.class.getName() + ".handleExamine($2, $3);";
|
||||
Util.insertAfterDeclared(thisClass, ctItemBehaviour, "examine", replace);*/
|
||||
Util.insertAfterDeclared(thisClass, ctItemBehaviour, "examine", replace);
|
||||
|
||||
// - Enable custom command handler - //
|
||||
CtClass ctCommunicator = classPool.get("com.wurmonline.server.creatures.Communicator");
|
||||
@@ -171,7 +173,6 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
+ "if(!mod.sin.wyvern.WyvernMods.customCommandHandler($1, this.player)){"
|
||||
+ " $_ = $proceed(tempBuffer);"
|
||||
+ "}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -207,6 +208,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
// Flavor Mobs:
|
||||
logger.info("Registering Flavor creatures.");
|
||||
ModCreatures.addCreature(new Avenger());
|
||||
ModCreatures.addCreature(new FireCrab());
|
||||
ModCreatures.addCreature(new ForestSpider());
|
||||
ModCreatures.addCreature(new Giant());
|
||||
ModCreatures.addCreature(new Charger());
|
||||
@@ -217,8 +219,8 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
// Event Mobs:
|
||||
logger.info("Registering Event creatures.");
|
||||
ModCreatures.addCreature(new IceCat());
|
||||
ModCreatures.addCreature(new FireCrab());
|
||||
ModCreatures.addCreature(new FireGiant());
|
||||
ModCreatures.addCreature(new GuardianMagranon());
|
||||
|
||||
// Bosses:
|
||||
logger.info("Registering Custom Boss creatures.");
|
||||
@@ -265,62 +267,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin(Player p) {
|
||||
Connection dbcon;
|
||||
PreparedStatement ps;
|
||||
boolean foundLeaderboardOpt = false;
|
||||
try {
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("SELECT * FROM LeaderboardOpt");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
if (!rs.getString("name").equals(p.getName())) continue;
|
||||
foundLeaderboardOpt = true;
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (!foundLeaderboardOpt) {
|
||||
logger.info("No leaderboard entry for "+p.getName()+". Creating one.");
|
||||
try {
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("INSERT INTO LeaderboardOpt (name) VALUES(\"" + p.getName() + "\")");
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
boolean foundPlayerStats = false;
|
||||
try {
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("SELECT * FROM PlayerStats");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
if (!rs.getString("NAME").equals(p.getName())) continue;
|
||||
foundPlayerStats = true;
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (!foundPlayerStats) {
|
||||
logger.info("No player stats entry for "+p.getName()+". Creating one.");
|
||||
try {
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("INSERT INTO PlayerStats (NAME) VALUES(\"" + p.getName() + "\")");
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
DatabaseHelper.onPlayerLogin(p);
|
||||
PlayerTitles.awardCustomTitles(p);
|
||||
}
|
||||
|
||||
@@ -340,6 +287,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
ModActions.registerAction(new ReceiveMailAction());
|
||||
ModActions.registerAction(new LeaderboardAction());
|
||||
ModActions.registerAction(new AddSubGroupAction());
|
||||
ModActions.registerAction(new SorcerySplitAction());
|
||||
logger.info("Registering Arena actions.");
|
||||
ModActions.registerAction(new SorceryCombineAction());
|
||||
//ModActions.registerAction(new VillageTeleportAction()); // [3/28/18] Disabled - Highway Portals added instead.
|
||||
@@ -348,85 +296,19 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
logger.info("Registering Dev actions.");
|
||||
ModActions.registerAction(new MissionAddAction());
|
||||
ModActions.registerAction(new MissionRemoveAction());
|
||||
ModActions.registerAction(new CreatureReportAction());
|
||||
ModActions.registerAction(new SmoothTerrainAction());
|
||||
logger.info("Setting custom creature corpse models.");
|
||||
MethodsBestiary.setTemplateVariables();
|
||||
/*if(Deities.getDeity(101) != null){ // Edit Breyk player god
|
||||
Deity breyk = Deities.getDeity(101);
|
||||
// Add some defining affinities
|
||||
breyk.repairer = true;
|
||||
breyk.learner = true;
|
||||
breyk.deathProtector = true;
|
||||
breyk.befriendCreature = true;
|
||||
// Remove some affinities
|
||||
breyk.warrior = false;
|
||||
breyk.healer = false;
|
||||
breyk.clayAffinity = false;
|
||||
}*/
|
||||
/*if(Deities.getDeity(102) != null){ // Edit Cyberhusky player god
|
||||
Deity cyberhusky = Deities.getDeity(102);
|
||||
// Add some defining affinities
|
||||
cyberhusky.hateGod = true;
|
||||
cyberhusky.allowsButchering = true;
|
||||
cyberhusky.warrior = true;
|
||||
// Remove some affinities
|
||||
cyberhusky.woodAffinity = false;
|
||||
cyberhusky.befriendCreature = false;
|
||||
}*/
|
||||
logger.info("Setting up Achievement templates.");
|
||||
AchievementChanges.onServerStarted();
|
||||
|
||||
DeityChanges.onServerStarted();
|
||||
|
||||
//espCounter = Servers.localServer.PVPSERVER; // Enables on PvP server by default.
|
||||
//espCounter = false;
|
||||
|
||||
SkillTemplate exorcism = SkillSystem.templates.get(SkillList.EXORCISM);
|
||||
int[] deps = {SkillList.GROUP_ALCHEMY};
|
||||
try {
|
||||
String newName = "Crystal handling";
|
||||
ReflectionUtil.setPrivateField(exorcism, ReflectionUtil.getField(exorcism.getClass(), "name"), newName);
|
||||
SkillSystem.skillNames.put(exorcism.getNumber(), newName);
|
||||
SkillSystem.namesToSkill.put(newName, exorcism.getNumber());
|
||||
ReflectionUtil.setPrivateField(exorcism, ReflectionUtil.getField(exorcism.getClass(), "dependencies"), deps);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to rename exorcism!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
SkillTemplate ballistae = SkillSystem.templates.get(SkillList.BALLISTA);
|
||||
int[] deps2 = {SkillList.GROUP_ALCHEMY};
|
||||
try {
|
||||
String newName = "Mystic components";
|
||||
ReflectionUtil.setPrivateField(ballistae, ReflectionUtil.getField(ballistae.getClass(), "name"), newName);
|
||||
SkillSystem.skillNames.put(ballistae.getNumber(), newName);
|
||||
SkillSystem.namesToSkill.put(newName, ballistae.getNumber());
|
||||
ReflectionUtil.setPrivateField(ballistae, ReflectionUtil.getField(ballistae.getClass(), "dependencies"), deps2);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to rename ballistae!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
SkillTemplate preaching = SkillSystem.templates.get(SkillList.PREACHING);
|
||||
int[] deps3 = {SkillList.MASONRY};
|
||||
try {
|
||||
String newName = "Gem augmentation";
|
||||
ReflectionUtil.setPrivateField(preaching, ReflectionUtil.getField(preaching.getClass(), "name"), newName);
|
||||
SkillSystem.skillNames.put(preaching.getNumber(), newName);
|
||||
SkillSystem.namesToSkill.put(newName, preaching.getNumber());
|
||||
ReflectionUtil.setPrivateField(preaching, ReflectionUtil.getField(preaching.getClass(), "dependencies"), deps3);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to rename preaching!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
SkillTemplate stealing = SkillSystem.templates.get(SkillList.STEALING);
|
||||
try {
|
||||
ReflectionUtil.setPrivateField(stealing, ReflectionUtil.getField(stealing.getClass(), "tickTime"), 0);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to set tickTime for stealing!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
SkillTemplate meditating = SkillSystem.templates.get(SkillList.MEDITATING);
|
||||
try {
|
||||
ReflectionUtil.setPrivateField(meditating, ReflectionUtil.getField(meditating.getClass(), "tickTime"), TimeConstants.HOUR_MILLIS);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
logger.info("Failed to set tickTime for meditating!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
meditating.setDifficulty(300f);
|
||||
SkillChanges.onServerStarted();
|
||||
|
||||
CreationEntry lockpicks = CreationMatrix.getInstance().getCreationEntry(ItemList.lockpick);
|
||||
try {
|
||||
@@ -437,88 +319,10 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Set mining difficulty down to be equivalent to digging.
|
||||
SkillTemplate mining = SkillSystem.templates.get(SkillList.MINING);
|
||||
mining.setDifficulty(3000f);
|
||||
// Triple lockpicking skill
|
||||
SkillTemplate lockpicking = SkillSystem.templates.get(SkillList.LOCKPICKING);
|
||||
lockpicking.setDifficulty(700f);
|
||||
} catch (IllegalArgumentException | ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Connection con = ModSupportDb.getModSupportDb();
|
||||
String sql;
|
||||
String tableName = "LeaderboardOpt";
|
||||
if (!ModSupportDb.hasTable(con, tableName)) {
|
||||
logger.info(tableName+" table not found in ModSupport. Creating table now.");
|
||||
sql = "CREATE TABLE "+tableName+" (\t\tname\t\t\t\tVARCHAR(30)\t\t\tNOT NULL DEFAULT 'Unknown',\t\tOPTIN\t\t\t\t\tINT\t\tNOT NULL DEFAULT 0)";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}
|
||||
tableName = "SteamIdMap";
|
||||
if (!ModSupportDb.hasTable(con, tableName)) {
|
||||
logger.info(tableName+" table not found in ModSupport. Creating table now.");
|
||||
sql = "CREATE TABLE "+tableName+" (\t\tNAME\t\t\t\tVARCHAR(30)\t\t\tNOT NULL DEFAULT 'Unknown',\t\tSTEAMID\t\t\t\t\tLONG\t\tNOT NULL DEFAULT 0)";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}
|
||||
tableName = "PlayerStats";
|
||||
if (!ModSupportDb.hasTable(con, tableName)) {
|
||||
logger.info(tableName+" table not found in ModSupport. Creating table now.");
|
||||
sql = "CREATE TABLE "+tableName+" (NAME VARCHAR(30) NOT NULL DEFAULT 'Unknown', KILLS INT NOT NULL DEFAULT 0, DEATHS INT NOT NULL DEFAULT 0, DEPOTS INT NOT NULL DEFAULT 0, HOTAS INT NOT NULL DEFAULT 0, TITANS INT NOT NULL DEFAULT 0, UNIQUES INT NOT NULL DEFAULT 0)";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}else{
|
||||
logger.info("Found "+tableName+". Checking if it has a unique column.");
|
||||
ResultSet rs = con.getMetaData().getColumns(null, null, tableName, "UNIQUES");
|
||||
if(rs.next()){
|
||||
logger.info(tableName+" already has a uniques column.");
|
||||
}else{
|
||||
logger.info("Detected no uniques column in "+tableName);
|
||||
sql = "ALTER TABLE "+tableName+" ADD COLUMN UNIQUES INT NOT NULL DEFAULT 0";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}
|
||||
}
|
||||
tableName = "ObjectiveTimers";
|
||||
if (!ModSupportDb.hasTable(con, tableName)) {
|
||||
logger.info(tableName+" table not found in ModSupport. Creating table now.");
|
||||
sql = "CREATE TABLE "+tableName+" (ID VARCHAR(30) NOT NULL DEFAULT 'Unknown', TIMER LONG NOT NULL DEFAULT 0)";
|
||||
PreparedStatement ps = con.prepareStatement(sql);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
try {
|
||||
Connection dbcon;
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("INSERT INTO ObjectiveTimers (ID, TIMER) VALUES(\"DEPOT\", 0)");
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
Connection dbcon;
|
||||
dbcon = ModSupportDb.getModSupportDb();
|
||||
ps = dbcon.prepareStatement("INSERT INTO ObjectiveTimers (ID, TIMER) VALUES(\"TITAN\", 0)");
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
SupplyDepots.initializeDepotTimer();
|
||||
Titans.initializeTitanTimer();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
DatabaseHelper.onServerStarted();
|
||||
}
|
||||
|
||||
public static long lastSecondPolled = 0;
|
||||
@@ -540,6 +344,8 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
public static final long pollUniqueRegenerationTime = TimeConstants.SECOND_MILLIS;
|
||||
public static long lastPolledUniqueCollection = 0;
|
||||
public static final long pollUniqueCollectionTime = TimeConstants.MINUTE_MILLIS*5;
|
||||
public static long lastPolledTerrainSmooth = 0;
|
||||
public static final long pollTerrainSmoothTime = TimeConstants.SECOND_MILLIS*5;
|
||||
@Override
|
||||
public void onServerPoll() {
|
||||
if((lastSecondPolled + TimeConstants.SECOND_MILLIS) < System.currentTimeMillis()){
|
||||
@@ -579,6 +385,10 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
CombatChanges.pollUniqueCollection();
|
||||
lastPolledUniqueCollection += pollUniqueCollectionTime;
|
||||
}
|
||||
if(lastPolledTerrainSmooth + pollTerrainSmoothTime < System.currentTimeMillis()){
|
||||
SmoothTerrainAction.onServerPoll();
|
||||
lastPolledTerrainSmooth += pollTerrainSmoothTime;
|
||||
}
|
||||
|
||||
// Update counter
|
||||
if(lastSecondPolled + TimeConstants.SECOND_MILLIS*10 > System.currentTimeMillis()){
|
||||
@@ -595,6 +405,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
lastPolledBloodlust = System.currentTimeMillis();
|
||||
lastPolledUniqueRegeneration = System.currentTimeMillis();
|
||||
lastPolledUniqueCollection = System.currentTimeMillis();
|
||||
lastPolledTerrainSmooth = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.wurmonline.mesh.Tiles;
|
||||
import com.wurmonline.server.Servers;
|
||||
import com.wurmonline.server.behaviours.AutoEquipMethods;
|
||||
import com.wurmonline.server.combat.Weapon;
|
||||
import com.wurmonline.server.creatures.*;
|
||||
import com.wurmonline.server.items.*;
|
||||
@@ -605,6 +607,11 @@ public class MethodsBestiary {
|
||||
// Goblin leader natural armour increase:
|
||||
setNaturalArmour(CreatureTemplate.GOBLIN_LEADER_CID, 0.055f);
|
||||
|
||||
// Worg armour reduction on Arena
|
||||
if(Servers.localServer.PVPSERVER) {
|
||||
setNaturalArmour(CreatureTemplate.WORG_CID, 0.3f);
|
||||
}
|
||||
|
||||
// Make titan minions drop no corpse
|
||||
setNoCorpse(IfritFiend.templateId);
|
||||
setNoCorpse(IfritSpider.templateId);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package mod.sin.wyvern.bounty;
|
||||
|
||||
import com.wurmonline.mesh.Tiles;
|
||||
import com.wurmonline.server.FailedException;
|
||||
import com.wurmonline.server.HistoryManager;
|
||||
import com.wurmonline.server.Players;
|
||||
import com.wurmonline.server.Server;
|
||||
import com.wurmonline.server.*;
|
||||
import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.creatures.CreatureTemplate;
|
||||
import com.wurmonline.server.creatures.CreatureTemplateFactory;
|
||||
@@ -311,6 +308,23 @@ public class LootBounty {
|
||||
boolean sendLootHelp = false;
|
||||
// Begin loot table drops
|
||||
int templateId = mob.getTemplate().getTemplateId();
|
||||
if(Servers.localServer.PVPSERVER && mob.isPlayer()){
|
||||
if(mob.isDeathProtected()) {
|
||||
logger.info("Death protection was active for " + mob.getName() + ". Inserting silver coin reward.");
|
||||
try {
|
||||
Item silver = ItemFactory.createItem(ItemList.coinSilver, 99f, null);
|
||||
corpse.insertItem(silver, true);
|
||||
} catch (FailedException | NoSuchTemplateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Item[] items = mob.getAllItems();
|
||||
for(Item item : items){
|
||||
if(item.isRepairable()){
|
||||
item.setDamage(Math.min(99f, item.getDamage() + Math.max(10f+(Server.rand.nextFloat()*5f), 10f * item.getDamageModifier(false))));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(templateId == Reaper.templateId || templateId == SpectralDrake.templateId){
|
||||
Server.getInstance().broadCastAlert("The "+mob.getName()+" has been slain. A new creature shall enter the realm shortly.");
|
||||
sendLootHelp = true;
|
||||
|
||||
@@ -216,7 +216,7 @@ public class PlayerBounty {
|
||||
try {
|
||||
//Map<Long, Long> attackers = ReflectionUtil.getPrivateField(creature, ReflectionUtil.getField(creature.getClass(), "attackers"));
|
||||
Map<Long, Long> attackers = Bounty.getAttackers(creature);
|
||||
if(!Bounty.isCombatant(attackers, player.getWurmId()) || creature.isPlayer() || creature.isReborn()){
|
||||
if((attackers != null && !Bounty.isCombatant(attackers, player.getWurmId())) || creature.isPlayer() || creature.isReborn()){
|
||||
return;
|
||||
}
|
||||
logger.info(player.getName()+" killed "+creature.getName());
|
||||
|
||||
@@ -92,6 +92,7 @@ public class Mastercraft {
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Home_Decorator", 600, "Home Decorator", "Home Decorator", -1, "NORMAL");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Arena_Champion", 601, "Champion of the Arena", "Champion of the Arena", -1, "NORMAL");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Pastamancer", 602, "Pastamancer", "Pastamancer", -1, "NORMAL");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Pizzamancer", 603, "Pizzamancer", "Pizzamancer", -1, "NORMAL");
|
||||
|
||||
// Special Event Titles
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Titan_Slayer", 700, "Titanslayer", "Titanslayer", -1, "NORMAL");
|
||||
|
||||
@@ -33,6 +33,14 @@ public class ItemUtil {
|
||||
ItemList.tomeMagicBlue,
|
||||
ItemList.tomeMagicWhite
|
||||
};
|
||||
public static boolean isSorcery(Item item){
|
||||
for(int id : sorceryIds){
|
||||
if(item.getTemplateId() == id){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static int[] plateChainTemplates = {
|
||||
ItemList.plateBoot,
|
||||
ItemList.plateGauntlet,
|
||||
@@ -266,4 +274,24 @@ public class ItemUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static boolean isSingleUseRune(byte rune){
|
||||
if(rune == -80){
|
||||
return true;
|
||||
}else if(rune == -81){
|
||||
return true;
|
||||
}else if(rune == -91){
|
||||
return true;
|
||||
}else if(rune == -97){
|
||||
return true;
|
||||
}else if(rune == -104){
|
||||
return true;
|
||||
}else if(rune == -107){
|
||||
return true;
|
||||
}else if(rune == -119){
|
||||
return true;
|
||||
}else if(rune == -126){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user