mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-19 22:23:11 +00:00
* Adds Pinatas that can be purchased by cargo and clown operatives! (#73868) ## About The Pull Request Pinata's drop various items when struck with a sufficiently powerful weapon. This PR adds two types, a standard one which can be bought from cargo which contains various candy items and a syndicate one which contains both candy items and explosives purchasable by clown operatives. The pinata functionality is also a component so admins can turn any structure/machine/mob into a pinata and customize the "candy" inside Sprites by @ Mey-Ha-Zah animated versions by me ## Why It's Good For The Game Adds a cute little celebration themed structure that can be bought by players to accommodate a celebration based gimmicks or the party trait. I think the options on things to do as a crew during a celebration are a bit limited at present with most of the options being making/purchasing food, activity wise the main example of a celebration item is pin the tail on the corgi which is a bit uninteresting, the pinata on the other hand is more cathartic and provides a "reward" in the form of various candy items for people who participate in smashing it. I also think its just funny to have clown operative gambling half their TC to try and get explosives. ## Changelog 🆑 Mey-Ha-Zah & NamelessFairy add: Added pinata crates to cargo, they contain various candy items. Fun at parties. add: Clown operatives can now purchase a weapons grade pinata, this contains both candy and explosives. Still fun at parties. admin: Admins can now turn players, mobs and objects into pinata's with the new pinata component. /🆑 * Adds Pinatas that can be purchased by cargo and clown operatives! --------- Co-authored-by: NamelessFairy <40036527+NamelessFairy@users.noreply.github.com>
63 lines
2.2 KiB
Plaintext
63 lines
2.2 KiB
Plaintext
///Objects or mobs with this componenet will drop items when taking damage.
|
|
/datum/component/pinata
|
|
///How much damage does an attack need to do to have a chance to drop "candy"
|
|
var/minimum_damage
|
|
///What is the likelyhood some "candy" should drop when attacked.
|
|
var/drop_chance
|
|
///A list of "candy" items that can be dropped when taking damage
|
|
var/candy
|
|
///Number of "candy" items dropped when the structure is destroyed/mob is killed, set to 0 if none. drop_chance and minimum damage are not applied.
|
|
var/death_drop
|
|
|
|
/datum/component/pinata/Initialize(
|
|
minimum_damage = 10,
|
|
drop_chance = 40,
|
|
candy = list(/obj/item/food/candy, /obj/item/food/lollipop/cyborg, /obj/item/food/gumball, /obj/item/food/bubblegum, /obj/item/food/chocolatebar),
|
|
death_drop = 5,
|
|
)
|
|
|
|
src.minimum_damage = minimum_damage
|
|
src.drop_chance = drop_chance
|
|
src.candy = candy
|
|
src.death_drop = death_drop
|
|
|
|
if(ismob(parent))
|
|
RegisterSignal(parent, COMSIG_MOB_APPLY_DAMAGE, PROC_REF(damage_inflicted))
|
|
RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(pinata_broken))
|
|
return
|
|
if(isobj(parent))
|
|
var/obj/parent_integrity_test = parent
|
|
if(parent_integrity_test.uses_integrity)
|
|
RegisterSignal(parent, COMSIG_ATOM_TAKE_DAMAGE, PROC_REF(damage_inflicted))
|
|
RegisterSignal(parent, COMSIG_ATOM_DESTRUCTION, PROC_REF(pinata_broken))
|
|
return
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
/datum/component/pinata/proc/damage_inflicted(obj/target, damage, damage_type)
|
|
SIGNAL_HANDLER
|
|
if(damage < minimum_damage || damage_type == STAMINA || damage_type == OXY)
|
|
return
|
|
if(!prob(drop_chance + damage)) //Higher damage means less rolls but higher odds on the roll
|
|
return
|
|
var/list/turf_options = get_adjacent_open_turfs(parent)
|
|
turf_options += get_turf(parent)
|
|
if(length(turf_options))
|
|
var/dropped_item = pick(candy)
|
|
new dropped_item(pick(turf_options))
|
|
|
|
/datum/component/pinata/proc/pinata_broken()
|
|
SIGNAL_HANDLER
|
|
for(var/i in 1 to death_drop)
|
|
var/dropped_item = pick(candy)
|
|
new dropped_item(get_turf(parent))
|
|
qdel(src)
|
|
|
|
/datum/component/pinata/Destroy(force, silent)
|
|
UnregisterSignal(parent, list(
|
|
COMSIG_MOB_APPLY_DAMAGE,
|
|
COMSIG_LIVING_DEATH,
|
|
COMSIG_ATOM_TAKE_DAMAGE,
|
|
COMSIG_ATOM_DESTRUCTION,
|
|
))
|
|
return ..()
|