Files
Bubberstation/code/modules/mob/living/basic/trader/trader.dm
SkyratBot e501a5c02e [MIRROR] Converts traders to basic mobs [MDB IGNORE] (#24673)
* Converts traders to basic mobs (#79187)

## About The Pull Request

This PR converts the two trader mobs into basic mobs, these being the
basic debug trader that buys ectoplasm and sells ghost burgers, and Mr
Bones, who buys empty milk cartons and bones, and sells bone relate
paraphernalia.

Traders now use dynamic appearance generation. The old sprites still
exist as hallucinations, and as shop signs.

Trader UI is now summoned via `COMSIG_ATOM_ATTACK_HAND`, which properly
cancels the attack chain, so there is no longer need to put it on
Interact.

I kept most of the original behaviour, but moved them off into a
component. I have also cached all the images generated for the radials,
I hope I have not overengineered it. I have also created a new datum,
which stores the trader's wares, needs, and speech patterns.

Admins can put the component along with the trader data on any living
mobs with an AI controller, turning them into traders. Keep in mind that
most AI has random idle movement, meaning they have a chance to walk
off, closing your trader radial.

![image](https://github.com/tgstation/tgstation/assets/2676196/a2b216e9-f9bf-46e1-83fa-3a41c8447176)

The trader AI consists of the following, first, when a trader sees
someone, they will deploy their shop, if one does not already exists.
The shop consists of a chair, and a holographic sign. If you attack
them, they will chase you with their weapons, and then return to their
chair when victorious. If the chair is somehow destroyed, they will
create a new shop when they see a new potential customer.

![image](https://github.com/tgstation/tgstation/assets/2676196/ad5fcd5a-996c-490f-938b-6bc11c91c4ee)

Mr Bones uses a variant of the AI, where they will run at you, and
deploy their shop when they reach you. I call this the jumpscare
variant. Below you can see me getting actually jumpscared because Mr
Bones has stepped on a yelling frog when I opened the maintenance door.

![image](https://github.com/tgstation/tgstation/assets/2676196/f47a5baa-e32d-4454-97f9-d90d027003d2)

I have also made an element that toggles an ai controlled combat mode
when it gains a target, and when it loses it. I am using it to make
Traders unable to trade while they are trying to kill a robber. To aid
this, I a have made
`/datum/ai_controller/proc/sig_remove_from_blackboard` send the
`COMSIG_AI_BLACKBOARD_KEY_CLEARED` signal, in case the trader kills a
mob that deletes itself on death. This means I could remove a signup
`/datum/component/appearance_on_aggro` was doing towards Qdeleting.

Below you can see Mr Bones shooting me with candy corn.

![image](https://github.com/tgstation/tgstation/assets/2676196/489e1072-e15a-412c-a8eb-9a3f0cca7bf6)

![image](https://github.com/tgstation/tgstation/assets/2676196/8f74b50f-ea35-467c-bb07-2ef38f84c453)

Traders actually only shoot you until you are conscious, so I survived
here in crit. Most mobs don't have crit state, so they just die, so I am
sticking by this voice line.

Thank you @ CoiledLamb  for help with the sale sign!

## Why It's Good For The Game

Two more mobs off the list. The AI and Componentized behaviours allows
us to set up new kind of traders.

## Changelog

🆑
refactor: Traders are basic mobs now. Please alert us of any strange
behaviours!
code: If there is only one option, radial lists will autopick it. This
behaviour can be turned off via a new argument.
/🆑

* Converts traders to basic mobs

---------

Co-authored-by: Profakos <profakos@gmail.com>
2023-10-31 02:16:50 -04:00

80 lines
3.1 KiB
Plaintext

/mob/living/basic/trader
name = "Trader"
desc = "Come buy some!"
unique_name = FALSE
icon = 'icons/mob/simple/simple_human.dmi'
maxHealth = 200
health = 200
melee_damage_lower = 10
melee_damage_upper = 10
attack_verb_continuous = "punches"
attack_verb_simple = "punch"
attack_sound = 'sound/weapons/punch1.ogg'
basic_mob_flags = DEL_ON_DEATH
unsuitable_atmos_damage = 2.5
combat_mode = FALSE
move_resist = MOVE_FORCE_STRONG
mob_biotypes = MOB_ORGANIC|MOB_HUMANOID
sentience_type = SENTIENCE_HUMANOID
speed = 0
ai_controller = /datum/ai_controller/basic_controller/trader
///Sound used when item sold/bought
var/sell_sound = 'sound/effects/cashregister.ogg'
///The currency name
var/currency_name = "credits"
///The spawner we use to create our look
var/spawner_path = /obj/effect/mob_spawn/corpse/human/generic_assistant
///Our species to create our look
var/species_path = /datum/species/human
///The loot we drop when we die
var/loot = list(/obj/effect/mob_spawn/corpse/human/generic_assistant)
///Casing used to shoot during retaliation
var/ranged_attack_casing = /obj/item/ammo_casing/shotgun/buckshot
///Sound to make while doing a retalitory attack
var/ranged_attack_sound = 'sound/weapons/gun/pistol/shot.ogg'
///Weapon path, for visuals
var/held_weapon_visual = /obj/item/gun/ballistic/shotgun
///Type path for the trader datum to use for retrieving the traders wares, speech, etc
var/trader_data_path = /datum/trader_data
/mob/living/basic/trader/Initialize(mapload)
. = ..()
apply_dynamic_human_appearance(src, species_path = species_path, mob_spawn_path = spawner_path, r_hand = held_weapon_visual)
var/datum/trader_data/trader_data = new trader_data_path
AddComponent(/datum/component/trader, trader_data = trader_data)
AddComponent(/datum/component/ranged_attacks, casing_type = ranged_attack_casing, projectile_sound = ranged_attack_sound, cooldown_time = 3 SECONDS)
AddElement(/datum/element/ai_retaliate)
AddElement(/datum/element/ai_swap_combat_mode, BB_BASIC_MOB_CURRENT_TARGET, string_list(trader_data.say_phrases[TRADER_BATTLE_START_PHRASE]), string_list(trader_data.say_phrases[TRADER_BATTLE_END_PHRASE]))
if(LAZYLEN(loot))
loot = string_list(loot)
AddElement(/datum/element/death_drops, loot)
var/datum/action/setup_shop/setup_shop = new (src, trader_data.shop_spot_type, trader_data.sign_type, trader_data.sell_sound, trader_data.say_phrases[TRADER_SHOP_OPENING_PHRASE])
setup_shop.Grant(src)
ai_controller.set_blackboard_key(BB_SETUP_SHOP, setup_shop)
/mob/living/basic/trader/mrbones
name = "Mr. Bones"
desc = "A skeleton merchant, he seems very humerus."
speak_emote = list("rattles")
speech_span = SPAN_SANS
mob_biotypes = MOB_UNDEAD|MOB_HUMANOID
icon_state = "mrbones"
gender = MALE
ai_controller = /datum/ai_controller/basic_controller/trader/jumpscare
sell_sound = 'sound/voice/hiss2.ogg'
species_path = /datum/species/skeleton
spawner_path = /obj/effect/mob_spawn/corpse/human/skeleton/mrbones
loot = list(/obj/effect/decal/remains/human)
ranged_attack_casing = /obj/item/ammo_casing/energy/bolt/halloween
held_weapon_visual = /obj/item/gun/ballistic/revolver
trader_data_path = /datum/trader_data/mr_bones