List of commits:
Subject Hash Author Date (UTC)
Switch inventories and stats to floating-point c6e4142e664648ca8f4aa913b48526093c985987 mse 2021-08-31 13:35:20
Switch scripting to floating-point & code comments eb067496f4edb4420c05a09dc034ad0a25ad1e56 mse 2021-08-31 11:06:01
Add top-level command: GOSUB 62e9520aec0471fe023ead290595f735a30eb806 mse 2021-08-26 09:31:27
Add persistent VN stats 2d1ffc35afd8ae0f477cbd5aac0559fc02571600 mse 2021-08-23 10:44:16
Bribes increase karma 643f0fc6da65316aa799bbe00cea2030e2c1ccd6 mse 2021-08-17 08:16:36
Add command: #RUMBLE <intensity> <milliseconds> 02964b2ecc57a48192522ef369e33c4912d2f0d2 mse 2021-08-16 07:17:40
Reset position in non-mouse menu selection c21eb6a9d238fa1909dbbbc49907ad09bfca52c8 mse 2021-08-16 03:30:49
Add haptic rumble for combat 65ff172308b0ba26b8930e8e83eb41bd36c6b008 mse 2021-08-15 06:11:25
Reduce joystick sensitivity 3804492a52d36c40cd51d42a971fe92f4fdd52ba mse 2021-08-14 22:37:19
Set audio buffer 1024 to reduce latency b1733b33b3342b32f08e1bafb5baf63ed7db419e mse 2021-07-11 02:56:22
Update readme, deps, bump to v0.5.0 2f96bc1fe9af48874750f2ba507eda5d704313b0 mse 2021-07-05 12:14:52
New license c9932a52aaa81e6b136510157bfc3ce3e10ab800 mse 2021-07-04 16:01:57
Fix joystick dead zone 303dc3276d27f2a123e5370b31b79cdf87afc879 mse 2021-06-26 07:09:28
Windows-compatible locale 65244a8360ad6a65fea64f43f115f5c93bf966dd mse 2021-06-11 17:13:26
Detect language using std::locale 60f1680d73e559dc85f6b85e9ca69cb9be717ae6 mse 2021-06-09 16:11:30
Rename data -> base and load game as mod ec3b8aa10ee005d89d897b43c68cecd4b9ea8a75 mse 2021-06-07 12:31:53
Replace function with macro cc34567bf5b5503d90ea989004606fcca240d3cd mse 2021-05-30 20:14:02
Bump version to 0.4.4 4b4eb20f18d047f34a94456b441ee55cc4c6248b mse 2021-05-30 03:48:53
Initial modding support with -m parameters 94429b99dd3c85d67d8a9fe8b2faee06c1e9fcde mse 2021-05-29 22:01:40
Moddable dialogue loading via FileOpen 6183fb4b8dde53f07f8e7bf6835a8fe7ca0a8a8c mse 2021-05-29 10:54:24
Commit c6e4142e664648ca8f4aa913b48526093c985987 - Switch inventories and stats to floating-point
Author: mse
Author date (UTC): 2021-08-31 13:35
Committer name: mse
Committer date (UTC): 2021-08-31 13:35
Parent(s): eb067496f4edb4420c05a09dc034ad0a25ad1e56
Signing key:
Tree: 1ca7a1bc4675536135bf91ddd5fdcdfbaebeadbd
File Lines added Lines deleted
confec.cpp 10 10
include/fworld.h 13 13
File confec.cpp changed (mode: 100644) (index e7529a4..7ee339f)
... ... int main( int argc, char* argv[] ){
1155 1155 // The item and the player character exist. // The item and the player character exist.
1156 1156 auto &player = world.entities[world.followEntity]; auto &player = world.entities[world.followEntity];
1157 1157 fworld::Inventory inv; fworld::Inventory inv;
1158 inv.set( item_name, 1 );
1158 inv.set( item_name, 1.0 );
1159 1159 if( world.inventoryCanTakeAll( if( world.inventoryCanTakeAll(
1160 1160 player.inventory, inv, inventory_slots ) ){ player.inventory, inv, inventory_slots ) ){
1161 1161 world.transferInventory( world.transferInventory(
 
... ... bool WorldInteract( int ent_index ){
3452 3452 world.items[player.inventory[i].first]; world.items[player.inventory[i].first];
3453 3453 if( item.flavor > 0 ){ if( item.flavor > 0 ){
3454 3454 // Remove the item from the player's inventory. // Remove the item from the player's inventory.
3455 auto &count = player.inventory[i].second;
3455 double &count = player.inventory[i].second;
3456 3456 count--; count--;
3457 if( count == 0 ){
3457 if( count == 0.0 ){
3458 3458 // Remove the item from the player's inventory. // Remove the item from the player's inventory.
3459 3459 player.inventory.erase( player.inventory.begin() + i ); player.inventory.erase( player.inventory.begin() + i );
3460 3460 deselecting = true; deselecting = true;
 
... ... bool WorldInteract( int ent_index ){
3487 3487 fworld::Inventory selectedItems = {}; fworld::Inventory selectedItems = {};
3488 3488 for( size_t i = 0; i < item_selected.size(); i++ ){ for( size_t i = 0; i < item_selected.size(); i++ ){
3489 3489 if( item_selected[i] ){ if( item_selected[i] ){
3490 selectedItems.push_back( { player.inventory[i].first, -1 } );
3490 selectedItems.push_back( { player.inventory[i].first, -1.0 } );
3491 3491 } }
3492 3492 } }
3493 3493 // Check if the player is using the required items. // Check if the player is using the required items.
 
... ... void DrawInventory(
5247 5247 for( auto &item : inventory ){ for( auto &item : inventory ){
5248 5248 item_x += world.items[item.first].icon.width * scale; item_x += world.items[item.first].icon.width * scale;
5249 5249 // Only show a number for stacks of multiple, zero, or negative items. // Only show a number for stacks of multiple, zero, or negative items.
5250 if( item.second != 1 ){
5250 if( item.second != 1.0 ){
5251 5251 fgl::drawText( fgl::drawText(
5252 std::to_string( item.second ),
5252 convo.stringifyNumber( item.second ),
5253 5253 font_inventory, font_inventory,
5254 5254 item_x, item_x,
5255 5255 pos_y, pos_y,
 
... ... void GameLoop( double d ){
5594 5594 auto &item = auto &item =
5595 5595 world.items[player.inventory[i].first]; world.items[player.inventory[i].first];
5596 5596 if( item_selected[i] if( item_selected[i]
5597 && player.inventory[i].second > 0
5597 && player.inventory[i].second > 0.0
5598 5598 && item.entity.sprite.success ){ && item.entity.sprite.success ){
5599 5599 AddEntity( item.entity, place_x, place_y ); AddEntity( item.entity, place_x, place_y );
5600 5600 player.inventory[i].second--; player.inventory[i].second--;
5601 if( player.inventory[i].second == 0 ){
5601 if( player.inventory[i].second == 0.0 ){
5602 5602 // Remove the item from the player's inventory. // Remove the item from the player's inventory.
5603 5603 player.inventory.erase( player.inventory.begin() + i ); player.inventory.erase( player.inventory.begin() + i );
5604 5604 // Deselect all. // Deselect all.
 
... ... void GameLoop( double d ){
6268 6268 for( auto &item : world.entities[world.followEntity].inventory ){ for( auto &item : world.entities[world.followEntity].inventory ){
6269 6269 itemOffX += world.items[item.first].icon.width * round_scale; itemOffX += world.items[item.first].icon.width * round_scale;
6270 6270 // Only show a number for stacks of multiple, zero, or negative items. // Only show a number for stacks of multiple, zero, or negative items.
6271 if( item.second != 1 ){
6271 if( item.second != 1.0 ){
6272 6272 fgl::drawText( fgl::drawText(
6273 std::to_string( item.second ),
6273 convo.stringifyNumber( item.second ),
6274 6274 font_inventory, font_inventory,
6275 6275 itemOffX, itemOffX,
6276 6276 0.0f, 0.0f,
File include/fworld.h changed (mode: 100755) (index ee77745..e6ed3ff)
... ... class mesa : public std::vector<std::pair<K,V>> {
93 93 } }
94 94 }; };
95 95
96 typedef mesa<std::string,int> Inventory;
96 typedef mesa<std::string,double> Inventory;
97 97
98 98 typedef std::vector<std::vector<int>> MapLayer; typedef std::vector<std::vector<int>> MapLayer;
99 99
 
... ... void World::loadItems( std::string filePath ){
929 929 entity.width = entity.sprite.width; entity.width = entity.sprite.width;
930 930 entity.height = entity.sprite.height; entity.height = entity.sprite.height;
931 931 entity.type = "pickup"; entity.type = "pickup";
932 entity.inventory.set( itemName, 1 );
932 entity.inventory.set( itemName, 1.0 );
933 933 entity.name = itemName; entity.name = itemName;
934 934 } }
935 935 // Add the item. // Add the item.
 
... ... void World::loadItems( std::string filePath ){
955 955 void World::deleteInventoryZeroes( Inventory &inv ){ void World::deleteInventoryZeroes( Inventory &inv ){
956 956 // Delete zero-quantity items from the inventory. // Delete zero-quantity items from the inventory.
957 957 for( auto it = inv.begin(); it != inv.end(); ){ for( auto it = inv.begin(); it != inv.end(); ){
958 if( it->second == 0 ){
958 if( it->second == 0.0 ){
959 959 it = inv.erase( it ); it = inv.erase( it );
960 960 }else{ }else{
961 961 it++; it++;
 
... ... char World::craft(
993 993 // Remove non-consumable items from the list. // Remove non-consumable items from the list.
994 994 for( size_t i = 0; i < itemNames.size(); i++ ){ for( size_t i = 0; i < itemNames.size(); i++ ){
995 995 auto &name = itemNames[i]; auto &name = itemNames[i];
996 if( recipe[name] < 1 ){
996 if( recipe[name] < 1.0 ){
997 997 // The recipe does not require a quantity of the item. // The recipe does not require a quantity of the item.
998 998 itemNames.erase( itemNames.begin() + i ); itemNames.erase( itemNames.begin() + i );
999 999 }else if( !ent.inventory.contains( name ) }else if( !ent.inventory.contains( name )
 
... ... Inventory World::decodeInventory( std::string str_inv ){
1062 1062 auto AddItem = [&]( std::string item ){ auto AddItem = [&]( std::string item ){
1063 1063 // Split an item declaration between name and count. // Split an item declaration between name and count.
1064 1064 size_t semi_at = item.find( ';' ); size_t semi_at = item.find( ';' );
1065 std::pair<std::string,int> inv_item;
1065 std::pair<std::string,double> inv_item;
1066 1066 if( semi_at > 0 && semi_at < item.size() - 1 ){ if( semi_at > 0 && semi_at < item.size() - 1 ){
1067 1067 inv_item = std::make_pair( inv_item = std::make_pair(
1068 1068 item.substr( 0, semi_at ), item.substr( 0, semi_at ),
1069 (int)safeStold( item.substr( semi_at + 1 ) )
1069 (double)safeStold( item.substr( semi_at + 1 ) )
1070 1070 ); );
1071 1071 // Only add the item if the count is positive or negative. // Only add the item if the count is positive or negative.
1072 if( inv_item.second != 0 ){
1072 if( inv_item.second != 0.0 ){
1073 1073 inv.push_back( inv_item ); inv.push_back( inv_item );
1074 1074 } }
1075 1075 } }
 
... ... Inventory World::decodeInventory( std::string str_inv ){
1086 1086 // inv_a can fit any one of the items from inv_b. // inv_a can fit any one of the items from inv_b.
1087 1087 bool World::inventoryCanTakeAny( Inventory &inv_a, Inventory &inv_b, int max_slots ){ bool World::inventoryCanTakeAny( Inventory &inv_a, Inventory &inv_b, int max_slots ){
1088 1088 for( auto &item : inv_b ){ for( auto &item : inv_b ){
1089 if( item.second > 0 ){
1089 if( item.second > 0.0 ){
1090 1090 // The item has a positive quantity. // The item has a positive quantity.
1091 1091 if( inv_a.contains( item.first ) ){ if( inv_a.contains( item.first ) ){
1092 1092 // The item already exists in inventory A. // The item already exists in inventory A.
 
... ... bool World::inventoryCanTakeAny( Inventory &inv_a, Inventory &inv_b, int max_slo
1106 1106 // inv_a can fit all of the items from inv_b. // inv_a can fit all of the items from inv_b.
1107 1107 bool World::inventoryCanTakeAll( Inventory &inv_a, Inventory &inv_b, int max_slots ){ bool World::inventoryCanTakeAll( Inventory &inv_a, Inventory &inv_b, int max_slots ){
1108 1108 for( auto &item : inv_b ){ for( auto &item : inv_b ){
1109 if( item.second > 0 ){
1109 if( item.second > 0.0 ){
1110 1110 // The item has a positive quantity. // The item has a positive quantity.
1111 1111 if( inv_a.contains( item.first ) ){ if( inv_a.contains( item.first ) ){
1112 1112 // The item already exists in inventory A. // The item already exists in inventory A.
 
... ... bool World::inventoryCanTakeAll( Inventory &inv_a, Inventory &inv_b, int max_slo
1126 1126 void World::transferInventory( Inventory &inv_a, Inventory &inv_b, int max_slots ){ void World::transferInventory( Inventory &inv_a, Inventory &inv_b, int max_slots ){
1127 1127 // Move all items possible from inv_a to inv_b. // Move all items possible from inv_a to inv_b.
1128 1128 for( auto &item_a : inv_a ){ for( auto &item_a : inv_a ){
1129 if( item_a.second > 0 ){
1129 if( item_a.second > 0.0 ){
1130 1130 // item_a has a positive quantity. // item_a has a positive quantity.
1131 1131 if( inv_b.contains( item_a.first ) ){ if( inv_b.contains( item_a.first ) ){
1132 1132 // item_a already exists in inventory B. // item_a already exists in inventory B.
 
... ... void World::transferInventory( Inventory &inv_a, Inventory &inv_b, int max_slots
1134 1134 if( item_a.first == item_b.first // Same item. if( item_a.first == item_b.first // Same item.
1135 1135 && item_b.second < items[item_b.first].stack ){ && item_b.second < items[item_b.first].stack ){
1136 1136 // There is room on the stack for more. // There is room on the stack for more.
1137 int transfer_count = std::min( item_a.second,
1137 double transfer_count = std::min( item_a.second,
1138 1138 items[item_b.first].stack - item_b.second ); items[item_b.first].stack - item_b.second );
1139 1139 // Put the items into inventory B. // Put the items into inventory B.
1140 1140 item_b.second += transfer_count; item_b.second += transfer_count;
 
... ... void World::transferInventory( Inventory &inv_a, Inventory &inv_b, int max_slots
1146 1146 // Item does not yet exist in inventory B. // Item does not yet exist in inventory B.
1147 1147 if( (int)inv_b.size() < max_slots ){ if( (int)inv_b.size() < max_slots ){
1148 1148 // Inventory B has a free slot. // Inventory B has a free slot.
1149 int transfer_count =
1150 std::min( item_a.second, items[item_a.first].stack );
1149 double transfer_count =
1150 std::min( item_a.second, (double)items[item_a.first].stack );
1151 1151 // Put the items into inv_b. // Put the items into inv_b.
1152 1152 inv_b.push_back( { item_a.first, transfer_count } ); inv_b.push_back( { item_a.first, transfer_count } );
1153 1153 // Remove the items from inv_a. // Remove the items from inv_a.
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using git:
git clone git://git.rocketgit.com/user/mse/ConfectionerEngine

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main