Class: LZRTag::Hook::Damager

Inherits:
Base
  • Object
show all
Defined in:
lib/lzrtag/hooks/standard_hooks.rb

Instance Method Summary collapse

Methods inherited from Base

#consume_event, describe_option, getCBs, getOptionDescriptions, on, #on, #on_hookin, #on_hookout

Constructor Details

#initialize(handler, **options) ⇒ Damager

Returns a new instance of Damager.



144
145
146
147
148
149
150
151
# File 'lib/lzrtag/hooks/standard_hooks.rb', line 144

def initialize(handler, **options)
  super(handler);

  @dmgPerShot = options[:dmgPerShot] || 40;
  @useDamageMultiplier = options[:useDamageMultiplier] || true;
  @friendlyFire = options[:friendlyFire] || false;
  @hitThreshold = options[:hitThreshold] || 10;
end

Instance Method Details

#process_raw_hit(hitPlayer, sourcePlayer) ⇒ Object



153
154
155
156
157
158
159
160
# File 'lib/lzrtag/hooks/standard_hooks.rb', line 153

def process_raw_hit(hitPlayer, sourcePlayer)
  unless(@friendlyFire)
    return false if hitPlayer.team == sourcePlayer.team
  end
  return false if(hitPlayer.dead && (hitPlayer.life < @hitThreshold));

  return true;
end