mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-27 21:35:13 -06:00
Merge branch 'master' into fist-of-guthix
This commit is contained in:
commit
cbb339518b
28 changed files with 173 additions and 177 deletions
|
|
@ -159,8 +159,8 @@ public final class GWDGraardorSwingHandler extends CombatSwingHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return getType().getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return getType().getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -192,8 +192,8 @@ public final class GWDKreeArraSwingHandler extends CombatSwingHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return getType().getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return getType().getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -143,8 +143,8 @@ public final class GWDTsutsarothSwingHandler extends CombatSwingHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return getType().getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return getType().getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@ public class GWDZilyanaSwingHandler extends CombatSwingHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return getType().getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return getType().getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -332,8 +332,8 @@ public final class TzhaarFightCaveNPC extends AbstractNPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -216,8 +216,8 @@ public final class ElvargNPC extends AbstractNPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -169,8 +169,8 @@ public final class MeldarMadNPC extends AbstractNPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -208,8 +208,8 @@ public class DragonfireSwingHandler extends CombatSwingHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return CombatStyle.MAGIC.getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return CombatStyle.MAGIC.getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -296,8 +296,8 @@ public final class KalphiteQueenNPC extends AbstractNPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -315,8 +315,8 @@ public class TormentedDemonNPC extends AbstractNPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(entity, attacker);
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
return style.getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -143,11 +143,11 @@ public final class KingBlackDragonNPC extends AbstractNPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculateDefence(Entity entity, Entity attacker) {
|
||||
public int calculateDefence(Entity victim, Entity attacker) {
|
||||
if (style == CombatStyle.MELEE) {
|
||||
return style.getSwingHandler().calculateDefence(entity, attacker);
|
||||
return style.getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
return CombatStyle.MAGIC.getSwingHandler().calculateDefence(entity, attacker);
|
||||
return CombatStyle.MAGIC.getSwingHandler().calculateDefence(victim, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package core.game.node.entity.player;
|
||||
|
||||
import api.ContentAPI;
|
||||
import core.game.component.Component;
|
||||
import core.game.container.Container;
|
||||
import core.game.container.impl.BankContainer;
|
||||
|
|
@ -70,6 +71,7 @@ import core.tools.RandomFunction;
|
|||
import core.tools.StringUtils;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.rs09.consts.Items;
|
||||
import rs09.ServerConstants;
|
||||
import rs09.game.VarpManager;
|
||||
import rs09.game.content.ame.RandomEventManager;
|
||||
|
|
@ -385,10 +387,10 @@ public class Player extends Entity {
|
|||
* @param force If we should force removal, a player engaged in combat will otherwise remain active until out of combat.
|
||||
*/
|
||||
public void clear(boolean force) {
|
||||
if (!force && allowRemoval()) {
|
||||
/*if (!force && allowRemoval()) {
|
||||
Repository.getDisconnectionQueue().add(this, true);
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
if (force) {
|
||||
Repository.getDisconnectionQueue().remove(getName());
|
||||
}
|
||||
|
|
@ -755,6 +757,14 @@ public class Player extends Entity {
|
|||
Arrays.fill(renderInfo.getAppearanceStamps(),0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player is wearing void.
|
||||
*/
|
||||
public boolean isWearingVoid(boolean melee){
|
||||
int helm = melee ? Items.VOID_MELEE_HELM_11665 : Items.VOID_RANGER_HELM_11664;
|
||||
return ContentAPI.inEquipment(this, helm, 1) && ContentAPI.inEquipment(this, Items.VOID_KNIGHT_ROBE_8840, 1) && ContentAPI.inEquipment(this, Items.VOID_KNIGHT_TOP_8839, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the player's scene graph.
|
||||
* @param login If the player is logging in.
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ public final class InterfaceManager {
|
|||
close(new Component(Components.OPTIONS_261)); // Settings
|
||||
close(new Component(Components.EMOTES_464)); // Emotes
|
||||
close(new Component(Components.MUSIC_V3_187)); // Music
|
||||
close(new Component(Components.LOGOUT_182)); // Logout
|
||||
//close(new Component(Components.LOGOUT_182)); // Logout
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import core.game.ge.GrandExchangeDatabase;
|
|||
import core.game.interaction.object.dmc.DMCHandler;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.info.login.PlayerParser;
|
||||
import rs09.Server;
|
||||
import rs09.ServerConstants;
|
||||
import rs09.game.ge.OfferManager;
|
||||
import rs09.game.system.SystemLogger;
|
||||
|
|
@ -57,6 +58,7 @@ public final class SystemTermination {
|
|||
if (!file.isDirectory()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
Server.getReactor().terminate();
|
||||
for (Iterator<Player> it = Repository.getPlayers().iterator(); it.hasNext();) {
|
||||
try {
|
||||
Player p = it.next();
|
||||
|
|
|
|||
|
|
@ -60,13 +60,7 @@ public class IoEventHandler {
|
|||
ByteBuffer buffer = ByteBuffer.allocate(100_000);
|
||||
IoSession session = (IoSession) key.attachment();
|
||||
if (channel.read(buffer) == -1) {
|
||||
if(session != null){
|
||||
if(session.getPlayer() != null){
|
||||
session.getPlayer().clear();
|
||||
}
|
||||
//key.cancel();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
buffer.flip();
|
||||
if (session == null) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import core.game.node.entity.impl.ForceMovement
|
|||
import core.game.node.entity.impl.Projectile
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.RunScript
|
||||
import core.game.node.entity.player.link.TeleportManager
|
||||
import core.game.node.entity.player.link.audio.Audio
|
||||
import core.game.node.entity.player.link.emote.Emotes
|
||||
|
|
@ -27,13 +26,14 @@ import core.game.system.task.Pulse
|
|||
import core.game.world.map.Direction
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
import core.game.world.map.RegionManager.getRegionChunk
|
||||
import core.game.world.map.path.Pathfinder
|
||||
import core.game.world.map.zone.MapZone
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
import core.game.world.map.zone.ZoneBuilder
|
||||
import core.game.world.update.flag.chunk.AnimateObjectUpdateFlag
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import core.tools.RandomFunction
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
|
|
@ -390,6 +390,16 @@ object ContentAPI {
|
|||
player.packetDispatch.sendSceneryAnimation(obj, getAnimation(animationId), global)
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an object animation independent of a player
|
||||
*/
|
||||
@JvmStatic
|
||||
fun animateScenery(obj: Scenery, animationId: Int){
|
||||
val animation = Animation(animationId)
|
||||
animation.setObject(obj)
|
||||
getRegionChunk(obj.location).flag(AnimateObjectUpdateFlag(animation))
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a ground item owned by the player
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ object Server {
|
|||
/**
|
||||
* The NIO reactor.
|
||||
*/
|
||||
@JvmStatic
|
||||
var reactor: NioReactor? = null
|
||||
|
||||
/**
|
||||
|
|
@ -72,7 +73,8 @@ object Server {
|
|||
Runtime.getRuntime().addShutdownHook(ServerConstants.SHUTDOWN_HOOK)
|
||||
SystemLogger.logInfo("Starting networking...")
|
||||
try {
|
||||
NioReactor.configure(43594 + GameWorld.settings?.worldId!!).start()
|
||||
reactor = NioReactor.configure(43594 + GameWorld.settings?.worldId!!)
|
||||
reactor!!.start()
|
||||
} catch (e: BindException) {
|
||||
SystemLogger.logErr("Port " + (43594 + GameWorld.settings?.worldId!!) + " is already in use!")
|
||||
throw e
|
||||
|
|
@ -88,7 +90,7 @@ object Server {
|
|||
while(scanner.hasNextLine()){
|
||||
val command = scanner.nextLine()
|
||||
when(command){
|
||||
"stop" -> SystemManager.flag(SystemState.TERMINATED)
|
||||
"stop" -> exitProcess(0)
|
||||
"players" -> System.out.println("Players online: " + (Repository.LOGGED_IN_PLAYERS.size))
|
||||
"update" -> SystemManager.flag(SystemState.UPDATING)
|
||||
"help","commands" -> printCommands()
|
||||
|
|
|
|||
|
|
@ -17,10 +17,15 @@ class RandomEventManager(val player: Player) {
|
|||
|
||||
fun fireEvent(){
|
||||
if(player.zoneMonitor.isRestricted(ZoneRestriction.RANDOM_EVENTS)){
|
||||
nextSpawn = GameWorld.ticks + 3000
|
||||
return
|
||||
}
|
||||
val ame = RandomEvents.values().random()
|
||||
event = ame.npc.create(player,ame.loot,ame.type)
|
||||
if(event!!.spawnLocation == null){
|
||||
nextSpawn = GameWorld.ticks + 3000
|
||||
return
|
||||
}
|
||||
event!!.init()
|
||||
nextSpawn = GameWorld.ticks + DELAY_TICKS
|
||||
SystemLogger.logRE("Fired ${event!!.name} for ${player.username}")
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ object DrillDemonUtils {
|
|||
fun teleport(player: Player){
|
||||
player.setAttribute(DD_KEY_RETURN_LOC,player.location)
|
||||
player.properties.teleportLocation = Location.create(3163, 4819, 0)
|
||||
player.interfaceManager.closeDefaultTabs()
|
||||
player.packetDispatch.sendInterfaceConfig(548, 69, true)
|
||||
player.packetDispatch.sendInterfaceConfig(746, 12, true)
|
||||
|
||||
ContentAPI.registerLogoutListener(player, "drilldemon"){p ->
|
||||
ContentAPI.teleport(p, player.getAttribute(DD_KEY_RETURN_LOC, p.location))
|
||||
|
|
@ -82,6 +85,9 @@ object DrillDemonUtils {
|
|||
player.removeAttribute(DD_KEY_TASK)
|
||||
player.removeAttribute(DD_CORRECT_OFFSET)
|
||||
player.removeAttribute(DD_CORRECT_COUNTER)
|
||||
player.interfaceManager.openDefaultTabs()
|
||||
player.packetDispatch.sendInterfaceConfig(548, 69, false)
|
||||
player.packetDispatch.sendInterfaceConfig(746, 12, false)
|
||||
}
|
||||
|
||||
fun animationForTask(task: Int): Animation {
|
||||
|
|
|
|||
|
|
@ -77,11 +77,11 @@ abstract class CombatSwingHandler(var type: CombatStyle?) {
|
|||
|
||||
/**
|
||||
* Calculates the maximum defence of the entity.
|
||||
* @param entity The entity.
|
||||
* @param victim The entity.
|
||||
* @param attacker The entity to defend against.
|
||||
* @return The maximum defence value.
|
||||
*/
|
||||
abstract fun calculateDefence(entity: Entity?, attacker: Entity?): Int
|
||||
abstract fun calculateDefence(victim: Entity?, attacker: Entity?): Int
|
||||
|
||||
/**
|
||||
* Gets the void set multiplier.
|
||||
|
|
@ -188,18 +188,17 @@ abstract class CombatSwingHandler(var type: CombatStyle?) {
|
|||
}
|
||||
val attack = calculateAccuracy(entity) * accuracyMod * mod * getSetMultiplier(entity, Skills.ATTACK)
|
||||
val defence = calculateDefence(victim, entity) * defenceMod * getSetMultiplier(victim, Skills.DEFENCE)
|
||||
val chance: Double
|
||||
chance = if (attack < defence) {
|
||||
(attack - 1) / (defence * 2)
|
||||
val chance: Double = if (attack < defence) {
|
||||
1 - ((defence + 2) / ((2 * attack) + 1))
|
||||
} else {
|
||||
1 - (defence + 1) / (attack * 2)
|
||||
attack / ((2 * defence) + 1)
|
||||
}
|
||||
val ratio = chance * 100
|
||||
val accuracy = floor(ratio)
|
||||
val block = floor(101 - ratio)
|
||||
val acc = Math.random() * accuracy
|
||||
val def = Math.random() * block
|
||||
return acc > def
|
||||
return (acc > def).also { if(entity?.username?.toLowerCase() == "test10") SystemLogger.logInfo("Should hit: $it") }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -202,14 +202,14 @@ open class MagicSwingHandler
|
|||
return (baseDamage * levelMod).toInt() + 1
|
||||
}
|
||||
|
||||
override fun calculateDefence(entity: Entity?, attacker: Entity?): Int {
|
||||
val level = entity!!.skills.getLevel(Skills.DEFENCE, true)
|
||||
override fun calculateDefence(victim: Entity?, attacker: Entity?): Int {
|
||||
val level = victim!!.skills.getLevel(Skills.DEFENCE, true)
|
||||
var prayer = 1.0
|
||||
if (entity is Player) {
|
||||
prayer += entity.prayer.getSkillBonus(Skills.MAGIC)
|
||||
if (victim is Player) {
|
||||
prayer += victim.prayer.getSkillBonus(Skills.MAGIC)
|
||||
}
|
||||
val effective = floor(level * prayer * 0.3) + entity.skills.getLevel(Skills.MAGIC, true) * 0.7
|
||||
val equipment = entity.properties.bonuses[WeaponInterface.BONUS_MAGIC + 5]
|
||||
val effective = floor(level * prayer * 0.3) + victim.skills.getLevel(Skills.MAGIC, true) * 0.7
|
||||
val equipment = victim.properties.bonuses[WeaponInterface.BONUS_MAGIC + 5]
|
||||
return floor((effective + 8) * (equipment + 64) / 10).toInt()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package rs09.game.node.entity.combat.handlers
|
||||
|
||||
import core.game.container.Container
|
||||
import api.ContentAPI
|
||||
import api.EquipmentSlot
|
||||
import core.game.container.impl.EquipmentContainer
|
||||
import core.game.content.quest.tutorials.tutorialisland.TutorialSession
|
||||
import core.game.content.quest.tutorials.tutorialisland.TutorialStage
|
||||
|
|
@ -18,7 +19,6 @@ import core.game.node.entity.state.EntityState
|
|||
import core.game.world.map.path.Pathfinder
|
||||
import core.tools.RandomFunction
|
||||
import rs09.game.node.entity.combat.CombatSwingHandler
|
||||
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks
|
||||
import kotlin.math.floor
|
||||
|
||||
/**
|
||||
|
|
@ -72,7 +72,7 @@ open class MeleeSwingHandler
|
|||
if (state.armourEffect === ArmourSet.VERAC || isAccurateImpact(entity, victim, CombatStyle.MELEE)) {
|
||||
val max = calculateHit(entity, victim, 1.0)
|
||||
state.maximumHit = max
|
||||
hit = RandomFunction.random(max)
|
||||
hit = RandomFunction.random(max + 1)
|
||||
}
|
||||
state.estimatedHit = hit
|
||||
if(victim != null) {
|
||||
|
|
@ -137,46 +137,36 @@ open class MeleeSwingHandler
|
|||
}
|
||||
|
||||
override fun calculateAccuracy(entity: Entity?): Int {
|
||||
val baseLevel = entity!!.skills.getStaticLevel(Skills.ATTACK)
|
||||
var weaponRequirement = baseLevel
|
||||
if (entity is Player) {
|
||||
val weapon = entity.equipment[3]
|
||||
weaponRequirement = weapon?.definition?.getRequirement(Skills.ATTACK) ?: 1
|
||||
//formula taken from wiki: https://oldschool.runescape.wiki/w/Damage_per_second/Melee#Step_six:_Calculate_the_hit_chance Yes I know it's old school. It's the best resource we have for potentially authentic formulae.
|
||||
entity ?: return 0
|
||||
var effectiveAttackLevel = entity.skills.getLevel(Skills.ATTACK).toDouble()
|
||||
if(entity is Player) effectiveAttackLevel = floor(effectiveAttackLevel + (entity.prayer.getSkillBonus(Skills.ATTACK) * effectiveAttackLevel))
|
||||
if(entity.properties.attackStyle.style == WeaponInterface.STYLE_ACCURATE) effectiveAttackLevel += 3
|
||||
else if(entity.properties.attackStyle.style == WeaponInterface.STYLE_CONTROLLED) effectiveAttackLevel += 1
|
||||
effectiveAttackLevel += 8
|
||||
if(entity is Player && entity.isWearingVoid(true)) effectiveAttackLevel *= 1.1
|
||||
effectiveAttackLevel = floor(effectiveAttackLevel)
|
||||
effectiveAttackLevel *= (entity.properties.bonuses[entity.properties.attackStyle.bonusType] + 64)
|
||||
|
||||
val helmetName = (if(entity is Player) ContentAPI.getItemFromEquipment(entity, EquipmentSlot.HAT)?.name ?: "null" else "null").toLowerCase()
|
||||
val amuletName = (if(entity is Player) ContentAPI.getItemFromEquipment(entity, EquipmentSlot.AMULET)?.name ?: "null" else "null").toLowerCase()
|
||||
val victimName = entity.properties.combatPulse.getVictim()?.name ?: "none"
|
||||
|
||||
if (entity is Player //Slayer helm/ black mask
|
||||
&& (helmetName.contains("black mask") || helmetName.contains("slayer helm"))
|
||||
&& entity.slayer.task?.ids?.contains((entity.properties.combatPulse.getVictim()?.id ?: 0)) == true
|
||||
) {
|
||||
effectiveAttackLevel *= 1.2
|
||||
}
|
||||
var weaponBonus = 0.0
|
||||
if (baseLevel > weaponRequirement) {
|
||||
weaponBonus = (baseLevel - weaponRequirement) * .3
|
||||
|
||||
else if (entity is Player //Salve amulet
|
||||
&& (amuletName.contains("salve"))
|
||||
&& checkUndead(victimName)
|
||||
) {
|
||||
effectiveAttackLevel *= 1.2
|
||||
}
|
||||
val style = entity.properties.attackStyle
|
||||
var level = entity.skills.getLevel(Skills.ATTACK)
|
||||
if(entity is Player && SkillcapePerks.isActive(SkillcapePerks.PRECISION_STRIKES,entity.asPlayer())){
|
||||
level += 6
|
||||
}
|
||||
var prayer = 1.0
|
||||
if (entity is Player) {
|
||||
prayer += entity.prayer.getSkillBonus(Skills.ATTACK)
|
||||
}
|
||||
var additional = 1.0 // Black mask/slayer helmet/salve/...
|
||||
if (entity.properties.combatPulse.getVictim() != null) {
|
||||
if (!entity.properties.combatPulse.getVictim()!!.isPlayer && entity is Player) {
|
||||
if (checkUndead(entity.getProperties().combatPulse.getVictim()!!.name) && entity.asPlayer().equipment[EquipmentContainer.SLOT_AMULET] != null) {
|
||||
if (entity.asPlayer().equipment[EquipmentContainer.SLOT_AMULET].id == 10588) {
|
||||
additional += 0.20
|
||||
} else if (entity.isPlayer() && entity.asPlayer().equipment[EquipmentContainer.SLOT_AMULET].id == 4081) {
|
||||
additional += 0.15
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var styleBonus = 0
|
||||
if (style.style == WeaponInterface.STYLE_ACCURATE) {
|
||||
styleBonus = 3
|
||||
} else if (style.style == WeaponInterface.STYLE_CONTROLLED) {
|
||||
styleBonus = 1
|
||||
}
|
||||
val effective = floor(level * prayer * additional + styleBonus + weaponBonus)
|
||||
val bonus = entity.properties.bonuses[style.bonusType]
|
||||
return floor((effective + 8) * (bonus + 64) / 10 * 1.10).toInt()
|
||||
|
||||
return floor(effectiveAttackLevel).toInt()
|
||||
}
|
||||
|
||||
override fun calculateHit(entity: Entity?, victim: Entity?, modifier: Double): Int {
|
||||
|
|
@ -198,22 +188,29 @@ open class MeleeSwingHandler
|
|||
return (1.3 + (cumulativeStr / 10) + (bonus / 80) + ((cumulativeStr * bonus) / 640)).toInt()
|
||||
}
|
||||
|
||||
override fun calculateDefence(entity: Entity?, attacker: Entity?): Int {
|
||||
val style = entity!!.properties.attackStyle
|
||||
var styleBonus = 0
|
||||
if (style.style == WeaponInterface.STYLE_DEFENSIVE || style.style == WeaponInterface.STYLE_LONG_RANGE) {
|
||||
styleBonus = 3
|
||||
} else if (style.style == WeaponInterface.STYLE_CONTROLLED) {
|
||||
styleBonus = 1
|
||||
override fun calculateDefence(victim: Entity?, attacker: Entity?): Int {
|
||||
//authentic formula, taken from OSRS wiki: https://oldschool.runescape.wiki/w/Damage_per_second/Melee#Step_five:_Calculate_the_Defence_roll
|
||||
victim ?: return 0
|
||||
attacker ?: return 0
|
||||
|
||||
when(victim){
|
||||
is Player -> {
|
||||
var effectiveDefenceLevel = victim.skills.getLevel(Skills.DEFENCE).toDouble()
|
||||
effectiveDefenceLevel = floor(effectiveDefenceLevel + (victim.prayer.getSkillBonus(Skills.DEFENCE) * effectiveDefenceLevel))
|
||||
if(victim.properties.attackStyle.style == WeaponInterface.STYLE_DEFENSIVE) effectiveDefenceLevel += 3
|
||||
else if(victim.properties.attackStyle.style == WeaponInterface.STYLE_CONTROLLED) effectiveDefenceLevel += 1
|
||||
effectiveDefenceLevel += 8
|
||||
effectiveDefenceLevel = floor(effectiveDefenceLevel)
|
||||
return floor(effectiveDefenceLevel * (victim.properties.bonuses[attacker.properties.attackStyle.bonusType + 5] + 64)).toInt()
|
||||
}
|
||||
is NPC -> {
|
||||
val defLevel = victim.skills.getLevel(Skills.DEFENCE)
|
||||
val styleDefenceBonus = victim.properties.bonuses[attacker.properties.attackStyle.bonusType + 5] + 64
|
||||
return defLevel * styleDefenceBonus
|
||||
}
|
||||
}
|
||||
val level = entity.skills.getLevel(Skills.DEFENCE)
|
||||
var prayer = 1.0
|
||||
if (entity is Player) {
|
||||
prayer += entity.prayer.getSkillBonus(Skills.DEFENCE)
|
||||
}
|
||||
val effective = floor(level * prayer + styleBonus)
|
||||
val equipment = entity.properties.bonuses[attacker!!.properties.attackStyle.bonusType + 5]
|
||||
return floor((effective + 8) * (equipment + 64) / 10).toInt()
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun getSetMultiplier(e: Entity?, skillId: Int): Double {
|
||||
|
|
@ -221,19 +218,6 @@ open class MeleeSwingHandler
|
|||
// System.out.println("Fiist number -> " + 1.0 + ((e.getSkills().getMaximumLifepoints() - e.getSkills().getLifepoints()) * 0.01));
|
||||
return 1.0 + (e!!.skills.maximumLifepoints - e.skills.lifepoints) * 0.01
|
||||
}
|
||||
if (e is Player) {
|
||||
val c: Container = e.equipment
|
||||
val itemId = c.getNew(EquipmentContainer.SLOT_HAT).id
|
||||
if ((skillId == Skills.ATTACK || skillId == Skills.STRENGTH) && (itemId in 8901..8921 || itemId == 13263)) {
|
||||
val victim = e.getProperties().combatPulse.getVictim()
|
||||
if (victim is NPC && victim.task == e.slayer.task) {
|
||||
return 1.15
|
||||
}
|
||||
}
|
||||
if (containsVoidSet(c) && c.getNew(EquipmentContainer.SLOT_HAT).id == 11665) {
|
||||
return 1.1
|
||||
}
|
||||
}
|
||||
return 1.0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ open class MultiSwingHandler(meleeDistance: Boolean, vararg attacks: SwitchAttac
|
|||
} else current.handler.calculateHit(entity, victim, modifier)
|
||||
}
|
||||
|
||||
override fun calculateDefence(entity: Entity?, attacker: Entity?): Int {
|
||||
return current.handler.calculateDefence(entity, attacker)
|
||||
override fun calculateDefence(victim: Entity?, attacker: Entity?): Int {
|
||||
return current.handler.calculateDefence(victim, attacker)
|
||||
}
|
||||
|
||||
override fun getSetMultiplier(e: Entity?, skillId: Int): Double {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package rs09.game.node.entity.combat.handlers
|
||||
|
||||
import api.ContentAPI
|
||||
import api.EquipmentSlot
|
||||
import core.game.container.Container
|
||||
import core.game.container.impl.EquipmentContainer
|
||||
import core.game.content.quest.tutorials.tutorialisland.TutorialSession
|
||||
|
|
@ -79,9 +81,9 @@ open class RangeSwingHandler
|
|||
}
|
||||
var hit = 0
|
||||
if (isAccurateImpact(entity, victim, CombatStyle.RANGE)) {
|
||||
val max = calculateHit(entity, victim, 1.0)
|
||||
val max = calculateHit(entity, victim, 1.0).also { if(entity?.name?.toLowerCase() == "test10") SystemLogger.logInfo("Damage: $it") }
|
||||
state.maximumHit = max
|
||||
hit = RandomFunction.random(max)
|
||||
hit = RandomFunction.random(max + 1)
|
||||
}
|
||||
state.estimatedHit = hit
|
||||
if (state.weapon.type == WeaponType.DOUBLE_SHOT) {
|
||||
|
|
@ -239,32 +241,16 @@ open class RangeSwingHandler
|
|||
}
|
||||
|
||||
override fun calculateAccuracy(entity: Entity?): Int {
|
||||
val baseLevel = entity!!.skills.getStaticLevel(Skills.RANGE)
|
||||
var weaponRequirement = baseLevel
|
||||
if (entity is Player) {
|
||||
val weapon = entity.equipment[3]
|
||||
weaponRequirement = weapon?.definition?.getRequirement(Skills.RANGE) ?: 1
|
||||
}
|
||||
var weaponBonus = 0.0
|
||||
if (baseLevel > weaponRequirement) {
|
||||
weaponBonus = (baseLevel - weaponRequirement) * .3
|
||||
}
|
||||
val level = entity.skills.getLevel(Skills.RANGE)
|
||||
var prayer = 1.0
|
||||
if (entity is Player) {
|
||||
prayer += entity.prayer.getSkillBonus(Skills.RANGE)
|
||||
}
|
||||
var additional = 1.0 // Slayer helmet/salve/...
|
||||
if(entity is Player && rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks.isActive(rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks.ACCURATE_MARKSMAN,entity.asPlayer())){
|
||||
additional += 0.5
|
||||
}
|
||||
var styleBonus = 0
|
||||
if (entity.properties.attackStyle.style == WeaponInterface.STYLE_RANGE_ACCURATE) {
|
||||
styleBonus = 3
|
||||
}
|
||||
val effective = floor(level * prayer * additional + styleBonus + weaponBonus)
|
||||
val bonus = entity.properties.bonuses[WeaponInterface.BONUS_RANGE]
|
||||
return floor((effective + 8) * (bonus + 64) / 10).toInt()
|
||||
entity ?: return 0
|
||||
var effectiveRangedLevel = entity.skills.getLevel(Skills.RANGE).toDouble()
|
||||
if(entity is Player) effectiveRangedLevel = floor(effectiveRangedLevel + (entity.prayer.getSkillBonus(Skills.RANGE) * effectiveRangedLevel))
|
||||
if(entity.properties.attackStyle.style == WeaponInterface.STYLE_RANGE_ACCURATE) effectiveRangedLevel += 3
|
||||
effectiveRangedLevel += 8
|
||||
if(entity is Player && entity.isWearingVoid(false)) effectiveRangedLevel *= 1.1
|
||||
effectiveRangedLevel = floor(effectiveRangedLevel)
|
||||
effectiveRangedLevel *= (entity.properties.bonuses[entity.properties.attackStyle.bonusType] + 64)
|
||||
|
||||
return floor(effectiveRangedLevel).toInt()
|
||||
}
|
||||
|
||||
override fun calculateHit(entity: Entity?, victim: Entity?, modifier: Double): Int {
|
||||
|
|
@ -277,30 +263,20 @@ open class RangeSwingHandler
|
|||
var cumulativeStr = floor(level * prayer)
|
||||
if (entity.properties.attackStyle.style == WeaponInterface.STYLE_RANGE_ACCURATE) {
|
||||
cumulativeStr += 3.0
|
||||
} else if (entity.properties.attackStyle.style == WeaponInterface.STYLE_LONG_RANGE) {
|
||||
cumulativeStr += 1.0
|
||||
}
|
||||
cumulativeStr *= getSetMultiplier(entity, Skills.RANGE)
|
||||
return (1.3 + (cumulativeStr / 10) + (bonus / 80) + ((cumulativeStr * bonus) / 640)).toInt()
|
||||
cumulativeStr *= (bonus + 64)
|
||||
return floor(1.5 + (ceil(cumulativeStr) / 640.0)).toInt()
|
||||
//return ((14 + cumulativeStr + bonus / 8 + cumulativeStr * bonus * 0.016865) * modifier).toInt() / 10 + 1
|
||||
}
|
||||
|
||||
override fun calculateDefence(entity: Entity?, attacker: Entity?): Int {
|
||||
val style = entity!!.properties.attackStyle
|
||||
var styleBonus = 0
|
||||
if (style.style == WeaponInterface.STYLE_DEFENSIVE || style.style == WeaponInterface.STYLE_LONG_RANGE) {
|
||||
styleBonus = 3
|
||||
} else if (style.style == WeaponInterface.STYLE_CONTROLLED) {
|
||||
styleBonus = 1
|
||||
}
|
||||
val level = entity.skills.getLevel(Skills.DEFENCE)
|
||||
var prayer = 1.0
|
||||
if (entity is Player) {
|
||||
prayer += entity.prayer.getSkillBonus(Skills.DEFENCE)
|
||||
}
|
||||
val effective = floor(level * prayer + styleBonus)
|
||||
val equipment = entity.properties.bonuses[WeaponInterface.BONUS_RANGE + 5]
|
||||
return floor((effective + 8) * (equipment + 64) / 10).toInt()
|
||||
override fun calculateDefence(victim: Entity?, attacker: Entity?): Int {
|
||||
victim ?: return 0
|
||||
attacker ?: return 0
|
||||
|
||||
val defLevel = victim.skills.getLevel(Skills.DEFENCE)
|
||||
val styleDefenceBonus = victim.properties.bonuses[attacker.properties.attackStyle.bonusType + 5] + 64
|
||||
return defLevel * styleDefenceBonus
|
||||
}
|
||||
|
||||
override fun getSetMultiplier(e: Entity?, skillId: Int): Double {
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ class SalamanderSwingHandler(private var style: CombatStyle) : CombatSwingHandle
|
|||
}
|
||||
}
|
||||
|
||||
override fun calculateDefence(entity: Entity?, attacker: Entity?): Int {
|
||||
return style.swingHandler.calculateDefence(entity, attacker)
|
||||
override fun calculateDefence(victim: Entity?, attacker: Entity?): Int {
|
||||
return style.swingHandler.calculateDefence(victim, attacker)
|
||||
}
|
||||
|
||||
override fun getSetMultiplier(e: Entity?, skillId: Int): Double {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
|
|||
PatchType.BUSH -> {
|
||||
if(isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,getBushDeathValue())
|
||||
else if(isDiseased && !isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,getBushDiseaseValue())
|
||||
else player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, plantable?.value ?: 0 + currentGrowthStage)
|
||||
//else player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, (plantable?.value ?: 0) + currentGrowthStage)
|
||||
}
|
||||
PatchType.TREE -> {
|
||||
if(isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset + 7,1)
|
||||
|
|
@ -100,7 +100,7 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
|
|||
|
||||
private fun getBushDiseaseValue(): Int{
|
||||
if(plantable == Plantable.POISON_IVY_SEED){
|
||||
return (plantable?.value ?: 0) + currentGrowthStage + 13
|
||||
return (plantable?.value ?: 0) + currentGrowthStage + 12
|
||||
} else {
|
||||
return (plantable?.value ?: 0) + currentGrowthStage + 65
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@ import rs09.game.world.GameWorld
|
|||
*/
|
||||
class AbyssPlugin : InteractionListener() {
|
||||
|
||||
val OBSTACLE = AbbysalObstacle.values().filter { it != AbbysalObstacle.MINE && it != AbbysalObstacle.SQUEEZE && it != AbbysalObstacle.PASSAGE}.map { it.option }.toTypedArray()
|
||||
val OBSTACLE = AbbysalObstacle.values().filter { it != AbbysalObstacle.MINE && it != AbbysalObstacle.SQUEEZE && it != AbbysalObstacle.PASSAGE && it != AbbysalObstacle.CHOP }.map { it.option }.toTypedArray()
|
||||
val miningObstacle = 7158
|
||||
val agilityObstacle = 7164
|
||||
val passage = 7154
|
||||
val chopObstacle = 7161
|
||||
|
||||
override fun defineListeners() {
|
||||
definePlugin(AbyssalNPC())
|
||||
|
|
@ -68,7 +69,11 @@ class AbyssPlugin : InteractionListener() {
|
|||
obstacle!!.handle(player, node as Scenery)
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(chopObstacle, SCENERY, "chop"){ player, node ->
|
||||
val obstacle = AbbysalObstacle.forObject(node as Scenery)
|
||||
obstacle!!.handle(player, node as Scenery)
|
||||
return@on true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class DisconnectionQueue {
|
|||
return false
|
||||
}
|
||||
if (entry.isClear) {
|
||||
SystemLogger.logInfo("Clearing player...")
|
||||
player.clear()
|
||||
}
|
||||
Repository.playerNames.remove(player.name)
|
||||
|
|
@ -61,8 +62,10 @@ class DisconnectionQueue {
|
|||
Repository.LOGGED_IN_PLAYERS.remove(player.details.username)
|
||||
SystemLogger.logInfo("Player cleared. Removed ${player.details.username}")
|
||||
try {
|
||||
player.communication.clan.leave(player, false)
|
||||
if(player.communication.clan != null)
|
||||
player.communication.clan.leave(player, false)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
if (player.isArtificial) {
|
||||
return true
|
||||
|
|
@ -194,8 +197,8 @@ class DisconnectionQueue {
|
|||
if (sql) {
|
||||
player.details.sqlManager.update(player)
|
||||
player.details.save()
|
||||
SQLEntryHandler.write(HighscoreSQLHandler(player))
|
||||
SQLEntryHandler.write(PlayerLogSQLHandler(player.monitor, player.name))
|
||||
/*SQLEntryHandler.write(HighscoreSQLHandler(player))
|
||||
SQLEntryHandler.write(PlayerLogSQLHandler(player.monitor, player.name))*/
|
||||
}
|
||||
return true
|
||||
} catch (t: Throwable) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue