Skip to content

Commit

Permalink
Merge pull request #226 from Defalt36/eat-everything
Browse files Browse the repository at this point in the history
Add server setting that when turned on allow players to eat all holdable objects
  • Loading branch information
risvh authored Feb 2, 2024
2 parents 2007d13 + c9f374e commit 779a292
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 6 deletions.
4 changes: 3 additions & 1 deletion gameSource/LivingLifePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2631,7 +2631,9 @@ void LivingLifePage::useOnSelf() {
sprintf( msg, "SELF %d %d %d#", x, y, -1 );
setNextActionMessage( msg, x, y );

if( getObject( ourLiveObject->holdingID )->foodValue > 0)
// this is for eatEverything mode
// not sure if these two condition are redundant
if( getObject( ourLiveObject->holdingID )->foodValue > 0 || holdingYumOrMeh )
nextActionEating = true;
}

Expand Down
15 changes: 15 additions & 0 deletions gameSource/objectBank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ static SimpleVector<int> allPossibleDeathMarkerIDs;

static SimpleVector<int> allPossibleFoodIDs;

static SimpleVector<int> allPossibleNonPermanentIDs;


static SimpleVector<TapoutRecord> tapoutRecords;

Expand Down Expand Up @@ -1124,6 +1126,10 @@ float initObjectBankStep() {
allPossibleFoodIDs.push_back( r->id );
}

if( ! r->permanent ) {
allPossibleNonPermanentIDs.push_back( r->id );
}

next++;


Expand Down Expand Up @@ -2445,6 +2451,7 @@ static void freeObjectRecord( int inID ) {
deathMarkerObjectIDs.deleteElementEqualTo( inID );
allPossibleDeathMarkerIDs.deleteElementEqualTo( inID );
allPossibleFoodIDs.deleteElementEqualTo( inID );
allPossibleNonPermanentIDs.deleteElementEqualTo( inID );

if( race <= MAX_RACE ) {
racePersonObjectIDs[ race ].deleteElementEqualTo( inID );
Expand Down Expand Up @@ -2534,6 +2541,7 @@ void freeObjectBank() {
deathMarkerObjectIDs.deleteAll();
allPossibleDeathMarkerIDs.deleteAll();
allPossibleFoodIDs.deleteAll();
allPossibleNonPermanentIDs.deleteAll();

for( int i=0; i<= MAX_RACE; i++ ) {
racePersonObjectIDs[i].deleteAll();
Expand Down Expand Up @@ -3435,6 +3443,7 @@ int addObject( const char *inDescription,
deathMarkerObjectIDs.deleteElementEqualTo( newID );
allPossibleDeathMarkerIDs.deleteElementEqualTo( newID );
allPossibleFoodIDs.deleteElementEqualTo( newID );
allPossibleNonPermanentIDs.deleteElementEqualTo( newID );

if( r->deathMarker ) {
deathMarkerObjectIDs.push_back( newID );
Expand Down Expand Up @@ -4659,6 +4668,12 @@ SimpleVector<int> *getAllPossibleFoodIDs() {



SimpleVector<int> *getAllPossibleNonPermanentIDs() {
return &allPossibleNonPermanentIDs;
}




ObjectRecord **getAllObjects( int *outNumResults ) {
SimpleVector<ObjectRecord *> records;
Expand Down
2 changes: 2 additions & 0 deletions gameSource/objectBank.h
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,8 @@ SimpleVector<int> *getAllPossibleDeathIDs();
// does NOT included use dummies
SimpleVector<int> *getAllPossibleFoodIDs();

// NOT destroyed or modified by caller
SimpleVector<int> *getAllPossibleNonPermanentIDs();



Expand Down
7 changes: 7 additions & 0 deletions server/cravings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

Craving noCraving = { -1, -1, 0 };

int eatEverythingModeEnabled = 0;




Expand Down Expand Up @@ -48,6 +50,11 @@ static Craving getRandomFood( int inLineageMaxFoodDepth,

SimpleVector<int> *allFoods = getAllPossibleFoodIDs();

if( eatEverythingModeEnabled ) {
// everything can be eaten
allFoods = getAllPossibleNonPermanentIDs();
}

SimpleVector<int> possibleFoods;

if( inLineageMaxFoodDepth > 0 ) {
Expand Down
2 changes: 2 additions & 0 deletions server/cravings.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ typedef struct Craving {

extern Craving noCraving;

extern int eatEverythingModeEnabled;



Craving getCravedFood( int inLineageEveID, int inPlayerGenerationNumber,
Expand Down
23 changes: 18 additions & 5 deletions server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ static int canYumChainBreak = 0;

static double minAgeForCravings = 10;

static int eatEverythingMode = 0;


// static double posseSizeSpeedMultipliers[4] = { 0.75, 1.25, 1.5, 2.0 };

Expand Down Expand Up @@ -6081,7 +6083,7 @@ static char isYummy( LiveObject *inPlayer, int inObjectID ) {
o = getObject( inObjectID );
}

if( o->foodValue == 0 ) {
if( o->foodValue == 0 && ! eatEverythingMode ) {
return false;
}

Expand Down Expand Up @@ -6111,7 +6113,7 @@ static char isReallyYummy( LiveObject *inPlayer, int inObjectID ) {
o = getObject( inObjectID );
}

if( o->foodValue == 0 ) {
if( o->foodValue == 0 && ! eatEverythingMode ) {
return false;
}

Expand Down Expand Up @@ -7085,6 +7087,11 @@ int processLoggedInPlayer( char inAllowReconnect,
minAgeForCravings = SettingsManager::getDoubleSetting( "minAgeForCravings",
10 );

eatEverythingMode = SettingsManager::getIntSetting( "eatEverythingMode", 0 );

// change the setting from cravings
eatEverythingModeEnabled = eatEverythingMode;


numConnections ++;

Expand Down Expand Up @@ -18483,7 +18490,7 @@ int main() {
ObjectRecord *obj =
getObject( nextPlayer->holdingID );

if( obj->foodValue > 0 ) {
if( obj->foodValue > 0 || eatEverythingMode ) {
holdingFood = true;

if( strstr( obj->description, "noFeeding" )
Expand Down Expand Up @@ -18960,7 +18967,7 @@ int main() {
}
// next case, holding food
// that couldn't be put into clicked clothing
else if( (obj->foodValue > 0 || obj->bonusValue > 0) &&
else if( (obj->foodValue > 0 || obj->bonusValue > 0 || eatEverythingMode) &&
(targetPlayer->foodStore < cap || strstr( obj->description, "modTool")) &&
! couldHaveGoneIn ) {

Expand All @@ -18973,7 +18980,13 @@ int main() {
targetPlayer->lastAteFillMax =
targetPlayer->foodStore;

targetPlayer->foodStore += obj->foodValue;
if ( eatEverythingMode ) {
// set the sustenance of everything to 1
targetPlayer->foodStore += 1;
}
else {
targetPlayer->foodStore += obj->foodValue;
}

updateYum( targetPlayer, obj->id,
targetPlayer == nextPlayer );
Expand Down
1 change: 1 addition & 0 deletions server/settings/eatEverythingMode.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0

0 comments on commit 779a292

Please sign in to comment.