fixed some bugs in new 'g'o system
[k8-i-v-a-n.git] / src / game / commands / PickUp.cpp
blob8a1c30483e44c431d887a485fb47e5a10f0e1436
1 COMMAND(PickUp) {
2 if (!Char->GetStackUnder()->GetVisibleItems(Char)) {
3 ADD_MESSAGE("There is nothing here to pick up!");
4 return false;
6 itemvectorvector PileVector;
7 Char->GetStackUnder()->Pile(PileVector, Char, CENTER);
8 for (int c = 0; c < 4; ++c) {
9 stack *Stack = Char->GetLSquareUnder()->GetStackOfAdjacentSquare(c);
10 if (Stack) Stack->Pile(PileVector, Char, 3-c);
12 if (PileVector.size() == 1) {
13 if (PileVector[0][0]->CanBePickedUp()) {
14 int Amount = PileVector[0].size();
15 if (Amount > 1) Amount = game::ScrollBarQuestion(CONST_S("How many ")+PileVector[0][0]->GetName(PLURAL)+'?', Amount, 1, 0, Amount, 0, WHITE, LIGHT_GRAY, DARK_GRAY);
16 if (!Amount) return false;
17 if ((!PileVector[0][0]->GetRoom() || PileVector[0][0]->GetRoom()->PickupItem(Char, PileVector[0][0], Amount)) &&
18 PileVector[0][0]->CheckPickUpEffect(Char)) {
19 if (PileVector[0][0]->IsCorpse() && ivanconfig::GetConfirmCorpses()) {
20 //if (!game::TruthQuestion(CONST_S("Do you really want to pick up the corpse? [y/N]"))) return false;
21 itemvector ToPickup;
22 game::DrawEverythingNoBlit();
23 Char->GetStackUnder()->DrawContents(ToPickup, Char, CONST_S("Do you really want to pick up the corpse?"), REMEMBER_SELECTED);
24 if (ToPickup.empty()) return false;
26 for (int c = 0; c < Amount; ++c) PileVector[0][c]->MoveTo(Char->GetStack());
27 ADD_MESSAGE("%s picked up.", PileVector[0][0]->GetName(INDEFINITE, Amount).CStr());
28 Char->DexterityAction(2);
29 return true;
31 return false;
32 } else {
33 ADD_MESSAGE("%s too large to pick up!", PileVector[0].size() == 1 ? "It is" : "They are");
34 return false;
37 truth Success = false;
38 stack::SetSelected(0);
39 for (;;) {
40 itemvector ToPickup;
41 game::DrawEverythingNoBlit();
42 Char->GetStackUnder()->DrawContents(ToPickup, Char, CONST_S("What do you want to pick up?"), REMEMBER_SELECTED);
43 if (ToPickup.empty()) break;
44 if (ToPickup[0]->CanBePickedUp()) {
45 if ((!ToPickup[0]->GetRoom() || ToPickup[0]->GetRoom()->PickupItem(Char, ToPickup[0], ToPickup.size())) &&
46 ToPickup[0]->CheckPickUpEffect(Char)) {
47 for (uInt c = 0; c < ToPickup.size(); ++c) ToPickup[c]->MoveTo(Char->GetStack());
48 ADD_MESSAGE("%s picked up.", ToPickup[0]->GetName(INDEFINITE, ToPickup.size()).CStr());
49 Success = true;
51 } else ADD_MESSAGE("%s too large to pick up!", ToPickup.size() == 1 ? "It is" : "They are");
53 if (Success) {
54 Char->DexterityAction(2);
55 return true;
57 return false;