Converted goblin village population sign into listener
This commit is contained in:
+27
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
-36
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user