diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index ef9f1e3b865..74f01144695 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -467,3 +467,7 @@ GLOBAL_LIST_INIT(pda_styles, sortList(list(MONO, VT, ORBITRON, SHARE))) #define ALIGNMENT_GOOD "good" #define ALIGNMENT_NEUT "neutral" #define ALIGNMENT_EVIL "evil" + +// Pirates threat +#define PIRATE_RESPONSE_NO_PAY "pirate_answer_no_pay" +#define PIRATE_RESPONSE_PAY "pirate_answer_pay" diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index 162d9c547d0..f90b9dae766 100755 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -95,14 +95,14 @@ if ("answerMessage") if (!authenticated(usr)) return - var/answer_index = text2num(params["answer"]) + var/answer_key = params["answer"] var/message_index = text2num(params["message"]) - if (!answer_index || !message_index || answer_index < 1 || message_index < 1) + if (!answer_key || !message_index || message_index < 1) return var/datum/comm_message/message = messages[message_index] - if (message.answered) + if (!(answer_key in message.possible_answers) || message.answered) return - message.answered = answer_index + message.answered = answer_key message.answer_callback.InvokeAsync() . = TRUE if ("callShuttle") diff --git a/code/modules/events/pirates.dm b/code/modules/events/pirates.dm index 798bdabf34b..c3a73f73370 100644 --- a/code/modules/events/pirates.dm +++ b/code/modules/events/pirates.dm @@ -37,12 +37,28 @@ payoff = max(payoff_min, FLOOR(D.account_balance * 0.80, 1000)) threat.title = "Business proposition" threat.content = "This is [ship_name]. Pay up [payoff] credits or you'll walk the plank." +<<<<<<< HEAD threat.possible_answers = list("We'll pay.","No way.") threat.answer_callback = CALLBACK(src,.proc/answered) SScommunications.send_message(threat,unique = TRUE) /datum/round_event/pirates/proc/answered() if(threat && threat.answered == 1) +======= + threat.possible_answers = list( + PIRATE_RESPONSE_PAY = "We'll pay.", + PIRATE_RESPONSE_NO_PAY = "No way.", + ) + threat.answer_callback = CALLBACK(GLOBAL_PROC, .proc/pirates_answered, threat, payoff, ship_name, initial_send_time, response_max_time) + addtimer(CALLBACK(GLOBAL_PROC, .proc/spawn_pirates, threat, FALSE), response_max_time) + SScommunications.send_message(threat,unique = TRUE) + +/proc/pirates_answered(datum/comm_message/threat, payoff, ship_name, initial_send_time, response_max_time) + if(world.time > initial_send_time + response_max_time) + priority_announce("Too late to beg for mercy!",sender_override = ship_name) + return + if(threat?.answered) +>>>>>>> cd56f3f974... Fix spawning multiple pirate ships and refactor comms console answer keys (#7608) var/datum/bank_account/D = SSeconomy.get_dep_account(ACCOUNT_CAR) if(D) if(D.adjust_money(-payoff)) @@ -51,6 +67,7 @@ return else priority_announce("Trying to cheat us? You'll regret this!", sound = SSstation.announcer.get_rand_alert_sound(), sender_override = ship_name) +<<<<<<< HEAD if(!shuttle_spawned) spawn_shuttle() else @@ -65,6 +82,13 @@ /datum/round_event/pirates/proc/spawn_shuttle() shuttle_spawned = TRUE +======= + spawn_pirates(threat, TRUE) + +/proc/spawn_pirates(datum/comm_message/threat, skip_answer_check) + if(!skip_answer_check && threat?.answered == PIRATE_RESPONSE_NO_PAY) + return +>>>>>>> cd56f3f974... Fix spawning multiple pirate ships and refactor comms console answer keys (#7608) var/list/candidates = pollGhostCandidates("Do you wish to be considered for pirate crew?", ROLE_TRAITOR) shuffle_inplace(candidates) diff --git a/tgui/packages/tgui/interfaces/CommunicationsConsole.js b/tgui/packages/tgui/interfaces/CommunicationsConsole.js index 95abce44d93..09ea6ede2ec 100644 --- a/tgui/packages/tgui/interfaces/CommunicationsConsole.js +++ b/tgui/packages/tgui/interfaces/CommunicationsConsole.js @@ -197,8 +197,8 @@ const PageBuyingShuttle = (props, context) => { data.budget < shuttle.creditCost ? (`You need ${ shuttle.creditCost - data.budget } more credits.` - ) : (shuttle.illegal - ? ILLEGAL_SHUTTLE_NOTICE + ) : (shuttle.illegal + ? ILLEGAL_SHUTTLE_NOTICE : undefined) } tooltipPosition="left" @@ -619,17 +619,17 @@ const PageMessages = (props, context) => { messages.map((message, messageIndex) => { let answers = null; - if (message.possibleAnswers.length > 0) { + if (Object.keys(message.possibleAnswers).length > 0) { answers = ( - {message.possibleAnswers.map((answer, answerIndex) => ( + {Object.entries(message.possibleAnswers).map((answer) => (