forked from 2009Scape/Server
Shooting star improvements
This commit is contained in:
parent
5097ff46fb
commit
e386724f94
3 changed files with 108 additions and 3 deletions
|
|
@ -18,12 +18,14 @@ import org.crandor.game.node.entity.player.link.diary.DiaryType;
|
|||
import org.crandor.game.node.item.Item;
|
||||
import org.crandor.game.node.object.GameObject;
|
||||
import org.crandor.game.node.object.ObjectBuilder;
|
||||
import org.crandor.game.world.GameWorld;
|
||||
import org.crandor.game.world.map.Location;
|
||||
import org.crandor.tools.RandomFunction;
|
||||
import org.crandor.tools.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
|
@ -175,8 +177,15 @@ public final class GatheringSkillPulse extends SkillPulse<GameObject> {
|
|||
} else {
|
||||
player.getPacketDispatch().sendMessage("You get some " + ItemDefinition.forId(reward).getName().toLowerCase() + ".");
|
||||
}
|
||||
// Calculate if the player should receive a bonus gem
|
||||
// Calculate if the player should receive a bonus gem or bonus ore or both
|
||||
if (!isMiningEssence && isMining) {
|
||||
//check for bonus ore from shooting star buff
|
||||
if(isMining && (player.getAttribute("SS Mining Bonus", GameWorld.getTicks()) > GameWorld.getTicks())){
|
||||
if(RandomFunction.getRandom(7) == 5) {
|
||||
player.getPacketDispatch().sendMessage("...you manage to mine a second ore thanks to the Star Sprite.");
|
||||
player.getInventory().add(item);
|
||||
}
|
||||
}
|
||||
int chance = 282;
|
||||
boolean altered = false;
|
||||
if (player.getEquipment().getNew(EquipmentContainer.SLOT_RING).getId() == 2572) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
package org.crandor.game.node.entity.state.impl;
|
||||
|
||||
import org.crandor.game.node.entity.Entity;
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.node.entity.state.StatePulse;
|
||||
import org.crandor.game.world.GameWorld;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Pulse for checking remaining time on a shooting star mining bonus and informing the player
|
||||
* @author ceik
|
||||
*/
|
||||
|
||||
public class DoubleOrePulse extends StatePulse {
|
||||
Player player;
|
||||
Entity entity;
|
||||
int ticks,currentTick;
|
||||
public DoubleOrePulse(Entity entity, int ticks, int currentTick){
|
||||
super(entity,1);
|
||||
this.ticks = ticks;
|
||||
this.currentTick = currentTick;
|
||||
this.player = entity.asPlayer();
|
||||
this.entity = entity;
|
||||
}
|
||||
@Override
|
||||
public boolean isSaveRequired(){return currentTick < ticks;}
|
||||
|
||||
@Override
|
||||
public void save(ByteBuffer buffer){
|
||||
buffer.putInt(ticks);
|
||||
buffer.putInt(currentTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatePulse parse(Entity entity, ByteBuffer buffer){
|
||||
return new DoubleOrePulse(entity, buffer.getInt(), buffer.getInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (currentTick == GameWorld.getTicks()) {
|
||||
if (entity instanceof Player) {
|
||||
if((int) entity.asPlayer().getAttribute("SS Mining Bonus") > GameWorld.getTicks()){
|
||||
entity.asPlayer().sendMessage("<col=006600>Your mining bonus is now active!</col>");
|
||||
}
|
||||
}
|
||||
}
|
||||
super.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
int ticksLeft = (int)player.getAttribute("SS Mining Bonus") - GameWorld.getTicks();
|
||||
int minutes = (int)Math.ceil((ticksLeft * .6) / 60);
|
||||
if(ticksLeft % 500 == 0L){
|
||||
player.sendMessage("<col=f0f095>You have " + minutes + " minutes of your mining bonus left</col>");
|
||||
}
|
||||
if(ticksLeft == 0){
|
||||
if((int)ticks <= GameWorld.getTicks()){
|
||||
player.sendMessage("<col=FF0000>Your mining bonus has run out!</col>");
|
||||
}
|
||||
}
|
||||
return !(ticks >= GameWorld.getTicks());
|
||||
}
|
||||
@Override
|
||||
public StatePulse create(Entity entity, Object... args) {
|
||||
return new DoubleOrePulse(entity, entity.asPlayer().getAttribute("SS Mining Bonus"), GameWorld.getTicks());
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,11 @@ import org.crandor.game.content.skill.Skills;
|
|||
import org.crandor.game.content.skill.free.gather.SkillingTool;
|
||||
import org.crandor.game.interaction.OptionHandler;
|
||||
import org.crandor.game.node.Node;
|
||||
import org.crandor.game.node.entity.impl.PulseManager;
|
||||
import org.crandor.game.node.entity.npc.NPC;
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.node.entity.state.StatePulse;
|
||||
import org.crandor.game.node.entity.state.impl.DoubleOrePulse;
|
||||
import org.crandor.game.node.item.Item;
|
||||
import org.crandor.game.node.object.GameObject;
|
||||
import org.crandor.game.node.object.ObjectBuilder;
|
||||
|
|
@ -69,6 +72,11 @@ public class ShootingStarPlugin extends OptionHandler {
|
|||
{"Mage Arena bank", Location.create(3093, 3962, 0)}
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks whether or not a discovery/first mine award has been given
|
||||
*/
|
||||
public static boolean isDiscovered = false;
|
||||
|
||||
/**
|
||||
* The star dust item id.
|
||||
*/
|
||||
|
|
@ -107,6 +115,7 @@ public class ShootingStarPlugin extends OptionHandler {
|
|||
/**
|
||||
* The star updating pulse.
|
||||
*/
|
||||
|
||||
private static final Pulse pulse = new Pulse(1) {
|
||||
|
||||
@Override
|
||||
|
|
@ -343,6 +352,7 @@ public class ShootingStarPlugin extends OptionHandler {
|
|||
object = null;
|
||||
crashSite = null;
|
||||
ticks = 0;
|
||||
isDiscovered = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -469,14 +479,25 @@ public class ShootingStarPlugin extends OptionHandler {
|
|||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
tool = SkillingTool.getPickaxe(player);
|
||||
if (star == null || object == null || !object.isActive()) {
|
||||
return false;
|
||||
}
|
||||
//checks if the star has been discovered and if not, awards the bonus xp. Xp can be awarded regardless of mining level as per the wiki.
|
||||
if(!isDiscovered) {
|
||||
player.getSkills().addExperience(Skills.MINING, 75 * player.getSkills().getStaticLevel(Skills.MINING));
|
||||
Repository.sendNews(player.getUsername() + " is the discoverer of the crashed star near " + crashSite + "!");
|
||||
isDiscovered = true;
|
||||
if (player.getSkills().getLevel(Skills.MINING) < star.getMiningLevel()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (player.getSkills().getLevel(Skills.MINING) < star.getMiningLevel()) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need a Mining level of at least " + star.getMiningLevel() + " in order to mine this layer.");
|
||||
return false;
|
||||
}
|
||||
tool = SkillingTool.getPickaxe(player);
|
||||
if (tool == null) {
|
||||
player.getPacketDispatch().sendMessage("You do not have a pickaxe to use.");
|
||||
return false;
|
||||
|
|
@ -737,7 +758,7 @@ public class ShootingStarPlugin extends OptionHandler {
|
|||
end();
|
||||
break;
|
||||
case 50:
|
||||
int dust = player.getInventory().getAmount(STAR_DUST);
|
||||
int dust = player.getInventory().getAmount(STAR_DUST) > 200 ? 200 : player.getInventory().getAmount(STAR_DUST);
|
||||
if (player.getInventory().remove(new Item(STAR_DUST, dust))) {
|
||||
int cosmicRunes = (int) (Math.ceil(0.76 * dust) * AMPLIFIER);
|
||||
int astralRunes = (int) (Math.ceil(0.26 * dust) * AMPLIFIER);
|
||||
|
|
@ -748,7 +769,12 @@ public class ShootingStarPlugin extends OptionHandler {
|
|||
player.getInventory().add(new Item(GOLD_ORE, goldOre), player);
|
||||
player.getInventory().add(new Item(COINS, coins), player);
|
||||
npc("I have rewarded you by making it so you can mine", "extra ore for the next 15 minutes. Also, have " + cosmicRunes, "cosmic runes, " + astralRunes + " astral runes, " + goldOre + " gold ore and " + coins, "coins.");
|
||||
player.setAttribute("SS Mining Bonus",System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(15));
|
||||
player.getSavedData().getGlobalData().setStarSpriteDelay(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1));
|
||||
int endTick = GameWorld.getTicks() + 1500;
|
||||
player.setAttribute("SS Mining Bonus",endTick);
|
||||
DoubleOrePulse orePulse = new DoubleOrePulse(player,endTick,GameWorld.getTicks());
|
||||
orePulse.run();
|
||||
}
|
||||
stage = 52;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue