Add ranged combat support

* Clean up the CombatAction and Attack code to make it easier to use for
  range.

* Add collision detection to the distance checks before attacking in the
  CombatAction.

* Create a Ruby DSL for defining projectile types and fix the
  ProjectileUpdateOperation so it uses the correct position offset.

* Fix the packet structure of the HintIconMessageEncoder.
This commit is contained in:
Gary Tierney
2016-01-03 22:24:43 +00:00
parent f80ea82ce7
commit 3082fade1d
35 changed files with 741 additions and 433 deletions
+16 -12
View File
@@ -1,12 +1,14 @@
java_import 'org.apollo.game.model.entity.EquipmentConstants'
class CombatUtil
def self.current_speed(_mob)
end
def self.calculate_max_hit(source)
strength = source.skill_set.get_skill(Skill::STRENGTH)
strength_stat = 5 #source.bonus_stat(:other, :strength)
strength_stat = 5 # source.bonus_stat(:other, :strength)
effective_strength_damage = (strength.current_level) #* prayer_multiplier
effective_strength_damage = (strength.current_level) # * prayer_multiplier
if [:aggressive, :alt_aggressive].include? source.combat_style
effective_strength_damage += 3
@@ -19,8 +21,8 @@ class CombatUtil
def self.calculate_accuracy(source, target)
weapon = EquipmentUtil.equipped_weapon source
weapon_class = weapon.weapon_class
combat_style = weapon_class.style_at source.combat_style
attack_type = weapon.weapon_class.attack_type combat_style
combat_style = weapon_class.selected_style source
attack_type = combat_style.attack_type
attack_stat = [1, 1].max
defence_stat = [1, 1].max
@@ -28,11 +30,11 @@ class CombatUtil
attack = source.skill_set.get_skill(Skill::ATTACK).current_level.to_f
defence = target.skill_set.get_skill(Skill::DEFENCE).current_level.to_f
attack_prayer_multiplier = 1 #TODO: Prayer
attack_prayer_multiplier = 1 # TODO: Prayer
attack_accuracy = attack_stat * attack * attack_prayer_multiplier
attack_accuracy = 0.1 if attack_accuracy < 0
defence_prayer_multiplier = 1 #TODO: Prayer
defence_prayer_multiplier = 1 # TODO: Prayer
defence_accuracy = defence_stat * defence * defence_prayer_multiplier
defence_accuracy = 1 if defence_accuracy < 0
@@ -42,7 +44,7 @@ class CombatUtil
# Calculates a hit for the given <i>Mob</i> and special attack flag.
def self.calculate_hit(source, target)
accuracy = calculate_accuracy source, target
accuracy = calculate_accuracy(source, target)
max_hit = calculate_max_hit(source) + 1
if rand <= accuracy
@@ -57,14 +59,16 @@ class EquipmentUtil
def self.equipped_weapon(source)
item = source.equipment.get(EquipmentConstants::WEAPON)
if item.nil?
return NAMED_WEAPONS[:unarmed]
end
return NAMED_WEAPONS[:unarmed] if item.nil?
WEAPONS[item.id]
end
def self.equipped_projectile(source)
def self.equipped_ammo(source)
item = source.equipment.get(EquipmentConstants::ARROWS)
return nil if item.nil?
AMMO[item.id]
end
end
end