-
-
Save bdew/6a5dcf5cae9af73b5c28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tweak base player speed | |
CtClass ctMovementScheme = classPool.getCtClass("com.wurmonline.server.creatures.MovementScheme"); | |
ctMovementScheme.getMethod("getSpeedModifier", "()F").insertAfter("if ($_>0 && this.creature.isPlayer()) {" + | |
" $_ = $_ * 1.1;" + | |
"};"); | |
CtClass ctCreature = classPool.getCtClass("com.wurmonline.server.creatures.Creature"); | |
// Change max weight | |
// 10500 is the multiplier - base is 7000 | |
ctCreature.getMethod("getCarryingCapacityLeft", "()I").setBody("{ " + | |
" try {" + | |
" return (int)this.skills.getSkill(102).getKnowledge(0.0) * 10500 - this.carriedWeight;" + | |
" } catch (com.wurmonline.server.skills.NoSuchSkillException nss) {" + | |
" logger.log(java.util.logging.Level.WARNING, \"No strength skill for \" + this, (java.lang.Throwable)nss);" + | |
" return 0;" + | |
" }" + | |
"}"); | |
ctCreature.getMethod("canCarry", "(I)Z").setBody("{ return getCarryingCapacityLeft() > $1; }"); | |
ctCreature.getMethod("getCarryCapacityFor", "(I)I").setBody("{ return (int) getCarryingCapacityLeft() / $1; }"); | |
// Adjust encumbered thresholds | |
ctCreature.getMethod("setMoveLimits", "()V").insertAfter( | |
"this.cantmove = this.cantmove * 1.5;" + | |
"this.encumbered = this.cantmove * 0.9;" + | |
"this.moveslow = this.cantmove * 0.75;" | |
); | |
// ======== VEHICLE TWEAKS | |
// Parameters: | |
// * ID of Creature or Item template | |
// * Base speed (not sure what unit) | |
// * Min height of dirt under vehicle that can be traversed (max depth for carts/mounts) | |
// * Max height of dirt under vehicle that can be traversed (clearance for boats) | |
// * Max slope | |
// * Wind impact (boats only) | |
ModVehicleBehaviours.addCreatureVehicle(64, new VehicleOverride(40f, -1.5f, 2500.0f, 0.06f)); //horse | |
ModVehicleBehaviours.addCreatureVehicle(83, new VehicleOverride(45f, -1.5f, 2500.0f, 0.06f)); //hellhorse | |
ModVehicleBehaviours.addItemVehicle(539, new VehicleOverride(1.2f, -1.5f, 2500.0f, 0.06f)); // cart | |
ModVehicleBehaviours.addItemVehicle(850, new VehicleOverride(1.2f, -1.5f, 2500.0f, 0.06f)); // wagon | |
ModVehicleBehaviours.addItemVehicle(490, new VehicleOverride(8f, -2500.0f, -0.5f, 2000.0f, (byte) 10)); // rowboat | |
ModVehicleBehaviours.addItemVehicle(491, new VehicleOverride(5f, -2500.0f, -0.5f, 2000.0f, (byte) 30)); // sailboat | |
ModVehicleBehaviours.addItemVehicle(540, new VehicleOverride(5f, -2500.0f, -0.5f, 2000.0f, (byte) 40)); // cog | |
ModVehicleBehaviours.addItemVehicle(541, new VehicleOverride(5f, -2500.0f, -0.5f, 2000.0f, (byte) 40)); // corbita | |
ModVehicleBehaviours.addItemVehicle(542, new VehicleOverride(8f, -2500.0f, -0.5f, 2000.0f, (byte) 30)); // knarr | |
ModVehicleBehaviours.addItemVehicle(543, new VehicleOverride(5f, -2500.0f, -0.5f, 2000.0f, (byte) 40)); // caravel | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.wurmonline.server.behaviours; | |
import com.wurmonline.server.creatures.Creature; | |
import com.wurmonline.server.items.Item; | |
import net.bdew.wurm.server.ServerMod; | |
import org.gotti.wurmunlimited.modsupport.vehicles.ModVehicleBehaviour; | |
public class VehicleOverride extends ModVehicleBehaviour { | |
public float maxSpeed; | |
public float maxDepth; | |
public float maxHeight; | |
public float maxHeightDiff; | |
public byte windImpact; | |
static boolean DEBUG = false; | |
public VehicleOverride(float maxSpeed, float maxDepth, float maxHeight, float maxHeightDiff, byte windImpact) { | |
this.maxSpeed = maxSpeed; | |
this.maxDepth = maxDepth; | |
this.maxHeight = maxHeight; | |
this.maxHeightDiff = maxHeightDiff; | |
this.windImpact = windImpact; | |
} | |
public VehicleOverride(float maxSpeed, float maxDepth, float maxHeight, float maxHeightDiff) { | |
this(maxSpeed, maxDepth, maxHeight, maxHeightDiff, (byte) 0); | |
} | |
@Override | |
public void setSettingsForVehicle(Creature creature, Vehicle vehicle) { | |
if (DEBUG) { | |
ServerMod.logInfo("Applying mount mod for: " + creature.getName()); | |
ServerMod.logInfo("maxSpeed: " + vehicle.getMaxSpeed() + " -> " + maxSpeed); | |
ServerMod.logInfo("maxDepth: " + vehicle.getMaxDepth() + " -> " + maxDepth); | |
ServerMod.logInfo("maxHeight: " + vehicle.getMaxHeight() + " -> " + maxHeight); | |
ServerMod.logInfo("maxHeightDiff: " + vehicle.getMaxHeightDiff() + " -> " + maxHeightDiff); | |
ServerMod.logInfo("windImpact: " + vehicle.getWindImpact() + " -> " + windImpact); | |
} | |
vehicle.setMaxSpeed(maxSpeed); | |
vehicle.setMaxDepth(maxDepth); | |
vehicle.setMaxHeight(maxHeight); | |
vehicle.setMaxHeightDiff(maxHeightDiff); | |
} | |
@Override | |
public void setSettingsForVehicle(Item item, Vehicle vehicle) { | |
if (DEBUG) { | |
ServerMod.logInfo("Applying vehicle mod for: " + item.getName()); | |
ServerMod.logInfo("maxSpeed: " + vehicle.getMaxSpeed() + " -> " + maxSpeed); | |
ServerMod.logInfo("maxDepth: " + vehicle.getMaxDepth() + " -> " + maxDepth); | |
ServerMod.logInfo("maxHeight: " + vehicle.getMaxHeight() + " -> " + maxHeight); | |
ServerMod.logInfo("maxHeightDiff: " + vehicle.getMaxHeightDiff() + " -> " + maxHeightDiff); | |
ServerMod.logInfo("windImpact: " + vehicle.getWindImpact() + " -> " + windImpact); | |
} | |
vehicle.setMaxSpeed(maxSpeed); | |
vehicle.setMaxDepth(maxDepth); | |
vehicle.setMaxHeight(maxHeight); | |
vehicle.setMaxHeightDiff(maxHeightDiff); | |
vehicle.setWindImpact(windImpact); | |
vehicle.setMaxAllowedLoadDistance(10); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment