Skip to content

Commit

Permalink
feat: Allow opening chests in wilderness
Browse files Browse the repository at this point in the history
  • Loading branch information
finduraf authored and finduraf committed Feb 13, 2025
1 parent e3f677a commit a6eb41d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions Main/Source/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ command* commandsystem::Command[] =
new command(&Drink, "drink liquid", 'D', 'D', 'D', true),
new command(&Taste, "taste a bit of liquid", 'T', 'T', 'T', true),
new command(&Dip, "dip into liquid", '!', '!', '!', false),
new command(&Open, "open", 'o', 'O', 'o', false),
new command(&Open, "open", 'o', 'O', 'o', true),
new command(&Close, "close", 'c', 'c', 'c', false),
new command(&Search, "search", 's', 's', 's', false),
new command(&Look, "look around", 'l', 'L', 'L', true),
Expand Down Expand Up @@ -330,6 +330,12 @@ truth commandsystem::Open(character* Char)
{
if(Char->CanOpen())
{
if(game::IsInWilderness())
{
item* Item = Char->GetStack()->DrawContents(Char, CONST_S("What do you want to open?"), 0, &item::IsOpenable);
return Item && Item->Open(Char);
}

int Key;

if(ivanconfig::GetSmartOpenCloseApply())
Expand Down Expand Up @@ -367,9 +373,7 @@ truth commandsystem::Open(character* Char)

if(Key == 'i')
{
item* Item = Char->GetStack()->DrawContents(Char,
CONST_S("What do you want to open?"),
0, &item::IsOpenable);
item* Item = Char->GetStack()->DrawContents(Char, CONST_S("What do you want to open?"), 0, &item::IsOpenable);
return Item && Item->Open(Char);
}
}
Expand All @@ -391,7 +395,7 @@ truth commandsystem::Open(character* Char)
Key = game::AskForKeyPress(CONST_S("What do you wish to open? "
"[press a direction key or space]"));
}
else
else // Old "stupid" open
{
truth OpenableItems = Char->GetStack()->SortedItems(Char, &item::IsOpenable);

Expand All @@ -404,16 +408,14 @@ truth commandsystem::Open(character* Char)

if(Key == 'i' && OpenableItems)
{
item* Item = Char->GetStack()->DrawContents(Char,
CONST_S("What do you want to open?"),
0, &item::IsOpenable);
item* Item = Char->GetStack()->DrawContents(Char, CONST_S("What do you want to open?"), 0, &item::IsOpenable);
return Item && Item->Open(Char);
}
}

v2 DirVect = game::GetDirectionVectorForKey(Key);

if(DirVect != ERROR_V2 && Char->GetArea()->IsValidPos(Char->GetPos() + DirVect)){
if(DirVect != ERROR_V2 && Char->GetArea()->IsValidPos(Char->GetPos() + DirVect)) {
return Char->GetNearLSquare(Char->GetPos() + DirVect)->Open(Char);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Main/Source/human.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7288,8 +7288,8 @@ void aslonawizard::GetAICommand()

EditAP(-GetSpellAPCost());

int GasMaterial[] = { MUSTARD_GAS, MAGIC_VAPOUR, SLEEPING_GAS, TELEPORT_GAS,
EVIL_WONDER_STAFF_VAPOUR, EVIL_WONDER_STAFF_VAPOUR };
const int GasMaterial[] = { MUSTARD_GAS, MAGIC_VAPOUR, SLEEPING_GAS, TELEPORT_GAS,
EVIL_WONDER_STAFF_VAPOUR, EVIL_WONDER_STAFF_VAPOUR };
ToBeCalled = golem::Spawn(GasMaterial[RAND() % 6]);
v2 Where = GetLevel()->GetNearestFreeSquare(ToBeCalled, Square->GetPos());

Expand Down

0 comments on commit a6eb41d

Please sign in to comment.