truth commandsystem::Throw(character* Char) { if(!Char->CheckThrow()) return false; if(!Char->GetStack()->GetItems()) { ADD_MESSAGE("You have nothing to throw!"); return false; } item* Item = Char->GetStack()->DrawContents(Char, CONST_S("What do you want to throw?")); if(Item) { int Answer = game::DirectionQuestion(CONST_S("In what direction do you wish to throw? " "[press a direction key]"), false); if(Answer == DIR_ERROR) return false; Char->ThrowItem(Answer, Item); Char->EditExperience(ARM_STRENGTH, 75, 1 << 8); Char->EditExperience(DEXTERITY, 75, 1 << 8); Char->EditExperience(PERCEPTION, 75, 1 << 8); Char->EditNP(-50); Char->DexterityAction(5); return true; } else return false; }
truth commandsystem::Zap(character* Char) { if(!Char->CheckZap()) return false; if(!Char->PossessesItem(&item::IsZappable)) { ADD_MESSAGE("You have nothing to zap with, %s.", game::Insult()); return false; } item* Item = Char->SelectFromPossessions(CONST_S("What do you want to zap with?"), &item::IsZappable); if(Item) { int Answer = game::DirectionQuestion(CONST_S("In what direction do you wish to zap? " "[press a direction key or '.']"), false, true); if(Answer == DIR_ERROR) return false; if(Item->Zap(Char, Char->GetPos(), Answer)) { Char->EditAP(-100000 / APBonus(Char->GetAttribute(PERCEPTION))); return true; } else return false; } else return false; }
void highscore::Draw() const { if(Score.empty()) { iosystem::TextScreen(CONST_S("There are no entries yet. " "Play a game to correct this.")); return; } if(GetVersion() != HIGH_SCORE_VERSION) { iosystem::TextScreen(CONST_S("The highscore file is for an other version of IVAN.")); return; } felist List(CONST_S("Adventurers' Hall of Fame")); festring Desc; for(uint c = 0; c < Score.size(); ++c) { Desc.Empty(); Desc << c + 1; Desc.Resize(5, ' '); Desc << Score[c]; Desc.Resize(13, ' '); Desc << Entry[c]; List.AddEntry(Desc, c == uint(LastAdd) ? WHITE : LIGHT_GRAY, 13); } List.SetFlags(FADE); List.SetPageLength(40); List.Draw(); }
truth commandsystem::ShowWeaponSkills(character* Char) { felist List(CONST_S("Your experience in weapon categories")); List.AddDescription(CONST_S("")); List.AddDescription(CONST_S("Category name Level Points Needed Battle bonus")); truth Something = false; festring Buffer; for(int c = 0; c < Char->GetAllowedWeaponSkillCategories(); ++c) { cweaponskill* Skill = Char->GetCWeaponSkill(c); if(Skill->GetHits() / 100 || (Char->IsUsingWeaponOfCategory(c))) { Buffer = Skill->GetName(c); Buffer.Resize(30); Buffer << Skill->GetLevel(); Buffer.Resize(40); Buffer << Skill->GetHits() / 100; Buffer.Resize(50); if(Skill->GetLevel() != 20) Buffer << (Skill->GetLevelMap(Skill->GetLevel() + 1) - Skill->GetHits()) / 100; else Buffer << '-'; Buffer.Resize(60); Buffer << '+' << (Skill->GetBonus() - 1000) / 10; if(Skill->GetBonus() % 10) Buffer << '.' << Skill->GetBonus() % 10; Buffer << '%'; if(Char->IsUsingWeaponOfCategory(c)) List.AddEntry(Buffer, WHITE); else List.AddEntry(Buffer, LIGHT_GRAY); Something = true; } } if(Char->AddSpecialSkillInfo(List)) Something = true; if(Something) { game::SetStandardListAttributes(List); List.Draw(); } else ADD_MESSAGE("You are not experienced in any weapon skill yet!"); return false; }
truth commandsystem::Drop(character* Char) { if(!Char->GetStack()->GetItems()) { ADD_MESSAGE("You have nothing to drop!"); return false; } truth Success = false; stack::SetSelected(0); for(;;) { itemvector ToDrop; game::DrawEverythingNoBlit(); Char->GetStack()->DrawContents(ToDrop, Char, CONST_S("What do you want to drop?"), REMEMBER_SELECTED); if(ToDrop.empty()) break; if(game::IsInWilderness()) { for(uint c = 0; c < ToDrop.size(); ++c) { if(game::TruthQuestion(CONST_S("Are you sure? You will never see ") + ToDrop[c]->CHAR_NAME(DEFINITE) + " again! [y/N]")) { ADD_MESSAGE("You drop %s.", ToDrop[c]->CHAR_NAME(DEFINITE)); ToDrop[c]->RemoveFromSlot(); ToDrop[c]->SendToHell(); } } } else if(!Char->GetRoom() || Char->GetRoom()->DropItem(Char, ToDrop[0], ToDrop.size())) { ADD_MESSAGE("%s dropped.", ToDrop[0]->GetName(INDEFINITE, ToDrop.size()).CStr()); for(uint c = 0; c < ToDrop.size(); ++c) { ToDrop[c]->MoveTo(Char->GetStackUnder()); } Success = true; } } if(Success) { Char->DexterityAction(2); return true; } return false; }
truth commandsystem::Quit(character* Char) { if(game::TruthQuestion(CONST_S("Your quest is not yet completed! Really quit? [y/N]"))) { Char->ShowAdventureInfo(); festring Msg = CONST_S("cowardly quit the game"); Char->AddScoreEntry(Msg, 0.75); game::End(Msg, !game::WizardModeIsActive() || game::TruthQuestion(CONST_S("Remove saves? [y/N]"))); return true; } else return false; }
truth commandsystem::Look(character* Char) { festring Msg; if(!game::IsInWilderness()) Char->GetLevel()->AddSpecialCursors(); if(!game::IsInWilderness()) Msg = CONST_S("Direction keys move cursor, ESC exits, 'i' examines items, 'c' examines a character."); else Msg = CONST_S("Direction keys move cursor, ESC exits, 'c' examines a character."); game::PositionQuestion(Msg, Char->GetPos(), &game::LookHandler, &game::LookKeyHandler, ivanconfig::GetLookZoom()); game::RemoveSpecialCursors(); return false; }
void ivanconfig::DirectionKeyMapDisplayer(const cycleoption* O, festring& Entry) { switch(O->Value) { case DIR_NORM: Entry << CONST_S("Normal"); break; case DIR_ALT: Entry << CONST_S("Alternative"); break; case DIR_HACK: Entry << CONST_S("NetHack"); break; } }
void consume::Handle() { item* Consuming = game::SearchItem(ConsumingID); if(!Consuming || !Consuming->Exists() || !Actor->IsOver(Consuming)) { Terminate(false); return; } character* Actor = GetActor(); if(!InDNDMode() && Actor->GetHungerState() >= BLOATED) if(Actor->IsPlayer()) { ADD_MESSAGE("You have a really hard time getting all this down your throat."); if(game::TruthQuestion(CONST_S("Continue ") + GetDescription() + "? [y/N]")) ActivateInDNDMode(); else { Terminate(false); return; } } else { Terminate(false); return; } if(!Actor->IsPlayer() && !Consuming->CanBeEatenByAI(Actor)) // item may be spoiled after action was started { Terminate(false); return; } /* Note: if backupped Actor has died of food effect, Action is deleted automatically, so we mustn't Terminate it */ if(Consuming->Consume(Actor, 500) && Actor->GetAction() == this && Actor->IsEnabled()) Terminate(true); else if(Actor->GetHungerState() == OVER_FED) { Actor->DeActivateVoluntaryAction(CONST_S("You are about to choke on this stuff.")); Actor->Vomit(Actor->GetPos(), 500 + RAND() % 500); } }
truth commandsystem::Go(character* Char) { int Dir = game::DirectionQuestion(CONST_S("In what direction do you want to go? [press a direction key]"), false); if(Dir == DIR_ERROR) return false; go* Go = go::Spawn(Char); Go->SetDirection(Dir); int OKDirectionsCounter = 0; for(int d = 0; d < Char->GetNeighbourSquares(); ++d) { lsquare* Square = Char->GetNeighbourLSquare(d); if(Square && Char->CanMoveOn(Square)) ++OKDirectionsCounter; } Go->SetIsWalkingInOpen(OKDirectionsCounter > 2); Char->SetAction(Go); Char->EditAP(Char->GetStateAPGain(100)); // gum solution Char->GoOn(Go, true); return truth(Char->GetAction()); }
truth ivanconfig::FrameSkipChangeInterface(numberoption* O) { O->ChangeValue(iosystem::NumberQuestion(CONST_S("Set frame skip (-2 = wait, -1 = auto, or 0 to 100):"), GetQuestionPos(), WHITE, !game::IsRunning())); clearToBackgroundAfterChangeInterface(); return false; }
void nefas::PrayBadEffect() { ADD_MESSAGE("A potion drops on your head and shatters into small bits."); PLAYER->ReceiveDamage(0, 2 + RAND() % 7, PHYSICAL_DAMAGE, HEAD); PLAYER->GetStackUnder()->AddItem(brokenbottle::Spawn()); PLAYER->CheckDeath(CONST_S("killed while enjoying the company of ") + GetName(), 0); }
truth ivanconfig::XBRZSquaresAroundPlayerChangeInterface(numberoption* O) { O->ChangeValue(iosystem::NumberQuestion(CONST_S("Set how many squares around player to use xBRZ at (0 for whole dungeon):"), GetQuestionPos(), WHITE, !game::IsRunning())); clearToBackgroundAfterChangeInterface(); return false; }
void cruentus::PrayBadEffect() { item* ToBe = PLAYER->GetMainWielded(); if(ToBe) { if(!ToBe->IsDestroyable(0)) { ToBe = PLAYER->GetSecondaryWielded(); if(!ToBe || !ToBe->IsDestroyable(0)) ADD_MESSAGE("%s tries to destroy your %s, but fails.", GetName(), PLAYER->GetMainWielded()->CHAR_NAME(UNARTICLED)); } } else { ToBe = PLAYER->GetSecondaryWielded(); if(ToBe && !ToBe->IsDestroyable(0)) ADD_MESSAGE("%s tries to destroy your %s, but fails.", GetName(), ToBe->CHAR_NAME(UNARTICLED)); } if(ToBe && ToBe->IsDestroyable(0)) { ADD_MESSAGE("%s destroys your weapon.", GetName()); ToBe->RemoveFromSlot(); ToBe->SendToHell(); } else { ADD_MESSAGE("%s gets mad and hits you!", GetName()); PLAYER->ReceiveDamage(0, 1 + RAND() % 30, PHYSICAL_DAMAGE, ALL, RAND() & 7); PLAYER->CheckDeath(CONST_S("destroyed by ") + GetName(), 0); } }
truth ivanconfig::WindowWidthChangeInterface(numberoption* O) { O->ChangeValue(iosystem::NumberQuestion(CONST_S("Set new window width (from 640 to your monitor screen max width):"), GetQuestionPos(), WHITE, !game::IsRunning())); clearToBackgroundAfterChangeInterface(); return false; }
void atavus::PrayBadEffect() { ADD_MESSAGE("You have not been good the whole year."); if(PLAYER->GetStack()->GetItems()) { int ToBeDeleted = RAND() % PLAYER->GetStack()->GetItems(); item* Disappearing = PLAYER->GetStack()->GetItem(ToBeDeleted); if(Disappearing->IsDestroyable(0)) { ADD_MESSAGE("Your %s disappears.", Disappearing->CHAR_NAME(UNARTICLED)); Disappearing->RemoveFromSlot(); Disappearing->SendToHell(); } else { ADD_MESSAGE("%s tries to remove your %s, but fails. You feel you are not so gifted anymore.", GetName(), Disappearing->CHAR_NAME(UNARTICLED)); PLAYER->EditAttribute(AGILITY, -1); PLAYER->EditAttribute(ARM_STRENGTH, -1); PLAYER->EditAttribute(ENDURANCE, -1); } } else { ADD_MESSAGE("You feel you are not so gifted anymore."); PLAYER->EditAttribute(AGILITY, -1); PLAYER->EditAttribute(ARM_STRENGTH, -1); PLAYER->EditAttribute(ENDURANCE, -1); } PLAYER->CheckDeath(CONST_S("killed by Atavus's humour")); }
truth ivanconfig::StackListPageLengthChangeInterface(numberoption* O) { O->ChangeValue(iosystem::NumberQuestion(CONST_S("Set new length of list pages (in entries):"), GetQuestionPos(), WHITE, !game::IsRunning())); clearToBackgroundAfterChangeInterface(); return false; }
truth ivanconfig::AltListItemWidthChangeInterface(numberoption* O) { O->ChangeValue(iosystem::NumberQuestion(CONST_S("Set new item list width:"), GetQuestionPos(), WHITE, !game::IsRunning())); clearToBackgroundAfterChangeInterface(); return false; }
truth configsystem::NormalNumberChangeInterface(numberoption* O) { O->ChangeValue(iosystem::NumberQuestion(CONST_S("Set new ") + O->Description + ':', v2(30, 30), WHITE, true)); return false; }
truth commandsystem::ForceVomit(character* Char) { if(Char->CanForceVomit()) { int Dir = game::DirectionQuestion(CONST_S("Where do you wish to vomit? [press a direction key]"), false, true); if(Dir != DIR_ERROR) { v2 VomitPos = Char->GetPos() + game::GetMoveVector(Dir); if(Char->GetArea()->IsValidPos(VomitPos)) { ccharacter* Other = Char->GetArea()->GetSquare(VomitPos)->GetCharacter(); if(Other && Other->GetTeam() != Char->GetTeam() && Other->GetRelation(Char) != HOSTILE && Other->CanBeSeenBy(Char) && !game::TruthQuestion("Do you really want to vomit at " + Other->GetObjectPronoun() + "? [y/N]")) return false; ADD_MESSAGE(Char->GetForceVomitMessage().CStr()); Char->Vomit(Char->GetPos() + game::GetMoveVector(Dir), 500 + RAND() % 500, false); Char->EditAP(-1000); return true; } } } else ADD_MESSAGE("You can't vomit."); return false; }
void legifer::PrayGoodEffect() { // I think this is a remnant of past development that you call upon Inlux rather than Legifer. --red_kangaroo ADD_MESSAGE("A booming voice echoes: \"Inlux! Inlux! Save us!\" A huge firestorm engulfs everything around you."); //ADD_MESSAGE("You are surrounded by the righteous flames of %s.", GetName()); game::GetCurrentLevel()->Explosion(PLAYER, CONST_S("killed by the holy flames of ") + GetName(), PLAYER->GetPos(), (Max(20 * PLAYER->GetAttribute(WISDOM), 1) + Max(GetRelation(), 0)) >> 3, false); }
truth ivanconfig::AutoSaveIntervalChangeInterface(numberoption* O) { O->ChangeValue(iosystem::NumberQuestion(CONST_S("Set new autosave interval (1-50000 turns, 0 for never):"), GetQuestionPos(), WHITE, !game::IsRunning())); clearToBackgroundAfterChangeInterface(); return false; }
truth ivanconfig::AutoSaveIntervalChangeInterface(numberoption* O) { O->ChangeValue(iosystem::NumberQuestion(CONST_S("Set new autosave interval (1-50000 turns, 0 for never):"), GetQuestionPos(), WHITE, !game::IsRunning())); if(game::IsRunning()) igraph::BlitBackGround(v2(16, 6), v2(game::GetScreenXSize() << 4, 23)); return false; }
truth ivanconfig::ContrastChangeInterface(numberoption* O) { iosystem::ScrollBarQuestion(CONST_S("Set new contrast value (0-200, '<' and '>' move the slider):"), GetQuestionPos(), O->Value, 5, 0, 200, O->Value, WHITE, LIGHT_GRAY, DARK_GRAY, game::GetMoveCommandKey(KEY_LEFT_INDEX), game::GetMoveCommandKey(KEY_RIGHT_INDEX), !game::IsRunning(), static_cast<scrollbaroption*>(O)->BarHandler); if(game::IsRunning()) igraph::BlitBackGround(v2(16, 6), v2(game::GetScreenXSize() << 4, 23)); return false; }
void mortifer::PrayBadEffect() { ADD_MESSAGE("A dark, booming voice shakes the area: \"PuNy MoRtAl! ThOu ArT nOt WoRtHy! I sHaLl dEsTrOy ThEe LiKe EvErYoNe ElSe!\" A bolt of black energy hits you."); PLAYER->ReceiveDamage(0, 1 + RAND() % 20, ENERGY, ALL); PLAYER->EditAttribute(AGILITY, -1); PLAYER->EditAttribute(ARM_STRENGTH, -1); PLAYER->EditAttribute(ENDURANCE, -1); PLAYER->CheckDeath(CONST_S("obliterated by the unholy power of ") + GetName(), 0); }
void configsystem::Show(void (*BackGroundDrawer)(), void (*ListAttributeInitializer)(felist&), truth SlaveScreen) { int Chosen; truth TruthChange = false; felist List(CONST_S("Which setting do you wish to configure?")); List.AddDescription(CONST_S("")); List.AddDescription(CONST_S("Setting Value")); for(;;) { if(SlaveScreen) BackGroundDrawer(); List.Empty(); for(int c = 0; c < Options; ++c) { festring Entry = Option[c]->Description; Entry.Capitalize(); Entry.Resize(60); Option[c]->DisplayeValue(Entry); List.AddEntry(Entry, LIGHT_GRAY); } if(SlaveScreen && ListAttributeInitializer) ListAttributeInitializer(List); List.SetFlags(SELECTABLE|(SlaveScreen ? DRAW_BACKGROUND_AFTERWARDS : 0) |(!SlaveScreen && !TruthChange ? FADE : 0)); Chosen = List.Draw(); festring String; if(Chosen < Options) TruthChange = Option[Chosen]->ActivateChangeInterface(); else { Save(); return; } } }
void ivanconfig::Initialize(const festring& UserName) { configsystem::AddOption(&DefaultPetName); configsystem::AddOption(&WarnAboutDanger); configsystem::AddOption(&AutoDropLeftOvers); configsystem::AddOption(&UseAlternativeKeys); configsystem::SetConfigFileName(CONST_S(LOCAL_STATE_DIR "/config/") + UserName + ".ivanrc"); configsystem::Load(); CalculateContrastLuminance(); }
truth commandsystem::Polymorph(character* Char) { character* NewForm; if(!Char->GetNewFormForPolymorphWithControl(NewForm)) return true; Char->Polymorph(NewForm, game::NumberQuestion(CONST_S("For how long?"), WHITE)); return true; }
truth commandsystem::Talk(character* Char) { if(!Char->CheckTalk()) return false; character* ToTalk = 0; int Characters = 0; for(int d = 0; d < 8; ++d) { lsquare* Square = Char->GetNaturalNeighbourLSquare(d); if(Square) { character* Dude = Square->GetCharacter(); if(Dude) { ToTalk = Dude; ++Characters; } } } if(!Characters) { ADD_MESSAGE("Find yourself someone to talk to first!"); return false; } else if(Characters == 1) return ToTalk->ChatMenu(); else { int Dir = game::DirectionQuestion(CONST_S("To whom do you wish to talk to? [press a direction key]"), false, true); if(Dir == DIR_ERROR || !Char->GetArea()->IsValidPos(Char->GetPos() + game::GetMoveVector(Dir))) return false; character* Dude = Char->GetNearSquare(Char->GetPos() + game::GetMoveVector(Dir))->GetCharacter(); if(Dude == Char) { ADD_MESSAGE("You talk to yourself for some time."); Char->EditExperience(WISDOM, -50, 1 << 7); Char->EditAP(-1000); return true; } else if(Dude) return Dude->ChatMenu(); else ADD_MESSAGE("You get no response."); } return false; }
void seges::PrayBadEffect() { if(PLAYER->UsesNutrition()) { ADD_MESSAGE("You feel Seges altering the contents of your stomach in an eerie way."); PLAYER->EditNP(-10000); PLAYER->CheckStarvationDeath(CONST_S("starved by ") + GetName()); } else ADD_MESSAGE("Seges tries to alter the contents of your stomach, but fails."); }