//================================================================================================= cstring Quest_Orcs2::FormatString(const string& str) { if(str == "name") return orc->hero->name.c_str(); else if(str == "close") return W.GetLocation(near_loc)->name.c_str(); else if(str == "close_dir") return GetLocationDirName(W.GetLocation(near_loc)->pos, GetTargetLocation().pos); else if(str == "target_loc") return GetTargetLocationName(); else if(str == "target_dir") return GetLocationDirName(W.GetWorldPos(), GetTargetLocation().pos); else { assert(0); return nullptr; } }
void AATPoint::GetTargetRangeRadial(fixed &range, fixed &radial) const { const fixed oldrange = range; const GeoPoint fprev = GetPrevious()->GetLocationRemaining(); const GeoPoint floc = GetLocation(); const Angle radialraw = (floc.Bearing(GetTargetLocation()) - fprev.Bearing(floc)).AsBearing(); const fixed d = floc.Distance(GetTargetLocation()); const fixed radius = floc.Distance(GetLocationMin()); const fixed rangeraw = min(fixed_one, d / radius); radial = radialraw.AsDelta().Degrees(); const fixed rangesign = (fabs(radial) > fixed(90)) ? fixed_minus_one : fixed_one; range = rangeraw * rangesign; if ((oldrange == fixed_zero) && (range == fixed_zero)) radial = fixed_zero; }
RangeAndRadial AATPoint::GetTargetRangeRadial(fixed oldrange) const { const auto fprev = GetPrevious()->GetLocationRemaining(); const auto floc = GetLocation(); const auto radialraw = (floc.Bearing(GetTargetLocation()) - fprev.Bearing(floc)).AsBearing(); auto radial = radialraw.AsDelta(); auto d = floc.Distance(GetTargetLocation()); if (radial < -Angle::QuarterCircle() || radial > Angle::QuarterCircle()) d = -d; const auto radius = negative(d) ? floc.Distance(GetLocationMin()) : floc.Distance(GetLocationMax()); const auto range = Clamp(d / radius, fixed(-1), fixed(1)); if (oldrange == fixed(0) && range == fixed(0)) radial = Angle::Zero(); return RangeAndRadial{ range, radial }; }
void FCommandTalentActive::Resolve() { if (Talent->IsA<UTalentActiveProjectile>()) { UTalentActiveProjectile* tp = Cast<UTalentActiveProjectile>(Talent); const FVector loca = Performer->GetPawn()->GetActorLocation(); FActorSpawnParameters fuckyou; fuckyou.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; AProjectile* projectile = Cast<AProjectile>(Performer->GetWorld()->SpawnActor(tp->Projectile, &loca, NULL, fuckyou)); projectile->SetUser(Performer->GetDehrgadaTWUCharacter()); projectile->SetTalent(Talent); if (Target && Talent->bCanTargetActor) { bool suc; ARollCalculatorCPP::Instance->RangedAttack(Target, Performer->GetDehrgadaTWUCharacter(), tp->Defense, tp->Range, tp->Falloff, suc); projectile->SetTarget(Target, (suc)?1:0); } else { projectile->SetTargetPoint(GetTargetLocation()); } } else { if (Target && Talent->bCanTargetActor) { ATalentManagerCPP::Instance->Use_Target(Talent, Performer->GetDehrgadaTWUCharacter(), Target); //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Target!")); } else { ATalentManagerCPP::Instance->Use_Location(Talent, Performer->GetDehrgadaTWUCharacter(), GetTargetLocation()); //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Location!")); } } Performer->GetDehrgadaTWUCharacter()->Stats->SpendVitals(Talent); }
//================================================================================================= void Quest_Orcs::SetProgress(int prog2) { switch(prog2) { case Progress::TalkedWithGuard: { if(prog != Progress::None) return; if(QM.RemoveQuestRumor(R_ORCS)) game->gui->journal->AddRumor(Format(game->txQuest[189], GetStartLocationName())); QM.quest_orcs2->orcs_state = Quest_Orcs2::State::GuardTalked; } break; case Progress::NotAccepted: { if(QM.RemoveQuestRumor(R_ORCS)) game->gui->journal->AddRumor(Format(game->txQuest[190], GetStartLocationName())); // mark guard to remove Unit*& u = QM.quest_orcs2->guard; if(u) { u->auto_talk = AutoTalkMode::No; u->temporary = true; u = nullptr; } QM.quest_orcs2->orcs_state = Quest_Orcs2::State::GuardTalked; } break; case Progress::Started: { OnStart(game->txQuest[191]); // remove rumor from pool QM.RemoveQuestRumor(R_ORCS); // mark guard to remove Unit*& u = QM.quest_orcs2->guard; if(u) { u->auto_talk = AutoTalkMode::No; u->temporary = true; u = nullptr; } // generate location Location& tl = *W.CreateLocation(L_DUNGEON, GetStartLocation().pos, 64.f, HUMAN_FORT, SG_ORCS, false); tl.SetKnown(); tl.st = 8; tl.active_quest = this; target_loc = tl.index; location_event_handler = this; at_level = tl.GetLastLevel(); dungeon_levels = at_level + 1; levels_cleared = 0; whole_location_event_handler = true; item_to_give[0] = Item::Get("q_orkowie_klucz"); spawn_item = Quest_Event::Item_GiveSpawned2; unit_to_spawn = UnitData::Get("q_orkowie_gorush"); spawn_unit_room = RoomTarget::Prison; unit_dont_attack = true; unit_to_spawn2 = g_spawn_groups[SG_ORCS].GetSpawnLeader(10); unit_spawn_level2 = -3; QM.quest_orcs2->orcs_state = Quest_Orcs2::State::Accepted; // questowe rzeczy msgs.push_back(Format(game->txQuest[192], GetStartLocationName(), W.GetDate())); msgs.push_back(Format(game->txQuest[193], GetStartLocationName(), GetTargetLocationName(), GetTargetLocationDir())); } break; case Progress::ClearedLocation: // oczyszczono lokacjê { OnUpdate(Format(game->txQuest[194], GetTargetLocationName(), GetStartLocationName())); } break; case Progress::Finished: // ukoñczono - nagroda { state = Quest::Completed; Team.AddReward(4000, 12000); OnUpdate(game->txQuest[195]); W.AddNews(Format(game->txQuest[196], GetTargetLocationName(), GetStartLocationName())); if(QM.quest_orcs2->orcs_state == Quest_Orcs2::State::OrcJoined) { QM.quest_orcs2->orcs_state = Quest_Orcs2::State::CompletedJoined; QM.quest_orcs2->days = Random(30, 60); GetTargetLocation().active_quest = nullptr; target_loc = -1; } else QM.quest_orcs2->orcs_state = Quest_Orcs2::State::Completed; } break; } prog = prog2; }
//================================================================================================= void Quest_Orcs2::SetProgress(int prog2) { bool apply = true; switch(prog2) { case Progress::TalkedOrc: // zapisz gorusha { orc = DialogContext::current->talker; orc->RevealName(true); } break; case Progress::NotJoined: break; case Progress::Joined: // dodaj questa { OnStart(game->txQuest[214]); msgs.push_back(Format(game->txQuest[170], W.GetDate())); msgs.push_back(game->txQuest[197]); // ustaw stan if(orcs_state == Quest_Orcs2::State::Accepted) orcs_state = Quest_Orcs2::State::OrcJoined; else { orcs_state = Quest_Orcs2::State::CompletedJoined; days = Random(30, 60); QM.quest_orcs->GetTargetLocation().active_quest = nullptr; QM.quest_orcs->target_loc = -1; } // do³¹cz do dru¿yny DialogContext::current->talker->dont_attack = false; Team.AddTeamMember(DialogContext::current->talker, true); if(Team.free_recruits > 0) --Team.free_recruits; } break; case Progress::TalkedAboutCamp: // powiedzia³ o obozie { target_loc = W.CreateCamp(W.GetWorldPos(), SG_ORCS, 256.f, false); Location& target = GetTargetLocation(); target.state = LS_HIDDEN; target.st = 11; target.active_quest = this; near_loc = W.GetNearestSettlement(target.pos); OnUpdate(game->txQuest[198]); orcs_state = Quest_Orcs2::State::ToldAboutCamp; } break; case Progress::TalkedWhereIsCamp: // powiedzia³ gdzie obóz { if(prog == Progress::TalkedWhereIsCamp) break; Location& target = GetTargetLocation(); Location& nearl = *W.GetLocation(near_loc); target.SetKnown(); done = false; location_event_handler = this; OnUpdate(Format(game->txQuest[199], GetLocationDirName(nearl.pos, target.pos), nearl.name.c_str())); } break; case Progress::ClearedCamp: // oczyszczono obóz orków { orc->StartAutoTalk(); W.AddNews(game->txQuest[200]); Team.AddExp(14000); } break; case Progress::TalkedAfterClearingCamp: // pogada³ po oczyszczeniu { orcs_state = Quest_Orcs2::State::CampCleared; days = Random(25, 50); GetTargetLocation().active_quest = nullptr; target_loc = -1; OnUpdate(game->txQuest[201]); } break; case Progress::SelectWarrior: // zostañ wojownikiem apply = false; ChangeClass(OrcClass::Warrior); break; case Progress::SelectHunter: // zostañ ³owc¹ apply = false; ChangeClass(OrcClass::Hunter); break; case Progress::SelectShaman: // zostañ szamanem apply = false; ChangeClass(OrcClass::Shaman); break; case Progress::SelectRandom: // losowo { OrcClass clas; if(DialogContext::current->pc->unit->GetClass() == Class::WARRIOR) { if(Rand() % 2 == 0) clas = OrcClass::Hunter; else clas = OrcClass::Shaman; } else if(DialogContext::current->pc->unit->GetClass() == Class::HUNTER) { if(Rand() % 2 == 0) clas = OrcClass::Warrior; else clas = OrcClass::Shaman; } else { int co = Rand() % 3; if(co == 0) clas = OrcClass::Warrior; else if(co == 1) clas = OrcClass::Hunter; else clas = OrcClass::Shaman; } apply = false; ChangeClass(clas); } break; case Progress::TalkedAboutBase: // pogada³ o bazie { done = false; Location& target = *W.CreateLocation(L_DUNGEON, W.GetWorldPos(), 256.f, THRONE_FORT, SG_ORCS, false); target.st = 15; target.active_quest = this; target.state = LS_HIDDEN; target_loc = target.index; OnUpdate(game->txQuest[202]); orcs_state = State::ToldAboutBase; } break; case Progress::TalkedWhereIsBase: // powiedzia³ gdzie baza { Location& target = GetTargetLocation(); target.SetKnown(); unit_to_spawn = UnitData::Get("q_orkowie_boss"); spawn_unit_room = RoomTarget::Throne; callback = WarpToThroneOrcBoss; at_level = target.GetLastLevel(); location_event_handler = nullptr; unit_event_handler = this; near_loc = W.GetNearestSettlement(target.pos); Location& nearl = *W.GetLocation(near_loc); OnUpdate(Format(game->txQuest[203], GetLocationDirName(nearl.pos, target.pos), nearl.name.c_str(), target.name.c_str())); done = false; orcs_state = State::GenerateOrcs; } break; case Progress::KilledBoss: // zabito bossa { orc->StartAutoTalk(); OnUpdate(game->txQuest[204]); W.AddNews(game->txQuest[205]); Team.AddLearningPoint(); } break; case Progress::Finished: // pogadano z gorushem { state = Quest::Completed; Team.AddReward(Random(9000, 11000), 25000); OnUpdate(game->txQuest[206]); QM.EndUniqueQuest(); // gorush Team.RemoveTeamMember(orc); Usable* tron = L.local_ctx.FindUsable("throne"); assert(tron); if(tron) { orc->ai->idle_action = AIController::Idle_WalkUse; orc->ai->idle_data.usable = tron; orc->ai->timer = 9999.f; } orc = nullptr; // orki UnitData* ud[12] = { UnitData::Get("orc"), UnitData::Get("q_orkowie_orc"), UnitData::Get("orc_fighter"), UnitData::Get("q_orkowie_orc_fighter"), UnitData::Get("orc_warius"), UnitData::Get("q_orkowie_orc_warius"), UnitData::Get("orc_hunter"), UnitData::Get("q_orkowie_orc_hunter"), UnitData::Get("orc_shaman"), UnitData::Get("q_orkowie_orc_shaman"), UnitData::Get("orc_chief"), UnitData::Get("q_orkowie_orc_chief") }; UnitData* ud_slaby = UnitData::Get("q_orkowie_slaby"); for(vector<Unit*>::iterator it = L.local_ctx.units->begin(), end = L.local_ctx.units->end(); it != end; ++it) { Unit& u = **it; if(u.IsAlive()) { if(u.data == ud_slaby) { // usuñ dont_attack, od tak :3 u.dont_attack = false; u.ai->change_ai_mode = true; } else { for(int i = 0; i < 6; ++i) { if(u.data == ud[i * 2]) { u.data = ud[i * 2 + 1]; u.ai->target = nullptr; u.ai->alert_target = nullptr; u.ai->state = AIController::Idle; u.ai->change_ai_mode = true; if(Net::IsOnline()) { NetChange& c = Add1(Net::changes); c.type = NetChange::CHANGE_UNIT_BASE; c.unit = &u; } break; } } } } } // zak³ada ¿e gadamy na ostatnim levelu, mam nadzieje ¿e gracz z tamt¹d nie spierdoli przed pogadaniem :3 MultiInsideLocation* multi = (MultiInsideLocation*)W.GetCurrentLocation(); for(vector<InsideLocationLevel>::iterator it = multi->levels.begin(), end = multi->levels.end() - 1; it != end; ++it) { for(vector<Unit*>::iterator it2 = it->units.begin(), end2 = it->units.end(); it2 != end2; ++it2) { Unit& u = **it2; if(u.IsAlive()) { for(int i = 0; i < 5; ++i) { if(u.data == ud[i * 2]) { u.data = ud[i * 2 + 1]; break; } } } } } // usuñ zw³oki po opuszczeniu lokacji orcs_state = State::ClearDungeon; } break; } if(apply) prog = prog2; }
//================================================================================================= void Quest_Goblins::SetProgress(int prog2) { prog = prog2; switch(prog2) { case Progress::NotAccepted: // nie zaakceptowano { if(QM.RemoveQuestRumor(R_GOBLINS)) game->gui->journal->AddRumor(Format(game->txQuest[211], GetStartLocationName())); } break; case Progress::Started: // zaakceptowano { OnStart(game->txQuest[212]); // usuñ plotkê QM.RemoveQuestRumor(R_GOBLINS); // dodaj lokalizacje target_loc = W.GetNearestLocation(GetStartLocation().pos, 1 << L_FOREST, true); Location& target = GetTargetLocation(); target.SetKnown(); target.reset = true; target.active_quest = this; target.st = 7; spawn_item = Quest_Event::Item_OnGround; item_to_give[0] = Item::Get("q_gobliny_luk"); // questowe rzeczy msgs.push_back(Format(game->txQuest[217], GetStartLocationName(), W.GetDate())); msgs.push_back(Format(game->txQuest[218], GetTargetLocationName(), GetTargetLocationDir())); // encounter Encounter* e = W.AddEncounter(enc); e->check_func = CzyMajaStaryLuk; e->dialog = GameDialog::TryGet("q_goblins_encounter"); e->dont_attack = true; e->group = SG_GOBLINS; e->location_event_handler = nullptr; e->pos = GetStartLocation().pos; e->quest = static_cast<Quest*>(this); e->chance = 10000; e->range = 32.f; e->text = game->txQuest[219]; e->timed = false; e->st = 6; } break; case Progress::BowStolen: // gobliny ukrad³y ³uk { Team.RemoveQuestItem(Item::Get("q_gobliny_luk")); OnUpdate(game->txQuest[220]); W.RemoveEncounter(enc); enc = -1; GetTargetLocation().active_quest = nullptr; W.AddNews(game->txQuest[221]); Team.AddExp(1000); } break; case Progress::TalkedAboutStolenBow: // poinformowano o kradzie¿y { state = Quest::Failed; OnUpdate(game->txQuest[222]); goblins_state = State::Counting; days = Random(15, 30); } break; case Progress::InfoAboutGoblinBase: // pos³aniec dostarczy³ info o bazie goblinów { state = Quest::Started; target_loc = W.GetRandomSpawnLocation(GetStartLocation().pos, SG_GOBLINS); Location& target = GetTargetLocation(); target.state = LS_KNOWN; target.st = 10; target.reset = true; target.active_quest = this; done = false; spawn_item = Quest_Event::Item_GiveSpawned; unit_to_spawn = g_spawn_groups[SG_GOBLINS].GetSpawnLeader(11); unit_spawn_level = -3; item_to_give[0] = Item::Get("q_gobliny_luk"); at_level = target.GetLastLevel(); OnUpdate(Format(game->txQuest[223], target.name.c_str(), GetTargetLocationDir(), GetStartLocationName())); goblins_state = State::MessengerTalked; } break; case Progress::GivenBow: // oddano ³uk { state = Quest::Completed; const Item* item = Item::Get("q_gobliny_luk"); DialogContext::current->pc->unit->RemoveItem(item, 1); DialogContext::current->talker->AddItem(item, 1, true); Team.AddReward(500, 2500); OnUpdate(game->txQuest[224]); goblins_state = State::GivenBow; GetTargetLocation().active_quest = nullptr; target_loc = -1; W.AddNews(game->txQuest[225]); } break; case Progress::DidntTalkedAboutBow: // nie chcia³eœ powiedzieæ o ³uku { OnUpdate(game->txQuest[226]); goblins_state = State::MageTalkedStart; } break; case Progress::TalkedAboutBow: // powiedzia³eœ o ³uku { state = Quest::Started; OnUpdate(game->txQuest[227]); goblins_state = State::MageTalked; } break; case Progress::PayedAndTalkedAboutBow: // zap³aci³eœ i powiedzia³eœ o ³uku { DialogContext::current->pc->unit->ModGold(-100); state = Quest::Started; OnUpdate(game->txQuest[228]); goblins_state = State::MageTalked; } break; case Progress::TalkedWithInnkeeper: // pogadano z karczmarzem { goblins_state = State::KnownLocation; Location& target = *W.CreateLocation(L_DUNGEON, W.GetWorldPos(), 128.f, THRONE_FORT, SG_GOBLINS, false); target.st = 12; target.SetKnown(); target.active_quest = this; target_loc = target.index; done = false; unit_to_spawn = UnitData::Get("q_gobliny_szlachcic2"); spawn_unit_room = RoomTarget::Throne; callback = DodajStraznikow; unit_dont_attack = true; unit_auto_talk = true; unit_event_handler = this; item_to_give[0] = nullptr; spawn_item = Quest_Event::Item_DontSpawn; at_level = target.GetLastLevel(); OnUpdate(Format(game->txQuest[229], target.name.c_str(), GetTargetLocationDir(), GetStartLocationName())); } break; case Progress::KilledBoss: // zabito szlachcica { state = Quest::Completed; OnUpdate(game->txQuest[230]); GetTargetLocation().active_quest = nullptr; QM.EndUniqueQuest(); W.AddNews(game->txQuest[231]); Team.AddLearningPoint(); Team.AddExp(15000); } break; } }
//================================================================================================= cstring Quest_Dungeon::GetTargetLocationDir() const { return GetLocationDirName(GetStartLocation().pos, GetTargetLocation().pos); }
//================================================================================================= cstring Quest_Dungeon::GetTargetLocationName() const { return GetTargetLocation().name.c_str(); }