mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Converted goblin village population sign into listener
This commit is contained in:
parent
ab17ef11a1
commit
dd6909908c
2 changed files with 27 additions and 36 deletions
|
|
@ -0,0 +1,27 @@
|
|||
package content.region.asgarnia.goblinvillage.handlers
|
||||
|
||||
import core.game.interaction.IntType
|
||||
import core.game.interaction.InteractionListener
|
||||
import core.game.node.entity.combat.DeathTask
|
||||
import core.game.world.map.RegionManager.getLocalNpcs
|
||||
import org.rs09.consts.Scenery
|
||||
|
||||
class GoblinVillagePopulationListener : InteractionListener{
|
||||
override fun defineListeners() {
|
||||
on(Scenery.SIGNPOST_31301, IntType.SCENERY, "read") { player, node ->
|
||||
var population = 3 // This covers General Wartface, General Bentnoze and Grubfoot
|
||||
val npcs = getLocalNpcs(player, 50) // This radius covers more than the goblin village.
|
||||
// There should be 18 Goblins walking around.
|
||||
// 10 are within the village walls where the generals are.
|
||||
// 8 of them are fighting each other on the west of the path to the village.
|
||||
// Total should be 21. They respawn really fast.
|
||||
for (n in npcs) {
|
||||
if (n.name == "Goblin" && !DeathTask.isDead(n)) {
|
||||
population++
|
||||
}
|
||||
player.dialogueInterpreter.sendPlainMessage(false, "Welcome to Goblin Village.", "Current population: $population")
|
||||
}
|
||||
return@on true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package content.region.asgarnia.goblinvillage.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import core.cache.def.impl.SceneryDefinition;
|
||||
import core.game.interaction.OptionHandler;
|
||||
import core.game.node.Node;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.world.map.RegionManager;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
@Initializable
|
||||
public class GoblinVillagePopulationPlugin extends OptionHandler {
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
SceneryDefinition.forId(31301).getHandlers().put("option:read", this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(Player player, Node node, String option) {
|
||||
int population = 2;
|
||||
final List<NPC> npcs = RegionManager.getLocalNpcs(player);
|
||||
for (NPC n : npcs) {
|
||||
if (n.getName().equals("Goblin")) {
|
||||
population++;
|
||||
player.getDialogueInterpreter().sendPlainMessage(false, "Welcome to Goblin Village.", "Current population: " + population);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue