Merge remote-tracking branch 'origin/master'

This commit is contained in:
Woah 2021-03-24 19:28:36 -04:00
commit c8bb99706e
9 changed files with 99 additions and 142 deletions

View file

@ -1,129 +0,0 @@
package core.game.content.activity.mta;
import core.game.node.entity.skill.magic.MagicSpell;
import core.game.node.entity.skill.magic.Runes;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.equipment.SpellType;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.item.Item;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Plugin;
import core.game.content.activity.mta.impl.GraveyardZone;
/**
* Represents the bones to banana spell.
* @author Emperor
* @author 'Vexia
* @version 1.0
*/
public final class BonesConvertingSpells extends MagicSpell {
/**
* The bone ids.
*/
private static final int[] BONES = new int[] { 526, 532, 6904, 6905, 6906, 6907 };
/**
* The graphic.
*/
private static final Graphics GRAPHIC = new Graphics(141, 96);
/**
* The animation.
*/
private static final Animation ANIMATION = new Animation(722);
/**
* The item to replace the bones with.
*/
private Item converted;
/**
* Constructs a new {@code BonesConvertingSpells} {@code Object}.
*/
public BonesConvertingSpells() {
/**
* empty.
*/
}
/**
* Constructs a new {@code BonesConvertingSpells} {@code Object}.
* @param level The level required.
* @param converted The item to replace the bones with.
* @param anim The animation.
* @param graphic The graphic.
* @param runes The runes.
*/
public BonesConvertingSpells(int level, final double experience, Item converted, Animation anim, Graphics graphic, Item... runes) {
super(SpellBook.MODERN, level, experience, anim, graphic, null, runes);
this.converted = converted;
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.MODERN.register(9, new BonesConvertingSpells(15, 25, new Item(1963), ANIMATION, GRAPHIC, Runes.EARTH_RUNE.getItem(2), Runes.WATER_RUNE.getItem(2), Runes.NATURE_RUNE.getItem(1)));
SpellBook.MODERN.register(40, new BonesConvertingSpells(60, 65, new Item(6883), ANIMATION, GRAPHIC, Runes.EARTH_RUNE.getItem(4), Runes.WATER_RUNE.getItem(4), Runes.NATURE_RUNE.getItem(2)));
return this;
}
@Override
public boolean meetsRequirements(Entity caster, boolean message, boolean remove) {
if (getSpellId() == 40 && !caster.asPlayer().getSavedData().getActivityData().isBonesToPeaches()) {
caster.asPlayer().sendMessage("You can only learn this spell from the Mage Training Arena.");
return false;
}
if (!hasBones(caster.asPlayer())) {
if (message) {
((Player) caster).getPacketDispatch().sendMessage("You aren't holding any bones!");
}
return false;
}
return super.meetsRequirements(caster, message, remove);
}
@Override
public boolean cast(Entity entity, Node target) {
Player p = (Player) entity;
boolean inGrave = p.getZoneMonitor().isInZone("Creature Graveyard");
if (p.getAttribute("cbs_tab", false) && inGrave && target.getId() >= 6904 && target.getId() <= 6907) {
p.sendMessage("This tablet cannot be used on bones from the Mage Training Arena.");
return false;
}
if (!p.getAttribute("cbs_tab", false) && !meetsRequirements(entity, true, true)) {
return false;
}
p.removeAttribute("cbs_tab");
for (int id : BONES) {
if (p.getInventory().contains(id, 1)) {
int amount = p.getInventory().getAmount(id);
if (inGrave) {
amount *= (GraveyardZone.BoneType.forItem(new Item(id)).ordinal() + 1);
}
p.getInventory().remove(new Item(id, amount));
p.getInventory().add(new Item(converted.getId(), amount));
}
}
visualize(entity, target);
return true;
}
/**
* Checks if the player has bones.
* @param player the player.
* @return {@code True} if so.
*/
private boolean hasBones(Player player) {
for (int id : BONES) {
if (player.getInventory().contains(id, 1)) {
return true;
}
}
return false;
}
}

View file

@ -52,7 +52,7 @@ public class MageTrainingArenaPlugin extends OptionHandler {
ItemDefinition.forId(TelekineticZone.STATUE).getHandlers().put("option:observe", this);
ItemDefinition.forId(TelekineticZone.STATUE).getHandlers().put("option:reset", this);
NPCDefinition.forId(3102).getHandlers().put("option:talk-to", this);
PluginManager.definePlugins(new CharmedWarriorDialogue(), new EntranceGuardianDialogue(), new RewardsGuardianDialogue(), new ProgressHatDialogue(), new EnchantmentGuardianDialogue(), new EnchantSpell(), new BonesConvertingSpells(), new GraveyardGuardianDialogue(), new AlchemyGuardianDialogue(), new TelekineticGrabSpell(), new TelekineticGuardianDialogue(), new MazeGuardianDialogue());
PluginManager.definePlugins(new CharmedWarriorDialogue(), new EntranceGuardianDialogue(), new RewardsGuardianDialogue(), new ProgressHatDialogue(), new EnchantmentGuardianDialogue(), new EnchantSpell(), new GraveyardGuardianDialogue(), new AlchemyGuardianDialogue(), new TelekineticGrabSpell(), new TelekineticGuardianDialogue(), new MazeGuardianDialogue());
return this;
}

View file

@ -141,6 +141,7 @@ public final class TzhaarFightCavesPlugin extends ActivityPlugin {
public void leave(Player player, int wave) {
activeNPCs.clear();
player.getProperties().setTeleportLocation(getSpawnLocation());
player.getSkills().restore();
if (wave == 63) {
if (!player.getInventory().add(new Item(6570))) {
GroundItemManager.create(new Item(6570), getSpawnLocation(), player);

View file

@ -3,13 +3,12 @@ package core.game.interaction.inter;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
import core.game.component.ComponentPlugin;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.skill.crafting.GlassProduct;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.RunScript;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.skill.crafting.GlassProduct;
import core.game.node.item.Item;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.update.flag.context.Animation;
import core.plugin.Initializable;
import core.plugin.Plugin;
@ -100,7 +99,8 @@ public final class GlassInterface extends ComponentPlugin {
public static void make(final Player player, final GlassProduct glass, final int amount) {
player.getInterfaceManager().close();
player.animate(ANIMATION);
GameWorld.getPulser().submit(new Pulse(2, player) {
player.getPulseManager().clear();
player.getPulseManager().run(new Pulse(2, player) {
int amt = amount;
@Override

View file

@ -11,7 +11,6 @@ import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.system.task.Pulse;
import core.game.world.map.Location;
import core.game.world.map.MapDistance;
import core.game.world.map.RegionManager;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
@ -50,7 +49,7 @@ public final class ChainhitSpecialHandler extends RangeSwingHandler implements P
/**
* The door support locations.
*/
private static final Location[] DOOR_SUPPORTS = new Location[] { Location.create(2545, 10145, 0), Location.create(2545, 10141, 0) };
private static final Location[] DOOR_SUPPORTS = new Location[] { Location.create(2545, 10145, 0), Location.create(2545, 10141, 0),Location.create(2543, 10143, 0) };
@Override
public Object fireEvent(String identifier, Object... args) {
@ -75,7 +74,7 @@ public final class ChainhitSpecialHandler extends RangeSwingHandler implements P
}
if (victim instanceof NPC) {
NPC npc = victim.asNpc();
if (npc.getId() == 2443) {
if (npc.getId() == 2440) {
for (Location l : DOOR_SUPPORTS) {
final NPC n = Repository.findNPC(l);
if (n == null) {
@ -176,7 +175,7 @@ public final class ChainhitSpecialHandler extends RangeSwingHandler implements P
private List<? extends Entity> getVictimsList(Entity e, Entity victim) {
List<? extends Entity> list = e.getAttribute("chain-hit_v");
if (list == null) {
int distance = MapDistance.RENDERING.getDistance() / 3;
int distance = 5;
if (victim instanceof NPC) {
e.setAttribute("chain-hit_v", list = RegionManager.getLocalNpcs(e, distance));
} else {

View file

@ -106,6 +106,9 @@ public class TeleportManager {
p.getDialogueInterpreter().close();
}
}
if(entity.getAttribute("tablet-spell",false)){
type = TeleportType.TELETABS;
}
this.teleportType = teleportType;
entity.getWalkingQueue().reset();
lastTeleport = currentTeleport;

View file

@ -1,5 +1,7 @@
package rs09.game.node.entity.skill.magic
import core.game.content.activity.mta.impl.GraveyardZone
import core.game.content.global.Bones
import core.game.node.entity.Entity
import core.game.node.entity.impl.Animator.Priority
import core.game.node.entity.impl.Projectile
@ -129,12 +131,42 @@ class ModernListeners : SpellListener("modern"){
}
private fun boneConvert(player: Player,bananas: Boolean){
if(!bananas && !player.savedData.activityData.isBonesToPeaches){
val isInMTA = player.zoneMonitor.isInZone("Creature Graveyard")
if(isInMTA && player.getAttribute("tablet-spell",false)){
player.sendMessage("You can not use this tablet in the Mage Training Arena.")
return
}
if(!bananas && !player.savedData.activityData.isBonesToPeaches && !player.getAttribute("tablet-spell",false)){
player.sendMessage("You can only learn this spell from the Mage Training Arena.")
return
}
val bones = if(isInMTA) intArrayOf(6904,6905,6906,6907) else Bones.values().map { it.itemId }.toIntArray()
for(item in player.inventory.toArray()){
item ?: continue
if(isInMTA){
if(bones.contains(item.id)){
val inInventory = player.inventory.getAmount(item.id)
val amount = inInventory * GraveyardZone.BoneType.forItem(Item(item.id)).ordinal + 1
if(amount > 0){
player.inventory.remove(Item(item.id,inInventory))
player.inventory.add(Item(if(bananas) Items.BANANA_1963 else Items.PEACH_6883,amount))
}
}
} else {
if(bones.contains(item.id)){
val inInventory = player.inventory.getAmount(item.id)
player.inventory.remove(Item(item.id,inInventory))
player.inventory.add(Item(if(bananas) Items.BANANA_1963 else Items.PEACH_6883,inInventory))
}
}
}
visualizeSpell(player,BONE_CONVERT_ANIM, BONE_CONVERT_GFX)
removeRunes(player)
addXP(player,if(bananas) 25.0 else 65.0)
setDelay(player,false)
}
private fun superheat(player: Player,item: Item){
@ -186,11 +218,10 @@ class ModernListeners : SpellListener("modern"){
if(player.inventory.remove(Item(item.id,1))) {
removeRunes(player)
player.audioManager.send(if (high) 97 else 98)
if (high) {
player.visualize(HIGH_ALCH_ANIM,HIGH_ALCH_GFX)
visualizeSpell(player,HIGH_ALCH_ANIM,HIGH_ALCH_GFX,97)
} else {
player.visualize(LOW_ALCH_ANIM,LOW_ALCH_GFX)
visualizeSpell(player,LOW_ALCH_ANIM,LOW_ALCH_GFX,98)
}
if(coins.amount > 0)

View file

@ -5,6 +5,8 @@ import core.game.node.Node
import core.game.node.entity.player.Player
import core.game.node.entity.skill.Skills
import core.game.node.item.Item
import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.context.Graphics
import rs09.game.interaction.Listener
import rs09.game.world.GameWorld
@ -35,6 +37,9 @@ abstract class SpellListener(val bookName: String) : Listener {
if(player.getAttribute("magic-delay",0) > GameWorld.ticks){
throw IllegalStateException()
}
if(player.getAttribute("tablet-spell",false)){
return
}
if(player.skills.getLevel(Skills.MAGIC) < magicLevel){
player.sendMessage("You need a magic level of $magicLevel to cast this spell.")
throw IllegalStateException()
@ -56,12 +61,22 @@ abstract class SpellListener(val bookName: String) : Listener {
fun removeRunes(player: Player){
player.inventory.remove(*player.getAttribute("spell:runes",ArrayList<Item>()).toTypedArray())
player.removeAttribute("spell:runes")
player.removeAttribute("tablet-spell")
}
fun addXP(player: Player,amount:Double){
if(player.getAttribute("tablet-spell",false)) return
player.skills.addExperience(Skills.MAGIC,amount)
}
fun visualizeSpell(player: Player,anim:Animation,gfx: Graphics,soundID: Int = -1){
if(player.getAttribute("tablet-spell",false)) return
player.visualize(anim,gfx)
if(soundID != -1){
player.audioManager.send(soundID)
}
}
fun setDelay(player: Player,isTeleport: Boolean = false){
if(!isTeleport) player.setAttribute("magic-delay",GameWorld.ticks + 3) else player.setAttribute("magic-delay",GameWorld.ticks + 5)
}

View file

@ -0,0 +1,37 @@
package rs09.game.node.entity.skill.magic
import core.game.node.entity.player.Player
import core.game.node.item.Item
import core.game.world.update.flag.context.Animation
import org.rs09.consts.Items
import rs09.game.interaction.InteractionListener
import rs09.game.node.entity.skill.magic.spellconsts.Modern
class SpellTablets : InteractionListener() {
val B2P_TABLET = Items.BONES_TO_PEACHES_8015
val B2B_TABLET = Items.BONES_TO_BANANAS_8014
override fun defineListeners() {
on(B2B_TABLET,ITEM,"break"){player, node ->
breakTablet(player)
SpellListeners.run(Modern.BONES_TO_BANANAS,SpellListener.NONE,"modern",player)
player.inventory.remove(Item(node.id))
return@on true
}
on(B2P_TABLET,ITEM,"break"){player, node ->
breakTablet(player)
SpellListeners.run(Modern.BONES_TO_PEACHES,SpellListener.NONE,"modern",player)
player.inventory.remove(Item(node.id))
return@on true
}
}
fun breakTablet(player: Player){
player.audioManager.send(979)
player.animator.forceAnimation(Animation(4069))
player.lock(5)
player.setAttribute("tablet-spell",true)
}
}