Merge branch 'summoning-renew' into 'master'

Allow renewing summoning familiars, and make bobs drop items on dismissal even...

See merge request 2009scape/2009scape!365
This commit is contained in:
Ceikry
2021-12-31 01:22:23 +00:00
4 changed files with 43 additions and 24 deletions
+2 -1
View File
@@ -82,4 +82,5 @@
- Add proper sound effects for the explorer's ring and fix leaf-bladed sword's sound effects.
- Fix wine of zamorak pickup interaction.
- Static clue drop ids replaced with their level appropriate proxy values
- Fix a bug where clue scrolls were rerolled to easy for most NPCs
- Fix a bug where clue scrolls were rerolled to easy for most NPCs
- Allow renewing summoning familiars, and make bobs drop items on dismissal even if their owners are ironmen.
@@ -55,13 +55,13 @@ public abstract class BurdenBeast extends Familiar {
if (owner.getInterfaceManager().hasMainComponent(671)) {
owner.getInterfaceManager().close();
}
if (!owner.getIronmanManager().isIronman()) {
for (Item item : container.toArray()) {
if (item != null) {
GroundItemManager.create(new GroundItem(item, location, 500, owner));
}
}
}
for (Item item : container.toArray()) {
if (item != null) {
GroundItemManager.create(new GroundItem(item, location, 500, owner));
}
}
container.clear();
super.dismiss();
}
@@ -209,4 +209,4 @@ public abstract class BurdenBeast extends Familiar {
return container;
}
}
}
@@ -311,13 +311,20 @@ public abstract class Familiar extends NPC implements Plugin<Object> {
}
}
public void refreshTimer() {
ticks = maximumTicks;
}
/**
* Sends the time remaining.
*/
private void sendTimeRemaining() {
int minutes = (int) Math.ceil(ticks * 0.01);
int hash = minutes << 7 | ((ticks - (minutes * 100)) > 49 ? 1 : 0) << 6;
owner.getConfigManager().set(1176, hash);
int minutes = ticks / 100;
int centiminutes = ticks % 100;
owner.varpManager.get(1176)
.setVarbit(7, minutes)
.setVarbit(6, centiminutes > 49 ? 1 : 0)
.send(owner);
}
/**
@@ -126,9 +126,14 @@ public final class FamiliarManager {
* @param deleteItem we should delete the item.
*/
public void summon(Item item, boolean pet, boolean deleteItem) {
boolean renew = false;
if (hasFamiliar()) {
player.getPacketDispatch().sendMessage("You already have a follower.");
return;
if(familiar.getPouchId() == item.getId()) {
renew = true;
} else {
player.getPacketDispatch().sendMessage("You already have a follower.");
return;
}
}
if (player.getZoneMonitor().isRestricted(ZoneRestriction.FOLLOWERS) && !player.getLocks().isLocked("enable_summoning")) {
player.getPacketDispatch().sendMessage("This is a Summoning-free area.");
@@ -151,24 +156,30 @@ public final class FamiliarManager {
return;
}
final int npcId = pouch.getNpcId();
Familiar fam = FAMILIARS.get(npcId);
Familiar fam = !renew ? FAMILIARS.get(npcId) : familiar;
if (fam == null) {
player.getPacketDispatch().sendMessage("Invalid familiar " + npcId + " - report on 2009scape github");
return;
}
fam = fam.construct(player, npcId);
if (fam.getSpawnLocation() == null) {
player.getPacketDispatch().sendMessage("The spirit in this pouch is too big to summon here. You will need to move to a larger");
player.getPacketDispatch().sendMessage("area.");
return;
}
if(!renew) {
fam = fam.construct(player, npcId);
if (fam.getSpawnLocation() == null) {
player.getPacketDispatch().sendMessage("The spirit in this pouch is too big to summon here. You will need to move to a larger");
player.getPacketDispatch().sendMessage("area.");
return;
}
}
if (!player.getInventory().remove(item)) {
return;
}
player.getSkills().updateLevel(Skills.SUMMONING, -pouch.getSummonCost(), 0);
player.getSkills().addExperience(Skills.SUMMONING, pouch.getSummonExperience());
familiar = fam;
spawnFamiliar();
if(!renew) {
familiar = fam;
spawnFamiliar();
} else {
familiar.refreshTimer();
}
if (player.getSkullManager().isWilderness()) {
player.getAppearance().sync();
}
@@ -500,4 +511,4 @@ public final class FamiliarManager {
public Map<Integer, PetDetails> getPetDetails() {
return petDetails;
}
}
}