From 1658e48bc1737ddea42bfbb42274407500923fe1 Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Thu, 8 Jun 2017 14:46:07 -0500 Subject: [PATCH] [READY] Gang Points Refactor - Now stored in the gang datum --- code/__DEFINES/misc.dm | 6 +- code/datums/mind.dm | 2 +- code/game/gamemodes/gang/gang.dm | 14 ++- code/game/gamemodes/gang/gang_datum.dm | 128 ++++++++++++++------- code/game/gamemodes/gang/gang_items.dm | 19 ++- code/game/gamemodes/gang/recaller.dm | 11 +- code/game/gamemodes/wizard/artefact.dm | 2 +- code/game/objects/effects/decals/crayon.dm | 20 +++- code/game/objects/objs.dm | 3 + code/modules/admin/verbs/onlyone.dm | 2 +- code/modules/clothing/neck/ties.dm | 3 + 11 files changed, 145 insertions(+), 65 deletions(-) diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index ab8fcb7d70..6ea8cd64ee 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -429,4 +429,8 @@ GLOBAL_LIST_INIT(ghost_others_options, list(GHOST_OTHERS_SIMPLE, GHOST_OTHERS_DE #define GIBTONITE_UNSTRUCK 0 #define GIBTONITE_ACTIVE 1 #define GIBTONITE_STABLE 2 -#define GIBTONITE_DETONATE 3 \ No newline at end of file +#define GIBTONITE_DETONATE 3 +//Gangster starting influences + +#define GANGSTER_SOLDIER_STARTING_INFLUENCE 5 +#define GANGSTER_BOSS_STARTING_INFLUENCE 20 diff --git a/code/datums/mind.dm b/code/datums/mind.dm index be5180c2ae..e1c6606400 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -989,7 +989,7 @@ if(!G || (src in G.bosses)) return SSticker.mode.remove_gangster(src,0,2,1) - G.bosses += src + G.bosses[src] = GANGSTER_BOSS_STARTING_INFLUENCE gang_datum = G special_role = "[G.name] Gang Boss" G.add_gang_hud(src) diff --git a/code/game/gamemodes/gang/gang.dm b/code/game/gamemodes/gang/gang.dm index 6606a0d871..5b97280e9a 100644 --- a/code/game/gamemodes/gang/gang.dm +++ b/code/game/gamemodes/gang/gang.dm @@ -62,7 +62,7 @@ GLOBAL_LIST_INIT(gang_outfit_pool, list(/obj/item/clothing/suit/jacket/leather,/ for(var/n in 1 to 3) var/datum/mind/boss = pick(antag_candidates) antag_candidates -= boss - G.bosses += boss + G.bosses[boss] = GANGSTER_BOSS_STARTING_INFLUENCE boss.gang_datum = G var/title if(n == 1) @@ -85,6 +85,7 @@ GLOBAL_LIST_INIT(gang_outfit_pool, list(/obj/item/clothing/suit/jacket/leather,/ sleep(rand(10,100)) for(var/datum/gang/G in gangs) for(var/datum/mind/boss_mind in G.bosses) + G.bosses[boss_mind] = GANGSTER_BOSS_STARTING_INFLUENCE //Force influence to be put on it. G.add_gang_hud(boss_mind) forge_gang_objectives(boss_mind) greet_gang(boss_mind) @@ -170,7 +171,7 @@ GLOBAL_LIST_INIT(gang_outfit_pool, list(/obj/item/clothing/suit/jacket/leather,/ return 0 if(check && gangster_mind.current.isloyal()) //Check to see if the potential gangster is implanted return 1 - G.gangsters += gangster_mind + G.gangsters[gangster_mind] = GANGSTER_SOLDIER_STARTING_INFLUENCE gangster_mind.gang_datum = G if(check) if(iscarbon(gangster_mind.current)) @@ -209,15 +210,24 @@ GLOBAL_LIST_INIT(gang_outfit_pool, list(/obj/item/clothing/suit/jacket/leather,/ if(!G.is_deconvertible && !remove_bosses) return 0 if(gangster_mind in G.gangsters) + G.reclaim_points(G.gangsters[gangster_mind]) G.gangsters -= gangster_mind removed = 1 if(remove_bosses && (gangster_mind in G.bosses)) + G.reclaim_points(G.bosses[gangster_mind]) G.bosses -= gangster_mind removed = 1 + if(G.tags_by_mind[gangster_mind] && islist(G.tags_by_mind[gangster_mind])) + var/list/tags_cache = G.tags_by_mind[gangster_mind] + for(var/v in tags_cache) + var/obj/effect/decal/cleanable/crayon/gang/c = v + c.set_mind_owner(null) + G.tags_by_mind -= gangster_mind if(!removed) return 0 + gangster_mind.special_role = null gangster_mind.gang_datum = null diff --git a/code/game/gamemodes/gang/gang_datum.dm b/code/game/gamemodes/gang/gang_datum.dm index d6aa1830f2..a2e7220106 100644 --- a/code/game/gamemodes/gang/gang_datum.dm +++ b/code/game/gamemodes/gang/gang_datum.dm @@ -8,6 +8,7 @@ var/list/datum/mind/gangsters = list() //gang B Members var/list/datum/mind/bosses = list() //gang A Bosses var/list/obj/item/device/gangtool/gangtools = list() + var/list/tags_by_mind = list() //Assoc list in format of tags_by_mind[mind_of_gangster] = list(tag1, tag2, tag3) where tags are the actual object decals. var/style var/fighting_style = "normal" var/list/territory = list() @@ -202,9 +203,9 @@ return var/added_names = "" var/lost_names = "" - + SSticker.mode.shuttle_check() // See if its time to start wrapping things up - + //Re-add territories that were reclaimed, so if they got tagged over, they can still earn income if they tag it back before the next status report var/list/reclaimed_territories = territory_new & territory_lost territory |= reclaimed_territories @@ -245,47 +246,90 @@ set_domination_time(new_time) message += "[seconds_remaining] seconds remain in hostile takeover.
" else - for(var/obj/item/device/gangtool/G in gangtools) - var/pmessage = message - var/points_new = 0 - if(istype(G, /obj/item/device/gangtool/soldier)) - points_new = max(0,round(3 - G.points/10)) + (sbonus) + (LAZYLEN(G.tags)/2) // Soldier points - pmessage += "Your influence has increased by [round(sbonus)] from your gang holding [LAZYLEN(territory)] territories, and a bonus of [round(LAZYLEN(G.tags)/2)] for territories you have personally marked and kept intact.
" - else - points_new = max(0,round(5 - G.points/10)) + LAZYLEN(territory) // Boss points, more focused on big picture - pmessage += "Your influence has increased by [round(points_new)] from your gang holding [territory.len] territories
" - G.points += points_new - var/mob/living/carbon/human/ganger = get(G.loc, /mob/living) - var/points_newer = 0 - var/static/inner = inner_outfit - var/static/outer = outer_outfit - if(ishuman(ganger) && ganger.mind in (gangsters|bosses)) - for(var/obj/C in ganger.contents) - if(C.type == inner_outfit) - points_newer += 2 - continue - if(C.type == outer_outfit) - points_newer += 2 - continue - switch(C.type) - if(/obj/item/clothing/neck/necklace/dope) - points_newer += 2 - if(/obj/item/clothing/head/collectable/petehat/gang) - points_newer += 4 - if(/obj/item/clothing/shoes/gang) - points_newer += 6 - if(/obj/item/clothing/mask/gskull) - points_newer += 5 - if(/obj/item/clothing/gloves/gang) - points_newer += 3 - if(/obj/item/weapon/storage/belt/military/gang) - points_newer += 4 - if(points_newer) - G.points += points_newer - pmessage += "Your influential choice of clothing has further increased your influence by [points_newer] points.
" - pmessage += "You now have [G.points] influence.
" - to_chat(ganger, "\icon[G] [pmessage]") + pay_territory_income_to_bosses() + pay_territory_income_to_soldiers(sbonus) + pay_all_clothing_bonuses() + announce_all_influence() +/datum/gang/proc/pay_all_clothing_bonuses() + for(var/datum/mind/mind in gangsters|bosses) + pay_clothing_bonus(mind) + +/datum/gang/proc/pay_clothing_bonus(var/datum/mind/gangsta) + var/mob/living/carbon/human/gangbanger = gangsta.current + . = 0 + if(!istype(gangbanger) || gangbanger.stat == DEAD) //Dead gangsters aren't influential at all! + return 0 + var/static/inner = inner_outfit + var/static/outer = outer_outfit + for(var/obj/item/C in gangbanger.contents) + if(C.type == inner_outfit) + . += 2 + continue + else if(C.type == outer_outfit) + . += 2 + continue + . += C.gang_contraband_value() + adjust_influence(gangsta, .) + if(.) + announce_to_mind(gangsta, "Your influential choice of clothing has increased your influence by [.] points!") + else + announce_to_mind(gangsta, "Unfortunately, you have not gained any additional influence from your drab, old, boring clothing. Learn to dress like a gangsta, bro!") //Kek + +/datum/gang/proc/pay_soldier_territory_income(datum/mind/soldier, sbonus = 0) + . = 0 + . = max(0,round(3 - gangsters[soldier]/10)) + (sbonus) + (get_soldier_territories(soldier)/2) + adjust_influence(soldier, .) + +/datum/gang/proc/get_soldier_territories(datum/mind/soldier) + if(!islist(tags_by_mind[soldier])) //They have no tagged territories! + return 0 + var/list/tags = tags_by_mind[soldier] + return tags.len + +/datum/gang/proc/pay_territory_income_to_soldiers(sbonus = 0) + for(var/datum/mind/soldier in gangsters) + var/returned = pay_soldier_territory_income(soldier) + if(!returned) + announce_to_mind(soldier, "You have not gained any influence from territories you personally tagged. Get to work, soldier!") + else + announce_to_mind(soldier, "You have gained [returned] influence from [get_soldier_territories(soldier)] territories you have personally tagged.") + +/datum/gang/proc/announce_all_influence() + for(var/datum/mind/MG in bosses|gangsters) + announce_total_influence(MG) + +/datum/gang/proc/pay_territory_income_to_bosses() + . = 0 + for(var/datum/mind/boss_mind in bosses) + var/inc = max(0,round(5 - bosses[boss_mind]/10)) + LAZYLEN(territory) + . += inc + adjust_influence(boss_mind, inc) + announce_to_mind(boss_mind, "Your influence has increased by [inc] from your gang holding [LAZYLEN(territory)] territories!") + +/datum/gang/proc/get_influence(datum/mind/gangster_mind) + if(gangster_mind in gangsters) + return gangsters[gangster_mind] + if(gangster_mind in bosses) + return bosses[gangster_mind] + +/datum/gang/proc/adjust_influence(datum/mind/gangster_mind, amount) + if(gangster_mind in gangsters) + gangsters[gangster_mind] += amount + if(gangster_mind in bosses) + bosses[gangster_mind] += amount + +/datum/gang/proc/announce_to_mind(datum/mind/gangster_mind, message) + if(gangster_mind.current && gangster_mind.current.stat != DEAD) + to_chat(gangster_mind.current, message) + +/datum/gang/proc/announce_total_influence(datum/mind/gangster_mind) + announce_to_mind(gangster_mind, "[name] Gang: You now have a total of [get_influence(gangster_mind)] influence!") + +/datum/gang/proc/reclaim_points(amount) + for(var/datum/mind/bawss in bosses) + adjust_influence(bawss, amount/bosses.len) + announce_to_mind(bawss, "[name] Gang: [amount/bosses.len] influence given from internal automatic restructuring.") //Multiverse diff --git a/code/game/gamemodes/gang/gang_items.dm b/code/game/gamemodes/gang/gang_items.dm index dae3c85be1..43e5fee8b4 100644 --- a/code/game/gamemodes/gang/gang_items.dm +++ b/code/game/gamemodes/gang/gang_items.dm @@ -11,7 +11,7 @@ if(check_canbuy && !can_buy(user, gang, gangtool)) return FALSE var/real_cost = get_cost(user, gang, gangtool) - gangtool.points -= real_cost + gang.adjust_influence(user.mind, -real_cost) spawn_item(user, gang, gangtool) return TRUE @@ -23,7 +23,7 @@ to_chat(user, spawn_msg) /datum/gang_item/proc/can_buy(mob/living/carbon/user, datum/gang/gang, obj/item/device/gangtool/gangtool) - return gang && (gangtool.points >= get_cost(user, gang, gangtool)) && can_see(user, gang, gangtool) + return gang && (gang.get_influence(user.mind) >= get_cost(user, gang, gangtool)) && can_see(user, gang, gangtool) /datum/gang_item/proc/can_see(mob/living/carbon/user, datum/gang/gang, obj/item/device/gangtool/gangtool) return TRUE @@ -118,6 +118,9 @@ name = "pimpin' hat" desc = "The undisputed king of style." +/obj/item/clothing/head/collectable/petehat/gang/gang_contraband_value() + return 4 + /datum/gang_item/clothing/mask name = "Golden Death Mask" id = "mask" @@ -129,6 +132,8 @@ icon_state = "gskull" desc = "Strike terror, and envy, into the hearts of your enemies." +/obj/item/clothing/mask/gskull/gang_contraband_value() + return 5 /datum/gang_item/clothing/shoes name = "Bling Boots" @@ -141,13 +146,15 @@ desc = "Stand aside peasants." icon_state = "bling" +/obj/item/clothing/shoes/gang/gang_contraband_value() + return 6 + /datum/gang_item/clothing/neck name = "Gold Necklace" id = "necklace" cost = 9 item_path = /obj/item/clothing/neck/necklace/dope - /datum/gang_item/clothing/hands name = "Decorative Brass Knuckles" id = "hand" @@ -160,6 +167,9 @@ icon_state = "knuckles" w_class = 3 +/obj/item/clothing/gloves/gang/gang_contraband_value() + return 3 + /datum/gang_item/clothing/belt name = "Badass Belt" id = "belt" @@ -173,7 +183,8 @@ desc = "The belt buckle simply reads 'BAMF'." storage_slots = 1 - +/obj/item/weapon/storage/belt/military/gang/gang_contraband_value() + return 4 /////////////////// //WEAPONS diff --git a/code/game/gamemodes/gang/recaller.dm b/code/game/gamemodes/gang/recaller.dm index 8363261c5d..8533ccf49e 100644 --- a/code/game/gamemodes/gang/recaller.dm +++ b/code/game/gamemodes/gang/recaller.dm @@ -15,7 +15,6 @@ var/outfits = 2 var/free_pen = 0 var/promotable = 0 - var/points = 15 var/list/tags = list() /obj/item/device/gangtool/Initialize() //Initialize supply point income if it hasn't already been started @@ -50,7 +49,7 @@ var/isboss = (user.mind == gang.bosses[1]) dat += "Registration: [gang.name] Gang [isboss ? "Boss" : "Lieutenant"]
" dat += "Organization Size: [gang.gangsters.len + gang.bosses.len] | Station Control: [round((gang.territory.len/GLOB.start_state.num_territories)*100, 1)]%
" - dat += "Your Influence: [points]
" + dat += "Your Influence: [gang.get_influence(user.mind)]
" dat += "Time until Influence grows: [time2text(SSticker.mode.gang_points.next_point_time - world.time, "mm:ss")]
" dat += "
" @@ -147,8 +146,9 @@ gang.gangtools += src icon_state = "gangtool-[gang.color]" if(!(user.mind in gang.bosses)) + var/cached_influence = gang.gangsters[user.mind] SSticker.mode.remove_gangster(user.mind, 0, 2) - gang.bosses += user.mind + gang.bosses[user.mind] = cached_influence user.mind.gang_datum = gang user.mind.special_role = "[gang.name] Gang Lieutenant" gang.add_gang_hud(user.mind) @@ -246,9 +246,6 @@ ///////////// Internal tool used by gang regulars /////////// -/obj/item/device/gangtool/soldier - points = 5 - /obj/item/device/gangtool/soldier/New(mob/user) . = ..() gang = user.mind.gang_datum @@ -264,7 +261,7 @@ dat += "
Takeover In Progress:
[gang.domination_time_remaining()] seconds remain
" dat += "Registration: [gang.name] - Foot Soldier
" dat += "Organization Size: [gang.gangsters.len + gang.bosses.len] | Station Control: [round((gang.territory.len/GLOB.start_state.num_territories)*100, 1)]%
" - dat += "Your Influence: [points]
" + dat += "Your Influence: [gang.get_influence(user.mind)]
" if(LAZYLEN(tags)) dat += "Your tags generate bonus influence for you.
You have tagged the following territories:" for(var/obj/effect/decal/cleanable/crayon/gang/T in tags) diff --git a/code/game/gamemodes/wizard/artefact.dm b/code/game/gamemodes/wizard/artefact.dm index f89833d315..9a21400653 100644 --- a/code/game/gamemodes/wizard/artefact.dm +++ b/code/game/gamemodes/wizard/artefact.dm @@ -243,7 +243,7 @@ if(!is_gangster(user)) var/datum/gang/multiverse/G = new(src, "[user.real_name]") SSticker.mode.gangs += G - G.bosses += user.mind + G.bosses[user.mind] = 0 G.add_gang_hud(user.mind) user.mind.gang_datum = G to_chat(user, "With your new found power you could easily conquer the station!") diff --git a/code/game/objects/effects/decals/crayon.dm b/code/game/objects/effects/decals/crayon.dm index 53ecfc8d62..2361510e46 100644 --- a/code/game/objects/effects/decals/crayon.dm +++ b/code/game/objects/effects/decals/crayon.dm @@ -30,27 +30,35 @@ layer = HIGH_OBJ_LAYER //Harder to hide do_icon_rotate = FALSE //These are designed to always face south, so no rotation please. var/datum/gang/gang - var/obj/item/device/gangtool/linked_tool + var/datum/mind/user_mind var/area/territory /obj/effect/decal/cleanable/crayon/gang/Initialize(mapload, var/datum/gang/G, var/e_name = "gang tag", var/rotation = 0, var/mob/user) if(!type || !G) qdel(src) + user_mind = user.mind territory = get_area(src) gang = G var/newcolor = G.color_hex icon_state = G.name G.territory_new |= list(territory.type = territory.name) - linked_tool = locate(/obj/item/device/gangtool) in user.contents - if(linked_tool) - linked_tool.tags += src + //If this isn't tagged by a specific gangster there's no bonus income. + set_mind_owner(user_mind) ..(mapload, newcolor, icon_state, e_name, rotation) +/obj/effect/decal/cleanable/crayon/gang/proc/set_mind_owner(datum/mind/mind) + if(istype(user_mind) && istype(gang) && islist(gang.tags_by_mind[user_mind])) //Clear us out of old ownership + gang.tags_by_mind[user_mind] -= src + if(istype(mind)) + if(!islist(gang.tags_by_mind[mind])) + gang.tags_by_mind[mind] = list() + gang.tags_by_mind[mind] += src + user_mind = mind + /obj/effect/decal/cleanable/crayon/gang/Destroy() - if(linked_tool) - linked_tool.tags -= src if(gang) gang.territory -= territory.type + set_mind_owner(null) gang.territory_new -= territory.type gang.territory_lost |= list(territory.type = territory.name) return ..() diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index 9766dbc26d..7482b4ca14 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -193,3 +193,6 @@ ..() if(unique_rename) to_chat(user, "Use a pen on it to rename it or change its description.") + +/obj/proc/gang_contraband_value() + return 0 diff --git a/code/modules/admin/verbs/onlyone.dm b/code/modules/admin/verbs/onlyone.dm index 37dab65b0c..299853ae53 100644 --- a/code/modules/admin/verbs/onlyone.dm +++ b/code/modules/admin/verbs/onlyone.dm @@ -99,7 +99,7 @@ GLOBAL_VAR_INIT(highlander, FALSE) var/datum/gang/multiverse/G = new(src, "[H.real_name]") SSticker.mode.gangs += G - G.bosses += H.mind + G.bosses[H.mind] = 0 //No they don't use influence but this prevents runtimes. G.add_gang_hud(H.mind) H.mind.gang_datum = G diff --git a/code/modules/clothing/neck/ties.dm b/code/modules/clothing/neck/ties.dm index 59dc504098..3affebc270 100644 --- a/code/modules/clothing/neck/ties.dm +++ b/code/modules/clothing/neck/ties.dm @@ -164,6 +164,9 @@ icon_state = "bling" item_color = "bling" +/obj/item/clothing/neck/necklace/dope/gang_contraband_value() + return 2 + //////////////// //OONGA BOONGA// ////////////////