mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Fixes to things using the PlayerState machinery:
- Charge now clears the state when it finishes, allowing consecutive uses without relogging. - Ava's device clears the state when unequipped, allong it to be equipped again later. - (Unrelated to states) Binding necklace now uses amulet-slot degradation instead of degrading your hat.
This commit is contained in:
parent
0e1a1c756c
commit
41686ac463
5 changed files with 27 additions and 22 deletions
|
|
@ -34,18 +34,16 @@ public final class AvasDevicePlugin implements Plugin<Object> {
|
|||
state.init();
|
||||
break;
|
||||
case "unequip":
|
||||
player.clearState("avadevice");
|
||||
if (args.length == 3) {
|
||||
Item second = (Item) args[2];
|
||||
if (second.getId() == 10498 || second.getId() == 10499) {
|
||||
player.clearState("avadevice");
|
||||
AvaDeviceState newState = (AvaDeviceState) player.registerState("avadevice");
|
||||
newState.setDevice(second.getId());
|
||||
newState.init();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(player.hasActiveState("avadevice")) player.clearState("avadevice");
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1386,7 +1386,10 @@ public class Player extends Entity {
|
|||
public void clearState(String key){
|
||||
State state = states.get(key);
|
||||
if(state == null) return;
|
||||
state.getPulse().stop();
|
||||
Pulse pulse = state.getPulse();
|
||||
if(pulse != null) {
|
||||
pulse.stop();
|
||||
}
|
||||
states.remove(key);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,14 +235,14 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
|||
}
|
||||
if (player.getInventory().remove(new Item(PURE_ESSENCE.getId(), amount)) && player.getInventory().remove(new Item(rune.getId(), amount))) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
if (RandomFunction.random(1, 3) == 1 || hasBindingNeckalce()) {
|
||||
if (RandomFunction.random(1, 3) == 1 || hasBindingNecklace()) {
|
||||
player.getInventory().add(new Item(combo.getRune().getId(), 1));
|
||||
player.getSkills().addExperience(Skills.RUNECRAFTING, combo.getExperience(), true);
|
||||
}
|
||||
}
|
||||
if (hasBindingNeckalce()) {
|
||||
player.getEquipment().get(EquipmentContainer.SLOT_HAT).setCharge(player.getEquipment().get(EquipmentContainer.SLOT_HAT).getCharge() - 1);
|
||||
if (1000 - player.getEquipment().get(EquipmentContainer.SLOT_HAT).getCharge() > 14) {
|
||||
if (hasBindingNecklace()) {
|
||||
player.getEquipment().get(EquipmentContainer.SLOT_AMULET).setCharge(player.getEquipment().get(EquipmentContainer.SLOT_AMULET).getCharge() - 1);
|
||||
if (1000 - player.getEquipment().get(EquipmentContainer.SLOT_AMULET).getCharge() > 14) {
|
||||
player.getEquipment().remove(BINDING_NECKLACE, true);
|
||||
player.getPacketDispatch().sendMessage("Your binding necklace crumbles into dust.");
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ public final class RuneCraftPulse extends SkillPulse<Item> {
|
|||
*
|
||||
* @return <code>True</code> if so.
|
||||
*/
|
||||
public boolean hasBindingNeckalce() {
|
||||
public boolean hasBindingNecklace() {
|
||||
return player.getEquipment().containsItem(BINDING_NECKLACE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ class AvaDeviceState(player: Player? = null) : State(player) {
|
|||
private val ACCUMULATOR_REWARDS = arrayOf(Items.STEEL_BAR_2353,Items.STEEL_2H_SWORD_1311,Items.STEEL_KNIFE_865,Items.STEEL_DAGGER_1207,Items.STEEL_MED_HELM_1141,Items.STEEL_DART_808,Items.STEEL_BOLTS_9141,Items.STEEL_ARROW_886,Items.IRON_BAR_2351)
|
||||
|
||||
override fun save(root: JSONObject) {
|
||||
if(pulse == null || !pulse!!.isRunning)
|
||||
root.put("device-id",device)
|
||||
root.put("device-id",device)
|
||||
}
|
||||
|
||||
override fun parse(_data: JSONObject) {
|
||||
|
|
@ -44,6 +43,8 @@ class AvaDeviceState(player: Player? = null) : State(player) {
|
|||
pulse = object : Pulse(TICKS){
|
||||
override fun pulse(): Boolean {
|
||||
if(!hasDevice(player)){
|
||||
player.clearState("avadevice")
|
||||
pulse = null
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -93,4 +94,4 @@ class AvaDeviceState(player: Player? = null) : State(player) {
|
|||
return false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,37 +5,40 @@ import core.game.system.task.Pulse
|
|||
import org.json.simple.JSONObject
|
||||
import rs09.game.node.entity.state.newsys.PlayerState
|
||||
import rs09.game.node.entity.state.newsys.State
|
||||
import rs09.game.world.GameWorld;
|
||||
|
||||
@PlayerState("godcharge")
|
||||
class GodspellChargedState(player: Player? = null) : State(player) {
|
||||
var TICKS = 700
|
||||
val DURATION = 700
|
||||
var startTick: Int = 0
|
||||
|
||||
override fun save(root: JSONObject) {
|
||||
if(TICKS > 0){
|
||||
root.put("ticksleft",TICKS)
|
||||
}
|
||||
root.put("ticks_elapsed", GameWorld.ticks - startTick)
|
||||
}
|
||||
|
||||
override fun parse(_data: JSONObject) {
|
||||
if(_data.containsKey("ticksleft")){
|
||||
TICKS = _data["ticksleft"].toString().toInt()
|
||||
if(_data.containsKey("ticks_elapsed")){
|
||||
startTick = GameWorld.ticks - _data["ticks_elapsed"].toString().toInt()
|
||||
}
|
||||
}
|
||||
|
||||
override fun newInstance(player: Player?): State {
|
||||
return GodspellChargedState(player)
|
||||
var ret = GodspellChargedState(player)
|
||||
ret.startTick = GameWorld.ticks
|
||||
return ret
|
||||
}
|
||||
|
||||
override fun createPulse() {
|
||||
player ?: return
|
||||
if(TICKS <= 0) return
|
||||
pulse = object : Pulse(TICKS){
|
||||
if(GameWorld.ticks - startTick >= DURATION) return
|
||||
pulse = object : Pulse(DURATION) {
|
||||
override fun pulse(): Boolean {
|
||||
player.sendMessage("Your magical charge fades away.")
|
||||
player.clearState("godcharge")
|
||||
pulse = null
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue