Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions code/datums/actions/mobs/dodge_roll.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/datum/action/cooldown/mob_cooldown/dodge_roll
name = "Dodge Roll"
button_icon = 'icons/mob/actions/actions_items.dmi'
button_icon_state = "sniper_zoom"
desc = "Perform a quick dodge roll in your facing direction. Grants complete invulnerability to damage during the roll."
cooldown_time = 3 SECONDS
/// Duration of invulnerability and rolling state
var/roll_duration = 0.8 SECONDS
/// Distance moved during roll
var/roll_distance = 3

/datum/action/cooldown/mob_cooldown/dodge_roll/Activate(atom/target_atom)
var/mob/living/L = owner
if(!istype(L) || L.incapacitated())
return FALSE

perform_dodge_roll(L)
StartCooldown()
return TRUE

/datum/action/cooldown/mob_cooldown/dodge_roll/proc/perform_dodge_roll(mob/living/user)
if(!user)
return

var/was_already_godmode = (user.status_flags & GODMODE) != 0

// Grant temporary invulnerability (no damage taken)
user.status_flags |= GODMODE
user.visible_message(
span_warning("[user] performs a nimble dodge roll!"),
span_notice("You perform a dodge roll, granting temporary invulnerability!")
)

// Animate spin / roll visual
animate(user, transform = turn(matrix(), 180), time = roll_duration / 2, loop = 1)
animate(transform = turn(matrix(), 360), time = roll_duration / 2)

// Move user forward in facing direction
for(var/i in 1 to roll_distance)
step(user, user.dir)
sleep(1)

// Remove invulnerability after roll finishes only if user was not originally in godmode
addtimer(CALLBACK(GLOBAL_PROC, /proc/end_dodge_invulnerability, user, was_already_godmode), roll_duration)

/proc/end_dodge_invulnerability(mob/living/user, was_already_godmode = FALSE)
if(!user || QDELETED(user))
return
if(!was_already_godmode)
user.status_flags &= ~GODMODE
user.transform = matrix() // Reset transform matrix
4 changes: 4 additions & 0 deletions html/changelogs/AutoChangeLog-MochiGem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
author: "MochiGem"
delete-after: True
changes:
- rscadd: "Added Dodge Rolling action with temporary invulnerability and GODMODE state preservation."
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@
#include "code\datums\actions\mobs\assume_form.dm"
#include "code\datums\actions\mobs\blood_warp.dm"
#include "code\datums\actions\mobs\charge.dm"
#include "code\datums\actions\mobs\dodge_roll.dm"
#include "code\datums\actions\mobs\charge_apc.dm"
#include "code\datums\actions\mobs\chase_target.dm"
#include "code\datums\actions\mobs\conjure_foamwall.dm"
Expand Down