Implemented Freaky Forester random event
Added admin ::freak command to trigger Freaky Forester
This commit is contained in:
@@ -483,10 +483,13 @@ abstract class CombatSwingHandler(var type: CombatStyle?) {
|
||||
is Player -> {player = entity; attStyle = entity.properties.attackStyle.style}
|
||||
else -> return
|
||||
}
|
||||
if (victim is NPC) EXPERIENCE_MOD *= victim.behavior.getXpMultiplier(victim, player)
|
||||
if (state != null) {
|
||||
val hit = state.totalDamage
|
||||
if (entity is Player) {
|
||||
player.skills.addExperience(Skills.HITPOINTS, hit * 1.33, true)
|
||||
var experience = hit * 1.33
|
||||
if (victim is NPC) experience *= victim.behavior.getXpMultiplier(victim, player)
|
||||
player.skills.addExperience(Skills.HITPOINTS, experience, true)
|
||||
}
|
||||
|
||||
var skill = -1
|
||||
@@ -513,8 +516,10 @@ abstract class CombatSwingHandler(var type: CombatStyle?) {
|
||||
|
||||
WeaponInterface.STYLE_CAST -> skill = Skills.MAGIC
|
||||
WeaponInterface.STYLE_DEFENSIVE_CAST -> {
|
||||
player.skills.addExperience(Skills.MAGIC, hit * 1.33, true)
|
||||
player.skills.addExperience(Skills.DEFENCE, hit.toDouble(), true)
|
||||
var experience = hit.toDouble()
|
||||
if (victim is NPC) experience *= victim.behavior.getXpMultiplier(victim, player)
|
||||
player.skills.addExperience(Skills.MAGIC, experience * 1.33, true)
|
||||
player.skills.addExperience(Skills.DEFENCE, experience, true)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,9 +99,10 @@ open class NPCBehavior(vararg val ids: Int = intArrayOf()) : ContentInterface {
|
||||
/**
|
||||
* Called after this NPC's drop table is rolled, but before the items are actually dropped, so the list can be manipulated.
|
||||
* @param self the NPC instance this behavior belongs to
|
||||
* @param killer the killer of the npc
|
||||
* @param drops the generated list of drops for this roll of the table
|
||||
*/
|
||||
open fun onDropTableRolled(self: NPC, drops: ArrayList<Item>) {}
|
||||
open fun onDropTableRolled(self: NPC, killer: Entity, drops: ArrayList<Item>) {}
|
||||
|
||||
/**
|
||||
* Called by combat-related code to check if this NPC can be attacked by the `attacker` entity.
|
||||
@@ -139,4 +140,14 @@ open class NPCBehavior(vararg val ids: Int = intArrayOf()) : ContentInterface {
|
||||
open fun getClippingSupplier(self: NPC) : ClipMaskSupplier? {
|
||||
return StandardClipMaskSupplier
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the combat experience gained from killing an entity
|
||||
* @param self the NPC instance this behavior belongs to
|
||||
* @param attacker entity attacking the npc
|
||||
* @return multiplier for final xp gain
|
||||
*/
|
||||
open fun getXpMultiplier(self: NPC, attacker: Entity) : Double {
|
||||
return 1.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public final class NPCDropTables {
|
||||
public void drop(NPC npc, Entity looter) {
|
||||
Player p = looter instanceof Player ? (Player) looter : null;
|
||||
ArrayList<Item> drops = table.roll(looter);
|
||||
npc.behavior.onDropTableRolled(npc, drops);
|
||||
npc.behavior.onDropTableRolled(npc, looter, drops);
|
||||
drops.forEach(item -> createDrop(item,p,npc,npc.getDropLocation()));
|
||||
}
|
||||
|
||||
|
||||
@@ -551,6 +551,11 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
||||
content.global.ame.RandomEventManager.getInstance(player)!!.event!!.init()
|
||||
}
|
||||
|
||||
define("freak", Privilege.ADMIN){ player, _ ->
|
||||
content.global.ame.RandomEventManager.getInstance(player)!!.event = RandomEvents.FREAKY_FORESTER.npc.create(player)
|
||||
content.global.ame.RandomEventManager.getInstance(player)!!.event!!.init()
|
||||
}
|
||||
|
||||
define("revent", Privilege.ADMIN){ player, _ ->
|
||||
println(player.pulseManager.current)
|
||||
content.global.ame.RandomEventManager.getInstance(player)!!.fireEvent()
|
||||
|
||||
Reference in New Issue
Block a user