Skip to content

Commit

Permalink
WIP on #607
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Feb 20, 2025
1 parent 3dea009 commit 7e149a4
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 1 deletion.
4 changes: 4 additions & 0 deletions proj/xc12/BoE.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
919B13A21BBCDF14009905A4 /* monst_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 919B13A11BBCDE18009905A4 /* monst_legacy.cpp */; };
919B13A41BBD8854009905A4 /* item_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 919B13A31BBD8849009905A4 /* item_legacy.cpp */; };
919B13A61BBDE986009905A4 /* spec_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 919B13A51BBDE985009905A4 /* spec_legacy.cpp */; };
919BE86B2D658BC6000C64C6 /* special-general.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 919BE86A2D658BBC000C64C6 /* special-general.cpp */; };
919CC2481B3772F300273FDA /* population.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC620A0FA2853700EEAE67 /* population.cpp */; };
919CC2491B3772FB00273FDA /* creature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 914698FE1A747C4500F20F5E /* creature.cpp */; };
919CC24B1B37730300273FDA /* item.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91279D3D0F9D1D6A007B0D52 /* item.cpp */; };
Expand Down Expand Up @@ -766,6 +767,7 @@
919B13A51BBDE985009905A4 /* spec_legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = spec_legacy.cpp; sourceTree = "<group>"; };
919B13A71BBE297B009905A4 /* scrollpane.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = scrollpane.hpp; sourceTree = "<group>"; };
919B13A81BBE2B54009905A4 /* scrollpane.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scrollpane.cpp; sourceTree = "<group>"; };
919BE86A2D658BBC000C64C6 /* special-general.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "special-general.cpp"; sourceTree = "<group>"; };
919DDBFA19006CC9003E7FED /* libboost_filesystem-mt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libboost_filesystem-mt.dylib"; path = "/opt/local/libexec/boost/1.76/lib/libboost_filesystem-mt.dylib"; sourceTree = "<absolute>"; };
919DDBFB19006CC9003E7FED /* libboost_system-mt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libboost_system-mt.dylib"; path = "/opt/local/libexec/boost/1.76/lib/libboost_system-mt.dylib"; sourceTree = "<absolute>"; };
919DDC091900750D003E7FED /* freetype.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = freetype.framework; path = /Library/Frameworks/freetype.framework; sourceTree = "<absolute>"; };
Expand Down Expand Up @@ -1248,6 +1250,7 @@
91279CC10F9D19DA007B0D52 /* monster.cpp */,
91E5C79D0F9F60FA00C21460 /* outdoors.cpp */,
91279C580F9D1253007B0D52 /* scenario.cpp */,
919BE86A2D658BBC000C64C6 /* special-general.cpp */,
91FDB5791A4E774E00DE5983 /* shop.cpp */,
91279CC60F9D1A02007B0D52 /* special.cpp */,
91E5C7B70F9F619D00C21460 /* talking.cpp */,
Expand Down Expand Up @@ -2099,6 +2102,7 @@
415EEEB02D5534A500B47408 /* prefs.cpp in Sources */,
919CC2701B3773EC00273FDA /* scrollbar.cpp in Sources */,
919CC2711B3773F300273FDA /* cursors.mac.mm in Sources */,
919BE86B2D658BC6000C64C6 /* special-general.cpp in Sources */,
919CC2721B3773F800273FDA /* fileio.cpp in Sources */,
919CC2741B37740200273FDA /* fileio_scen.cpp in Sources */,
919CC2751B37740A00273FDA /* render_image.cpp in Sources */,
Expand Down
1 change: 0 additions & 1 deletion src/scenario/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class cItem {
unsigned short type_flag;
unsigned int is_special;
short value;
unsigned int weight;

This comment has been minimized.

Copy link
@NQNStudios

NQNStudios Feb 20, 2025

Collaborator

This seems wrong?

unsigned int special_class;
miss_num_t missile;
location item_loc;
Expand Down
113 changes: 113 additions & 0 deletions src/scenario/special-general.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//
// special-general.cpp
// BoE
//
// Created by Celtic Minstrel on 2025-02-18.
//

#include "special.hpp"

using namespace node_builder_fields;

auto S_NONE = node_builder_t(eSpecType::NONE).finish();
auto S_SETFLAG = node_builder_t(eSpecType::SET_SDF).sdf().msg().finish();
auto S_INCFLAG = node_builder_t(eSpecType::INC_SDF).sdf().msg().finish();
auto S_MSG = node_builder_t(eSpecType::DISPLAY_MSG).msg().finish();
auto S_SHOP = node_builder_t(eSpecType::ENTER_SHOP).msg1(eSpecPicker::MSG_SINGLE).ex1a(STRT_SHOP).ex1b(STRT_COST_ADJ).jump(eSpecPicker::NONE).finish();
auto S_MSG_SM = node_builder_t(eSpecType::DISPLAY_SM_MSG).msg().finish();
auto S_FLIPFLAG = node_builder_t(eSpecType::FLIP_SDF).sdf().msg().finish();
auto S_RANDFLAG = node_builder_t(eSpecType::SDF_RANDOM).sdf().msg().finish();
auto S_ADDFLAG = node_builder_t(eSpecType::SDF_ADD).sdf().msg().finish();
auto S_SUBFLAG = node_builder_t(eSpecType::SDF_DIFF).sdf().msg().finish();
auto S_STORY = node_builder_t(eSpecType::STORY_DIALOG).msg1(eSpecPicker::MSG_SINGLE).pic().finish();
auto S_PREVENT = node_builder_t(eSpecType::CANT_ENTER).msg().finish();
auto S_TIME = node_builder_t(eSpecType::CHANGE_TIME).msg().finish();
auto S_TIMER = node_builder_t(eSpecType::SCEN_TIMER_START).msg().ex1b(+eSpecPicker::NODE).finish();
auto S_SND = node_builder_t(eSpecType::PLAY_SOUND).ex1a(eSpecPicker::SOUND).finish();
auto S_HORSE_OWN = node_builder_t(eSpecType::CHANGE_HORSE_OWNER).msg().finish();
auto S_BOAT_OWN = node_builder_t(eSpecType::CHANGE_BOAT_OWNER).msg().finish();
auto S_TOWN_VIS = node_builder_t(eSpecType::SET_TOWN_VISIBILITY).msg().ex1a(STRT_TOWN).finish();
auto S_EVENT = node_builder_t(eSpecType::MAJOR_EVENT_OCCURRED).msg().finish();
auto S_FORCEGIVE = node_builder_t(eSpecType::FORCED_GIVE).msg().ex1a(STRT_ITEM).ex1b(eSpecPicker::NODE).finish();
auto S_BUYTYPE = node_builder_t(eSpecType::BUY_ITEMS_OF_TYPE).msg().ex1b(eSpecPicker::NODE).finish();
auto S_GLOBAL = node_builder_t(eSpecType::CALL_GLOBAL).jump(+eSpecPicker::NODE).finish();
auto S_SETROW = node_builder_t(eSpecType::SET_SDF_ROW).finish();
auto S_COPYFLAG = node_builder_t(eSpecType::COPY_SDF).sdf().sdf(EX1A, EX1B).finish();
auto S_PICTURE = node_builder_t(eSpecType::DISPLAY_PICTURE).msg1(eSpecPicker::MSG_SINGLE).ex1a(PIC_FULL).finish();
auto S_REST = node_builder_t(eSpecType::REST).msg().finish();
auto S_MSG_TITLE = node_builder_t(eSpecType::TITLED_MSG).msg().msg3(eSpecPicker::MSG_SINGLE).pic().finish();
auto S_END_SCEN = node_builder_t(eSpecType::END_SCENARIO).finish();
auto S_SETPTR = node_builder_t(eSpecType::SET_POINTER).sdf().finish();
auto S_CAMPFLAG = node_builder_t(eSpecType::SET_CAMP_FLAG).sdf().msg1(+eSpecPicker::MSG_SINGLE).finish();
auto S_DEBUG = node_builder_t(eSpecType::PRINT_NUMS).sdf().finish();
auto S_MULFLAG = node_builder_t(eSpecType::SDF_DIFF).sdf().msg().finish();
auto S_DIVFLAG = node_builder_t(eSpecType::SDF_DIFF).sdf().sdf(EX1C, EX2C).msg().finish();
auto S_EXPFLAG = node_builder_t(eSpecType::SDF_DIFF).sdf().msg().finish();
auto S_TERCHANGE = node_builder_t(eSpecType::CHANGE_TER).msg().loc(EX1A, EX1B).ex2a(STRT_TER).finish();
auto S_TERSWAP = node_builder_t(eSpecType::SWAP_TER).msg().loc(EX1A, EX1B).ex2a(STRT_TER).ex2b(STRT_TER).finish();
auto S_TERTRANS = node_builder_t(eSpecType::TRANS_TER).msg().loc(EX1A, EX1B).ex2a(STRT_TER).finish();
auto S_BUF_CLEAR = node_builder_t(eSpecType::CLEAR_BUF).finish();
auto S_BUF_ADDSTR = node_builder_t(eSpecType::APPEND_STRING).ex1a(eSpecPicker::MSG_SINGLE).finish();
auto S_BUF_ADDNUM = node_builder_t(eSpecType::APPEND_NUM).finish();
auto S_BUF_ADDMONST = node_builder_t(eSpecType::APPEND_MONST).ex1a(STRT_MONST).finish();
auto S_BUF_ADDITEM = node_builder_t(eSpecType::APPEND_ITEM).ex1a(STRT_ITEM).finish();
auto S_BUF_ADDTER = node_builder_t(eSpecType::APPEND_TER).ex1a(STRT_TER).finish();
auto S_PAUSE = node_builder_t(eSpecType::PAUSE).finish();
auto S_TALK = node_builder_t(eSpecType::START_TALK).pict(PIC_TALK).ex1b(STRT_MONST).jump(eSpecPicker::NONE).finish();
auto S_QUEST = node_builder_t(eSpecType::UPDATE_QUEST).msg().ex1a(STRT_QUEST).ex1b(STRT_QUEST_STATUS).finish();
auto S_BUF_SWAP = node_builder_t(eSpecType::SWAP_STR_BUF).msg().finish();
auto S_ALTER_SIGN = node_builder_t(eSpecType::STR_BUF_TO_SIGN).msg().finish();

auto dead_ends = {eSpecType::TOWN_GENERIC_STAIR, eSpecType::TOWN_STAIR};
// Key:
// space - no button
// m - Create/Edit button to edit message pair (covers msg1 and msg2 together)
// M - Create/Edit button to edit single message
// $ - As above, but always a scenario message
// d - Create/Edit button to edit dialog message sequence (covers msg1 and msg2 together)
// b - Choose button to select a button label
// p - Choose button to select a picture (uses pictype for type)
// ? - Choose button to select a picture type
// s - Create/Edit button to edit special node
// S - As above, but always a scenario node
// x - Choose button to select a sound
// X - Choose button to select a trap type
// T - Choose button to select a town
// i - Choose button to select an item
// I - Choose button to select a special item
// t - Choose button to select a terrain type
// c - Choose button to select a monster type
// C - Choose button to select a monster statistic
// a - Choose button to select an alchemy recipe
// A - Choose button to select a mage spell
// P - Choose button to select a priest spell
// k - Choose button to select a skill
// K - As above, but add the special pseudo-skills for the if-statistic node
// f - Choose button to select a field type
// F - As above, but also include Dispel and Smash
// q - Choose button to select a trait
// Q - Choose button to select a species
// = - Choose button to select a comparison method (<=, <, =, >, >=)
// + - Choose button to select stat cumulation mode
// * - Choose button to select a special node context
// @ - Choose button to select a monster attitude
// D - Choose button to select a damage type
// ! - Choose button to select an explosion animation type
// / - Choose button to select generic stairway text
// : - Choose stairway trigger conditions
// L - Choose button to select a town lighting type
// & - Choose button to select a shop
// % - Choose button to select shop cost adjustment
// { - Choose button to select a spell pattern
// } - As above, but allows you to select which version of the rotateable field
// ^ - Choose button to select a positioning mode
// e - Choose button to select a status effect
// E - Choose button to select a party status effect
// w - Choose button to select main party status effect
// j - Choose button to select a quest
// J - Choose button to select a quest status
// < - Choose button to select a cardinal direction
// ~ - Choose button to select a weapon enchantment
// _ - Choose button to select a full sheet
// 0..9 - Choose button to select a specific type of picture
// (terrain, monster, dialog, talk, item, pc, field, boom, missile, status)
132 changes: 132 additions & 0 deletions src/scenario/special.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,39 @@ node_function_t::node_function_t(char c) {
}
}

node_function_t::node_function_t(eSpecPicker button)
: button(button)
{}

node_function_t::node_function_t(eStrType str)
: button(eSpecPicker::STRING)
, str_type(str)
{}

node_function_t::node_function_t(ePicType pic)
: button(eSpecPicker::PICTURE)
, pic_type(pic)
{}

node_function_t operator+(eSpecPicker picker) {
node_function_t n(picker);
if(picker == eSpecPicker::NODE || picker == eSpecPicker::MSG_PAIR || picker == eSpecPicker::MSG_SINGLE || picker == eSpecPicker::MSG_SEQUENCE) {
n.force_global = true;
}
if(picker == eSpecPicker::FIELD) {
n.augmented = true;
}
return n;
}

node_function_t operator+(eStrType str) {
node_function_t n(str);
if(str == STRT_SPELL_PAT || str == STRT_SKILL) {
n.augmented = true;
}
return n;
}

std::string node_function_t::label() const {
return get_node_string("specials-text", self, lbl_idx);
}
Expand Down Expand Up @@ -927,3 +960,102 @@ node_function_t node_properties_t::ex2c(const cSpecial&) const {
node_function_t node_properties_t::jump(const cSpecial&) const {
return f_jmp;
}

using namespace node_builder_fields;


node_builder_t& node_builder_t::sdf() {
// The intent is to specify that sdf1,sdf2 is a stuff done flag.
// But specifying that two fields are a stuff done flag isn't implemented yet.
return sdf(SDF1, SDF2);
}

node_builder_t& node_builder_t::msg() {
return msg1(eSpecPicker::MSG_PAIR).msg2(eSpecPicker::NONE);
};

node_builder_t& node_builder_t::rect() {
// The intent is to specify that ex1a,ex1b, and ex2a,ex2b are locations.
// But specifying that two fields are a location isn't implemented yet.
return loc(EX1A, EX1B).loc(EX2A, EX2B);
};

node_builder_t& node_builder_t::pic() {
return pict(eSpecPicker::PICTURE).ptyp(STRT_PICT);
}

node_builder_t& node_builder_t::sdf1(node_function_t picker) {
return field(SDF1, picker);
}

node_builder_t& node_builder_t::sdf2(node_function_t picker) {
return field(SDF2, picker);
}

node_builder_t& node_builder_t::jump(node_function_t picker) {
return field(JUMP, picker);
}

node_builder_t& node_builder_t::msg1(node_function_t picker) {
return field(MSG1, picker);
}

node_builder_t& node_builder_t::msg2(node_function_t picker) {
return field(MSG2, picker);
}

node_builder_t& node_builder_t::msg3(node_function_t picker) {
return field(MSG3, picker);
}

node_builder_t& node_builder_t::pict(node_function_t picker) {
return field(PICT, picker);
}

node_builder_t& node_builder_t::ptyp(node_function_t picker) {
return field(PTYP, picker);
}

node_builder_t& node_builder_t::ex1a(node_function_t picker) {
return field(EX1A, picker);
}

node_builder_t& node_builder_t::ex1b(node_function_t picker) {
return field(EX1B, picker);
}

node_builder_t& node_builder_t::ex1c(node_function_t picker) {
return field(EX1C, picker);
}

node_builder_t& node_builder_t::ex2a(node_function_t picker) {
return field(EX2A, picker);
}

node_builder_t& node_builder_t::ex2b(node_function_t picker) {
return field(EX2B, picker);
}

node_builder_t& node_builder_t::ex2c(node_function_t picker) {
return field(EX2C, picker);
}

node_builder_t& node_builder_t::field(node_builder_fields::eNodeField field, node_function_t picker) {
// node.*field_map[field] = picker;
return *this;
}

node_builder_t& node_builder_t::sdf(node_builder_fields::eNodeField a, node_builder_fields::eNodeField b) {
// A stuff done flag picker isn't implemented yet.
return *this;
}

node_builder_t& node_builder_t::loc(node_builder_fields::eNodeField a, node_builder_fields::eNodeField b) {
// A location picker isn't implemented yet
return *this;
}

node_properties_t node_builder_t::finish() {
// TODO: Add it to the map
return node;
}
41 changes: 41 additions & 0 deletions src/scenario/special.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ struct node_function_t {
std::string help() const; // maybe we don't need this though? I guess it would be for a hypothetical help button next to each field to give addition info on how that one field works.
node_function_t();
node_function_t(char c);
node_function_t(eSpecPicker button);
node_function_t(eStrType str);
node_function_t(ePicType pic);
// TODO: a way to set force_global or augmented to true
private:
eSpecType self = eSpecType::NONE;
std::string lbl;
Expand All @@ -168,6 +172,9 @@ struct node_function_t {
friend struct node_properties_t;
};

node_function_t operator+(eSpecPicker);
node_function_t operator+(eStrType);

struct node_properties_t {
eSpecType self;
eSpecCat cat;
Expand All @@ -183,8 +190,42 @@ struct node_properties_t {
static void load();
private:
node_function_t f_sd1, f_sd2, f_jmp, f_m1, f_m2, f_m3, f_pic, f_pt, f_x1a, f_x1b, f_x1c, f_x2a, f_x2b, f_x2c;
friend struct node_builder_t;
};

const node_properties_t& operator* (eSpecType t);

namespace node_builder_fields {
enum eNodeField { SDF1, SDF2, MSG1, MSG2, MSG3, PICT, PTYP, EX1A, EX1B, EX1C, EX2A, EX2B, EX2C, JUMP };
}

struct node_builder_t {
node_builder_t(eSpecType type);
~node_builder_t();
node_builder_t& sdf(); // fills SDF1 and SDF2
node_builder_t& msg(); // fills M1 and M2
node_builder_t& rect();// fills ex1a, ex1b, ex2a, ex2b
node_builder_t& pic(); // fills pic, pictype
node_builder_t& field(node_builder_fields::eNodeField field, node_function_t picker);
node_builder_t& sdf1(node_function_t picker);
node_builder_t& sdf2(node_function_t picker);
node_builder_t& jump(node_function_t picker);
node_builder_t& msg1(node_function_t picker);
node_builder_t& msg2(node_function_t picker);
node_builder_t& msg3(node_function_t picker);
node_builder_t& pict(node_function_t picker);
node_builder_t& ptyp(node_function_t picker);
node_builder_t& ex1a(node_function_t picker);
node_builder_t& ex1b(node_function_t picker);
node_builder_t& ex1c(node_function_t picker);
node_builder_t& ex2a(node_function_t picker);
node_builder_t& ex2b(node_function_t picker);
node_builder_t& ex2c(node_function_t picker);
node_builder_t& sdf(node_builder_fields::eNodeField a, node_builder_fields::eNodeField b);
node_builder_t& loc(node_builder_fields::eNodeField a, node_builder_fields::eNodeField b);
node_properties_t finish();
private:
node_properties_t node;
};

#endif

0 comments on commit 7e149a4

Please sign in to comment.