Skip to content

Commit

Permalink
Merge pull request #2031 from MistakeNot4892/giddyup
Browse files Browse the repository at this point in the history
Adds mob riding for small mobs and simple_animals.
  • Loading branch information
out-of-phaze authored Feb 26, 2024
2 parents ca2087c + 34fc05d commit 73d27c9
Show file tree
Hide file tree
Showing 23 changed files with 257 additions and 115 deletions.
1 change: 0 additions & 1 deletion code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,3 @@

/atom/movable/proc/get_object_size()
return ITEM_SIZE_NORMAL

11 changes: 9 additions & 2 deletions code/game/atoms_movable_grabs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,12 @@
return try_make_grab(user)
return ..()

/atom/movable/proc/try_make_grab(var/mob/living/user, var/defer_hand = FALSE)
return istype(user) && CanPhysicallyInteract(user) && !user.lying && user.make_grab(src)
/atom/movable/proc/try_make_grab(mob/living/user, defer_hand = FALSE)
if(istype(user) && CanPhysicallyInteract(user) && !user.lying)
if(user == buckled_mob)
return give_control_grab(buckled_mob)
return user.make_grab(src, defer_hand = defer_hand)
return null

/atom/movable/proc/give_control_grab(var/mob/M)
return
3 changes: 3 additions & 0 deletions code/modules/mob/animations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
sleep(4)
reset_offsets()

if(buckled_mob)
buckled_mob.do_attack_animation(A, weapon)

/mob/proc/clear_shown_overlays(var/list/show_to, var/image/I)
for(var/client/C in show_to)
C.images -= I
Expand Down
78 changes: 47 additions & 31 deletions code/modules/mob/grab/grab_datum.dm
Original file line number Diff line number Diff line change
@@ -1,38 +1,54 @@
/decl/grab
var/name = "generic grab"
var/decl/grab/upgrab // The grab that this will upgrade to if it upgrades, null means no upgrade
var/decl/grab/downgrab // The grab that this will downgrade to if it downgrades, null means break grab on downgrade
var/stop_move = 0 // Whether or not the grabbed person can move out of the grab
var/reverse_facing = 0 // Whether the person being grabbed is facing forwards or backwards.
var/shield_assailant = 0 // Whether the person you're grabbing will shield you from bullets.,,
var/point_blank_mult = 1 // How much the grab increases point blank damage.
var/damage_stage = 1 // Affects how much damage is being dealt using certain actions.
var/same_tile = 0 // If the grabbed person and the grabbing person are on the same tile.
var/can_throw = 0 // If the grabber can throw the person grabbed.
var/downgrade_on_action = 0 // If the grab needs to be downgraded when the grabber does stuff.
var/downgrade_on_move = 0 // If the grab needs to be downgraded when the grabber moves.
var/force_danger = 0 // If the grab is strong enough to be able to force someone to do something harmful to them.
var/restrains = 0 // If the grab acts like cuffs and prevents action from the victim.
var/grab_slowdown = 0.15 // Multiplier for the object size (w_class or mob_size) of the grabbed atom, applied as slowdown.
var/shift = 0 // Whether or not this grab causes atoms to adjust their pixel offsets according to grabber dir.
var/adjust_plane = TRUE // Whether or not this grab causes atoms to adjust their plane/layer according to grabber dir.
var/success_up = "You get a better grip on $rep_affecting$."
var/success_down = "You adjust your grip on $rep_affecting$."
var/fail_up = "You can't get a better grip on $rep_affecting$!"
var/fail_down = "You can't seem to relax your grip on $rep_affecting$!"
var/icon
var/icon_state
var/upgrade_cooldown = 40
var/action_cooldown = 40
var/name = "generic grab"
/// Whether or not the grabbed person can move out of the grab
var/stop_move = 0
/// Whether the person being grabbed is facing forwards or backwards.
var/reverse_facing = 0
/// Whether the person you're grabbing will shield you from bullets.,,
var/shield_assailant = 0
/// How much the grab increases point blank damage.
var/point_blank_mult = 1
/// Affects how much damage is being dealt using certain actions.
var/damage_stage = 1
/// If the grabbed person and the grabbing person are on the same tile.
var/same_tile = 0
/// If the grabber can throw the person grabbed.
var/can_throw = 0
/// If the grab needs to be downgraded when the grabber does stuff.
var/downgrade_on_action = 0
/// If the grab needs to be downgraded when the grabber moves.
var/downgrade_on_move = 0
/// If the grab is strong enough to be able to force someone to do something harmful to them.
var/force_danger = 0
/// If the grab acts like cuffs and prevents action from the victim.
var/restrains = 0
/// Multiplier for the object size (w_class or mob_size) of the grabbed atom, applied as slowdown.
var/grab_slowdown = 0.15
/// Whether or not this grab causes atoms to adjust their pixel offsets according to grabber dir.
var/shift = 0
/// Whether or not this grab causes atoms to adjust their plane/layer according to grabber dir.
var/adjust_plane = TRUE
var/success_up = "You get a better grip on $rep_affecting$."
var/success_down = "You adjust your grip on $rep_affecting$."
var/fail_up = "You can't get a better grip on $rep_affecting$!"
var/fail_down = "You can't seem to relax your grip on $rep_affecting$!"
var/grab_icon = 'icons/mob/screen1.dmi'
var/grab_icon_state = "reinforce"
var/upgrade_cooldown = 40
var/action_cooldown = 40
var/can_downgrade_on_resist = 1
var/list/break_chance_table = list(100)
var/breakability = 2
var/breakability = 2
/// The names of different intents for use in attack logs
var/help_action = "help intent"
var/disarm_action = "disarm intent"
var/grab_action = "grab intent"
var/harm_action = "harm intent"
/// The grab that this will upgrade to if it upgrades, null means no upgrade
var/decl/grab/upgrab
/// The grab that this will downgrade to if it downgrades, null means break grab on downgrade
var/decl/grab/downgrab

// The names of different intents for use in attack logs
var/help_action = "help intent"
var/disarm_action = "disarm intent"
var/grab_action = "grab intent"
var/harm_action = "harm intent"

/decl/grab/Initialize()
if(ispath(upgrab, /decl/grab))
Expand Down
8 changes: 4 additions & 4 deletions code/modules/mob/grab/grab_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@

/obj/item/grab/on_update_icon()
. = ..()
if(current_grab.icon)
icon = current_grab.icon
if(current_grab.icon_state)
icon_state = current_grab.icon_state
if(current_grab.grab_icon)
icon = current_grab.grab_icon
if(current_grab.grab_icon_state)
icon_state = current_grab.grab_icon_state

/obj/item/grab/proc/throw_held()
return current_grab.throw_held(src)
Expand Down
11 changes: 5 additions & 6 deletions code/modules/mob/grab/normal/grab_normal.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/decl/grab/normal
name = "grab"
icon = 'icons/mob/screen1.dmi'
help_action = "inspect"
disarm_action = "pin"
grab_action = "jointlock"
harm_action = "dislocate"
name = "grab"
help_action = "inspect"
disarm_action = "pin"
grab_action = "jointlock"
harm_action = "dislocate"
var/drop_headbutt = 1

/decl/grab/normal/on_hit_help(var/obj/item/grab/G, var/atom/A, var/proximity)
Expand Down
28 changes: 14 additions & 14 deletions code/modules/mob/grab/normal/norm_aggressive.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/decl/grab/normal/aggressive
name = "aggressive grab"
upgrab = /decl/grab/normal/neck
downgrab = /decl/grab/normal/passive
shift = 12
stop_move = 1
reverse_facing = 0
shield_assailant = 0
point_blank_mult = 1.5
damage_stage = 1
same_tile = 0
can_throw = 1
force_danger = 1
breakability = 3
icon_state = "reinforce1"
name = "aggressive grab"
upgrab = /decl/grab/normal/neck
downgrab = /decl/grab/normal/passive
shift = 12
stop_move = 1
reverse_facing = 0
shield_assailant = 0
point_blank_mult = 1.5
damage_stage = 1
same_tile = 0
can_throw = 1
force_danger = 1
breakability = 3
grab_icon_state = "reinforce1"
break_chance_table = list(5, 20, 40, 80, 100)

/decl/grab/normal/aggressive/process_effect(var/obj/item/grab/G)
Expand Down
28 changes: 14 additions & 14 deletions code/modules/mob/grab/normal/norm_kill.dm
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/decl/grab/normal/kill
name = "strangle"
downgrab = /decl/grab/normal/neck
shift = 0
stop_move = 1
reverse_facing = 1
shield_assailant = 0
point_blank_mult = 2
damage_stage = 3
same_tile = 1
force_danger = 1
restrains = 1
name = "strangle"
downgrab = /decl/grab/normal/neck
shift = 0
stop_move = 1
reverse_facing = 1
shield_assailant = 0
point_blank_mult = 2
damage_stage = 3
same_tile = 1
force_danger = 1
restrains = 1
downgrade_on_action = 1
downgrade_on_move = 1
icon_state = "kill1"
break_chance_table = list(5, 20, 40, 80, 100)
downgrade_on_move = 1
grab_icon_state = "kill1"
break_chance_table = list(5, 20, 40, 80, 100)

/decl/grab/normal/kill/process_effect(var/obj/item/grab/G)
var/mob/living/affecting = G.get_affecting_mob()
Expand Down
30 changes: 15 additions & 15 deletions code/modules/mob/grab/normal/norm_neck.dm
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/decl/grab/normal/neck
name = "chokehold"
upgrab = /decl/grab/normal/kill
downgrab = /decl/grab/normal/aggressive
drop_headbutt = 0
shift = -10
stop_move = 1
reverse_facing = 1
shield_assailant = 1
point_blank_mult = 2
damage_stage = 2
same_tile = 1
can_throw = 1
force_danger = 1
restrains = 1
icon_state = "kill"
name = "chokehold"
upgrab = /decl/grab/normal/kill
downgrab = /decl/grab/normal/aggressive
drop_headbutt = 0
shift = -10
stop_move = 1
reverse_facing = 1
shield_assailant = 1
point_blank_mult = 2
damage_stage = 2
same_tile = 1
can_throw = 1
force_danger = 1
restrains = 1
grab_icon_state = "kill"
break_chance_table = list(3, 18, 45, 100)

/decl/grab/normal/neck/process_effect(var/obj/item/grab/G)
Expand Down
18 changes: 9 additions & 9 deletions code/modules/mob/grab/normal/norm_passive.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/decl/grab/normal/passive
name = "passive hold"
upgrab = /decl/grab/normal/struggle
shift = 8
stop_move = 0
reverse_facing = 0
shield_assailant = 0
point_blank_mult = 1.1
same_tile = 0
icon_state = "reinforce"
name = "passive hold"
upgrab = /decl/grab/normal/struggle
shift = 8
stop_move = 0
reverse_facing = 0
shield_assailant = 0
point_blank_mult = 1.1
same_tile = 0
grab_icon_state = "reinforce"
break_chance_table = list(15, 60, 100)

/decl/grab/normal/passive/on_hit_disarm(var/obj/item/grab/G, var/atom/A, var/proximity)
Expand Down
26 changes: 13 additions & 13 deletions code/modules/mob/grab/normal/norm_struggle.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/decl/grab/normal/struggle
name = "struggle grab"
upgrab = /decl/grab/normal/aggressive
downgrab = /decl/grab/normal/passive
shift = 8
stop_move = 1
reverse_facing = 0
point_blank_mult = 1
same_tile = 0
breakability = 3
grab_slowdown = 0.35
upgrade_cooldown = 20
name = "struggle grab"
upgrab = /decl/grab/normal/aggressive
downgrab = /decl/grab/normal/passive
shift = 8
stop_move = 1
reverse_facing = 0
point_blank_mult = 1
same_tile = 0
breakability = 3
grab_slowdown = 0.35
upgrade_cooldown = 20
can_downgrade_on_resist = 0
icon_state = "reinforce"
break_chance_table = list(5, 20, 30, 80, 100)
grab_icon_state = "reinforce"
break_chance_table = list(5, 20, 30, 80, 100)

/decl/grab/normal/struggle/process_effect(var/obj/item/grab/G)
var/mob/living/affecting = G.get_affecting_mob()
Expand Down
49 changes: 49 additions & 0 deletions code/modules/mob/grab/simple/simple_control.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/decl/grab/simple/control
name = "controlling grab"
shift = 0
adjust_plane = FALSE

/decl/grab/simple/control/on_hit_help(var/obj/item/grab/G, var/atom/A, var/proximity)
if(A == G.assailant)
A = G.affecting
if(isliving(G.affecting))
var/mob/living/living_mob = G.affecting
return living_mob.handle_rider_help_order(G.assailant, A, proximity)
return FALSE

/decl/grab/simple/control/on_hit_disarm(var/obj/item/grab/G, var/atom/A, var/proximity)
if(A == G.assailant)
A = G.affecting
if(isliving(G.affecting))
var/mob/living/living_mob = G.affecting
return living_mob.handle_rider_disarm_order(G.assailant, A, proximity)
return FALSE

/decl/grab/simple/control/on_hit_grab(var/obj/item/grab/G, var/atom/A, var/proximity)
if(A == G.assailant)
A = G.affecting
if(isliving(G.affecting))
var/mob/living/living_mob = G.affecting
return living_mob.handle_rider_grab_order(G.assailant, A, proximity)
return FALSE

/decl/grab/simple/control/on_hit_harm(var/obj/item/grab/G, var/atom/A, var/proximity)
if(A == G.assailant)
A = G.affecting
if(isliving(G.affecting))
var/mob/living/living_mob = G.affecting
return living_mob.handle_rider_harm_order(G.assailant, A, proximity)
return FALSE

// Override these for mobs that will respond to instructions from a rider.
/mob/living/proc/handle_rider_harm_order(mob/user, atom/target, proximity)
return FALSE

/mob/living/proc/handle_rider_grab_order(mob/user, atom/target, proximity)
return FALSE

/mob/living/proc/handle_rider_disarm_order(mob/user, atom/target, proximity)
return FALSE

/mob/living/proc/handle_rider_help_order(mob/user, atom/target, proximity)
return FALSE
1 change: 0 additions & 1 deletion code/modules/mob/grab/simple/simple_passive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
shield_assailant = 0
point_blank_mult = 1
same_tile = 0
icon_state = "reinforce"
break_chance_table = list(15, 60, 100)

/decl/grab/simple/upgrade(obj/item/grab/G)
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/living/carbon/carbon_grabs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
for(var/obj/item/grab/grab in get_held_items())
. += grab

/mob/living/carbon/make_grab(var/atom/movable/target, var/grab_tag = /decl/grab/simple)
. = ..(target, species?.grab_type || grab_tag)
/mob/living/carbon/make_grab(atom/movable/target, grab_tag = /decl/grab/simple, defer_hand = FALSE, force_grab_tag = FALSE)
grab_tag = (!force_grab_tag && species?.grab_type) || grab_tag
return ..()
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human_grabs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
if(istype(C))
C.leave_evidence(grabber)

/mob/living/carbon/human/make_grab(var/atom/movable/target, var/grab_tag = /decl/grab/simple)
/mob/living/carbon/human/make_grab(atom/movable/target, grab_tag = /decl/grab/simple, defer_hand = FALSE, force_grab_tag = FALSE)
. = ..()
if(.)
remove_cloaking_source(species)
Loading

0 comments on commit 73d27c9

Please sign in to comment.