bool HeroesTownGate(Heroes & hero, const Castle* castle) { if(castle) { Interface::Basic & I = Interface::Basic::Get(); const s32 src = hero.GetIndex(); const s32 dst = castle->GetIndex(); if(!Maps::isValidAbsIndex(src) || !Maps::isValidAbsIndex(dst)) return false; AGG::PlaySound(M82::KILLFADE); hero.GetPath().Hide(); hero.FadeOut(); Cursor::Get().Hide(); hero.Move2Dest(dst); I.gameArea.SetCenter(hero.GetCenter()); GameFocus::SetRedraw(); I.Redraw(); AGG::PlaySound(M82::KILLFADE); hero.GetPath().Hide(); hero.FadeIn(); // educate spells if(! Settings::Get().ExtHeroLearnSpellsWithDay()) castle->MageGuildEducateHero(hero); return true; } return false; }
bool ActionSpellDimensionDoor(Heroes & hero) { const u8 distance = Spell::CalculateDimensionDoorDistance(hero.GetPower(), hero.GetArmy().GetHitPoints()); Interface::Basic & I = Interface::Basic::Get(); Cursor & cursor = Cursor::Get(); // center hero cursor.Hide(); I.gameArea.SetCenter(hero.GetCenter()); GameFocus::SetRedraw(); I.Redraw(); const s32 src = hero.GetIndex(); // get destination const s32 dst = I.GetDimensionDoorDestination(src, distance, hero.isShipMaster()); if(Maps::isValidAbsIndex(src) && Maps::isValidAbsIndex(dst)) { AGG::PlaySound(M82::KILLFADE); hero.GetPath().Reset(); hero.FadeOut(); hero.SpellCasted(Spell::DIMENSIONDOOR); cursor.Hide(); hero.Move2Dest(dst, true); I.gameArea.SetCenter(hero.GetCenter()); GameFocus::SetRedraw(); I.Redraw(); AGG::PlaySound(M82::KILLFADE); hero.FadeIn(); hero.ActionNewPosition(); return false; /* SpellCasted apply */ } return false; }
void Heroes::MoveStep(Heroes & hero, s32 index_from, s32 index_to, bool newpos) { if(newpos) { hero.Move2Dest(index_to); hero.GetPath().PopFront(); // possible hero is die if(!hero.isFreeman() && index_to == hero.GetPath().GetDestinationIndex()) { hero.GetPath().Reset(); hero.Action(index_to); hero.SetMove(false); } } else { hero.ApplyPenaltyMovement(); hero.GetPath().Reset(); hero.Action(index_to); hero.SetMove(false); } }