Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
85 lines (61 sloc) 1.67 KB
---
syntax:
- "attack <character>"
- "attack <character> with <prop>"
- "kill <character>"
- "kill <character> with <prop>"
- "stab <character>"
- "stab <character> with <prop>"
- "kick <character>"
- "kick <prop>"
- "punch <character>"
- "hit <character>"
- "hit <prop>"
- "beat <character>"
- "smash <prop>"
logic: |
weapon = prop ? prop.id : ''
output = ''
if prop && !character
output = @game.event(prop, 'on_break')
if (output == '')
output << "Is wanton destruction really the answer?\n"
end
else
if !character.dead
attack_strength = @player.strength
# target character is now hostile
character.hostile = true
# if a weapon hasn't been selected, pick best one
if weapon.empty?
weapon = @player.determine_best_weapon
end
# if applicable, add weapon strength to attack strength
if not weapon.empty?
attack_strength += @props[weapon].traits['attack_strength']
else
weapon = 'your fists'
end
if @props[weapon]
weapon = @props[weapon].noun
end
attack_strength = attack_strength < 2 ? 2 : attack_strength
damage = rand(attack_strength)
character.hp = character.hp - damage
output << "You attack #{noun} with #{weapon}"
if (damage == 0)
output << ", but do no damage.\n"
else
output << " for #{damage.to_s} HP damage.\n"
end
if character.hp < 1
output << character.kill
output << "You have killed #{noun}.\n"
else
output << "#{noun_cap} has #{(character.hp).to_s} HP.\n"
end
else
output << "#{noun_cap} is already dead.\n"
end
end
output
Jump to Line
Something went wrong with that request. Please try again.