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

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