From 4e0f56499356fda5e145d0b4846cc97e1be67fb5 Mon Sep 17 00:00:00 2001 From: Alan Date: Sat, 1 Aug 2026 02:16:25 -0400 Subject: [PATCH] Migrate newspaper to the new attack chain. (#32332) * Migrate newspaper to the new attack chain. * Apply suggestions from CRUNCH review. Co-authored-by: CRUNCH <143041327+CRUNCH-Borg@users.noreply.github.com> Signed-off-by: Alan * Apply suggestion from CRUNCH review. Co-authored-by: CRUNCH <143041327+CRUNCH-Borg@users.noreply.github.com> Signed-off-by: Alan --------- Signed-off-by: Alan Co-authored-by: CRUNCH <143041327+CRUNCH-Borg@users.noreply.github.com> --- code/modules/newscaster/obj/newspaper.dm | 235 ++++++++++++----------- 1 file changed, 127 insertions(+), 108 deletions(-) diff --git a/code/modules/newscaster/obj/newspaper.dm b/code/modules/newscaster/obj/newspaper.dm index f093f133a83..f28aa5a2ae1 100644 --- a/code/modules/newscaster/obj/newspaper.dm +++ b/code/modules/newscaster/obj/newspaper.dm @@ -31,100 +31,108 @@ var/scribble_page = null /// Whether the newspaper is rolled or not, making it a deadly weapon. var/rolled = FALSE + new_attack_chain = TRUE /obj/item/newspaper/Initialize(mapload) . = ..() if(!news_content) news_content = list() -/obj/item/newspaper/attack_self__legacy__attackchain(mob/user) +/obj/item/newspaper/activate_self(mob/user) + if(..()) + return ITEM_INTERACT_COMPLETE + if(rolled) to_chat(user, SPAN_WARNING("Unroll it first!")) - return - if(ishuman(user)) - var/mob/living/carbon/human/human_user = user - var/dat = {""} - pages = 0 - switch(screen) - if(SCREEN_COVER) //Cover - dat += "
The Griffon
" - dat += "
Nanotrasen-standard newspaper, for use on Nanotrasen Space Facilities

" - if(!length(news_content)) - if(important_message) - dat += "Contents:
    **Important Security Announcement** \[page [pages+2]\]
" - else - dat += "Other than the title, the rest of the newspaper is unprinted..." + return ITEM_INTERACT_COMPLETE + + if(!user.is_literate()) + to_chat(user, SPAN_WARNING("The paper is full of unintelligible symbols!")) + return ITEM_INTERACT_COMPLETE + + var/mob/living/carbon/human/human_user = user + add_fingerprint(user) + var/dat = {""} + pages = 0 + switch(screen) + if(SCREEN_COVER) //Cover + dat += "
The Griffon
" + dat += "
Nanotrasen-standard newspaper, for use on Nanotrasen Space Facilities

" + if(!length(news_content)) + if(important_message) + dat += "Contents:
    **Important Security Announcement** \[page [pages+2]\]
" else - dat += "Contents:
    " - for(var/datum/feed_channel/NP in news_content) - pages++ - if(important_message) - dat += "**Important Security Announcement** \[page [pages+2]\]
    " - var/temp_page=0 - for(var/datum/feed_channel/NP in news_content) - temp_page++ - dat += "[NP.channel_name] \[page [temp_page+1]\]
    " - dat += "
" - if(scribble_page==curr_page) - dat += "
There is a small scribble near the end of this page... It reads: \"[scribble]\"" - dat+= "
Next Page
Done reading
" - if(SCREEN_PAGE_INNER) // X channel pages inbetween. - for(var/datum/feed_channel/NP in news_content) - pages++ //Let's get it right again. - var/datum/feed_channel/C = news_content[curr_page] - dat += "[C.channel_name] \[created by: [C.author]\]

" - if(C.censored) - dat += "This channel was deemed dangerous to the general welfare of the station and therefore marked with a D-Notice. Its contents were not transferred to the newspaper at the time of printing." - else - if(!length(C.messages)) - dat += "No Feed stories stem from this channel..." - else - dat += "
    " - var/i = 0 - for(var/datum/feed_message/MESSAGE in C.messages) - var/title = (MESSAGE.censor_flags & NEWSCASTER_CENSOR_STORY) ? "\[REDACTED\]" : MESSAGE.title - var/body = (MESSAGE.censor_flags & NEWSCASTER_CENSOR_STORY) ? "\[REDACTED\]" : MESSAGE.body - i++ - dat += "[title]
    " - dat += "[body]
    " - if(MESSAGE.img) - user << browse_rsc(MESSAGE.img, "tmp_photo[i].png") - dat += "
    " - dat += "\[Story by [MESSAGE.author]\]

    " - dat += "
" - if(scribble_page==curr_page) - dat += "
There is a small scribble near the end of this page... It reads: \"[scribble]\"" - dat+= "

Previous Page
Next Page
" - if(SCREEN_PAGE_LAST) //Last page + dat += "Other than the title, the rest of the newspaper is unprinted..." + else + dat += "Contents:
    " for(var/datum/feed_channel/NP in news_content) pages++ - if(important_message!=null) - dat += "
    Wanted Issue:


    " - dat += "Criminal name: [important_message.author]
    " - dat += "Description: [important_message.body]
    " - dat += "Photo:: " - if(important_message.img) - user << browse_rsc(important_message.img, "tmp_photow.png") - dat += "
    " - else - dat += "None" - else - dat += "Apart from some uninteresting Classified ads, there's nothing on this page..." - if(scribble_page==curr_page) - dat += "
    There is a small scribble near the end of this page... It reads: \"[scribble]\"" - dat+= "
    " + if(important_message) + dat += "**Important Security Announcement** \[page [pages+2]\]
    " + var/temp_page=0 + for(var/datum/feed_channel/NP in news_content) + temp_page++ + dat += "[NP.channel_name] \[page [temp_page+1]\]
    " + dat += "
" + if(scribble_page==curr_page) + dat += "
There is a small scribble near the end of this page... It reads: \"[scribble]\"" + dat+= "
Next Page
Done reading
" + if(SCREEN_PAGE_INNER) // X channel pages inbetween. + for(var/datum/feed_channel/NP in news_content) + pages++ //Let's get it right again. + var/datum/feed_channel/C = news_content[curr_page] + dat += "[C.channel_name] \[created by: [C.author]\]

" + if(C.censored) + dat += "This channel was deemed dangerous to the general welfare of the station and therefore marked with a D-Notice. Its contents were not transferred to the newspaper at the time of printing." else - // No trailing punctuation so that it's easy to copy and paste the address - if(GLOB.configuration.url.github_url) - dat += "We're sorry to break your immersion, but there has been an error with the newscaster. Please report this error, along with any more information you have, to [GLOB.configuration.url.github_url]/issues/new?template=bug_report.md" + if(!length(C.messages)) + dat += "No Feed stories stem from this channel..." else - dat += "We're sorry to break your immersion, but there has been an error with the newscaster. Unfortunately there is no GitHub URL set in the config. This is really bad." + dat += "
    " + var/i = 0 + for(var/datum/feed_message/MESSAGE in C.messages) + var/title = (MESSAGE.censor_flags & NEWSCASTER_CENSOR_STORY) ? "\[REDACTED\]" : MESSAGE.title + var/body = (MESSAGE.censor_flags & NEWSCASTER_CENSOR_STORY) ? "\[REDACTED\]" : MESSAGE.body + i++ + dat += "[title]
    " + dat += "[body]
    " + if(MESSAGE.img) + user << browse_rsc(MESSAGE.img, "tmp_photo[i].png") + dat += "
    " + dat += "\[Story by [MESSAGE.author]\]

    " + dat += "
" + if(scribble_page==curr_page) + dat += "
There is a small scribble near the end of this page... It reads: \"[scribble]\"" + dat+= "

Previous Page
Next Page
" + if(SCREEN_PAGE_LAST) //Last page + for(var/datum/feed_channel/NP in news_content) + pages++ + if(important_message!=null) + dat += "
Wanted Issue:


" + dat += "Criminal name: [important_message.author]
" + dat += "Description: [important_message.body]
" + dat += "Photo:: " + if(important_message.img) + user << browse_rsc(important_message.img, "tmp_photow.png") + dat += "
" + else + dat += "None" + else + dat += "Apart from some uninteresting Classified ads, there's nothing on this page..." + if(scribble_page==curr_page) + dat += "
There is a small scribble near the end of this page... It reads: \"[scribble]\"" + dat+= "
Previous Page
" + else + // No trailing punctuation so that it's easy to copy and paste the address. + if(GLOB.configuration.url.github_url) + dat += "We're sorry to break your immersion, but there has been an error with the newscaster. Please report this error, along with any more information you have, to [GLOB.configuration.url.github_url]/issues/new?template=bug_report.md" + else + dat += "We're sorry to break your immersion, but there has been an error with the newscaster. Unfortunately there is no GitHub URL set in the config. This is really bad." - dat += "

[curr_page+1]
" - human_user << browse(dat, "window=newspaper_main;size=300x400") - onclose(human_user, "newspaper_main") - else - to_chat(user, SPAN_WARNING("The paper is full of unintelligible symbols!")) + dat += "

[curr_page+1]
" + human_user << browse(dat, "window=newspaper_main;size=300x400") + onclose(human_user, "newspaper_main") + return ITEM_INTERACT_COMPLETE /obj/item/newspaper/Topic(href, href_list) if(..()) @@ -153,37 +161,48 @@ curr_page-- playsound(loc, "pageturn", 50, TRUE) if(loc == M) - attack_self__legacy__attackchain(M) + activate_self(M) -/obj/item/newspaper/attackby__legacy__attackchain(obj/item/W, mob/user, params) - if(is_pen(W)) - if(rolled) - to_chat(user, SPAN_WARNING("Unroll it first!")) - return - if(scribble_page == curr_page) - to_chat(user, SPAN_NOTICE("There's already a scribble in this page... You wouldn't want to make things too cluttered, would you?")) - else - var/s = tgui_input_text(user, "Write something", "Newspaper") - if(!s || !Adjacent(user)) - return - scribble_page = curr_page - scribble = s - user.visible_message(SPAN_NOTICE("[user] scribbles something on [src]."),\ - SPAN_NOTICE("You scribble on page number [curr_page] of [src].")) - attack_self__legacy__attackchain(user) - return - return ..() +/obj/item/newspaper/item_interaction(mob/living/user, obj/item/used, list/modifiers) + if(!is_pen(used)) + return ..() + + if(rolled) + to_chat(user, SPAN_WARNING("Unroll it first!")) + return ITEM_INTERACT_COMPLETE + + if(scribble_page == curr_page) + to_chat(user, SPAN_NOTICE("There's already a scribble in this page... You wouldn't want to make things too cluttered, would you?")) + return ITEM_INTERACT_COMPLETE + + var/new_text = tgui_input_text(user, "Write something", "Newspaper") + if(!new_text || !Adjacent(user)) + return ITEM_INTERACT_COMPLETE + scribble_page = curr_page + scribble = new_text + user.visible_message( + SPAN_NOTICE("[user] scribbles something on [src]."), + SPAN_NOTICE("You scribble on page number [curr_page] of [src]."), + SPAN_HEAR("You hear scribbling...") + ) + add_fingerprint(user) + activate_self(user) + return ITEM_INTERACT_COMPLETE /obj/item/newspaper/AltClick(mob/user) - if(ishuman(user) && Adjacent(user) && !user.incapacitated()) - rolled = !rolled - icon_state = "newspaper[rolled ? "_rolled" : ""]" - update_icon() - var/verbtext = "[rolled ? "" : "un"]roll" - user.visible_message(SPAN_NOTICE("[user] [verbtext]s [src]."),\ - SPAN_NOTICE("You [verbtext] [src].")) - name = "[rolled ? "rolled" : ""] [initial(name)]" - return ..() + if(!(ishuman(user) && Adjacent(user) && !user.incapacitated())) + return ..() + + rolled = !rolled + icon_state = "newspaper[rolled ? "_rolled" : ""]" + update_icon() + var/verbtext = "[rolled ? "" : "un"]roll" + user.visible_message( + SPAN_NOTICE("[user] [verbtext]s [src]."), + SPAN_NOTICE("You [verbtext] [src]."), + SPAN_HEAR("You hear a roll of paper [verbtext]ing.") + ) + name = "[rolled ? "rolled" : ""] [initial(name)]" #undef SCREEN_COVER #undef SCREEN_PAGE_INNER