Rewrote all the logic, encoding, etc for player/npc rendering masks (Animations, force movements, etc.)

Groundwork for modular 578 support has now been laid (at least in regards to render masks)
Introduced an improved and more accurate API for using force movement (the old API is still around, all of its methods marked as deprecated)
Converted a couple example cases to using the new force movement API just as a proof of concept
Added a method to tick/time conversion methods to convert between client cycles and ticks
Added all authentically-named buffer read/write methods to the buffer class
This commit is contained in:
Ceikry
2023-05-25 14:58:40 +00:00
committed by Ryan
parent 9329d9d008
commit 2cb8d82648
58 changed files with 963 additions and 1259 deletions
@@ -9,7 +9,7 @@ import core.game.node.item.Item
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.update.flag.context.ChatMessage
import core.game.world.update.flag.player.ChatFlag
import core.game.world.update.flag.*
import core.integrations.discord.Discord
import org.json.simple.JSONArray
import org.json.simple.JSONObject
@@ -132,14 +132,14 @@ class DoublingMoney : Script() {
val message = arrayOf("Doubling Money", "Doubling Money", "Doubling Money!", "Doubling moneyy").random()
val messageEffect = arrayOf(0, 256).random()
val ctx = ChatMessage(bot, message, messageEffect, message.length)
bot.updateMasks.register(ChatFlag(ctx))
bot.updateMasks.register(EntityFlag.Chat, ctx)
sleepTime = 8
}
Effort.VERY_HIGH -> {
val message = arrayOf("Doubling money!", "Doubling money").random()
val messageEffect = arrayOf(771, 2818, 2562, 768, 512, 2304, 2560, 769, 1792).random()
val ctx = ChatMessage(bot, message, messageEffect, message.length)
bot.updateMasks.register(ChatFlag(ctx))
bot.updateMasks.register(EntityFlag.Chat, ctx)
sleepTime = 9
}
}
@@ -198,7 +198,7 @@ class DoublingMoney : Script() {
if (botTradeModule.getInterface() == TradeModule.ACCEPT_INTERFACE && coinsFromBot > 0 && effort == Effort.VERY_HIGH) {
val message = "Payed ${(if (coinsFromBot < 1000) "${coinsFromBot}gp" else "${coinsFromBot / 1000}k")}"
val ctx = ChatMessage(bot, message, 512, message.length)
bot.updateMasks.register(ChatFlag(ctx))
bot.updateMasks.register(EntityFlag.Chat, ctx)
sleepTime = 7
}
@@ -325,7 +325,7 @@ class DoublingMoney : Script() {
if (effort == Effort.VERY_HIGH) {
val message = "Received ${(if (coins.amount < 1000) "${coins.amount}gp" else "${coins.amount / 1000}k")}"
val ctx = ChatMessage(bot, message, 256, message.length)
bot.updateMasks.register(ChatFlag(ctx))
bot.updateMasks.register(EntityFlag.Chat, ctx)
}
}
@@ -9,7 +9,6 @@ import core.game.system.task.Pulse
import core.game.world.GameWorld
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.player.FaceLocationFlag
import core.plugin.Initializable
import core.plugin.Plugin
@@ -136,7 +135,7 @@ class BasaltRockShortcut : AgilityShortcut {
player.sendMessage(noJump)
} else {
player.lock(3)
player.faceLocation(FaceLocationFlag.getFaceLocation(player, Location.create(2518, 3611, 0)))
player.faceLocation(Location.create(2518, 3611, 0))
AgilityHandler.forceWalk(player, -1, Location.create(2516, 3611, 0), Location.create(2518, 3611, 0), Animation.create(769), 20, 0.0, null, 1)
}
return true
@@ -147,7 +146,7 @@ class BasaltRockShortcut : AgilityShortcut {
player.sendMessage(noJump)
} else {
player.lock(3)
player.faceLocation(FaceLocationFlag.getFaceLocation(player, Location.create(2516, 3611, 0)))
player.faceLocation(Location.create(2516, 3611, 0))
AgilityHandler.forceWalk(player, -1, Location.create(2518, 3611, 0), Location.create(2516, 3611, 0), Animation.create(769), 20, 0.0, null, 1)
}
return true
@@ -199,4 +198,4 @@ class BasaltRockShortcut : AgilityShortcut {
}
})
}
}
}
@@ -12,7 +12,6 @@ import core.game.node.scenery.SceneryBuilder;
import core.game.world.GameWorld;
import core.game.world.map.RegionManager;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.player.FaceLocationFlag;
import core.tools.RandomFunction;
/**
@@ -129,7 +128,7 @@ public final class FireMakingPulse extends SkillPulse<Item> {
SceneryBuilder.add(object, fire.getLife(), getAsh(player, fire, object));
GroundItemManager.destroy(groundItem);
player.moveStep();
player.faceLocation(FaceLocationFlag.getFaceLocation(player, object));
player.faceLocation(object.getFaceLocation(player.getLocation()));
player.getSkills().addExperience(Skills.FIREMAKING,fire.getXp());
int playerRegion = player.getViewport().getRegion().getId();
@@ -191,4 +190,4 @@ public final class FireMakingPulse extends SkillPulse<Item> {
}
return false;
}
}
}
@@ -4,7 +4,6 @@ import core.cache.def.impl.NPCDefinition;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.player.Player;
import core.game.world.update.flag.player.FaceLocationFlag;
import core.plugin.Initializable;
import core.plugin.Plugin;
@@ -39,7 +38,7 @@ public final class FamiliarNPCOptionPlugin extends OptionHandler {
}
switch (option) {
case "pick-up":
player.faceLocation(FaceLocationFlag.getFaceLocation(player, familiar));
player.faceLocation(familiar.getFaceLocation(player.getLocation()));
player.getFamiliarManager().pickup();
break;
case "interact-with":
@@ -12,7 +12,6 @@ import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.map.RegionManager;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.player.FaceLocationFlag;
import core.plugin.Initializable;
import core.plugin.Plugin;
import core.plugin.ClassScanner;
@@ -153,7 +152,7 @@ public class ForgeRegentNPC extends Familiar {
familiar.moveStep();
GroundItemManager.destroy(ground);
player.getSkills().addExperience(Skills.FIREMAKING, log.getXp() + 10);
familiar.faceLocation(FaceLocationFlag.getFaceLocation(familiar, object));
familiar.faceLocation(object.getFaceLocation(familiar.getLocation()));
SceneryBuilder.add(object, log.getLife(), FireMakingPulse.getAsh(player, log, object));
if (player.getViewport().getRegion().getId() == 10806) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 1, 9);
@@ -21,7 +21,6 @@ import core.game.world.GameWorld;
import core.game.world.map.RegionManager;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.game.world.update.flag.player.FaceLocationFlag;
import core.plugin.Plugin;
import core.plugin.ClassScanner;
@@ -132,7 +131,7 @@ public class PyreLordNPC extends Familiar {
familiar.moveStep();
GroundItemManager.destroy(ground);
player.getSkills().addExperience(Skills.FIREMAKING, log.getXp() + 10);
familiar.faceLocation(FaceLocationFlag.getFaceLocation(familiar, object));
familiar.faceLocation(object.getFaceLocation(familiar.getLocation()));
SceneryBuilder.add(object, log.getLife(), FireMakingPulse.getAsh(player, log, object));
if (player.getViewport().getRegion().getId() == 10806) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 1, 9);
@@ -38,6 +38,7 @@ import core.tools.RandomFunction;
import static core.api.ContentAPIKt.animateScenery;
import static core.api.ContentAPIKt.submitWorldPulse;
import static core.api.ContentAPIKt.animationDuration;
import static core.api.ContentAPIKt.forceMove;
/**
* Handles the puro puro activity.
@@ -161,13 +162,7 @@ public final class PuroPuroPlugin extends MapZone implements Plugin<Object> {
player.sendMessage("You use your strength to push through the wheat. It's hard work though.");
}
player.setAttribute("cantMove", true);
GameWorld.getPulser().submit(new Pulse(1) {
@Override
public boolean pulse() {
ForceMovement.run(player, player.getLocation(), dest, Animation.create(6594), Animation.create(6594), Direction.getLogicalDirection(player.getLocation(), object.getLocation()), 3, 3);
return true;
}
});
forceMove(player, player.getLocation(), dest, 0, 265, null, 6595, null);
}
/**
@@ -85,22 +85,7 @@ class TreeGnomeVillageListeners : InteractionListener {
return@on true
}
on(looseRailing, IntType.SCENERY, "squeeze-through"){ player, _ ->
if(player.location != location(2516,3161,0)) {
squeezeThrough(player)
} else {
player.pulseManager.run(object : Pulse(0) {
var count = 0
override fun pulse(): Boolean {
when (count) {
0 -> ForceMovement.run(player,player.location,player.location.transform(Direction.WEST,1))
2 -> squeezeThrough(player)
3 -> return true
}
count++
return false
}
})
}
squeezeThrough(player)
return@on true
}
on(crumbledWall, IntType.SCENERY, "climb-over"){ player, _ ->
@@ -132,71 +117,55 @@ class TreeGnomeVillageListeners : InteractionListener {
return@on true
}
}
}
fun squeezeThrough(player: Player){
val squeezeAnim = Animation.create(3844)
if(player.location.y >= 3161) {
AgilityHandler.forceWalk(
player,
-1,
player.location,
player.location.transform(Direction.SOUTH, 1),
squeezeAnim,
5,
0.0,
null
)
} else {
AgilityHandler.forceWalk(
player,
-1,
player.location,
player.location.transform(Direction.NORTH, 1),
squeezeAnim,
5,
0.0,
null
)
fun squeezeThrough(player: Player){
val squeezeAnim = Animation.create(3844)
var dest = if (player.location.y >= 3161)
player.location.transform(Direction.SOUTH, 1)
else
player.location.transform(Direction.NORTH, 1)
forceMove(player, player.location, dest, 0, 80, anim = 3844)
}
}
private class ClimbWall : DialogueFile() {
val climbAnimation = Animation(839)
val wallLoc = Location(2509,3253,0)
override fun handle(componentID: Int, buttonID: Int) {
if(questStage(player!!, TreeGnomeVillage.questName) > 30){
val northSouth = if (player!!.location.y <= wallLoc.y) Direction.NORTH else Direction.SOUTH
when(stage){
0 -> sendDialogue(player!!,"The wall has been reduced to rubble. It should be possible to climb over the remains").also{ stage++ }
1 -> AgilityHandler.forceWalk(player!!, -1, player!!.location, player!!.location.transform(northSouth, 2), climbAnimation, 20, 0.0, null).also {
end()
if(northSouth == Direction.SOUTH) return
val lowerGuard: NPC = RegionManager.getNpc(player!!.location, NPCs.KHAZARD_COMMANDER_478, 6) ?: return
GameWorld.Pulser.submit(object : Pulse(0) {
var count = 0
override fun pulse(): Boolean {
when (count) {
0 -> {
player!!.lock(4)
lowerGuard.sendChat("What? How did you manage to get in here.")
}
2 -> {
player!!.sendChat("I've come for the orb.")
}
3 -> {
lowerGuard.sendChat("I'll never let you take it.")
lowerGuard.attack(player)
player!!.unlock()
return true
private class ClimbWall : DialogueFile() {
val climbAnimation = Animation(839)
val wallLoc = Location(2509,3253,0)
override fun handle(componentID: Int, buttonID: Int) {
if(questStage(player!!, TreeGnomeVillage.questName) > 30){
val northSouth = if (player!!.location.y <= wallLoc.y) Direction.NORTH else Direction.SOUTH
when(stage){
0 -> sendDialogue(player!!,"The wall has been reduced to rubble. It should be possible to climb over the remains").also{ stage++ }
1 -> AgilityHandler.forceWalk(player!!, -1, player!!.location, player!!.location.transform(northSouth, 2), climbAnimation, 20, 0.0, null).also {
end()
if(northSouth == Direction.SOUTH) return
val lowerGuard: NPC = RegionManager.getNpc(player!!.location, NPCs.KHAZARD_COMMANDER_478, 6) ?: return
GameWorld.Pulser.submit(object : Pulse(0) {
var count = 0
override fun pulse(): Boolean {
when (count) {
0 -> {
player!!.lock(4)
lowerGuard.sendChat("What? How did you manage to get in here.")
}
2 -> {
player!!.sendChat("I've come for the orb.")
}
3 -> {
lowerGuard.sendChat("I'll never let you take it.")
lowerGuard.attack(player)
player!!.unlock()
return true
}
}
count++
return false
}
count++
return false
}
})
})
}
}
}
}
}
}
}
@@ -9,7 +9,6 @@ import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.update.flag.context.Animation;
import core.plugin.Initializable;
import core.game.world.update.flag.player.FaceLocationFlag;
/**
* Represents the dialogue plugin used for mithril seeds.
@@ -64,7 +63,7 @@ public final class MithrilSeedsDialogue extends DialoguePlugin {
switch (buttonId) {
case 1: // First option
player.lock(2);
player.faceLocation(FaceLocationFlag.getFaceLocation(player, flower));
player.faceLocation(flower.getFaceLocation(player.getLocation()));
player.animate(ANIMATION);
GameWorld.getPulser().submit(new Pulse(2, player, flower) {
@Override
@@ -11,7 +11,6 @@ import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.map.RegionManager;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.player.FaceLocationFlag;
import core.plugin.Initializable;
import core.plugin.Plugin;
import core.tools.RandomFunction;
@@ -67,7 +66,7 @@ public final class MithrilSeedsPlugin extends OptionHandler {
player.getPulseManager().run(new Pulse(1, player) {
@Override
public boolean pulse() {
player.faceLocation(FaceLocationFlag.getFaceLocation(player, object));
player.faceLocation(object.getFaceLocation(player.getLocation()));
player.getDialogueInterpreter().open(1 << 16 | 1, object);
return true;
}
@@ -29,7 +29,6 @@ import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.map.zone.ZoneBorders;
import core.game.world.map.zone.ZoneRestriction;
import core.game.world.update.flag.player.AppearanceFlag;
import core.tools.RandomFunction;
/**
@@ -140,7 +139,7 @@ public final class TzhaarFightPitsPlugin extends ActivityPlugin {
lastVictor.getAchievementDiaryManager().finishTask(lastVictor, DiaryType.KARAMJA, 2, 0);
addTokkul(lastVictor);
lastVictor.getAppearance().setSkullIcon(SKULL_ID);
lastVictor.getUpdateMasks().register(new AppearanceFlag(lastVictor));
lastVictor.updateAppearance();
lastVictor.getPacketDispatch().sendString("Current Champion: " + getChampionName(), INTERFACE_ID, 0);
resetDamagePulse(lastVictor);
}
@@ -158,7 +157,7 @@ public final class TzhaarFightPitsPlugin extends ActivityPlugin {
player.getInteraction().remove(Option._P_ATTACK);
if (player.getAppearance().getSkullIcon() == SKULL_ID) {
player.getAppearance().setSkullIcon(-1);
player.getUpdateMasks().register(new AppearanceFlag(player));
player.updateAppearance();
}
}
}
@@ -190,7 +189,7 @@ public final class TzhaarFightPitsPlugin extends ActivityPlugin {
}
if (lastVictor.getAppearance().getSkullIcon() == SKULL_ID) {
player.getAppearance().setSkullIcon(-1);
player.getUpdateMasks().register(new AppearanceFlag(player));
player.updateAppearance();
}
}
@@ -238,7 +237,7 @@ public final class TzhaarFightPitsPlugin extends ActivityPlugin {
}
if (e instanceof Player && (player = (Player) e).getAppearance().getSkullIcon() == SKULL_ID) {
player.getAppearance().setSkullIcon(-1);
player.getUpdateMasks().register(new AppearanceFlag(player));
player.updateAppearance();
}
return super.leave(e, logout);
}