forked from ParadiseSS13/Paradise
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9546526
commit 514e10d
Showing
4 changed files
with
84 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include "_clumsy_table.dm" | ||
|
||
#include "code/clumsy_table.dm" | ||
#include "code/clumsy_climb_component.dm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/datum/component/clumsy_climb_component | ||
var/thrown_chance = 80 //default for all human-sized livings | ||
var/force_mod = 0.1 //коэффицент уменьшения урона при сбрасывании предмета | ||
var/max_thrown_objects = 15 | ||
var/max_thrown_objects_low = 5 | ||
|
||
/datum/component/clumsy_climb_component/Initialize() | ||
//RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, PROC_REF(Repaint)) | ||
if(!isatom(parent)) | ||
return COMPONENT_INCOMPATIBLE | ||
|
||
/datum/component/clumsy_climb_component/RegisterWithParent() | ||
RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, PROC_REF(cross)) | ||
RegisterSignal(parent, COMSIG_CLIMBED_ON, PROC_REF(cross)) | ||
|
||
/datum/component/clumsy_climb_component/UnregisterFromParent() | ||
UnregisterSignal(parent, list(COMSIG_MOVABLE_CROSSED, COMSIG_CLIMBED_ON)) | ||
|
||
/datum/component/clumsy_climb_component/proc/cross(atom/table, mob/living/climber) | ||
if(!table.contents) | ||
return | ||
|
||
if(!istype(climber)) | ||
return | ||
|
||
var/mob/living/user = climber | ||
if(user.mob_size <= MOB_SIZE_SMALL && !user.throwing) | ||
return | ||
|
||
max_thrown_objects = initial(max_thrown_objects) | ||
if(!user.throwing) | ||
max_thrown_objects = max_thrown_objects_low | ||
|
||
clumsy_stuff(user) | ||
|
||
|
||
/datum/component/clumsy_climb_component/proc/clumsy_stuff(mob/living/user) | ||
if(!user) | ||
return | ||
|
||
switch(user.mob_size) | ||
if(MOB_SIZE_LARGE) | ||
thrown_chance = 100 | ||
if(MOB_SIZE_SMALL) | ||
thrown_chance = 20 | ||
if(MOB_SIZE_TINY) | ||
thrown_chance = 10 | ||
|
||
if(HAS_TRAIT(user, TRAIT_CLUMSY)) | ||
thrown_chance += 20 | ||
if(user.mind?.miming) | ||
thrown_chance -= 30 | ||
|
||
thrown_chance = clamp(thrown_chance, 1, 100) | ||
|
||
var/list/thrown_atoms = list() | ||
|
||
for(var/turf/T in range(0, user)) //Preventing from rotating stuff in an inventory | ||
for(var/atom/movable/I in T) | ||
if(!I.anchored && !isliving(I) && prob(thrown_chance)) | ||
thrown_atoms += I | ||
if(thrown_atoms.len >= max_thrown_objects) | ||
break | ||
|
||
var/atom/thrown_target | ||
for(var/obj/item/I in thrown_atoms) | ||
I.force *= force_mod | ||
I.throwforce *= force_mod //no killing using shards :lul: | ||
thrown_target = get_edge_target_turf(user, get_dir(user, get_step_away(I, user))) | ||
I.throw_at(target = thrown_target, range = 1, speed = 1) | ||
I.pixel_x = rand(-6, 6) | ||
I.pixel_y = rand(0, 10) | ||
I.force /= force_mod | ||
I.throwforce /= force_mod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,12 @@ | ||
/obj/structure/do_climb(mob/living/user) | ||
if(!user) | ||
return ..() | ||
|
||
if(..()) | ||
clumsy_stuff(user) | ||
#define COMSIG_CLIMBED_ON "climb_on" | ||
|
||
/obj/structure/table/Crossed(atom/movable/AM, oldloc) | ||
/obj/structure/table/Initialize(mapload) | ||
. = ..() | ||
AddComponent(/datum/component/clumsy_climb_component, 15) | ||
|
||
if(!isliving(AM)) | ||
return | ||
var/mob/living/user = AM | ||
if(user.mob_size <= MOB_SIZE_SMALL && !user.throwing) | ||
return | ||
|
||
var/max_throws_count = 5 | ||
if(user.throwing) | ||
max_throws_count = 15 | ||
|
||
clumsy_stuff(user, max_throws_count) | ||
|
||
/obj/structure/proc/clumsy_stuff(mob/living/user, max_throws_count = 15) | ||
/obj/structure/do_climb(mob/living/user) | ||
if(!user) | ||
return | ||
var/slopchance = 80 //default for all human-sized livings | ||
var/force_mult = 0.1 //коэффицент уменьшения урона при сбрасывании предмета | ||
|
||
switch(user.mob_size) | ||
if(MOB_SIZE_LARGE) slopchance = 100 | ||
if(MOB_SIZE_SMALL) slopchance = 20 | ||
if(MOB_SIZE_TINY) slopchance = 10 | ||
|
||
if(HAS_TRAIT(user, TRAIT_CLUMSY)) | ||
slopchance += 20 | ||
if(user.mind?.miming) | ||
slopchance -= 30 | ||
|
||
slopchance = clamp(slopchance, 1, 100) | ||
|
||
var/list/thrownatoms = list() | ||
|
||
for(var/turf/T in range(0, src)) //Preventing from rotating stuff in an inventory | ||
for(var/atom/movable/AM in T) | ||
if(!AM.anchored && !isliving(AM) && prob(slopchance)) | ||
thrownatoms += AM | ||
if(thrownatoms.len >= max_throws_count) | ||
break | ||
return ..() | ||
|
||
var/atom/throwtarget | ||
for(var/obj/item/AM in thrownatoms) | ||
AM.force *= force_mult | ||
AM.throwforce *= force_mult //no killing using shards :lul: | ||
throwtarget = get_edge_target_turf(user, get_dir(src, get_step_away(AM, src))) | ||
AM.throw_at(target = throwtarget, range = 1, speed = 1) | ||
AM.pixel_x = rand(-6, 6) | ||
AM.pixel_y = rand(0, 10) | ||
AM.force /= force_mult | ||
AM.throwforce /= force_mult | ||
if(..()) | ||
SEND_SIGNAL(src, COMSIG_CLIMBED_ON, user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters