Skip to content

Commit

Permalink
hmm
Browse files Browse the repository at this point in the history
  • Loading branch information
Helg2 committed Aug 25, 2024
1 parent a08fc9b commit 99aee84
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 21 deletions.
8 changes: 8 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
///Move mod for going diagonally
#define DIAG_MOVEMENT_ADDED_DELAY_MULTIPLIER (sqrt(2))

//Mob swap modes, for mobs bumping other mobs

///Mode for bumpint into the bumped mob
#define NO_SWAP 0
///Mode for swapping through the bumped mob
#define SWAPPING 1
///Mode for phasing through the bumped mob
#define PHASING 2

//Pain or shock reduction for different reagents
#define PAIN_REDUCTION_VERY_LIGHT -5 //alkysine
Expand Down
18 changes: 18 additions & 0 deletions code/modules/mob/living/carbon/human/human_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,21 @@
if(germ_level < GERM_LEVEL_MOVE_CAP && prob(8))
germ_level++
return ..()

/mob/living/carbon/human/return_mob_swap_mode(mob/living/target)
if(isxeno(target))
return NO_SWAP
// the puller can always swap with its victim if on grab intent
if(target.pulledby == src && a_intent == INTENT_GRAB)
return SWAPPING
/* If we're moving diagonally, but the mob isn't on the diagonal destination turf and the destination turf is enterable we have no reason to shuffle/push them
* However we also do not want mobs of smaller move forces being able to pass us diagonally if our move resist is larger, unless they're the same faction as us */
if(moving_diagonally && (get_dir(src, target) in GLOB.cardinals) && get_step(src, dir).Enter(src, loc) && (target.faction == faction || target.move_resist <= move_force))
return PHASING
// Restrained people act if they were on 'help' intent to prevent a person being pulled from being seperated from their puller
else if(a_intent == INTENT_HELP || restrained())
if(move_force > target.move_resist)
return SWAPPING
else if(target.a_intent == INTENT_HELP || target.restrained())
return SWAPPING
return NO_SWAP
18 changes: 18 additions & 0 deletions code/modules/mob/living/carbon/xenomorph/xenomorph.dm
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,21 @@ Returns TRUE when loc_weeds_type changes. Returns FALSE when it doesn’t change
/mob/living/carbon/xenomorph/send_speech(message_raw, message_range = 7, obj/source = src, bubble_type = bubble_icon, list/spans, datum/language/message_language=null, message_mode, tts_message, list/tts_filter)
. = ..()
playsound(loc, talk_sound, 25, 1)

/mob/living/carbon/xenomorph/return_mob_swap_mode(mob/living/target)
// the puller can always swap with its victim if on grab intent
if(target.pulledby == src && a_intent == INTENT_GRAB)
return SWAPPING
/* If we're moving diagonally, but the mob isn't on the diagonal destination turf and the destination turf is enterable we have no reason to shuffle/push them
* However we also do not want mobs of smaller move forces being able to pass us diagonally if our move resist is larger, unless they're the same faction as us */
if(moving_diagonally && (get_dir(src, target) in GLOB.cardinals) && get_step(src, dir).Enter(src, loc) && (target.faction == faction || target.move_resist <= move_force))
return PHASING
// Restrained people act if they were on 'help' intent to prevent a person being pulled from being seperated from their puller
if(a_intent == INTENT_HELP || restrained())
// xenos swap with fellow xenos
if(get_xeno_hivenumber() == target.get_xeno_hivenumber())
return SWAPPING
// check for petrified targets
else if(move_force > target.move_resist)
return SWAPPING
return NO_SWAP
30 changes: 9 additions & 21 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,6 @@
/mob/living/is_drawable(allowmobs = TRUE)
return (allowmobs && can_inject())

#define NO_SWAP 0
#define SWAPPING 1
#define PHASING 2

/mob/living/Bump(atom/A)
. = ..()
if(.) //We are thrown onto something.
Expand All @@ -358,23 +354,7 @@
return

if(!L.buckled && !L.anchored)
var/mob_swap_mode = NO_SWAP
// the puller can always swap with its victim if on grab intent
if(L.pulledby == src && a_intent == INTENT_GRAB)
mob_swap_mode = SWAPPING
// Restrained people act if they were on 'help' intent to prevent a person being pulled from being seperated from their puller
else if(a_intent == INTENT_HELP || restrained())
// xenos swap with fellow xenos and almost whoever they want
if(isxeno(src) && (get_xeno_hivenumber() == L.get_xeno_hivenumber() || move_force > L.move_resist))
mob_swap_mode = SWAPPING
// if target isn't xeno, target isn't petrified, or we're not xeno, and both on help intents, then we swap
else if(!isxeno(L) && (move_force > L.move_resist || !isxeno(src)) && (L.a_intent == INTENT_HELP || L.restrained()))
mob_swap_mode = SWAPPING
/* If we're moving diagonally, but the mob isn't on the diagonal destination turf and the destination turf is enterable we have no reason to shuffle/push them
* However we also do not want mobs of smaller move forces being able to pass us diagonally if our move resist is larger, unless they're the same faction as us
*/
if(moving_diagonally && (get_dir(src, L) in GLOB.cardinals) && (L.faction == faction || L.move_resist <= move_force) && get_step(src, dir).Enter(src, loc))
mob_swap_mode = PHASING
var/mob_swap_mode = return_mob_swap_mode(L)
if(mob_swap_mode)
//switch our position with L
if(loc && !loc.Adjacent(L.loc))
Expand Down Expand Up @@ -420,6 +400,14 @@
if(PushAM(A))
return TURF_ENTER_ALREADY_MOVED

/// Returns mob_swap_mode for Bump() with other mobs
/mob/living/proc/return_mob_swap_mode(mob/living/target)
if(move_force > target.move_resist || target.a_intent == INTENT_HELP || target.restrained())
return SWAPPING
if(moving_diagonally && (get_dir(src, target) in GLOB.cardinals) && get_step(src, dir).Enter(src, loc))
return PHASING
return NO_SWAP

//Called when we want to push an atom/movable
/mob/living/proc/PushAM(atom/movable/AM, force = move_force)
if(AM.anchored)
Expand Down

0 comments on commit 99aee84

Please sign in to comment.