Mizar999 / godot-roguelike

A coffee-break roguelike made with Godot game engine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Combat

Mizar999 opened this issue · comments

commented
  • Add a game log
  • Add an attack action
  • Implement basic combat mechanics
func attack(source, target) -> void:
    if attackHits(source, target):
        applyHits(source, target)

func attackHits(source, target) -> bool:
    var result = roll(source.dex)
    if result < 0.25:
        return false
    return (source.dex - (target.dex * 0.5) + result) > 4

func roll(sides: int) -> float:
    var result = (rand() * rand()) * sides * 0.5
    if result > (sides - 0.5):
        result += roll(sides)
    return result