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
+34
View File
@@ -0,0 +1,34 @@
AMMO = {}
def create_ammo(item_matcher, properties, &block)
items = find_entities :item, item_matcher, -1
fail "Unable to find ammo matching #{item_matcher}" unless items.size > 0
projectile_type = properties[:projectile_type]
fail "Unable to find projectile type #{projectile_type}" unless PROJECTILE_TYPES.key? projectile_type
properties[:projectile_type] = PROJECTILE_TYPES[projectile_type]
items.each do |item_id|
AMMO[item_id] = Ammo.new(item_id, properties)
AMMO[item_id].instance_eval &block if block_given?
end
end
private
class Ammo
attr_reader :item, :weapon_classes, :projectile, :projectile_type, :level_requirement, :drop_rate, :graphic
include Combat::BonusContainer
def initialize(item, weapon_classes:, projectile:, projectile_type:, level_requirement:, drop_rate:, graphic: nil)
@item = item
@weapon_classes = weapon_classes
@projectile = projectile
@projectile_type = projectile_type
@level_requirement = level_requirement
@drop_rate = drop_rate
@graphic = graphic
end
end