mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Add support for overridding movement animations
This commit is contained in:
@@ -0,0 +1,194 @@
|
|||||||
|
package org.apollo.game.model.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of animations for {@link Player}s. Contains animations such as standing, turning, running, etc.
|
||||||
|
*
|
||||||
|
* @author Steve Soltys
|
||||||
|
*/
|
||||||
|
public class AnimationMap {
|
||||||
|
/**
|
||||||
|
* The default animation set for {@link Player}s.
|
||||||
|
*/
|
||||||
|
public static final AnimationMap DEFAULT_ANIMATION_SET = new AnimationMap(0x328, 0x337, 0x333, 0x334, 0x335, 0x336, 0x338);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animation for standing in place.
|
||||||
|
*/
|
||||||
|
private int stand;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animation for turning while idle.
|
||||||
|
*/
|
||||||
|
private int idleTurn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animation for walking.
|
||||||
|
*/
|
||||||
|
private int walking;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animation for turning 180 degrees.
|
||||||
|
*/
|
||||||
|
private int turnAround;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animation for turning 90 degrees right.
|
||||||
|
*/
|
||||||
|
private int turnRight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animation for turning 90 degrees left.
|
||||||
|
*/
|
||||||
|
private int turnLeft;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The animation for running.
|
||||||
|
*/
|
||||||
|
private int running;
|
||||||
|
|
||||||
|
public AnimationMap(int stand, int idleTurn, int walking, int turnAround, int turnRight, int turnLeft, int running) {
|
||||||
|
this.stand = stand;
|
||||||
|
this.idleTurn = idleTurn;
|
||||||
|
this.walking = walking;
|
||||||
|
this.turnAround = turnAround;
|
||||||
|
this.turnRight = turnRight;
|
||||||
|
this.turnLeft = turnLeft;
|
||||||
|
this.running = running;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicates this animation set.
|
||||||
|
*
|
||||||
|
* @return the duplicated animation set.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AnimationMap clone() {
|
||||||
|
return new AnimationMap(stand, idleTurn, walking, turnAround, turnRight, turnLeft, running);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation for standing in place.
|
||||||
|
*
|
||||||
|
* @return the animation.
|
||||||
|
*/
|
||||||
|
public int getStand() {
|
||||||
|
return stand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animation for standing in place.
|
||||||
|
*
|
||||||
|
* @param stand the animation.
|
||||||
|
*/
|
||||||
|
public void setStand(int stand) {
|
||||||
|
this.stand = stand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation for turning while idle.
|
||||||
|
*
|
||||||
|
* @return the animation.
|
||||||
|
*/
|
||||||
|
public int getIdleTurn() {
|
||||||
|
return idleTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animation for standing in place.
|
||||||
|
*
|
||||||
|
* @param idleTurn the animation.
|
||||||
|
*/
|
||||||
|
public void setIdleTurn(int idleTurn) {
|
||||||
|
this.idleTurn = idleTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation for walking.
|
||||||
|
*
|
||||||
|
* @return the animation.
|
||||||
|
*/
|
||||||
|
public int getWalking() {
|
||||||
|
return walking;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animation for walking.
|
||||||
|
*
|
||||||
|
* @param walking the animation.
|
||||||
|
*/
|
||||||
|
public void setWalking(int walking) {
|
||||||
|
this.walking = walking;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation for turning 180 degrees.
|
||||||
|
*
|
||||||
|
* @return the animation.
|
||||||
|
*/
|
||||||
|
public int getTurnAround() {
|
||||||
|
return turnAround;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animation for turning 180 degrees.
|
||||||
|
*
|
||||||
|
* @param turnAround the animation.
|
||||||
|
*/
|
||||||
|
public void setTurnAround(int turnAround) {
|
||||||
|
this.turnAround = turnAround;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation for turning 90 degrees right.
|
||||||
|
*
|
||||||
|
* @return the animation.
|
||||||
|
*/
|
||||||
|
public int getTurnRight() {
|
||||||
|
return turnRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animation for turning 90 degrees right.
|
||||||
|
*
|
||||||
|
* @param turnRight the animation.
|
||||||
|
*/
|
||||||
|
public void setTurnRight(int turnRight) {
|
||||||
|
this.turnRight = turnRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation for turning 90 degrees left.
|
||||||
|
*
|
||||||
|
* @return the animation.
|
||||||
|
*/
|
||||||
|
public int getTurnLeft() {
|
||||||
|
return turnLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animation for turning 90 degrees left.
|
||||||
|
*
|
||||||
|
* @param turnLeft the animation.
|
||||||
|
*/
|
||||||
|
public void setTurnLeft(int turnLeft) {
|
||||||
|
this.turnLeft = turnLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation for running.
|
||||||
|
*
|
||||||
|
* @return the animation.
|
||||||
|
*/
|
||||||
|
public int getRunning() {
|
||||||
|
return running;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the animation for running.
|
||||||
|
*
|
||||||
|
* @param running the animation.
|
||||||
|
*/
|
||||||
|
public void setRunning(int running) {
|
||||||
|
this.running = running;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,6 +64,11 @@ import org.apollo.util.security.PlayerCredentials;
|
|||||||
*/
|
*/
|
||||||
public final class Player extends Mob {
|
public final class Player extends Mob {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code Mob}s current set of animations used in appearance updates.
|
||||||
|
*/
|
||||||
|
private AnimationMap animations = AnimationMap.DEFAULT_ANIMATION_SET;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default viewing distance, in tiles.
|
* The default viewing distance, in tiles.
|
||||||
*/
|
*/
|
||||||
@@ -317,6 +322,15 @@ public final class Player extends Mob {
|
|||||||
return friends.contains(username.toLowerCase());
|
return friends.contains(username.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current set of animations used for character movement.
|
||||||
|
*
|
||||||
|
* @return The animation set.
|
||||||
|
*/
|
||||||
|
public final AnimationMap getAnimations() {
|
||||||
|
return animations;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player's appearance.
|
* Gets the player's appearance.
|
||||||
*
|
*
|
||||||
@@ -797,6 +811,15 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the set of animations to use in {@code Mob} appearance updates.
|
||||||
|
*
|
||||||
|
* @param animations The set of animations to use.
|
||||||
|
*/
|
||||||
|
public final void setAnimations(AnimationMap animations) {
|
||||||
|
this.animations = animations;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the player's appearance.
|
* Sets the player's appearance.
|
||||||
*
|
*
|
||||||
|
|||||||
+9
-7
@@ -9,6 +9,7 @@ import org.apollo.game.model.Graphic;
|
|||||||
import org.apollo.game.model.Item;
|
import org.apollo.game.model.Item;
|
||||||
import org.apollo.game.model.Position;
|
import org.apollo.game.model.Position;
|
||||||
import org.apollo.game.model.entity.EquipmentConstants;
|
import org.apollo.game.model.entity.EquipmentConstants;
|
||||||
|
import org.apollo.game.model.entity.AnimationMap;
|
||||||
import org.apollo.game.model.entity.setting.Gender;
|
import org.apollo.game.model.entity.setting.Gender;
|
||||||
import org.apollo.game.model.inv.Inventory;
|
import org.apollo.game.model.inv.Inventory;
|
||||||
import org.apollo.game.sync.block.AnimationBlock;
|
import org.apollo.game.sync.block.AnimationBlock;
|
||||||
@@ -207,13 +208,14 @@ public final class PlayerSynchronizationMessageEncoder extends MessageEncoder<Pl
|
|||||||
playerProperties.put(DataType.BYTE, color);
|
playerProperties.put(DataType.BYTE, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerProperties.put(DataType.SHORT, 0x328); // stand
|
AnimationMap animations = block.getAnimations();
|
||||||
playerProperties.put(DataType.SHORT, 0x337); // stand turn
|
playerProperties.put(DataType.SHORT, animations.getStand()); // stand
|
||||||
playerProperties.put(DataType.SHORT, 0x333); // walk
|
playerProperties.put(DataType.SHORT, animations.getIdleTurn()); // stand turn
|
||||||
playerProperties.put(DataType.SHORT, 0x334); // turn 180
|
playerProperties.put(DataType.SHORT, animations.getWalking()); // walk
|
||||||
playerProperties.put(DataType.SHORT, 0x335); // turn 90 cw
|
playerProperties.put(DataType.SHORT, animations.getTurnAround()); // turn 180
|
||||||
playerProperties.put(DataType.SHORT, 0x336); // turn 90 ccw
|
playerProperties.put(DataType.SHORT, animations.getTurnRight()); // turn 90 cw
|
||||||
playerProperties.put(DataType.SHORT, 0x338); // run
|
playerProperties.put(DataType.SHORT, animations.getTurnLeft()); // turn 90 ccw
|
||||||
|
playerProperties.put(DataType.SHORT, animations.getRunning()); // run
|
||||||
|
|
||||||
playerProperties.put(DataType.LONG, block.getName());
|
playerProperties.put(DataType.LONG, block.getName());
|
||||||
playerProperties.put(DataType.BYTE, block.getCombatLevel());
|
playerProperties.put(DataType.BYTE, block.getCombatLevel());
|
||||||
|
|||||||
+13
-34
@@ -2,36 +2,14 @@ package org.apollo.game.release.r377;
|
|||||||
|
|
||||||
import org.apollo.cache.def.EquipmentDefinition;
|
import org.apollo.cache.def.EquipmentDefinition;
|
||||||
import org.apollo.game.message.impl.PlayerSynchronizationMessage;
|
import org.apollo.game.message.impl.PlayerSynchronizationMessage;
|
||||||
import org.apollo.game.model.Animation;
|
import org.apollo.game.model.*;
|
||||||
import org.apollo.game.model.Appearance;
|
|
||||||
import org.apollo.game.model.Direction;
|
|
||||||
import org.apollo.game.model.Graphic;
|
|
||||||
import org.apollo.game.model.Item;
|
|
||||||
import org.apollo.game.model.Position;
|
|
||||||
import org.apollo.game.model.entity.EquipmentConstants;
|
import org.apollo.game.model.entity.EquipmentConstants;
|
||||||
|
import org.apollo.game.model.entity.AnimationMap;
|
||||||
import org.apollo.game.model.entity.setting.Gender;
|
import org.apollo.game.model.entity.setting.Gender;
|
||||||
import org.apollo.game.model.inv.Inventory;
|
import org.apollo.game.model.inv.Inventory;
|
||||||
import org.apollo.game.sync.block.AnimationBlock;
|
import org.apollo.game.sync.block.*;
|
||||||
import org.apollo.game.sync.block.AppearanceBlock;
|
import org.apollo.game.sync.seg.*;
|
||||||
import org.apollo.game.sync.block.ChatBlock;
|
import org.apollo.net.codec.game.*;
|
||||||
import org.apollo.game.sync.block.ForceChatBlock;
|
|
||||||
import org.apollo.game.sync.block.ForceMovementBlock;
|
|
||||||
import org.apollo.game.sync.block.GraphicBlock;
|
|
||||||
import org.apollo.game.sync.block.HitUpdateBlock;
|
|
||||||
import org.apollo.game.sync.block.InteractingMobBlock;
|
|
||||||
import org.apollo.game.sync.block.SecondaryHitUpdateBlock;
|
|
||||||
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
|
||||||
import org.apollo.game.sync.block.TurnToPositionBlock;
|
|
||||||
import org.apollo.game.sync.seg.AddPlayerSegment;
|
|
||||||
import org.apollo.game.sync.seg.MovementSegment;
|
|
||||||
import org.apollo.game.sync.seg.SegmentType;
|
|
||||||
import org.apollo.game.sync.seg.SynchronizationSegment;
|
|
||||||
import org.apollo.game.sync.seg.TeleportSegment;
|
|
||||||
import org.apollo.net.codec.game.DataOrder;
|
|
||||||
import org.apollo.net.codec.game.DataTransformation;
|
|
||||||
import org.apollo.net.codec.game.DataType;
|
|
||||||
import org.apollo.net.codec.game.GamePacket;
|
|
||||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
|
||||||
import org.apollo.net.meta.PacketType;
|
import org.apollo.net.meta.PacketType;
|
||||||
import org.apollo.net.release.MessageEncoder;
|
import org.apollo.net.release.MessageEncoder;
|
||||||
|
|
||||||
@@ -208,13 +186,14 @@ public final class PlayerSynchronizationMessageEncoder extends MessageEncoder<Pl
|
|||||||
playerProperties.put(DataType.BYTE, color);
|
playerProperties.put(DataType.BYTE, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerProperties.put(DataType.SHORT, 0x328); // stand
|
AnimationMap animations = block.getAnimations();
|
||||||
playerProperties.put(DataType.SHORT, 0x337); // stand turn
|
playerProperties.put(DataType.SHORT, animations.getStand()); // stand
|
||||||
playerProperties.put(DataType.SHORT, 0x333); // walk
|
playerProperties.put(DataType.SHORT, animations.getIdleTurn()); // stand turn
|
||||||
playerProperties.put(DataType.SHORT, 0x334); // turn 180
|
playerProperties.put(DataType.SHORT, animations.getWalking()); // walk
|
||||||
playerProperties.put(DataType.SHORT, 0x335); // turn 90 cw
|
playerProperties.put(DataType.SHORT, animations.getTurnAround()); // turn 180
|
||||||
playerProperties.put(DataType.SHORT, 0x336); // turn 90 ccw
|
playerProperties.put(DataType.SHORT, animations.getTurnRight()); // turn 90 cw
|
||||||
playerProperties.put(DataType.SHORT, 0x338); // run
|
playerProperties.put(DataType.SHORT, animations.getTurnLeft()); // turn 90 ccw
|
||||||
|
playerProperties.put(DataType.SHORT, animations.getRunning()); // run
|
||||||
|
|
||||||
playerProperties.put(DataType.LONG, block.getName());
|
playerProperties.put(DataType.LONG, block.getName());
|
||||||
playerProperties.put(DataType.BYTE, block.getCombatLevel());
|
playerProperties.put(DataType.BYTE, block.getCombatLevel());
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.apollo.game.sync.block;
|
package org.apollo.game.sync.block;
|
||||||
|
|
||||||
import org.apollo.game.model.Appearance;
|
import org.apollo.game.model.Appearance;
|
||||||
|
import org.apollo.game.model.entity.AnimationMap;
|
||||||
import org.apollo.game.model.inv.Inventory;
|
import org.apollo.game.model.inv.Inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,6 +11,11 @@ import org.apollo.game.model.inv.Inventory;
|
|||||||
*/
|
*/
|
||||||
public final class AppearanceBlock extends SynchronizationBlock {
|
public final class AppearanceBlock extends SynchronizationBlock {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The player's movement animations.
|
||||||
|
*/
|
||||||
|
private final AnimationMap animations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player's appearance.
|
* The player's appearance.
|
||||||
*/
|
*/
|
||||||
@@ -53,32 +59,35 @@ public final class AppearanceBlock extends SynchronizationBlock {
|
|||||||
/**
|
/**
|
||||||
* Creates the appearance block. Assumes that the player is not appearing as an npc.
|
* Creates the appearance block. Assumes that the player is not appearing as an npc.
|
||||||
*
|
*
|
||||||
* @param name The player's username, encoded to base 37.
|
* @param name The player's username, encoded to base 37.
|
||||||
* @param appearance The {@link Appearance}.
|
* @param appearance The {@link Appearance}.
|
||||||
* @param combat The player's combat.
|
* @param combat The player's combat.
|
||||||
* @param skill The player's skill, or 0 if showing the combat level.
|
* @param skill The player's skill, or 0 if showing the combat level.
|
||||||
* @param equipment The player's equipment.
|
* @param equipment The player's equipment.
|
||||||
* @param headIcon The head icon id of the player.
|
* @param headIcon The head icon id of the player.
|
||||||
* @param isSkulled Whether or not the player is skulled.
|
* @param isSkulled Whether or not the player is skulled.
|
||||||
|
* @param animations
|
||||||
*/
|
*/
|
||||||
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int headIcon, boolean isSkulled) {
|
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int headIcon, boolean isSkulled, AnimationMap animations) {
|
||||||
this(name, appearance, combat, skill, equipment, headIcon, isSkulled, -1);
|
this(name, animations, appearance, combat, skill, equipment, headIcon, isSkulled, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the appearance block.
|
* Creates the appearance block.
|
||||||
*
|
*
|
||||||
* @param name The player's username, encoded to base 37.
|
* @param name The player's username, encoded to base 37.
|
||||||
|
* @param animations
|
||||||
* @param appearance The {@link Appearance}.
|
* @param appearance The {@link Appearance}.
|
||||||
* @param combat The player's combat.
|
* @param combat The player's combat.
|
||||||
* @param skill The player's skill, or 0 if showing the combat level.
|
* @param skill The player's skill, or 0 if showing the combat level.
|
||||||
* @param equipment The player's equipment.
|
* @param equipment The player's equipment.
|
||||||
* @param headIcon The prayer icon id of this player.
|
* @param headIcon The prayer icon id of this player.
|
||||||
* @param isSkulled Whether or not the player is skulled.
|
* @param isSkulled Whether or not the player is skulled.
|
||||||
* @param npcId The npc id of the player, if they are appearing as an npc, (otherwise {@code -1}).
|
* @param npcId The npc id of the player, if they are appearing as an npc, (otherwise {@code -1}).
|
||||||
*/
|
*/
|
||||||
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int headIcon, boolean isSkulled, int npcId) {
|
AppearanceBlock(long name, AnimationMap animations, Appearance appearance, int combat, int skill, Inventory equipment, int headIcon, boolean isSkulled, int npcId) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.animations = animations;
|
||||||
this.appearance = appearance;
|
this.appearance = appearance;
|
||||||
this.combat = combat;
|
this.combat = combat;
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
@@ -97,6 +106,15 @@ public final class AppearanceBlock extends SynchronizationBlock {
|
|||||||
return npcId != -1;
|
return npcId != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the player's {@link AnimationMap}.
|
||||||
|
*
|
||||||
|
* @return The player's animations.
|
||||||
|
*/
|
||||||
|
public AnimationMap getAnimations() {
|
||||||
|
return animations;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player's {@link Appearance}.
|
* Gets the player's {@link Appearance}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public abstract class SynchronizationBlock {
|
|||||||
int combat = player.getSkillSet().getCombatLevel();
|
int combat = player.getSkillSet().getCombatLevel();
|
||||||
int id = player.hasNpcDefinition() ? player.getDefinition().getId() : -1;
|
int id = player.hasNpcDefinition() ? player.getDefinition().getId() : -1;
|
||||||
|
|
||||||
return new AppearanceBlock(player.getEncodedName(), player.getAppearance(), combat, 0, player.getEquipment(), player.getPrayerIcon(), player.isSkulled(), id);
|
return new AppearanceBlock(player.getEncodedName(), player.getAnimations(), player.getAppearance(), combat, 0, player.getEquipment(), player.getPrayerIcon(), player.isSkulled(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user