Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a module which allows for borgs to do magic! #637

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
33 changes: 24 additions & 9 deletions code/modules/admin/verbs/borgpanel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,24 @@
"scrambledcodes" = borg.scrambledcodes
)
.["upgrades"] = list()
var/static/list/not_shown_upgrades = list(/obj/item/borg/upgrade/hypospray)
for (var/upgradetype in subtypesof(/obj/item/borg/upgrade)-not_shown_upgrades) //hypospray is a dummy parent for hypospray upgrades
var/obj/item/borg/upgrade/upgrade = upgradetype
if (initial(upgrade.model_type) && !is_type_in_list(borg.model, initial(upgrade.model_type))) // Upgrade requires a different model //HEY ASSHOLE, INITIAL DOESNT WORK WITH LISTS
continue
var/list/excluded_upgrades = list(
/obj/item/borg/upgrade/hypospray, //hypospray is a dummy parent for hypospray upgrades
/obj/item/borg/upgrade/transform,
/obj/item/borg/upgrade/rename,
/obj/item/borg_restart_board,
/obj/item/borg/upgrade/modkit,
)
for (var/upgradetype in subtypesof(/obj/item/borg/upgrade)-excluded_upgrades)
var/obj/item/borg/upgrade/upgrade = new upgradetype()
if(upgrade.model_type) // Only show upgrades that can be given. Cannot initial() lists either.
// is_type_in_list() doesn't work, so this:
var/has_req_module = FALSE
for(var/req_model_type in upgrade.model_type)
if(borg.model.type == req_model_type)
has_req_module = TRUE
break
if(!has_req_module)
continue
var/installed = FALSE
if (locate(upgradetype) in borg)
installed = TRUE
Expand All @@ -79,7 +92,7 @@
.["ais"] += list(list("name" = ai.name, "ref" = REF(ai), "connected" = (borg.connected_ai == ai)))


/datum/borgpanel/ui_act(action, params)
/datum/borgpanel/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
Expand Down Expand Up @@ -149,17 +162,19 @@
borg.fully_replace_character_name(borg.real_name,new_name)
if ("toggle_upgrade")
var/upgradepath = text2path(params["upgrade"])
var/obj/item/borg/upgrade/installedupgrade = locate(upgradepath) in borg
var/obj/item/borg/upgrade/installedupgrade = locate(upgradepath) in borg.upgrades
if (installedupgrade)
message_admins("[key_name_admin(user)] removed the [installedupgrade] upgrade from [ADMIN_LOOKUPFLW(borg)].")
log_silicon("[key_name(user)] removed the [installedupgrade] upgrade from [key_name(borg)].")
qdel(installedupgrade) // see [mob/living/silicon/robot/on_upgrade_deleted()].
else
var/obj/item/borg/upgrade/upgrade = new upgradepath(borg)
upgrade.action(borg, user)
borg.upgrades += upgrade
message_admins("[key_name_admin(user)] added the [upgrade] borg upgrade to [ADMIN_LOOKUPFLW(borg)].")
log_silicon("[key_name(user)] added the [upgrade] borg upgrade to [key_name(borg)].")
if(upgrade.action(borg, user))
borg.add_to_upgrades(upgrade)
else
qdel(upgrade)
if ("toggle_radio")
var/channel = params["channel"]
if (channel in borg.radio.channels) // We're removing a channel
Expand Down
1 change: 1 addition & 0 deletions maplestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6486,6 +6486,7 @@
#include "maplestation_modules\code\modules\mod\mod_control.dm"
#include "maplestation_modules\code\modules\mod\modules\modules_general.dm"
#include "maplestation_modules\code\modules\movespeed\modifiers\reagent.dm"
#include "maplestation_modules\code\modules\objects\robot_magic.dm"
#include "maplestation_modules\code\modules\paperwork\stamps.dm"
#include "maplestation_modules\code\modules\pixel_shift\code\pixel_shift_component.dm"
#include "maplestation_modules\code\modules\pixel_shift\code\pixel_shift_keybind.dm"
Expand Down
12 changes: 12 additions & 0 deletions maplestation_modules/code/modules/magic/mana/living_mana.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
//Silicon stuff
/mob/living/silicon
has_initial_mana_pool = TRUE

/mob/living/silicon/get_initial_mana_pool_type()
return /datum/mana_pool/mob/living/silicon

/datum/mana_pool/mob/living/silicon
maximum_mana_capacity = 25


//Carbon stuff
/mob/living/carbon
has_initial_mana_pool = TRUE

Expand Down
47 changes: 47 additions & 0 deletions maplestation_modules/code/modules/objects/robot_magic.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

/obj/item/borg/upgrade/magic
name = "borg magical focus"
desc = "A magical focus which allows borgs to create magic."
icon = 'maplestation_modules/icons/obj/devices/circuitry_n_data.dmi'
icon_state = "cyborg_magic_focus"
w_class = WEIGHT_CLASS_SMALL

has_initial_mana_pool = TRUE
///the mana pool from the borg that the upgrade is inside. Set to null when not in a borg.
var/datum/mana_pool/borg_mana_pool = null

//mana pool stuff for the magic borg upgrade
/datum/mana_pool/borg_focus
maximum_mana_capacity = CARBON_BASE_MANA_CAPACITY //same as carbons!

/obj/item/borg/upgrade/magic/get_initial_mana_pool_type()
return /datum/mana_pool/borg_focus

/obj/item/borg/upgrade/magic/action(mob/living/silicon/robot/borg)
. = ..()
if(.)
//add the spells to the borg's actions
var/list/list_value = borg.client.prefs.read_preference(/datum/preference/spellbook)
for (var/datum/spellbook_item/entry in spellbook_list_to_datums(list_value))
entry.apply(borg, list_value[entry.type])

//store the borg's current mana pool for returning it when the module is removed
if (borg.mana_pool != null) //incase the borg has no mana pool
borg_mana_pool = borg.mana_pool

//put the upgrade's magic pool into the borg.
borg.initialize_mana_pool_if_possible()

borg.set_mana_pool(mana_pool)

/obj/item/borg/upgrade/magic/deactivate(mob/living/silicon/robot/borg)
. = ..()
if(.)
//removes the spells
for (var/datum/action/cooldown/spell/action_to_remove in borg.actions)
action_to_remove.Remove(borg)
//resets the mana pool to before
borg.set_mana_pool(borg_mana_pool)
borg.initialize_mana_pool_if_possible()
borg_mana_pool = null //removes the borg's mana pool var from the upgrade as this upgrade being removed from the borg

Binary file not shown.
Loading