Skip to content

Commit

Permalink
Merge pull request #74844 from Fris0uman/graveless_souls
Browse files Browse the repository at this point in the history
Jsonized end screen: How I learned to stop worrying and win the Cataclysm
  • Loading branch information
Maleclypse authored Jul 9, 2024
2 parents fa408f7 + 29a0e02 commit 7f1fea9
Show file tree
Hide file tree
Showing 14 changed files with 430 additions and 174 deletions.
113 changes: 113 additions & 0 deletions data/json/ascii_art/graveyard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
[
{
"type": "ascii_art",
"id": "ascii_rip_cross",
"picture": [
" _______ ___",
" < `/ |",
" > _ _ (",
" | |_) | |_) |",
" | | \\ | | |",
" ______.__<color_green>%</color>_| |________ __",
" _/ \\| |",
"| <",
"| |",
"| |",
"|_____.-._____ _/|_________|",
" | |",
" | |",
" | <",
" | |",
" | _ |",
" |__/ |",
" <color_green>%</color> / `--. |<color_green>%</color>",
" <color_red>*</color> .<color_green>%%</color>| -< <color_brown>@</color><color_green>%%%</color>",
" `\\<color_green>%</color>`<color_brown>@</color>| |<color_brown>@@</color><color_green>%</color><color_brown>@</color><color_green>%%</color>",
" .<color_green>%%%</color><color_brown>@@@</color>|<color_green>%</color> ` <color_green>%</color> <color_brown>@@@</color><color_green>%%</color><color_brown>@</color><color_green>%%%%</color>",
" _.<color_green>%%%%%%</color><color_brown>@@@@@@</color><color_green>%%%</color>__/\\<color_green>%</color><color_brown>@@</color><color_green>%%</color><color_brown>@@@@@@@</color><color_green>%%%%%%</color>"
]
},
{
"type": "ascii_art",
"id": "ascii_rip_inverted_cross",
"picture": [
" _______ ___",
" | \\/ |",
" | |",
" | |",
" | |",
" | |",
" | |",
" | |",
" | <",
" | _ |",
" |__/ |",
" _____.__%_| |_________ _",
" _/ \\| \\",
"| <",
"| |",
"| |",
"|____.-._______ __/|__________|",
" <color_green>%</color> / `_-. _ |<color_green>%</color>",
" <color_red>*</color> .<color_green>%%</color>| |_) | |_)< <color_brown>@<color_green>%%%</color>",
" `\\<color_green>%</color>`<color_brown>@</color>| | \\ | | |<color_brown>@@</color><color_green>%@<color_green>%%</color>",
" .<color_green>%%%</color><color_brown>@@@</color>|<color_green>%</color> ` <color_green>%</color> <color_brown>@@@</color><color_green>%%</color><color_brown>@</color><color_green>%%%%</color>",
" _.<color_green>%%%%%%</color><color_brown>@@@@@@</color><color_green>%%%</color>__/\\<color_green>%</color><color_brown>@@</color><color_green>%%</color><color_brown>@@@@@@@</color><color_green>%%%%%%</color>"
]
},
{
"type": "ascii_art",
"id": "ascii_tombstone",
"picture": [
" _________ ____ ",
" _/ `/ \\_ ",
" _/ _ _ \\_. ",
" _<color_green>%</color>\\ |_) | |_) \\_ ",
" _/ \\/ | \\ | | \\_ ",
" _/ \\_ ",
"| |",
" ) < ",
"| |",
"| |",
"| _ |",
"|__/ |",
" / `--. |",
"| ( ",
"| |",
"| |",
"| <color_green>%</color> . |",
"| <color_brown>@</color>` <color_green>%%</color> |",
"| <color_green>%</color><color_brown>@</color><color_green>%</color><color_brown>@</color><color_green>%</color>\\ <color_red>*</color> <color_green>%</color>`<color_green>%</color><color_brown>@</color><color_green>%</color>|",
"<color_green>%%</color><color_brown>@@@</color>.<color_green>%</color><color_brown>@</color><color_green>%</color>\\<color_green>%%</color> `\\ <color_green>%%</color>.<color_green>%%</color><color_brown>@@</color><color_green>%</color><color_brown>@</color>",
"<color_brown>@</color><color_green>%</color><color_brown>@@</color><color_green>%%%%%</color><color_brown>@@@@@@</color><color_green>%%%%%%%%</color><color_brown>@@</color><color_green>%%</color><color_brown>@@@</color><color_green>%%%</color><color_brown>@</color><color_green>%%</color><color_brown>@</color>"
]
},
{
"type": "ascii_art",
"id": "ascii_portal_storm_win",
"picture": [
" ",
" <color_light_blue>|</color> ",
" <color_light_blue>-.-</color> ",
" <color_light_blue>|</color> ",
" ",
" ",
" <color_yellow>|</color> ",
" <color_yellow>_._</color> ",
" <color_yellow>|</color> ",
" ",
" ",
" ",
" <color_yellow>|</color> ",
" <color_yellow>-.-</color> ",
" <color_yellow>|</color> ",
" ",
" <color_light_blue>|</color> ",
" <color_light_blue>_._</color> ",
" <color_light_blue>|</color> ",
" ",
" ",
" "
]
}
]
6 changes: 6 additions & 0 deletions data/json/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -4993,5 +4993,11 @@
"desc": [ "Applied by leap special attack of burned frog zombies, conditional for related spell." ],
"max_duration": "5 m",
"show_in_info": true
},
{
"type": "effect_type",
"id": "a_winner_is_u",
"name": [ "Winning!" ],
"//": "Used to display the winning screen upon winning like a winner."
}
]
64 changes: 64 additions & 0 deletions data/json/end_screen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[
{
"type": "end_screen",
"id": "death_tombstone",
"priority": 0,
"picture_id": "ascii_tombstone",
"condition": { "not": "u_is_alive" },
"added_info": [
[ [ 6, 8 ], "In memory of: <u_name>" ],
[ [ 13, 9 ], "Survived: <time_survived>" ],
[ [ 15, 10 ], "Kills: <total_kills>" ]
],
"last_words_label": "Last Words:"
},
{
"type": "end_screen",
"id": "death_cross",
"priority": 100,
"picture_id": "ascii_rip_cross",
"condition": {
"and": [
{ "not": "u_is_alive" },
{
"or": [ { "u_has_item": "holybook_bible1" }, { "u_has_item": "holybook_bible2" }, { "u_has_item": "holybook_bible3" } ]
},
{ "not": { "and": [ { "u_has_trait": "CANNIBAL" }, { "u_has_trait": "PSYCHOPATH" } ] } }
]
},
"added_info": [
[ [ 8, 8 ], "In memory of: <color_green><u_name></color>" ],
[ [ 15, 9 ], "Survived: <time_survived>" ],
[ [ 17, 10 ], "Kills: <total_kills>" ]
],
"last_words_label": "Last Words:"
},
{
"type": "end_screen",
"id": "death_inverted_cross",
"priority": 100,
"picture_id": "ascii_rip_inverted_cross",
"condition": { "and": [ { "not": "u_is_alive" }, { "or": [ { "u_has_trait": "CANNIBAL" }, { "u_has_trait": "PSYCHOPATH" } ] } ] },
"added_info": [
[ [ 8, 14 ], "In memory of: <color_green><u_name></color>" ],
[ [ 15, 15 ], "Survived: <time_survived>" ],
[ [ 17, 16 ], "Kills: <total_kills>" ]
],
"last_words_label": "Last Words:"
},
{
"type": "end_screen",
"id": "portal_storm_win",
"priority": 200,
"picture_id": "ascii_portal_storm_win",
"condition": { "and": [ { "not": "u_is_alive" }, { "u_has_effect": "a_winner_is_u" } ] },
"added_info": [
[ [ 6, 6 ], "You <color_pink>won</color>" ],
[ [ 8, 7 ], "<u_name>..." ],
[ [ 4, 10 ], "...<u_name>, who's that?" ],
[ [ 15, 11 ], "Not your problem anymore." ],
[ [ 9, 15 ], "What a <color_pink>success</color>." ],
[ [ 4, 21 ], "Something struggled for: <time_survived>" ]
]
}
]
8 changes: 7 additions & 1 deletion data/json/npcs/EOC_talkers/portal_storm.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@
"type": "talk_topic",
"id": "TALK_PORTAL_STORM_WILL_IT",
"dynamic_line": "&You do not exist anymore. Something else exists elsewhere, and vaguely remembers being you. Its (torment?/joy?/confusion?/freedom?) will never truly end.",
"responses": [ { "text": "An ending? The cataclysm was bad but was this better?", "topic": "TALK_DONE", "effect": [ "u_die" ] } ]
"responses": [
{
"text": "An ending? The cataclysm was bad but was this better?",
"topic": "TALK_DONE",
"effect": [ "u_die", { "u_add_effect": "a_winner_is_u", "duration": "PERMANENT" } ]
}
]
}
]
36 changes: 36 additions & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Use the `Home` key to return to the top.
- [Damage Info Ordering](#damage-info-ordering)
- [Dreams](#dreams)
- [Disease](#disease)
- [End Screen](#end-screen)
- [Emitters](#emitters)
- [Item Groups](#item-groups)
- [Item Category](#item-category)
Expand Down Expand Up @@ -1512,6 +1513,41 @@ Using `damage_info_order` we can reorder how these are shown, and even determine
}
```

### End Screen

| Identifier | Description
|--- |---
| `id` | (_mandatory_) Unique ID. Must be one continuous word, use underscores if necessary.
| `priority` | (_mandatory_) Int used to chose among several end sreens with valid conditions, higher value have higher priority. Priority 0 is the default tombstone end.
| `picture_id` | (_mandatory_) ID of an ascii art, see #Ascii_arts.
| `condition` | (_mandatory_) Conditions necessary to display this end screen. See the "Dialogue conditions" section of [NPCs](NPCs.md) for the full syntax.
| `added_info` | (_optional_) Vector of pairs of a pair of int character offset and Line number and a string to be written on the end screen. The string can use talk tags, see the "Special Custom Entries" section of [NPCs](NPCs.md) for the full syntax.
| `last_words_label` | (_optional_) String used to label the last word input prompt. If left empty no prompt will be displayed.

```json
{
"type": "end_screen",
"id": "death_cross",
"priority": 1,
"picture_id": "ascii_rip_cross",
"condition": {
"and": [
{ "not": "u_is_alive" },
{
"or": [ { "u_has_item": "holybook_bible1" }, { "u_has_item": "holybook_bible2" }, { "u_has_item": "holybook_bible3" } ]
},
{ "not": { "and": [ { "u_has_trait": "CANNIBAL" }, { "u_has_trait": "PSYCHOPATH" } ] } }
]
},
"added_info": [
[ [ 8, 8 ], "In memory of: <u_name>" ],
[ [ 15, 9 ], "Survived: <time_survived>" ],
[ [ 17, 10 ], "Kills: <total_kills>" ]
],
"last_words_label": "Last Words:"
}
```

### Emitters

Emitters randomly place [fields](#field-types) around their positions - every turn for monster emissions, every ten seconds for furniture/terrain.
Expand Down
2 changes: 2 additions & 0 deletions doc/NPCs.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ Field | Used for...
`<current_activity>` | displays npc's current activity
`<punc>` | displays a random punctuation from: `.`, ``, `!`
`<mypronoun>` | displays npc's pronoun
`<total_kills>` | total kills of the Player
`<time_survived>` | time since start of the game
`<topic_item>` | referenced item
`<topic_item_price>` | referenced item unit price
`<topic_item_my_total_price>` | TODO Add
Expand Down
2 changes: 2 additions & 0 deletions lang/string_extractor/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .parsers.effect import parse_effect_on_condition
from .parsers.effect_type import parse_effect_type
from .parsers.enchant import parse_enchant
from .parsers.end_screen import parse_end_screen
from .parsers.event_statistic import parse_event_statistic
from .parsers.faction import parse_faction
from .parsers.fault import parse_fault
Expand Down Expand Up @@ -137,6 +138,7 @@ def dummy_parser(json, origin):
"effect_type": parse_effect_type,
"emit": dummy_parser,
"enchantment": parse_enchant,
"end_screen": parse_end_screen,
"engine": parse_generic,
"event_statistic": parse_event_statistic,
"event_transformation": dummy_parser,
Expand Down
8 changes: 8 additions & 0 deletions lang/string_extractor/parsers/end_screen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from ..write_text import write_text


def parse_end_screen(json, origin):
if "last_words_label" in json:
write_text(json["last_words_label"], origin,
comment="String used to label the last word input prompt."
"ex: \"Last Words:\")")
42 changes: 42 additions & 0 deletions src/end_screen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "assign.h"
#include "condition.h"
#include "end_screen.h"
#include "generic_factory.h"

namespace
{
generic_factory<end_screen> end_screen_factory( "end_screen" );
} // namespace

template<>
const end_screen &string_id<end_screen>::obj()const
{
return end_screen_factory.obj( *this );
}

template<>
bool string_id<end_screen>::is_valid() const
{
return end_screen_factory.is_valid( *this );
}

void end_screen::load_end_screen( const JsonObject &jo, const std::string &src )
{
end_screen_factory.load( jo, src );
}

void end_screen::load( const JsonObject &jo, std::string_view )
{
mandatory( jo, was_loaded, "id", id );
mandatory( jo, was_loaded, "picture_id", picture_id );
mandatory( jo, was_loaded, "priority", priority );
read_condition( jo, "condition", condition, false );

optional( jo, was_loaded, "added_info", added_info );
optional( jo, was_loaded, "last_words_label", last_words_label );
}

const std::vector<end_screen> &end_screen::get_all()
{
return end_screen_factory.get_all();
}
30 changes: 30 additions & 0 deletions src/end_screen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once
#ifndef CATA_SRC_DEATH_SCREEN_H
#define CATA_SRC_DEATH_SCREEN_H

#include <iosfwd>
#include <vector>

#include "ascii_art.h"
#include "effect_on_condition.h"
#include "type_id.h"

class JsonObject;

struct end_screen {
public:
static void load_end_screen( const JsonObject &jo, const std::string &src );

void load( const JsonObject &jo, std::string_view );
static const std::vector<end_screen> &get_all();
bool was_loaded = false;

end_screen_id id;
ascii_art_id picture_id;
std::function<bool( dialogue & )> condition;
int priority;
std::vector<std::pair<std::pair<int, int>, std::string>> added_info;
std::string last_words_label;
};

#endif // CATA_SRC_DEATH_SCREEN_H
Loading

0 comments on commit 7f1fea9

Please sign in to comment.