From 56a759d7e391ab66369ce0bbf217b4fb24f58d44 Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Fri, 27 Oct 2017 12:19:52 +0300 Subject: [PATCH] "catch the spider" subquest (comm., by Clawzfire) --- script/chars/tourist.dat | 2 +- src/game/char.h | 1 + src/game/game.cpp | 6 +- src/game/game.h | 3 + src/game/humans/humanoid_tourist.cpp | 160 +++++++++++++++++++--------- src/game/nonhumans/largecreature_lobhse.cpp | 7 +- src/game/nonhumans/nonhumanoid_spider.cpp | 2 + 7 files changed, 124 insertions(+), 57 deletions(-) rewrite src/game/humans/humanoid_tourist.cpp (78%) diff --git a/script/chars/tourist.dat b/script/chars/tourist.dat index b44ef00..5ec3957 100644 --- a/script/chars/tourist.dat +++ b/script/chars/tourist.dat @@ -35,7 +35,7 @@ tourist LegMainColor = rgb16(50, 100, 132); CapColor = rgb16(40, 40, 40); AttackStyle = USE_ARMS|USE_LEGS|USE_HEAD; - HostileReplies == "\"Daddy!!! Hit this man!!! He teases me!!!\""; + //k8: moved to the engine (due to spider subquest) HostileReplies == "\"Daddy!!! Hit this man!!! He teases me!!!\""; FriendlyReplies := { "\"A real native!!! Can I touch him, mommy? Can I? Can I?\"", diff --git a/src/game/char.h b/src/game/char.h index e3d6e34..7f9aad6 100644 --- a/src/game/char.h +++ b/src/game/char.h @@ -997,6 +997,7 @@ public: virtual truth CheckIfSatiated () { return GetNP() > SATIATED_LEVEL; } virtual void SignalNaturalGeneration () {} virtual truth IsBunny () const { return false; } + virtual truth IsSpider () const { return false; } void SetConfig (int, int = 0); bodypartslot *GetBodyPartSlot (int I) { return &BodyPartSlot[I]; } virtual truth CheckConsume (cfestring &) const; diff --git a/src/game/game.cpp b/src/game/game.cpp index 8183193..92f4fa0 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -112,6 +112,7 @@ v2 game::GlobalRainSpeed; sLong game::GlobalRainTimeModifier; truth game::PlayerSumoChampion; truth game::PlayerSolicitusChampion; +truth game::TouristHasSpider; feuLong game::SquarePartEmitationTick = 0; sLong game::Turn; truth game::PlayerRunning; @@ -424,6 +425,7 @@ truth game::Init (cfestring &Name) { GlobalRainTimeModifier = 2048-(RAND()&4095); PlayerSumoChampion = false; PlayerSolicitusChampion = false; + TouristHasSpider = false; protosystem::InitCharacterDataBaseFlags(); memset(EquipmentMemory, 0, sizeof(EquipmentMemory)); PlayerRunning = false; @@ -787,7 +789,7 @@ truth game::Save (cfestring &SaveName) { SaveFile << WizardMode << SeeWholeMapCheatMode << GoThroughWallsCheat; SaveFile << Tick << Turn << InWilderness << NextCharacterID << NextItemID << NextTrapID << NecroCounter; SaveFile << SumoWrestling << PlayerSumoChampion << GlobalRainTimeModifier; - SaveFile << PlayerSolicitusChampion; + SaveFile << PlayerSolicitusChampion << TouristHasSpider; //sLong Seed = RAND(); //femath::SetSeed(Seed); //SaveFile << Seed; @@ -840,7 +842,7 @@ int game::Load (cfestring &SaveName) { SaveFile >> WizardMode >> SeeWholeMapCheatMode >> GoThroughWallsCheat; SaveFile >> Tick >> Turn >> InWilderness >> NextCharacterID >> NextItemID >> NextTrapID >> NecroCounter; SaveFile >> SumoWrestling >> PlayerSumoChampion >> GlobalRainTimeModifier; - SaveFile >> PlayerSolicitusChampion; + SaveFile >> PlayerSolicitusChampion >> TouristHasSpider; //femath::SetSeed(ReadType(sLong, SaveFile)); femath::LoadPRNG(SaveFile); SaveFile >> AveragePlayerArmStrengthExperience; diff --git a/src/game/game.h b/src/game/game.h index 5e4718e..1b3d918 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -438,6 +438,8 @@ public: static truth PlayerIsSumoChampion() { return PlayerSumoChampion; } static truth PlayerIsSolicitusChampion() { return PlayerSolicitusChampion; } static void MakePlayerSolicitusChampion() { PlayerSolicitusChampion = true; } + static truth ChildTouristHasSpider () { return TouristHasSpider; } + static void SetTouristHasSpider () { TouristHasSpider = true; } static v2 GetSunLightDirectionVector(); static int CalculateMinimumEmitationRadius(col24); static feuLong IncreaseSquarePartEmitationTicks(); @@ -604,6 +606,7 @@ private: static sLong GlobalRainTimeModifier; static truth PlayerSumoChampion; static truth PlayerSolicitusChampion; + static truth TouristHasSpider; static feuLong SquarePartEmitationTick; static cint LargeMoveDirection[]; static sLong Turn; diff --git a/src/game/humans/humanoid_tourist.cpp b/src/game/humans/humanoid_tourist.cpp dissimilarity index 78% index 369fb1e..6783ee3 100644 --- a/src/game/humans/humanoid_tourist.cpp +++ b/src/game/humans/humanoid_tourist.cpp @@ -1,52 +1,108 @@ -#ifdef HEADER_PHASE -CHARACTER(tourist, humanoid) -{ - public: - virtual character* GetLeader() const; - protected: - virtual void GetAICommand(); -}; - - -#else - - - -character* tourist::GetLeader() const -{ - character* Guide = game::GetTeam(TOURIST_GUIDE_TEAM)->GetLeader(); - return Guide && Guide->GetRelation(this) != HOSTILE ? Guide : GetTeam()->GetLeader(); -} - - - -void tourist::GetAICommand() -{ - if(game::IsSumoWrestling() && !(RAND() % 10)) - { - if(GetConfig() == HUSBAND) - { - if(RAND() & 1) - ADD_MESSAGE("%s shouts: \"Show that skinny wimp what you've got, Huang!\"", CHAR_DESCRIPTION(DEFINITE)); - else - ADD_MESSAGE("%s screams: \"Go for it, Huang!\"", CHAR_DESCRIPTION(DEFINITE)); - } - else if(GetConfig() == WIFE) - { - if(RAND() & 1) - ADD_MESSAGE("%s encourages you: \"Knock him out, %s!\"", CHAR_DESCRIPTION(DEFINITE), game::GetPlayerName().CStr()); - else - ADD_MESSAGE("%s cheers you: \"A handsome guy like you can't lose to that banana ball!\"", CHAR_DESCRIPTION(DEFINITE)); - } - else if(GetConfig() == CHILD) - { - if(RAND() & 1) - ADD_MESSAGE("%s yells: \"More blood on the ring!!!\"", CHAR_DESCRIPTION(DEFINITE)); - else - ADD_MESSAGE("%s cries: \"Kill him, Pong!!!\"", CHAR_DESCRIPTION(DEFINITE)); - } - } - - humanoid::GetAICommand(); -} -#endif +#ifdef HEADER_PHASE +CHARACTER(tourist, humanoid) +{ + public: + tourist () : Said(0) {} + virtual void BeTalkedTo (); + virtual character* GetLeader() const; + protected: + virtual void GetAICommand(); + private: + sLong Said; +}; + + +#else + + +character *tourist::GetLeader () const { + character *Guide = game::GetTeam(TOURIST_GUIDE_TEAM)->GetLeader(); + return (Guide && Guide->GetRelation(this) != HOSTILE ? Guide : GetTeam()->GetLeader()); +} + + +void tourist::GetAICommand () { + if (game::IsSumoWrestling() && !(RAND()%10)) { + if (GetConfig() == HUSBAND) { + if (RAND()&1) + ADD_MESSAGE("%s shouts: \"Show that skinny wimp what you've got, Huang!\"", CHAR_DESCRIPTION(DEFINITE)); + else + ADD_MESSAGE("%s screams: \"Go for it, Huang!\"", CHAR_DESCRIPTION(DEFINITE)); + } else if (GetConfig() == WIFE) { + if (RAND()&1) + ADD_MESSAGE("%s encourages you: \"Knock him out, %s!\"", CHAR_DESCRIPTION(DEFINITE), game::GetPlayerName().CStr()); + else + ADD_MESSAGE("%s cheers you: \"A handsome guy like you can't lose to that banana ball!\"", CHAR_DESCRIPTION(DEFINITE)); + } else if (GetConfig() == CHILD) { + if (RAND()&1) + ADD_MESSAGE("%s yells: \"More blood on the ring!!!\"", CHAR_DESCRIPTION(DEFINITE)); + else + ADD_MESSAGE("%s cries: \"Kill him, Pong!!!\"", CHAR_DESCRIPTION(DEFINITE)); + } + } + + humanoid::GetAICommand(); +} + + +void tourist::BeTalkedTo () { + if (GetConfig() == CHILD) { + character *Spider = 0; + + // check all enabled members of PLAYER_TEAM + truth isLob = false; + for (auto &tm : game::GetTeam(PLAYER_TEAM)->GetMember()) { + if (tm->IsEnabled() && !tm->IsPlayer() && tm->IsSpider()) { + if (tm->GetNameSingular() == "behemoth spider") { + // lobh-se found + Spider = tm; + isLob = true; + break; + } else if (tm->GetConfig() == LARGE || tm->GetConfig() == GIANT) { + Spider = tm; + } + } + } + + if (GetRelation(PLAYER) == HOSTILE) { ADD_MESSAGE("\"Daddy!!! Hit this man!!! He teases me!!!\""); return; } + + // implement truthquestion + proper dialogue // quest fulfilled + if (Spider && !game::ChildTouristHasSpider()) { + ADD_MESSAGE("\"Wow, what a cool spider!!! Can I have it mister? Can I?\""); + festring GiveSpider = CONST_S("Will you give ")+Spider->CHAR_NAME(DEFINITE)+CONST_S(" to ")+CHAR_NAME(DEFINITE)+CONST_S("?"); + if (game::TruthQuestion(GiveSpider)) { + ADD_MESSAGE("\"Thanks a lot mister!!! Here, you can have this.\""); + item *Reward = 0; // create gift item + // lobh-se? + if (isLob) { + Reward = scrollofwishing::Spawn(); + } else { + // other spider + Reward = stick::Spawn(); + Reward->InitMaterials(MAKE_MATERIAL(BALSA_WOOD)); // balsa stick + } + PLAYER->GetStack()->AddItem(Reward); // add gift to player's inventory + ADD_MESSAGE("%s hands you %s.", CHAR_NAME(DEFINITE), Reward->CHAR_NAME(INDEFINITE)); + team *Team = game::GetTeam(TOURIST_TEAM); + Spider->ChangeTeam(Team); // change spider to tourist team + game::SetTouristHasSpider(); // sets game::TouristHasSpider to true + } else { + ADD_MESSAGE("\"Aw... you're no fun!!!\""); + } + } else if (!Spider && !game::ChildTouristHasSpider()) { + // kid does not have spider; normal chat + ProcessAndAddMessage(GetFriendlyReplies()[RandomizeReply(Said, GetFriendlyReplies().Size)]); + } else if (game::ChildTouristHasSpider() && !(RAND()%4)) { + ADD_MESSAGE("\"My friends back home will be so jealous of my new pet spider!!!\""); + } else { + // kid has spider; normal chat (no spider request) + ProcessAndAddMessage(GetFriendlyReplies()[RandomizeReply(Said, GetFriendlyReplies().Size - 1)]); + } + } else { + // not child tourist; normal chat + character::BeTalkedTo(); + } +} + + +#endif diff --git a/src/game/nonhumans/largecreature_lobhse.cpp b/src/game/nonhumans/largecreature_lobhse.cpp index 588a98c..d08041a 100644 --- a/src/game/nonhumans/largecreature_lobhse.cpp +++ b/src/game/nonhumans/largecreature_lobhse.cpp @@ -1,6 +1,8 @@ #ifdef HEADER_PHASE CHARACTER(lobhse, largecreature) { + public: + virtual truth IsSpider() const { return true; } protected: virtual truth SpecialBiteEffect(character*, v2, int, int, truth, truth Critical, int DoneDamage); virtual void GetAICommand(); @@ -42,10 +44,11 @@ truth lobhse::SpecialBiteEffect(character* Char, v2, int, int, truth BlockedByAr void lobhse::GetAICommand() { - StandIdleAI(); + SeekLeader(GetLeader()); // will follow if tamed + if (FollowLeader(GetLeader())) return; + //StandIdleAI(); //k8:??? removed in comm. fork if (MoveRandomly()) { web *Web = web::Spawn(); - // Web->SetStrength(GetConfig() == LARGE ? 50 : 100); if (GetLSquareUnder()->AddTrap(Web)) { if (CanBeSeenByPlayer()) ADD_MESSAGE("%s spins a web.", CHAR_NAME(DEFINITE)); diff --git a/src/game/nonhumans/nonhumanoid_spider.cpp b/src/game/nonhumans/nonhumanoid_spider.cpp index 84ddbcf..44044ae 100644 --- a/src/game/nonhumans/nonhumanoid_spider.cpp +++ b/src/game/nonhumans/nonhumanoid_spider.cpp @@ -1,6 +1,8 @@ #ifdef HEADER_PHASE CHARACTER(spider, nonhumanoid) { + public: + virtual truth IsSpider() const { return true; } protected: virtual truth SpecialBiteEffect(character*, v2, int, int, truth, truth Critical, int DoneDamage); virtual void GetAICommand(); -- 2.11.4.GIT