# HG changeset patch # User nemo # Date 1346343204 14400 # Node ID efc75c2d3be9372d5938b15f42d299906a6d32b1 # Parent fd91aa100ce0674718a9a87de67780f51a22b0d4# Parent 644eabbc9218e93db1ad3829d53c9e5174a05537 checkpoint merge diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Fri Jul 20 18:48:04 2012 -0400 +++ b/QTfrontend/CMakeLists.txt Thu Aug 30 12:13:24 2012 -0400 @@ -85,6 +85,7 @@ hwform.cpp main.cpp team.cpp + campaign.cpp ui_hwform.cpp ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp ) @@ -121,6 +122,7 @@ HWApplication.h hwform.h team.h + campaign.h util/DataManager.h ) diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/campaign.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/campaign.cpp Thu Aug 30 12:13:24 2012 -0400 @@ -0,0 +1,91 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "campaign.h" +#include "gameuiconfig.h" +#include "hwconsts.h" +#include "gamecfgwidget.h" +#include "bgwidget.h" +#include "mouseoverfilter.h" +#include "tcpBase.h" + +#include "DataManager.h" + +extern QString campaign, campaignTeam; + +QStringList getCampMissionList(QString & campaign) +{ + QSettings campfile(DataManager::instance().findFileForRead("Missions/Campaign/" + campaign + "/campaign.ini"), QSettings::IniFormat, 0); + campfile.setIniCodec("UTF-8"); + unsigned int mNum = campfile.value("MissionNum", 0).toInt(); + + QStringList missionList; + for (unsigned int i = 0; i < mNum; i++) + { + missionList += campfile.value(QString("Mission %1/Name").arg(i + 1)).toString(); + } + return missionList; +} + +unsigned int getCampProgress(QString & teamName, QString & campName) +{ + QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); + teamfile.setIniCodec("UTF-8"); + return teamfile.value("Campaign " + campName + "/Progress", 0).toInt(); +} + +QString getCampaignScript(QString campaign, unsigned int mNum) +{ + QSettings campfile(DataManager::instance().findFileForRead("Missions/Campaign/" + campaign + "/campaign.ini"), QSettings::IniFormat, 0); + campfile.setIniCodec("UTF-8"); + return campfile.value(QString("Mission %1/Script").arg(mNum)).toString(); +} + + + + + + + diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/campaign.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/campaign.h Thu Aug 30 12:13:24 2012 -0400 @@ -0,0 +1,42 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef CAMPAIGN_H +#define CAMPAIGN_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "netserver.h" +#include "game.h" +#include "ui_hwform.h" +#include "SDLInteraction.h" +#include "bgwidget.h" + +QStringList getCampMissionList(QString & campaign); +unsigned int getCampProgress(QString & teamName, QString & campName); +QString getCampaignScript(QString campaign, unsigned int mNum); + +#endif diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/game.cpp --- a/QTfrontend/game.cpp Fri Jul 20 18:48:04 2012 -0400 +++ b/QTfrontend/game.cpp Thu Aug 30 12:13:24 2012 -0400 @@ -21,7 +21,6 @@ #include #include #include -#include #include "game.h" #include "hwconsts.h" @@ -30,7 +29,8 @@ #include "teamselect.h" #include "KB.h" #include "proto.h" -#include "ThemeModel.h" + +#include QString training, campaign; // TODO: Cleaner solution? @@ -98,7 +98,7 @@ HWProto::addStringToBuffer(buf, QString("eammprob %1").arg(ammostr.mid(cAmmoNumber, cAmmoNumber))); HWProto::addStringToBuffer(buf, QString("eammdelay %1").arg(ammostr.mid(2 * cAmmoNumber, cAmmoNumber))); HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber))); - if(gamecfg->schemeData(15).toBool() || !gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore")); + if(!gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore")); HWProto::addStringListToBuffer(buf, team.teamGameConfig(gamecfg->getInitHealth())); ; diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/game.h --- a/QTfrontend/game.h Fri Jul 20 18:48:04 2012 -0400 +++ b/QTfrontend/game.h Thu Aug 30 12:13:24 2012 -0400 @@ -54,7 +54,7 @@ void StartQuick(); void StartNet(); void StartTraining(const QString & file); - void StartCampaign(const QString & file); + void StartCampaign(const QString & camp, const QString & campScript, const QString & campTeam); void abort(); GameState gameState; bool netSuspend; @@ -72,6 +72,7 @@ void GameStats(char type, const QString & info); void HaveRecord(bool isDemo, const QByteArray & record); void ErrorMessage(const QString &); + void CampStateChanged(int); public slots: void FromNet(const QByteArray & msg); @@ -103,6 +104,8 @@ void SendCampaignConfig(); void ParseMessage(const QByteArray & msg); void SetGameState(GameState state); + void sendCampaignVar(QByteArray varToSend); + void writeCampaignVar(QByteArray varVal); }; #endif diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Fri Jul 20 18:48:04 2012 -0400 +++ b/QTfrontend/hwform.cpp Thu Aug 30 12:13:24 2012 -0400 @@ -51,6 +51,7 @@ #include "hwform.h" #include "game.h" #include "team.h" +#include "campaign.h" #include "teamselect.h" #include "selectWeapon.h" #include "gameuiconfig.h" @@ -162,6 +163,7 @@ #endif UpdateTeamsLists(); + InitCampaignPage(); UpdateCampaignPage(0); UpdateWeapons(); @@ -273,6 +275,7 @@ connect(ui.pageCampaign->BtnStartCampaign, SIGNAL(clicked()), this, SLOT(StartCampaign())); connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int))); + connect(ui.pageCampaign->CBCampaign, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int))); connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()), @@ -1354,6 +1357,7 @@ void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo) { game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); + connect(game, SIGNAL(CampStateChanged(int)), this, SLOT(UpdateCampaignPageProgress(int))); connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); @@ -1418,7 +1422,13 @@ { CreateGame(0, 0, 0); - game->StartCampaign(ui.pageCampaign->CBSelect->itemData(ui.pageCampaign->CBSelect->currentIndex()).toString()); + QComboBox *combo = ui.pageCampaign->CBMission; + QString camp = ui.pageCampaign->CBCampaign->currentText(); + unsigned int mNum = combo->count() - combo->currentIndex(); + QString miss = getCampaignScript(camp, mNum); + QString campTeam = ui.pageCampaign->CBTeam->currentText(); + + game->StartCampaign(camp, miss, campTeam); } void HWForm::CreateNetGame() @@ -1544,24 +1554,49 @@ } } +void HWForm::InitCampaignPage() +{ + ui.pageCampaign->CBCampaign->clear(); + HWTeam team(ui.pageCampaign->CBTeam->currentText()); + + QStringList entries = DataManager::instance().entryList( + "Missions/Campaign", + QDir::Dirs, + QStringList("[^\\.]*") + ); + + unsigned int n = entries.count(); + for(unsigned int i = 0; i < n; i++) + { + ui.pageCampaign->CBCampaign->addItem(QString(entries[i]), QString(entries[i])); + } +} + + void HWForm::UpdateCampaignPage(int index) { Q_UNUSED(index); HWTeam team(ui.pageCampaign->CBTeam->currentText()); - ui.pageCampaign->CBSelect->clear(); + ui.pageCampaign->CBMission->clear(); + + QString campaignName = ui.pageCampaign->CBCampaign->currentText(); + QStringList missionEntries = getCampMissionList(campaignName); + QString tName = team.name(); + unsigned int n = missionEntries.count(); + unsigned int m = getCampProgress(tName, campaignName); - QStringList entries = DataManager::instance().entryList( - "Missions/Campaign", - QDir::Files, - QStringList("*#*.lua") - ); + for (unsigned int i = min(m + 1, n); i > 0; i--) + { + ui.pageCampaign->CBMission->addItem(QString("Mission %1: ").arg(i) + QString(missionEntries[i-1]), QString(missionEntries[i-1])); + } +} - unsigned int n = entries.count(); - for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++) - { - ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); - } +void HWForm::UpdatecampaignPageProgress(int index) +{ + int missionIndex = ui.pageCampaign->CBMission->currentIndex(); + UpdateCampaignPage(0); + ui.pageCampaign->CBMission->setCurrentIndex(missionIndex); } // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality] diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Fri Jul 20 18:48:04 2012 -0400 +++ b/QTfrontend/hwform.h Thu Aug 30 12:13:24 2012 -0400 @@ -121,6 +121,8 @@ void onFrontendEffects(bool value); void Music(bool checked); void UpdateCampaignPage(int index); + void UpdatecampaignPageProgress(int index); + void InitCampaignPage(); //Starts the transmission process for the feedback void SendFeedback(); //Make a xml representation of the issue to be created diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/ui/page/pagecampaign.cpp --- a/QTfrontend/ui/page/pagecampaign.cpp Fri Jul 20 18:48:04 2012 -0400 +++ b/QTfrontend/ui/page/pagecampaign.cpp Thu Aug 30 12:13:24 2012 -0400 @@ -31,11 +31,13 @@ pageLayout->setRowStretch(0, 1); pageLayout->setRowStretch(3, 1); - CBSelect = new QComboBox(this); CBTeam = new QComboBox(this); + CBMission = new QComboBox(this); + CBCampaign = new QComboBox(this); pageLayout->addWidget(CBTeam, 1, 1); - pageLayout->addWidget(CBSelect, 2, 1); + pageLayout->addWidget(CBCampaign, 2, 1); + pageLayout->addWidget(CBMission, 3, 1); BtnStartCampaign = new QPushButton(this); BtnStartCampaign->setFont(*font14); diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/ui/page/pagecampaign.h --- a/QTfrontend/ui/page/pagecampaign.h Fri Jul 20 18:48:04 2012 -0400 +++ b/QTfrontend/ui/page/pagecampaign.h Thu Aug 30 12:13:24 2012 -0400 @@ -29,7 +29,8 @@ PageCampaign(QWidget* parent = 0); QPushButton *BtnStartCampaign; - QComboBox *CBSelect; + QComboBox *CBMission; + QComboBox *CBCampaign; QComboBox *CBTeam; protected: diff -r fd91aa100ce0 -r efc75c2d3be9 QTfrontend/ui/page/pagesingleplayer.cpp --- a/QTfrontend/ui/page/pagesingleplayer.cpp Fri Jul 20 18:48:04 2012 -0400 +++ b/QTfrontend/ui/page/pagesingleplayer.cpp Thu Aug 30 12:13:24 2012 -0400 @@ -48,7 +48,7 @@ BtnCampaignPage = addButton(":/res/Campaign.png", middleLine, 0, true); BtnCampaignPage->setToolTip(tr("Campaign Mode")); BtnCampaignPage->setWhatsThis(tr("Campaign Mode")); - BtnCampaignPage->setVisible(false); + BtnCampaignPage->setVisible(true); BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 1, true); BtnTrainPage->setToolTip(tr("Training Mode")); diff -r fd91aa100ce0 -r efc75c2d3be9 hedgewars/uCommandHandlers.pas --- a/hedgewars/uCommandHandlers.pas Fri Jul 20 18:48:04 2012 -0400 +++ b/hedgewars/uCommandHandlers.pas Thu Aug 30 12:13:24 2012 -0400 @@ -783,6 +783,11 @@ fastUntilLag:= StrToInt(s) <> 0 end; +procedure chCampVar(var s:shortstring); +begin + CampaignVariable := s; +end; + procedure initModule; begin //////// Begin top sorted by freq analysis not including chatmsg @@ -866,6 +871,7 @@ RegisterVariable('-cur_l' , @chCurL_m , true ); RegisterVariable('+cur_r' , @chCurR_p , true ); RegisterVariable('-cur_r' , @chCurR_m , true ); + RegisterVariable('campvar' , @chCampVar , true ); end; procedure freeModule; diff -r fd91aa100ce0 -r efc75c2d3be9 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Fri Jul 20 18:48:04 2012 -0400 +++ b/hedgewars/uGears.pas Thu Aug 30 12:13:24 2012 -0400 @@ -564,7 +564,7 @@ Gear:= GearsList; while Gear <> nil do begin - if Gear^.State and gstInvisible = 0 then + if (Gear^.State and gstInvisible = 0) and (Gear^.Message and gmRemoveFromList = 0) then begin x:= hwRound(Gear^.X) + WorldDx; y:= hwRound(Gear^.Y) + WorldDy; diff -r fd91aa100ce0 -r efc75c2d3be9 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Fri Jul 20 18:48:04 2012 -0400 +++ b/hedgewars/uIO.pas Thu Aug 30 12:13:24 2012 -0400 @@ -127,6 +127,10 @@ 'N': GameType:= gmtNet; 'S': GameType:= gmtSave; else OutError(errmsgIncorrectUse + ' IPC "T" :' + s[2], true) end; + 'V': begin + if s[2] = '.' then + ParseCommand('campvar ' + copy(s, 3, length(s) - 2), true); + end else loTicks:= SDLNet_Read16(@s[byte(s[0]) - 1]); AddCmd(loTicks, s); diff -r fd91aa100ce0 -r efc75c2d3be9 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Fri Jul 20 18:48:04 2012 -0400 +++ b/hedgewars/uScript.pas Thu Aug 30 12:13:24 2012 -0400 @@ -80,7 +80,8 @@ uTextures, uLandGraphics, SDLh, - SysUtils; + SysUtils, + uIO; var luaState : Plua_State; ScriptAmmoLoadout : shortstring; @@ -1658,6 +1659,68 @@ lc_getcurammotype := 1; end; +function lc_savecampaignvar(L : Plua_State): LongInt; Cdecl; +begin + if lua_gettop(L) <> 2 then + LuaError('Lua: Wrong number of parameters passed to SaveCampaignVar!') + else begin + SendIPC('V!' + lua_tostring(L, 1) + ' ' + lua_tostring(L, 2) + #0); + end; + lc_savecampaignvar := 0; +end; + +function lc_getcampaignvar(L : Plua_State): LongInt; Cdecl; +begin + if (lua_gettop(L) <> 1) then + LuaError('Lua: Wrong number of parameters passed to GetCampaignVar!') + else + SendIPCAndWaitReply('V?' + lua_tostring(L, 1)); + lua_pushstring(L, str2pchar(CampaignVariable)); + lc_getcampaignvar := 1; +end; + +function lc_hidehog(L: Plua_State): LongInt; Cdecl; +var gear: PGear; +begin + if lua_gettop(L) <> 1 then + LuaError('Lua: Wrong number of parameters passed to HideHog!') + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + hiddenHedgehogs[hiddenHedgehogsNumber]:=gear^.hedgehog; + inc(hiddenHedgehogsNumber); + HideHog(gear^.hedgehog); + end; + lc_hidehog := 0; +end; + +function lc_restorehog(L: Plua_State): LongInt; Cdecl; +var hog: PHedgehog; + i, j: LongInt; +begin + if lua_gettop(L) <> 1 then + LuaError('Lua: Wrong number of parameters passed to RestoreHog!') + else + begin + i := 0; + while (i < hiddenHedgehogsNumber) do + begin + if hiddenHedgehogs[i]^.gearHidden^.uid = lua_tointeger(L, 1) then + begin + hog := hiddenHedgehogs[i]; + RestoreHog(hog); + dec(hiddenHedgehogsNumber); + for j := i to hiddenHedgehogsNumber - 1 do + hiddenHedgehogs[j] := hiddenHedgehogs[j + 1]; + lc_restorehog := 0; + exit; + end; + inc(i); + end; + end; + lc_restorehog := 0; +end; + // boolean TestRectForObstacle(x1, y1, x2, y2, landOnly) function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; var rtn: Boolean; @@ -2177,6 +2240,10 @@ ScriptSetInteger('gstInvisible' ,$00200000); // register functions +lua_register(luaState, _P'HideHog', @lc_hidehog); +lua_register(luaState, _P'RestoreHog', @lc_restorehog); +lua_register(luaState, _P'SaveCampaignVar', @lc_savecampaignvar); +lua_register(luaState, _P'GetCampaignVar', @lc_getcampaignvar); lua_register(luaState, _P'band', @lc_band); lua_register(luaState, _P'bor', @lc_bor); lua_register(luaState, _P'bnot', @lc_bnot); diff -r fd91aa100ce0 -r efc75c2d3be9 hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Fri Jul 20 18:48:04 2012 -0400 +++ b/hedgewars/uVariables.pas Thu Aug 30 12:13:24 2012 -0400 @@ -65,6 +65,7 @@ autoCameraOn : boolean; CheckSum : LongWord; + CampaignVariable: shortstring; GameTicks : LongWord; GameState : TGameState; GameType : TGameType; @@ -181,6 +182,8 @@ hiTicks: Word; LuaGoals : shortstring; + hiddenHedgehogs : array [0..cMaxHHs] of PHedgehog; + hiddenHedgehogsNumber : longint; VoiceList : array[0..7] of TVoice = ( ( snd: sndNone; voicepack: nil), diff -r fd91aa100ce0 -r efc75c2d3be9 share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/backstab.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/backstab.lua Thu Aug 30 12:13:24 2012 -0400 @@ -0,0 +1,1051 @@ +loadfile(GetDataPath() .. "Scripts/Locale.lua")() +loadfile(GetDataPath() .. "Scripts/Animate.lua")() + +-----------------------------Constants--------------------------------- +choiceAccepted = 1 +choiceRefused = 2 +choiceAttacked = 3 + +choiceEliminate = 1 +choiceSpare = 2 + +leaksNum = 1 +denseNum = 2 +waterNum = 3 +buffaloNum = 4 +chiefNum = 5 +princessNum = 6 +wiseNum = 7 + +spyKillStage = 1 +platformStage = 2 +wave3Stage = 3 + +tmpVar = 0 + +nativeNames = {loc("Leaks A Lot"), loc("Dense Cloud"), loc("Fiery Water"), + loc("Raging Buffalo"), loc("Righteous Beard"), loc("Fell From Heaven"), + loc("Wise Oak"), loc("Eagle Eye"), loc("Flaming Worm")} + +nativeHats = {"Rambo", "RobinHood", "pirate_jack", "zoo_Bunny", "IndianChief", + "tiara", "AkuAku", "None", "None"} + +nativePos = {{887, 329}, {1050, 288}, {1731, 707}, + {830, 342}, {1001, 290}, {773, 340}, + {953, 305}, {347, 648}, {314, 647}} + +nativeDir = {"Right", "Left", "Left", + "Right", "Left", "Right", + "Left", "Right", "Right"} + +cannibalNames = {loc("Brain Teaser"), loc("Bone Jackson"), loc("Gimme Bones"), + loc("Hedgibal Letter"), loc("Bloodpie"), loc("Scalp Muncher"), + loc("Back Breaker"), loc("Dahmer"), loc("Meiwes"), + loc("Ear Sniffer"), loc("Regurgitator"), loc("Muriel")} + +cannibalPos = {{3607, 1472}, {3612, 1487}, {3646, 1502}, + {3694, 1509}, {3746, 1525}, {3704, 1513}, + {3607, 1472}, {3612, 1487}, {3646, 1502}, + {3694, 1509}, {3746, 1525}, {3704, 1513}} + +cannibalDir = {"Left", "Left", "Left", + "Left", "Left", "Left", + "Left", "Left", "Left", + "Left", "Left", "Left"} + +cyborgPos = {1369, 574} +cyborgPos2 = {1308, 148} + +deployedPos = {2522, 1365} +-----------------------------Variables--------------------------------- +natives = {} +nativeDead = {} +nativeHidden = {} +nativeRevived = {} +nativesNum = 0 + +cannibals = {} +cannibalDead = {} +cannibalHidden = {} + +speakerHog = nil +spyHog = nil +deployedHog = nil + +cyborgHidden = false + +m2Choice = 0 +m2DenseDead = 0 +m4DenseDead = 0 +m4BuffaloDead = 0 +m4WaterDead = 0 +m4ChiefDead = 0 +m4LeaksDead = 0 + +needRevival = false +gearr = nil +startElimination = 0 +stage = 0 +choice = 0 +highJumped = false +TurnsLeft = 0 +startNativesNum = 0 + +startAnim = {} +afterChoiceAnim = {} +wave2Anim = {} +wave2DeadAnim = {} +wave3DeadAnim = {} + +-----------------------------Animations-------------------------------- +function Wave2Reaction() + local i = 1 + local gearr = nil + while nativeDead[i] == true do + i = i + 1 + end + gearr = natives[i] + if nativeDead[denseNum] ~= true and band(GetState(natives[denseNum]), gstDrowning) == 0 then + AnimInsertStepNext({func = AnimCustomFunction, args = {dense, EmitDenseClouds, {"Left"}}}) + AnimInsertStepNext({func = AnimTurn, args = {dense, "Left"}}) + end + if nativeDead[buffaloNum] ~= true and band(GetState(natives[buffaloNum]), gstDrowning) == 0 then + AnimInsertStepNext({func = AnimSay, args = {natives[buffaloNum], loc("Let them have a taste of my fury!"), SAY_SHOUT, 6000}}) + end + AnimInsertStepNext({func = AnimSay, args = {gearr, loc("There's more of them? When did they become so hungry?"), SAY_SHOUT, 8000}}) +end + +function EmitDenseClouds(dir) + local dif + if dir == "Left" then + dif = 10 + else + dif = -10 + end + AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {natives[denseNum], 800}}) + AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {natives[denseNum], 800}}) + AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false}) +end + +function SaySafe() + local i = 1 + while gearr == nil do + if nativeDead[i] ~= true and nativeHidden[i] ~= true then + gearr = natives[i] + end + i = i + 1 + end + AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("We are indeed."), SAY_SAY, 2500}}) + AnimInsertStepNext({func = AnimSay, args = {gearr, loc("I think we are safe here."), SAY_SAY, 4000}}) +end + +function ReviveNatives() + for i = 1, 7 do + if nativeHidden[i] == true and nativeDead[i] ~= true then + RestoreHog(natives[i]) + nativeHidden[i] = false + nativeRevived[i] = true + AnimInsertStepNext({func = AnimOutOfNowhere, args = {natives[i], unpack(nativePos[i])}}) + end + end +end + +function WonderAlive() + if nativeRevived[waterNum] == true then + AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("I'm...alive? How? Why?"), SAY_THINK, 3500}}) + AnimInsertStepNext({func = AnimWait, args = {natives[waterNum], 800}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[waterNum], "Left"}}) + AnimInsertStepNext({func = AnimWait, args = {natives[waterNum], 800}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[waterNum], "Right"}}) + end + if nativeRevived[leaksNum] == true and nativeRevived[denseNum] == true then + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("But why would they help us?"), SAY_SAY, 4000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("It must be the aliens!"), SAY_SAY, 3500}}) + AnimInsertStepNext({func = AnimSay, args = {natives[princessNum], loc("You just appeared out of thin air!"), SAY_SAY, 5000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("But...we died!"), SAY_SAY, 2500}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("This must be the caves!"), SAY_SAY, 3500}}) + AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Dude, where are we?"), SAY_SAY, 3000}}) + AnimInsertStepNext({func = AnimWait, args = {natives[leaksNum], 800}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[leaksNum], "Right"}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[denseNum], "Left"}}) + AnimInsertStepNext({func = AnimWait, args = {natives[leaksNum], 800}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[leaksNum], "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[denseNum], "Right"}}) + AnimInsertStepNext({func = AnimWait, args = {natives[leaksNum], 800}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[leaksNum], "Right"}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[denseNum], "Left"}}) + AnimInsertStepNext({func = AnimWait, args = {natives[leaksNum], 800}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[leaksNum], "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[denseNum], "Right"}}) + AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[leaksNum], CondNeedToTurn, {natives[leaksNum], natives[princessNum]}}}) + if nativeDead[chiefNum] ~= true then + AnimInsertStepNext({func = AnimTurn, args = {natives[chiefNum], "Right"}}) + end + elseif nativeRevived[leaksNum] == true then + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Why would they do this?"), SAY_SAY, 6000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("It must be the aliens' deed."), SAY_SAY, 5000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("Do not laugh, inexperienced one, for he speaks the truth!"), SAY_SAY, 10000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Yeah, sure! I died. Hillarious!"), SAY_SAY, 6000}}) + AnimInsertStepNext({func = AnimSay, args = {gearr, loc("You're...alive!? But we saw you die!"), SAY_SAY, 6000}}) + AnimInsertStepNext({func = AnimSay, args = {gearr, loc("???"), SAY_SAY, 2000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Wow, what a dream!"), SAY_SAY, 3000}}) + if nativeDead[chiefNum] ~= true then + AnimInsertStepNext({func = AnimTurn, args = {natives[chiefNum], "Right"}}) + end + AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[leaksNum], CondNeedToTurn, {natives[leaksNum], natives[wiseNum]}}}) + AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[leaksNum], CondNeedToTurn, {natives[leaksNum], gearr}}}) + elseif nativeRevived[denseNum] == true then + AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Dude, that's so cool!"), SAY_SAY, 3000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("It must be the aliens' deed."), SAY_SAY, 5000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("But that's impossible!"), SAY_SAY, 3000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("It was not a dream, unwise one!"), SAY_SAY, 5000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Exactly, man! That was my dream."), SAY_SAY, 5000}}) + AnimInsertStepNext({func = AnimSay, args = {gearr, loc("You're...alive!? But we saw you die!"), SAY_SAY, 6000}}) + AnimInsertStepNext({func = AnimSay, args = {gearr, loc("???"), SAY_SAY, 2000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Dude, wow! I just had the weirdest high!"), SAY_SAY, 6000}}) + if nativeDead[chiefNum] ~= true then + AnimInsertStepNext({func = AnimTurn, args = {natives[chiefNum], "Right"}}) + end + AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[denseNum], CondNeedToTurn, {natives[denseNum], natives[wiseNum]}}}) + AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[denseNum], CondNeedToTurn, {natives[denseNum], gearr}}}) + end +end + +function ExplainAlive() + if needRevival == true and m4WaterDead == 1 then + RestoreCyborg() + SetGearPosition(cyborg, unpack(cyborgPos)) + AnimInsertStepNext({func = AnimCustomFunction, args = {water, HideCyborg, {}}}) + AnimInsertStepNext({func = AnimSwitchHog, args = {water}}) + AnimInsertStepNext({func = AnimSay, args = {cyborg, loc("The answer is...entertaintment. You'll see what I mean."), SAY_SAY, 8000}}) + AnimInsertStepNext({func = AnimSay, args = {cyborg, loc("You're probably wondering why I bought you back..."), SAY_SAY, 8000}}) + end +end + +function SpyDebate() + if m2Choice == choiceAccepted then + spyHog = natives[denseNum] + AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("What shall we do with the traitor?"), SAY_SAY, 6000}}) + AnimInsertStepNext({func = SetHealth, swh = false, args = {natives[denseNum], 26}}) + AnimInsertStepNext({func = AnimVisualGear, args = {GetGearPosition(natives[denseNum]), vgtExplosion, 0, true}}) + AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("Here, let me help you!"), SAY_SAY, 3000}}) + if nativeDead[chiefNum] == true then + AnimInsertStepNext({func = AnimSay, args = {natives[princessNum], loc("You killed my father, you monster!"), SAY_SAY, 5000}}) + end + AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Look, I had no choice!"), SAY_SAY, 3000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("You have been giving us out to the enemy, haven't you!"), SAY_SAY, 7000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("You're a pathetic liar!"), SAY_SAY, 3000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Interesting! Last time you said you killed a cannibal!"), SAY_SAY, 7000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("I told you, I just found them."), SAY_SAY, 4500}}) + AnimInsertStepNext({func = AnimCustomFunction, args = {natives[denseNum], EmitDenseClouds, {"Left"}}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Where did you get the weapons in the forest, Dense Cloud?"), SAY_SAY, 8000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Not now, Fiery Water!"), SAY_SAY, 3000}}) + else + spyHog = natives[waterNum] + AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("What shall we do with the traitor?"), SAY_SAY, 5000}}) + AnimInsertStepNext({func = SetHealth, swh = false, args = {natives[waterNum], 26}}) + AnimInsertStepNext({func = AnimVisualGear, args = {nativePos[denseNum][1] + 50, nativePos[denseNum][2], vgtExplosion, 0, true}}) + AnimInsertStepNext({func = AnimSay, args = {natives[princessNum], loc("I can't believe what I'm hearing!"), SAY_SAY, 5500}}) + AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("You know what? I don't even regret anything!"), SAY_SAY, 7000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[princessNum], loc("In fact, you are the only one that's been acting strangely."), SAY_SAY, 8000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("Are you accusing me of something?"), SAY_SAY, 3500}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Seems like every time you take a \"walk\", the enemy find us!"), SAY_SAY, 8000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("You know...taking a stroll."), SAY_SAY, 3500}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Where have you been?!"), SAY_SAY, 3000}}) + end + if nativeRevived[waterNum] == true then + AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("You won't believe what happened to me!"), SAY_SAY, 5500}}) + end + AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("Hey, guys!"), SAY_SAY, 2000}}) + AnimInsertStepNext({func = AnimMove, args = {natives[waterNum], "Left", nativePos[denseNum][1] + 50, nativePos[denseNum][2]}}) + AnimInsertStepNext({func = AnimJump, args = {natives[waterNum], "back"}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[waterNum], "Right"}}) + AnimInsertStepNext({func = AnimMove, args = {natives[waterNum], "Left", 1228, 412}}) + AnimInsertStepNext({func = AnimJump, args = {natives[waterNum], "long"}}) + AnimInsertStepNext({func = AnimJump, args = {natives[waterNum], "long"}}) + AnimInsertStepNext({func = AnimJump, args = {natives[waterNum], "long"}}) + AnimInsertStepNext({func = AnimTurn, args = {natives[waterNum], "Left"}}) + AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("There must be a spy among us!"), SAY_SAY, 4000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[princessNum], loc("We made sure noone followed us!"), SAY_SAY, 4000}}) + AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("What? Here? How did they find us?!"), SAY_SAY, 5000}}) +end + +function AnimationSetup() + table.insert(startAnim, {func = AnimWait, args = {natives[leaksNum], 3000}}) + table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], SaySafe, {}}}) + if needRevival == true then + table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, ReviveNatives, {}}}) + table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], WonderAlive, {}}}) + table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, ExplainAlive, {}}}) + end + table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], RestoreWave, {1}}}) + table.insert(startAnim, {func = AnimOutOfNowhere, args = {cannibals[1], unpack(cannibalPos[1])}}) + table.insert(startAnim, {func = AnimOutOfNowhere, args = {cannibals[2], unpack(cannibalPos[2])}}) + table.insert(startAnim, {func = AnimOutOfNowhere, args = {cannibals[3], unpack(cannibalPos[3])}}) + table.insert(startAnim, {func = AnimWait, args = {natives[leaksNum], 1000}}) + table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], SpyDebate, {}}}) + AddSkipFunction(startAnim, SkipStartAnim, {}) +end + +function SetupWave2Anim() + for i = 7, 1, -1 do + if nativeDead[i] ~= true then + speakerHog = natives[i] + end + end + table.insert(wave2Anim, {func = AnimOutOfNowhere, args = {cannibals[4], unpack(cannibalPos[4])}}) + table.insert(wave2Anim, {func = AnimOutOfNowhere, args = {cannibals[5], unpack(cannibalPos[5])}}) + table.insert(wave2Anim, {func = AnimOutOfNowhere, args = {cannibals[6], unpack(cannibalPos[6])}}) + table.insert(wave2Anim, {func = AnimSay, args = {speakerHog, loc("Look out! There's more of them!"), SAY_SHOUT, 5000}}) + AddSkipFunction(wave2Anim, SkipWave2Anim, {}) +end + +function SetupWave2DeadAnim() + for i = 7, 1, -1 do + if nativeDead[i] ~= true then + deployedHog = natives[i] + end + end + if nativeDead[wiseNum] ~= true and band(GetState(natives[wiseNum]), gstDrowning) == 0 then + if nativesNum > 1 then + table.insert(wave2DeadAnim, {func = AnimWait, args = {natives[wiseNum], 1500}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("What a strange feeling!"), SAY_THINK, 3000}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I need to warn the others."), SAY_THINK, 3000}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("If only I had a way..."), SAY_THINK, 3000}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("Oh, silly me! I forgot that I'm the shaman."), SAY_THINK, 6000}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], TeleportNatives, {}}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], TurnNatives, {natives[wiseNum]}}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], CondNeedToTurn, {natives[wiseNum], deployedHog}}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I sense another wave of cannibals heading our way!"), SAY_SAY, 6500}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("We need to prevent their arrival!"), SAY_SAY, 4500}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("Go, quick!"), SAY_SAY, 2500}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], DeployHog, {}}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], RestoreCyborg, {}}}) + table.insert(wave2DeadAnim, {func = AnimOutOfNowhere, swh = false, args = {cyborg, cyborgPos2[1], cyborgPos2[2]}}) + table.insert(wave2DeadAnim, {func = AnimTurn, args = {cyborg, "Left"}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, IsolateNatives, {}}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, PutCGI, {}}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I want to see how it handles this!"), SAY_SAY, 6000}}) + table.insert(wave2DeadAnim, {func = AnimSwitchHog, args = {deployedHog}}) + table.insert(wave2DeadAnim, {func = AnimDisappear, args = {cyborg, 0, 0}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, DeployHog, {}}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborg, {}}}) + else + table.insert(wave2DeadAnim, {func = AnimWait, args = {natives[wiseNum], 1500}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("What a strange feeling!"), SAY_THINK, 3000}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I sense another wave of cannibals heading my way!"), SAY_THINK, 6500}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I need to prevent their arrival!"), SAY_THINK, 4500}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("If only I had a way..."), SAY_THINK, 3000}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("Oh, silly me! I forgot that I'm the shaman."), SAY_THINK, 6000}}) + end + else + table.insert(wave2DeadAnim, {func = AnimWait, args = {cyborg, 1500}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, RestoreCyborg, {}}}) + table.insert(wave2DeadAnim, {func = AnimOutOfNowhere, args = {cyborg, cyborgPos2[1], cyborgPos2[2]}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, TeleportNatives, {}}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, TurnNatives, {cyborg}}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("Oh, my! This is even more entertaining than I've expected!"), SAY_SAY, 7500}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("You might want to find a way to instantly kill arriving cannibals!"), SAY_SAY, 8000}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I believe there's more of them."), SAY_SAY, 4000}}) + if nativesNum > 1 then + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], RestoreCyborg, {}}}) + table.insert(wave2DeadAnim, {func = AnimOutOfNowhere, swh = false, args = {cyborg, cyborgPos2[1], cyborgPos2[2]}}) + table.insert(wave2DeadAnim, {func = AnimTurn, args = {cyborg, "Left"}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, IsolateNatives, {}}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, PutCGI, {}}}) + table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I want to see how it handles this!"), SAY_SAY, 6000}}) + end + table.insert(wave2DeadAnim, {func = AnimSwitchHog, args = {deployedHog}}) + table.insert(wave2DeadAnim, {func = AnimDisappear, swh = false, args = {cyborg, 0, 0}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {deployedHog, DeployHog, {}}}) + table.insert(wave2DeadAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborg, {}}}) + end + AddSkipFunction(wave2DeadAnim, SkipWave2DeadAnim, {}) +end + +function IsolateNatives() + PlaceGirder(710, 299, 6) + PlaceGirder(690, 299, 6) + PlaceGirder(761, 209, 4) + PlaceGirder(921, 209, 4) + PlaceGirder(1081, 209, 4) + PlaceGirder(761, 189, 4) + PlaceGirder(921, 189, 4) + PlaceGirder(1081, 189, 4) + PlaceGirder(761, 169, 4) + PlaceGirder(921, 169, 4) + PlaceGirder(1081, 169, 4) + PlaceGirder(761, 149, 4) + PlaceGirder(921, 149, 4) + PlaceGirder(1081, 149, 4) + PlaceGirder(761, 129, 4) + PlaceGirder(921, 129, 4) + PlaceGirder(1081, 129, 4) + PlaceGirder(1120, 261, 2) + PlaceGirder(1140, 261, 2) + PlaceGirder(1160, 261, 2) + AddAmmo(deployedHog, amDEagle, 0) + AddAmmo(deployedHog, amFirePunch, 0) +end + +function PutCGI() + AddVisualGear(710, 299, vgtExplosion, 0, true) + AddVisualGear(690, 299, vgtExplosion, 0, true) + AddVisualGear(761, 209, vgtExplosion, 0, true) + AddVisualGear(921, 209, vgtExplosion, 0, true) + AddVisualGear(1081, 209, vgtExplosion, 0, true) + AddVisualGear(761, 189, vgtExplosion, 0, true) + AddVisualGear(921, 189, vgtExplosion, 0, true) + AddVisualGear(1081, 189, vgtExplosion, 0, true) + AddVisualGear(761, 169, vgtExplosion, 0, true) + AddVisualGear(921, 169, vgtExplosion, 0, true) + AddVisualGear(1081, 169, vgtExplosion, 0, true) + AddVisualGear(761, 149, vgtExplosion, 0, true) + AddVisualGear(921, 149, vgtExplosion, 0, true) + AddVisualGear(1081, 149, vgtExplosion, 0, true) + AddVisualGear(761, 129, vgtExplosion, 0, true) + AddVisualGear(921, 129, vgtExplosion, 0, true) + AddVisualGear(1081, 129, vgtExplosion, 0, true) + AddVisualGear(1120, 261, vgtExplosion, 0, true) + AddVisualGear(1140, 261, vgtExplosion, 0, true) + AddVisualGear(1160, 261, vgtExplosion, 0, true) +end + +function TeleportNatives() + nativePos[waterNum] = {1100, 288} + for i = 1, 7 do + if nativeDead[i] ~= true then + AnimTeleportGear(natives[i], unpack(nativePos[i])) + end + end +end + +function TurnNatives(hog) + for i = 1, 7 do + if nativeDead[i] == false then + if GetX(natives[i]) < GetX(hog) then + AnimTurn(natives[i], "Right") + else + AnimTurn(natives[i], "Left") + end + end + end +end + +function DeployHog() + AnimSwitchHog(deployedHog) + AnimTeleportGear(deployedHog, unpack(deployedPos)) + if deployedHog ~= natives[wiseNum] then + AnimSay(deployedHog, loc("Why me?!"), SAY_THINK, 2000) + end +end + +function SetupAfterChoiceAnim() + for i = 7, 1, -1 do + if nativeDead[i] ~= true then + if natives[i] ~= spyHog then + speakerHog = natives[i] + end + end + end + if choice == choiceEliminate then + table.insert(afterChoiceAnim, {func = AnimWait, args = {speakerHog, 1500}}) + table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("He won't be selling us out anymore!"), SAY_SAY, 6000}}) + if nativeDead[princessNum] ~= true and m4ChiefDead == 1 then + table.insert(afterChoiceAnim, {func = AnimSay, args = {natives[princessNum], loc("That's for my father!"), SAY_SAY, 3500}}) + end + table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("Let's show those cannibals what we're made of!"), SAY_SAY, 7000}}) + else + table.insert(afterChoiceAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], CondNeedToTurn, {speakerHog, spyHog}}}) + table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("We'll spare your life for now!"), SAY_SAY, 4500}}) + table.insert(afterChoiceAnim, {func = AnimSay, args = {spyHog, loc("May the spirits aid you in all your quests!"), SAY_SAY, 7000}}) + table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("I just don't want to sink to your level."), SAY_SAY, 6000}}) + table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("Let's show those cannibals what we're made of!"), SAY_SAY, 7000}}) + end + table.insert(afterChoiceAnim, {func = AnimSay, args = {natives[8], loc("Let us help, too!"), SAY_SAY, 3000}}) + table.insert(afterChoiceAnim, {func = AnimTurn, args = {speakerHog, "Left", SAY_SAY, 7000}}) + table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("No. You and the rest of the tribe are safer there!"), SAY_SAY, 7000}}) + AddSkipFunction(afterChoiceAnim, SkipAfterChoiceAnim, {}) +end + +function SetupHogDeadAnim(gear) + hogDeadAnim = {} + if nativesNum == 0 then + return + end + local hogDeadStrings = {loc("They killed " .. gear .."! You bastards!"), + loc(gear .. "! Why?!"), + loc("That was just mean!"), + loc("Oh no, not " .. gear .. "!"), + loc("Why " .. gear .. "? Why?"), + loc("What has " .. gear .. " ever done to you?!")} + table.insert(hogDeadAnim, {func = AnimSay, args = {CurrentHedgehog, hogDeadStrings[7 - nativesNum], SAY_SHOUT, 4000}}) +end + +function AfterHogDeadAnim() + freshDead = nil + TurnTimeLeft = TurnTime +end + +--------------------------Anim skip functions-------------------------- + +function AfterAfterChoiceAnim() + stage = 0 + AddEvent(CheckWaveDead, {1}, DoWaveDead, {1}, 0) + AddAmmo(speakerHog, amSwitch, 100) + SetGearMessage(speakerHog, 0) + SetState(speakerHog, 0) + TurnTimeLeft = -1 + ShowMission(loc("Backstab"), loc("The food bites back"), loc("Defeat the cannibals"), 1, 4000) + SpawnCrates() +end + +function SkipAfterChoiceAnim() + SetGearMessage(CurrentHedgehog, 0) + AnimSwitchHog(speakerHog) +end + +function AfterWave2Anim() + AddEvent(CheckWaveDead, {2}, DoWaveDead, {2}, 0) + SetGearMessage(CurrentHedgehog, 0) + SetState(CurrentHedgehog, 0) + SpawnCrates() + TurnTimeLeft = TurnTime +end + +function SkipWave2DeadAnim() + TeleportNatives() + DeployHog() + HideCyborg() +end + +function SpawnPlatformCrates() + SpawnAmmoCrate(2494, 1262, amMine) + SpawnAmmoCrate(2574, 1279, amSMine) + SpawnAmmoCrate(2575, 1267, amMine) + SpawnAmmoCrate(2617, 1259, amSMine) + SpawnUtilityCrate(2579, 1254, amMine) + SpawnUtilityCrate(2478, 1243, amMine) +end + +function AfterWave2DeadAnim() + TurnsLeft = 13 + stage = platformStage + SpawnPlatformCrates() + AddEvent(CheckTurnsOver, {}, DoTurnsOver, {3}, 0) + AddEvent(CheckWaveDead, {3}, DoWaveDead, {3}, 0) + AddEvent(CheckDeployedDead, {}, DoDeployedDead, {}, 0) + TurnTimeLeft = 0 + ShowMission(loc("Backstab"), loc("Drills"), loc("You have 12 turns until the next wave arrives.|Make sure the arriving cannibals are greeted appropriately!|If the hog dies, the cause is lost.|Hint: you might want to use some mines..."), 1, 12000) +end + +function DoTurnsOver() + stage = wave3Stage + RestoreWave(3) +end + +function SkipWave2Anim() + AnimSwitchHog(speakerHog) +end + +function SkipStartAnim() + SetGearPosition(natives[waterNum], nativePos[denseNum][1] + 50, nativePos[denseNum][2]) + RestoreWave(1) + ReviveNatives() + SetGearMessage(CurrentHedgehog, 0) + SetState(CurrentHedgehog, 0) + if m2Choice == choiceAccepted then + spyHog = natives[denseNum] + else + spyHog = natives[waterNum] + end + SetHealth(spyHog, 26) +end + +function AfterStartAnim() + AnimSwitchHog(natives[leaksNum]) + TurnTimeLeft = -1 + stage = spyKillStage + AddEvent(CheckChoice, {}, DoChoice, {}, 0) + AddEvent(CheckKilledOther, {}, DoKilledOther, {}, 0) + AddEvent(CheckChoiceRefuse, {}, DoChoiceRefuse, {}, 0) + ShowMission(loc("Backstab"), loc("Judas"), loc("Kill the traitor...or spare his life!|Kill him or press [Precise]!"), 1, 8000) + ---------------------- + SetHealth(natives[leaksNum], 1) +end + +-----------------------------Events------------------------------------ +function CheckTurnsOver() + return TurnsLeft == 0 +end + +function CheckDeployedDead() + return deployedDead +end + +function DoDeployedDead() + ShowMission(loc("Backstab"), loc("Brutus"), loc("You have failed to save the tribe!"), 0, 6000) + ParseCommand("teamgone " .. loc("Natives")) + ParseCommand("teamgone " .. loc("Tribe")) + TurnTimeLeft = 0 +end + +function CheckChoice() + return choice ~= 0 and tmpVar == 0 +end + +function CheckDeaths() + for i = 1, 7 do + if natives[i] ~= spyHog and band(GetState(natives[i]), gstAttacked) ~= 0 then + return true + end + end + return false +end + +function DoChoice() + RemoveEventFunc(CheckChoiceRefuse) + SetupAfterChoiceAnim() + AddAnim(afterChoiceAnim) + AddFunction({func = AfterAfterChoiceAnim, args = {}}) +end + +function CheckChoiceRefuse() + return highJumped == true and StoppedGear(CurrentHedgehog) +end + +function DoChoiceRefuse() + choice = choiceSpare +end + +function CheckKilledOther() + if stage ~= spyKillStage then + return false + end + return (nativesNum < startNativesNum and choice ~= choiceEliminate) or + (nativesNum < startNativesNum - 1 and choice == choiceEliminate) +end + +function DoKilledOther() + ShowMission(loc("Backstab"), loc("Brutus"), loc("You have killed an innocent hedgehog!"), 0, 6000) + ParseCommand("teamgone " .. loc("Natives")) + ParseCommand("teamgone " .. loc("Tribe")) + TurnTimeLeft = 0 +end + +function CheckWaveDead(index) + for i = (index - 1) * 3 + 1, index * 3 do + if cannibalDead[i] ~= true or CurrentHedgehog == cannibals[i] then + return false + end + end + return true +end + +function DoWaveDead(index) + TurnTimeLeft = 0 + if index == 1 then + RestoreWave(2) + SetupWave2Anim() + AddAnim(wave2Anim) + AddFunction({func = AfterWave2Anim, args = {}}) + elseif index == 2 then + SetupWave2DeadAnim() + AddAnim(wave2DeadAnim) + AddFunction({func = AfterWave2DeadAnim, args = {}}) + elseif index == 3 then + HideNatives() + SetupWave3DeadAnim() + AddAnim(wave3DeadAnim) + AddFunction({func = AfterWave3DeadAnim, args = {}}) + end +end + +function HideNatives() + for i = 1, 9 do + if nativeDead[i] ~= true and natives[i] ~= deployedHog then + if nativeHidden[i] ~= true then + HideHog(natives[i]) + nativeHidden[i] = true + end + end + end +end + +function SetupWave3DeadAnim() + table.insert(wave3DeadAnim, {func = AnimTurn, args = {deployedHog, "Left"}}) + table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("That ought to show them!"), SAY_SAY, 4000}}) + table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("Guys, do you think there's more of them?"), SAY_SHOUT, 7000}}) + table.insert(wave3DeadAnim, {func = AnimVisualGear, args = {deployedHog, unpack(nativePos[wiseNum]), vgtFeather, 0, true, true}}) + table.insert(wave3DeadAnim, {func = AnimWait, args = {deployedHog, 1000}}) + table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("Where are they?!"), SAY_THINK, 3000}}) + table.insert(wave3DeadAnim, {func = AnimCustomFunction, args = {deployedHog, RestoreCyborg, {}}}) + table.insert(wave3DeadAnim, {func = AnimOutOfNowhere, args = {cyborg, 4040, 782}}) + table.insert(wave3DeadAnim, {func = AnimSay, args = {cyborg, loc("These primitive people are so funny!"), SAY_THINK, 6500}}) + table.insert(wave3DeadAnim, {func = AnimMove, args = {cyborg, "Right", 4060, 0}}) + table.insert(wave3DeadAnim, {func = AnimCustomFunction, args = {deployedHog, HideCyborg, {}}}) + table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("I need to find the others!"), SAY_THINK, 4500}}) + table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("I have to follow that alien."), SAY_THINK, 4500}}) +end + +function SkipWave3DeadAnim() + AnimSwitchHog(deployedHog) +end + +function AfterWave3DeadAnim() + if nativeDead[leaksNum] == true then + SaveCampaignVar("M5LeaksDead", "1") + else + SaveCampaignVar("M5LeaksDead", "0") + end + if nativeDead[denseNum] == true then + SaveCampaignVar("M5DenseDead", "1") + else + SaveCampaignVar("M5DenseDead", "0") + end + if nativeDead[waterNum] == true then + SaveCampaignVar("M5WaterDead", "1") + else + SaveCampaignVar("M5WaterDead", "0") + end + if nativeDead[buffaloNum] == true then + SaveCampaignVar("M5BuffaloDead", "1") + else + SaveCampaignVar("M5BuffaloDead", "0") + end + if nativeDead[princessNum] == true then + SaveCampaignVar("M5PrincessDead", "1") + else + SaveCampaignVar("M5PrincessDead", "0") + end + if nativeDead[wiseNum] == true then + SaveCampaignVar("M5WiseDead", "1") + else + SaveCampaignVar("M5WiseDead", "0") + end + if nativeDead[chiefNum] == true then + SaveCampaignVar("M5ChiefDead", "1") + else + SaveCampaignVar("M5ChiefDead", "0") + end + SaveCampaignVar("M5Choice", "" .. choice) + SaveCampaignVar("Progress", "5") + + for i = 1, 7 do + if natives[i] == deployedHog then + SaveCampaignVar("M5DeployedNum", "" .. i) + end + end + + ParseCommand("teamgone " .. loc("Tribe")) + ParseCommand("teamgone " .. loc("Assault Team")) + ParseCommand("teamgone " .. loc("Reinforcements")) + ParseCommand("teamgone " .. loc("011101001")) + TurnTimeLeft = 0 +end + +-----------------------------Misc-------------------------------------- + +function SpawnCrates() + SpawnAmmoCrate(0, 0, amDrill) + SpawnAmmoCrate(0, 0, amGrenade) + SpawnAmmoCrate(0, 0, amBazooka) + SpawnAmmoCrate(0, 0, amDynamite) + SpawnAmmoCrate(0, 0, amGrenade) + SpawnAmmoCrate(0, 0, amMine) + SpawnAmmoCrate(0, 0, amShotgun) + SpawnAmmoCrate(0, 0, amFlamethrower) + SpawnAmmoCrate(0, 0, amMolotov) + SpawnAmmoCrate(0, 0, amSMine) + SpawnAmmoCrate(0, 0, amMortar) + SpawnUtilityCrate(0, 0, amRope) + SpawnUtilityCrate(0, 0, amRope) + SpawnUtilityCrate(0, 0, amParachute) + SpawnUtilityCrate(0, 0, amParachute) + SetHealth(SpawnHealthCrate(0, 0), 25) + SetHealth(SpawnHealthCrate(0, 0), 25) + SetHealth(SpawnHealthCrate(0, 0), 25) + SetHealth(SpawnHealthCrate(0, 0), 25) + SetHealth(SpawnHealthCrate(0, 0), 25) + SetHealth(SpawnHealthCrate(0, 0), 25) +end + + +function RestoreWave(index) + for i = (index - 1) * 3 + 1, index * 3 do + if cannibalHidden[i] == true then + RestoreHog(cannibals[i]) + FollowGear(cannibals[i]) + cannibalHidden[i] = false + end + end +end + +function GetVariables() + m2DenseDead = tonumber(GetCampaignVar("M2DenseDead")) + m2Choice = tonumber(GetCampaignVar("M2Choice")) + m4DenseDead = tonumber(GetCampaignVar("M4DenseDead")) + m4LeaksDead = tonumber(GetCampaignVar("M4LeaksDead")) + m4ChiefDead = tonumber(GetCampaignVar("M4ChiefDead")) + m4WaterDead = tonumber(GetCampaignVar("M4WaterDead")) + m4BuffaloDead = tonumber(GetCampaignVar("M4BuffaloDead")) +end + +function HideCyborg() + if cyborgHidden == false then + HideHog(cyborg) + cyborgHidden = true + end +end + +function RestoreCyborg() + if cyborgHidden == true then + RestoreHog(cyborg) + cyborgHidden = false + end +end + +function SetupPlace() + startElimination = 1 + HideHog(cyborg) + cyborgHidden = true + for i = 1, 9 do + HideHog(cannibals[i]) + cannibalHidden[i] = true + end + if m4LeaksDead == 1 then + HideHog(natives[leaksNum]) + nativeHidden[leaksNum] = true + needRevival = true + end + if m4DenseDead == 1 then + if m2Choice ~= choiceAccepted then + DeleteGear(natives[denseNum]) + else + HideHog(natives[denseNum]) + nativeHidden[denseNum] = true + needRevival = true + end + end + if m4WaterDead == 1 then + HideHog(natives[waterNum]) + nativeHidden[waterNum] = true + needRevival = true + end + if m4ChiefDead == 1 then + DeleteGear(natives[chiefNum]) + SetGearPosition(natives[princessNum], unpack(nativePos[buffaloNum])) + nativePos[princessNum] = nativePos[buffaloNum] + end + if m4BuffaloDead == 1 then + DeleteGear(natives[buffaloNum]) + end + startElimination = 0 + PlaceGirder(3568, 1461, 1) + PlaceGirder(440, 523, 5) + PlaceGirder(350, 441, 1) + PlaceGirder(405, 553, 5) + PlaceGirder(316, 468, 1) + PlaceGirder(1319, 168, 0) + startNativesNum = nativesNum +end + +function SetupEvents() +end + +function SetupAmmo() + AddAmmo(natives[princessNum], amSwitch, 0) +end + +function AddHogs() + AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy") + for i = 1, 7 do + natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i]) + end + nativesNum = 7 + + AddTeam(loc("Tribe"), 29438, "Bone", "Island", "HillBilly", "cm_birdy") + for i = 8, 9 do + natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i]) + end + + + AddTeam(loc("Assault Team"), 14483456, "Skull", "Island", "Pirate", "cm_vampire") + for i = 1, 6 do + cannibals[i] = AddHog(cannibalNames[i], 1, 50, "vampirichog") + end + + AddTeam(loc("Reinforcements"), 14483456, "Skull", "Island", "Pirate", "cm_vampire") + for i = 7, 9 do + cannibals[i] = AddHog(cannibalNames[i], 1, 50, "vampirichog") + end + + AddTeam(loc("011101001"), 14483456, "ring", "UFO", "Robot", "cm_star") + cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1") + + for i = 1, 9 do + SetGearPosition(natives[i], unpack(nativePos[i])) + AnimTurn(natives[i], nativeDir[i]) + end + + SetGearPosition(cyborg, 0, 0) + + for i = 1, 9 do + SetGearPosition(cannibals[i], unpack(cannibalPos[i])) + AnimTurn(cannibals[i], cannibalDir[i]) + end +end + +function CondNeedToTurn(hog1, hog2) + xl, xd = GetX(hog1), GetX(hog2) + if xl > xd then + AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}}) + elseif xl < xd then + AnimInsertStepNext({func = AnimTurn, args = {hog2, "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {hog1, "Right"}}) + end +end + +-----------------------------Main Functions---------------------------- + +function onGameInit() + Seed = 2 + GameFlags = gfSolidLand + TurnTime = 60000 + CaseFreq = 0 + MinesNum = 6 + MinesTime = 3000 + Explosives = 6 + Delay = 10 + Map = "Cave" + Theme = "Nature" + SuddenDeathTurns = 3000 + + AddHogs() + AnimInit() +end + +function onGameStart() + GetVariables() + SetupAmmo() + SetupPlace() + AnimationSetup() + SetupEvents() + AddAnim(startAnim) + AddFunction({func = AfterStartAnim, args = {}}) +end + +function onGameTick() + AnimUnWait() + if ShowAnimation() == false then + return + end + ExecuteAfterAnimations() + CheckEvents() +end + +function onGearDelete(gear) + for i = 1, 7 do + if gear == natives[i] then + nativeDead[i] = true + nativesNum = nativesNum - 1 + if startElimination == 0 then + freshDead = nativeNames[i] + end + end + end + + for i = 1, 9 do + if gear == cannibals[i] then + cannibalDead[i] = true + end + end + + if gear == spyHog and stage == spyKillStage then + freshDead = nil + choice = choiceEliminate + tmpVar = 1 + end +end + +function onGearAdd(gear) +end + +function onAmmoStoreInit() + SetAmmo(amDEagle, 9, 0, 0, 0) + SetAmmo(amSniperRifle, 4, 0, 0, 0) + SetAmmo(amFirePunch, 9, 0, 0, 0) + SetAmmo(amWhip, 9, 0, 0, 0) + SetAmmo(amBaseballBat, 9, 0, 0, 0) + SetAmmo(amHammer, 9, 0, 0, 0) + SetAmmo(amLandGun, 9, 0, 0, 0) + SetAmmo(amSnowball, 8, 0, 0, 0) + SetAmmo(amGirder, 4, 0, 0, 2) + SetAmmo(amParachute, 4, 0, 0, 2) + SetAmmo(amSwitch, 8, 0, 0, 2) + SetAmmo(amSkip, 8, 0, 0, 0) + SetAmmo(amRope, 5, 0, 0, 3) + SetAmmo(amBlowTorch, 3, 0, 0, 3) + SetAmmo(amPickHammer, 0, 0, 0, 3) + SetAmmo(amLowGravity, 0, 0, 0, 2) + SetAmmo(amDynamite, 0, 0, 0, 3) + SetAmmo(amBazooka, 4, 0, 0, 4) + SetAmmo(amGrenade, 4, 0, 0, 4) + SetAmmo(amMine, 2, 0, 0, 2) + SetAmmo(amSMine, 2, 0, 0, 2) + SetAmmo(amMolotov, 2, 0, 0, 3) + SetAmmo(amFlamethrower, 2, 0, 0, 3) + SetAmmo(amShotgun, 4, 0, 0, 4) + SetAmmo(amTeleport, 0, 0, 0, 2) + SetAmmo(amDrill, 0, 0, 0, 4) + SetAmmo(amMortar, 0, 0, 0, 4) +end + +j = 0 + +function onNewTurn() + tmpVar = 0 + if AnimInProgress() then + TurnTimeLeft = -1 + return + end + + if GetHogTeamName(CurrentHedgehog) == loc("Tribe") then + TurnTimeLeft = 0 + return + end + TurnsLeft = TurnsLeft - 1 + + if stage == spyKillStage then + if CurrentHedgehog == spyHog or GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then + TurnTimeLeft = 0 + else + SetGearMessage(CurrentHedgehog, 0) + TurnTimeLeft = -1 + end + else + if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == loc("Natives") then + SetupHogDeadAnim(freshDead) + AddAnim(hogDeadAnim) + AddFunction({func = AfterHogDeadAnim, args = {}}) + end + end +end + +function onGearDamage(gear, damage) +end + +function onPrecise() + if GameTime > 2500 then + SetAnimSkip(true) + end + if stage == spyKillStage then + highJumped = true + end +end diff -r fd91aa100ce0 -r efc75c2d3be9 share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/campaign.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/campaign.ini Thu Aug 30 12:13:24 2012 -0400 @@ -0,0 +1,22 @@ +MissionNum=5 +ResetRetry=1 + +[Mission 1] +Name=First Blood +Script=first_blood.lua + +[Mission 2] +Name=The Shadow Falls +Script=shadow.lua + +[Mission 3] +Name=The Journey Back +Script=journey.lua + +[Mission 4] +Name=United We Stand +Script=united.lua + +[Mission 5] +Name=Backstab +Script=backstab.lua diff -r fd91aa100ce0 -r efc75c2d3be9 share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua Thu Aug 30 12:13:24 2012 -0400 @@ -0,0 +1,731 @@ +loadfile(GetDataPath() .. "Scripts/Locale.lua")() +loadfile(GetDataPath() .. "Scripts/Animate.lua")() + +-----------------------------Variables--------------------------------- +startDialogue = {} +damageAnim = {} +onShroomAnim = {} +onFlowerAnim = {} +tookParaAnim = {} +tookPunchAnim = {} +onMoleHeadAnim = {} +tookRope2Anim = {} +challengeAnim = {} +challengeFailedAnim = {} +challengeCompletedAnim = {} +beforeKillAnim = {} +closeCannim = {} +cannKilledAnim = {} +cannKilledEarlyAnim = {} +princessDamagedAnim = {} +elderDamagedAnim = {} +pastMoleHeadAnim = {} + + +targets = {} +crates = {} +targXdif2 = {2755, 2638, 2921, 2973, 3162, 3067, 3062, 1300} +targYdif2 = {1197, 1537, 1646, 1857, 1804, 1173, 1167, 1183} +targXdif1 = {2749, 2909, 2770, 2836, 1558, 1305} +targYdif1 = {1179, 1313, 1734, 1441, 1152, 1259} +targetPosX = {{821, 866, 789}, {614, 656, 638}, {1238, 1237, 1200}} +targetPosY = {{1342, 1347, 1326}, {1112, 1121, 1061}, {1152, 1111, 1111}} +crateNum = {6, 8} + + +stage = 1 +cratesCollected = 0 +chalTries = 0 +targetsDestroyed = 0 +targsWave = 1 +tTime = -1 +difficulty = 0 + +cannibalVisible = false +cannibalKilles = false +youngdamaged = false +youngKilled = false +elderDamaged = false +princessDamaged = false +elderKilled = false +princessKilled = false +rope1Taken = false +paraTaken = false +rope2Taken = false +punchTaken = false +canKilled = false +desertTaken = false +challengeFailed = false +difficultyChoice = false +princessFace = "Left" +elderFace = "Left" + +goals = { + [startDialogue] = {loc("First Blood"), loc("First Steps"), loc("Press [Left] or [Right] to move around, [Enter] to jump"), 1, 4000}, + [onShroomAnim] = {loc("First Blood"), loc("A leap in a leap"), loc("Go on top of the flower"), 1, 4000}, + [onFlowerAnim] = {loc("First Blood"), loc("Hightime"), loc("Collect the crate on the right.|Hint: Select the rope, [Up] or [Down] to aim, [Space] to fire, directional keys to move.|Ropes can be fired again in the air!"), 1, 7000}, + [tookParaAnim] = {loc("First Blood"), loc("Omnivore"), loc("Get on the head of the mole"), 1, 4000}, + [onMoleHeadAnim] = {loc("First Blood"), loc("The Leap of Faith"), loc("Use the parachute ([Space] while in air) to get the next crate"), 1, 4000}, + [tookRope2Anim] = {loc("First Blood"), loc("The Rising"), loc("Do the deed"), 1, 4000}, + [tookPunchAnim] = {loc("First Blood"), loc("The Slaughter"), loc("Destroy the targets!|Hint: Select the Shoryuken and hit [Space]|P.S. You can use it mid-air."), 1, 5000}, + [challengeAnim] = {loc("First Blood"), loc("The Crate Frenzy"), loc("Collect the crates within the time limit!|If you fail, you'll have to try again."), 1, 5000}, + [challengeFailedAnim] = {loc("First Blood"), loc("The Crate Frenzy"), loc("Collect the crates within the time limit!|If you fail, you'll have to try again."), 1, 5000}, + [challengeCompletedAnim] = {loc("First Blood"), loc("The Ultimate Weapon"), loc("Destroy the targets!|Hint: [Up], [Down] to aim, [Space] to shoot"), 1, 5000}, + [beforeKillAnim] = {loc("First Blood"), loc("The First Blood"), loc("Kill the cannibal!"), 1, 5000}, + [closeCannim] = {loc("First Blood"), loc("The First Blood"), loc("KILL IT!"), 1, 5000} +} +-----------------------------Animations-------------------------------- +function Skipanim(anim) + AnimSwitchHog(youngh) + if goals[anim] ~= nil then + ShowMission(unpack(goals[anim])) + end + if anim == startDialogue then + HogTurnLeft(princess, false) + end +end + +function SkipDamageAnim(anim) + SwitchHog(youngh) + SetInputMask(0xFFFFFFFF) +end + +function SkipOnShroom() + Skipanim(onShroomAnim) + SetGearPosition(elderh, 2700, 1278) +end + +function AnimationSetup() + AddSkipFunction(damageAnim, SkipDamageAnim, {damageAnim}) + table.insert(damageAnim, {func = AnimWait, args = {youngh, 500}, skipFunc = Skipanim, skipArgs = damageAnim}) + table.insert(damageAnim, {func = AnimSay, args = {elderh, loc("Watch your steps, young one!"), SAY_SAY, 2000}}) + table.insert(damageAnim, {func = AnimGearWait, args = {youngh, 500}}) + + AddSkipFunction(princessDamagedAnim, SkipDamageAnim, {princessDamagedAnim}) + table.insert(princessDamagedAnim, {func = AnimWait, args = {princess, 500}, skipFunc = Skipanim, skipArgs = princessDamagedAnim}) + table.insert(princessDamagedAnim, {func = AnimSay, args = {princess, loc("Why do men keep hurting me?"), SAY_THINK, 3000}}) + table.insert(princessDamagedAnim, {func = AnimGearWait, args = {youngh, 500}}) + + AddSkipFunction(elderDamagedAnim, SkipDamageAnim, {elderDamagedAnim}) + table.insert(elderDamagedAnim, {func = AnimWait, args = {elderh, 500}, skipFunc = Skipanim, skipArgs = elderDamagedAnim}) + table.insert(elderDamagedAnim, {func = AnimSay, args = {elderh, loc("Violence is not the answer to your problems!"), SAY_SAY, 3000}}) + table.insert(elderDamagedAnim, {func = AnimGearWait, args = {youngh, 500}}) + + AddSkipFunction(startDialogue, Skipanim, {startDialogue}) + table.insert(startDialogue, {func = AnimWait, args = {youngh, 3500}, skipFunc = Skipanim, skipArgs = startDialogue}) + table.insert(startDialogue, {func = AnimCaption, args = {youngh, loc("Once upon a time, on an island with great natural resources, lived two tribes in heated conflict..."), 5000}}) + table.insert(startDialogue, {func = AnimCaption, args = {youngh, loc("One tribe was peaceful, spending their time hunting and training, enjoying the small pleasures of life..."), 5000}}) + table.insert(startDialogue, {func = AnimCaption, args = {youngh, loc("The other one were all cannibals, spending their time eating the organs of fellow hedgehogs..."), 5000}}) + table.insert(startDialogue, {func = AnimCaption, args = {youngh, loc("And so it began..."), 1000}}) + table.insert(startDialogue, {func = AnimSay, args = {elderh, loc("What are you doing at a distance so great, young one?"), SAY_SHOUT, 4000}}) + table.insert(startDialogue, {func = AnimSay, args = {elderh, loc("Come closer, so that your training may continue!"), SAY_SHOUT, 6000}}) + table.insert(startDialogue, {func = AnimSay, args = {youngh, loc("This is it! It's time to make Fell From Heaven fall for me..."), SAY_THINK, 6000}}) + table.insert(startDialogue, {func = AnimJump, args = {youngh, "long"}}) + table.insert(startDialogue, {func = AnimTurn, args = {princess, "Right"}}) + table.insert(startDialogue, {func = AnimSwitchHog, args = {youngh}}) + table.insert(startDialogue, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("First Steps"), loc("Press [Left] or [Right] to move around, [Enter] to jump"), 1, 4000}}) + + AddSkipFunction(onShroomAnim, SkipOnShroom, {onShroomAnim}) + table.insert(onShroomAnim, {func = AnimSay, args = {elderh, loc("I can see you have been training diligently."), SAY_SAY, 4000}, skipFunc = Skipanim, skipArgs = onShroomAnim}) + table.insert(onShroomAnim, {func = AnimSay, args = {elderh, loc("The wind whispers that you are ready to become familiar with tools, now..."), SAY_SAY, 4000}}) + table.insert(onShroomAnim, {func = AnimSay, args = {elderh, loc("Open that crate and we will continue!"), SAY_SAY, 5000}}) + table.insert(onShroomAnim, {func = AnimMove, args = {elderh, "Right", 2700, 0}}) + table.insert(onShroomAnim, {func = AnimTurn, args = {elderh, "Left"}}) + table.insert(onShroomAnim, {func = AnimSay, args = {princess, loc("He moves like an eagle in the sky."), SAY_THINK, 4000}}) + table.insert(onShroomAnim, {func = AnimSwitchHog, args = {youngh}}) + table.insert(onShroomAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("A leap in a leap"), loc("Go on top of the flower"), 1, 4000}}) + + AddSkipFunction(onFlowerAnim, Skipanim, {onFlowerAnim}) + table.insert(onFlowerAnim, {func = AnimSay, args = {elderh, loc("See that crate farther on the right?"), SAY_SAY, 4000}}) + table.insert(onFlowerAnim, {func = AnimSay, args = {elderh, loc("Swing, Leaks A Lot, on the wings of the wind!"), SAY_SAY, 6000}}) + table.insert(onFlowerAnim, {func = AnimSay, args = {princess, loc("His arms are so strong!"), SAY_THINK, 4000}}) + table.insert(onFlowerAnim, {func = AnimSwitchHog, args = {youngh}}) + table.insert(onFlowerAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("Hightime"), loc("Collect the crate on the right.|Hint: Select the rope, [Up] or [Down] to aim, [Space] to fire, directional keys to move.|Ropes can be fired again in the air!"), 1, 7000}}) + + AddSkipFunction(tookParaAnim, Skipanim, {tookParaAnim}) + table.insert(tookParaAnim, {func = AnimGearWait, args = {youngh, 1000}, skipFunc = Skipanim, skipArgs = tookParaAnim}) + table.insert(tookParaAnim, {func = AnimSay, args = {elderh, loc("Use the rope to get on the head of the mole, young one!"), SAY_SHOUT, 4000}}) + table.insert(tookParaAnim, {func = AnimSay, args = {elderh, loc("Worry not, for it is a peaceful animal! There is no reason to be afraid..."), SAY_SHOUT, 5000}}) + table.insert(tookParaAnim, {func = AnimSay, args = {elderh, loc("We all know what happens when you get frightened..."), SAY_SAY, 4000}}) + table.insert(tookParaAnim, {func = AnimSay, args = {youngh, loc("So humiliating..."), SAY_SAY, 4000}}) + table.insert(tookParaAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("Omnivore"), loc("Get on the head of the mole"), 1, 4000}}) + table.insert(tookParaAnim, {func = AnimSwitchHog, args = {youngh}}) + + AddSkipFunction(onMoleHeadAnim, Skipanim, {onMoleHeadAnim}) + table.insert(onMoleHeadAnim, {func = AnimSay, args = {elderh, loc("Perfect! Now try to get the next crate without hurting yourself!"), SAY_SAY, 4000}, skipFunc = Skipanim, skipArgs = onMoleHeadAnim}) + table.insert(onMoleHeadAnim, {func = AnimSay, args = {elderh, loc("The giant umbrella from the last crate should help break the fall."), SAY_SAY, 4000}}) + table.insert(onMoleHeadAnim, {func = AnimSay, args = {princess, loc("He's so brave..."), SAY_THINK, 4000}}) + table.insert(onMoleHeadAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Leap of Faith"), loc("Use the parachute ([Space] while in air) to get the next crate"), 1, 4000}}) + table.insert(onMoleHeadAnim, {func = AnimSwitchHog, args = {youngh}}) + + AddSkipFunction(pastMoleHeadAnim, Skipanim, {pastMoleHeadAnim}) + table.insert(pastMoleHeadAnim, {func = AnimSay, args = {elderh, loc("I see you have already taken the leap of faith."), SAY_SAY, 4000}, skipFunc = Skipanim, skipArgs = pastMoleHeadAnim}) + table.insert(pastMoleHeadAnim, {func = AnimSay, args = {elderh, loc("Get that crate!"), SAY_SAY, 4000}}) + table.insert(pastMoleHeadAnim, {func = AnimSwitchHog, args = {youngh}}) + + AddSkipFunction(tookRope2Anim, Skipanim, {tookRope2Anim}) + table.insert(tookRope2Anim, {func = AnimSay, args = {elderh, loc("Impressive...you are still dry as the corpse of a hawk after a week in the desert..."), SAY_SAY, 5000}, skipFunc = Skipanim, skipArgs = tookRope2Anim}) + table.insert(tookRope2Anim, {func = AnimSay, args = {elderh, loc("You probably know what to do next..."), SAY_SAY, 4000}}) + table.insert(tookRope2Anim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Rising"), loc("Do the deed"), 1, 4000}}) + table.insert(tookRope2Anim, {func = AnimSwitchHog, args = {youngh}}) + + AddSkipFunction(tookPunchAnim, Skipanim, {tookPunchAnim}) + table.insert(tookPunchAnim, {func = AnimSay, args = {elderh, loc("It is time to practice your fighting skills."), SAY_SAY, 4000}}) + table.insert(tookPunchAnim, {func = AnimSay, args = {elderh, loc("Imagine those targets are the wolves that killed your parents! Take your anger out on them!"), SAY_SAY, 5000}}) + table.insert(tookPunchAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Slaughter"), loc("Destroy the targets!|Hint: Select the Shoryuken and hit [Space]|P.S. You can use it mid-air."), 1, 5000}}) + table.insert(tookPunchAnim, {func = AnimSwitchHog, args = {youngh}}) + + AddSkipFunction(challengeAnim, Skipanim, {challengeAnim}) + table.insert(challengeAnim, {func = AnimSay, args = {elderh, loc("I hope you are prepared for a small challenge, young one."), SAY_SAY, 4000}, skipFunc = Skipanim, skipArgs = challengeAnim}) + table.insert(challengeAnim, {func = AnimSay, args = {elderh, loc("Your movement skills will be evaluated now."), SAY_SAY, 4000}}) + table.insert(challengeAnim, {func = AnimSay, args = {elderh, loc("Collect all the crates, but remember, our time in this life is limited!"), SAY_SAY, 4000}}) + table.insert(challengeAnim, {func = AnimSay, args = {elderh, loc("How difficult would you like it to be?")}}) + table.insert(challengeAnim, {func = AnimSwitchHog, args = {youngh}}) + table.insert(challengeAnim, {func = AnimWait, args = {youngh, 500}}) + + AddSkipFunction(challengeFailedAnim, Skipanim, {challengeFailedAnim}) + table.insert(challengeFailedAnim, {func = AnimSay, args = {elderh, loc("Hmmm...perhaps a little more time will help."), SAY_SAY, 4000}, skipFunc = Skipanim, skipArgs = challengeFailedAnim}) + table.insert(challengeFailedAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Crate Frenzy"), loc("Collect the crates within the time limit!|If you fail, you'll have to try again."), 1, 5000}}) + table.insert(challengeFailedAnim, {func = AnimSwitchHog, args = {youngh}}) + + AddSkipFunction(challengeCompletedAnim, Skipanim, {challengeCompletedAnim}) + table.insert(challengeCompletedAnim, {func = AnimSay, args = {elderh, loc("The spirits of the ancerstors are surely pleased, Leaks A Lot."), SAY_SAY, 4000}, skipFunc = Skipanim, skipArgs = challengeCompletedAnim}) + table.insert(challengeCompletedAnim, {func = AnimSay, args = {elderh, loc("You have proven yourself worthy to see our most ancient secret!"), SAY_SAY, 4000}}) + table.insert(challengeCompletedAnim, {func = AnimSay, args = {elderh, loc("The weapon in that last crate was bestowed upon us by the ancients!"), SAY_SAY, 4000}}) + table.insert(challengeCompletedAnim, {func = AnimSay, args = {elderh, loc("Use it with precaution!"), SAY_SAY, 4000}}) + table.insert(challengeCompletedAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Ultimate Weapon"), loc("Destroy the targets!|Hint: [Up], [Down] to aim, [Space] to shoot"), 1, 5000}}) + table.insert(challengeCompletedAnim, {func = AnimSwitchHog, args = {youngh}}) + + AddSkipFunction(beforeKillAnim, Skipanim, {beforeKillAnim}) + table.insert(beforeKillAnim, {func = AnimSay, args = {elderh, loc("What do my faulty eyes observe? A spy!"), SAY_SHOUT, 4000}, skipFunc = Skipanim, skipArgs = beforeKillAnim}) + table.insert(beforeKillAnim, {func = AnimFollowGear, args = {cannibal}}) + table.insert(beforeKillAnim, {func = AnimWait, args = {cannibal, 1000}}) + table.insert(beforeKillAnim, {func = AnimSay, args = {elderh, loc("Destroy him, Leaks A Lot! He is responsible for the deaths of many of us!"), SAY_SHOUT, 4000}}) + table.insert(beforeKillAnim, {func = AnimSay, args = {cannibal, loc("Oh, my!"), SAY_THINK, 4000}}) + table.insert(beforeKillAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The First Blood"), loc("Kill the cannibal!"), 1, 5000}}) + table.insert(beforeKillAnim, {func = AnimSwitchHog, args = {youngh}}) + + AddSkipFunction(closeCannim, Skipanim, {closeCannim}) + table.insert(closeCannim, {func = AnimSay, args = {elderh, loc("I see you would like his punishment to be more...personal..."), SAY_SAY, 4000}, skipFunc = Skipanim, skipArgs = closeCannim}) + table.insert(closeCannim, {func = AnimSay, args = {cannibal, loc("I'm certain that this is a misunderstanding, fellow hedgehogs!"), SAY_SAY, 4000}}) + table.insert(closeCannim, {func = AnimSay, args = {cannibal, loc("If only I were given a chance to explain my being here..."), SAY_SAY, 4000}}) + table.insert(closeCannim, {func = AnimSay, args = {elderh, loc("Do not let his words fool you, young one! He will stab you in the back as soon as you turn away!"), SAY_SAY, 6000}}) + table.insert(closeCannim, {func = AnimSay, args = {elderh, loc("Here...pick your weapon!"), SAY_SAY, 5000}}) + table.insert(closeCannim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The First Blood"), loc("KILL IT!"), 1, 5000}}) + table.insert(closeCannim, {func = AnimSwitchHog, args = {youngh}}) + + table.insert(cannKilledAnim, {func = AnimSay, args = {elderh, loc("Yes, yeees! You are now ready to enter the real world!"), SAY_SHOUT, 6000}}) + + table.insert(cannKilledEarlyAnim, {func = AnimSay, args = {elderh, loc("What?! A cannibal? Here? There is no time to waste! Come, you are prepared."), SAY_SHOUT, 4000}}) +end +-----------------------------Events------------------------------------ +function CheckNeedToTurn(gear) + if gear == princess then + if princessKilled ~= true then + if (GetX(princess) > GetX(youngh) and princessFace == "Right") + or (GetX(princess) < GetX(youngh) and princessFace == "Left") then + --if (GetX(princess) > GetX(youngh)) + -- or (GetX(princess) < GetX(youngh)) then + return true + end + end + else + if elderKilled ~= true then + if (GetX(elderh) > GetX(youngh) and elderFace == "Right") + or (GetX(elderh) < GetX(youngh) and elderFace == "Left") then + return true + end + end + end + return false +end + +function DoNeedToTurn(gear) + if gear == princess then + if GetX(princess) > GetX(youngh) then + HogTurnLeft(princess, true) + princessFace = "Left" + elseif GetX(princess) < GetX(youngh) then + HogTurnLeft(princess, false) + princessFace = "Right" + end + else + if GetX(elderh) > GetX(youngh) then + HogTurnLeft(elderh, true) + elderFace = "Left" + elseif GetX(elderh) < GetX(youngh) then + HogTurnLeft(elderh, false) + elderFace = "Right" + end + end +end + +function CheckDamage() + return youngdamaged and StoppedGear(youngh) +end + +function DoOnDamage() + AddAnim(damageAnim) + youngdamaged = false + AddFunction({func = ResetTurnTime, args = {}}) +end + +function CheckDeath() + return youngKilled +end + +function DoDeath() + RemoveEventFunc(CheckKilledOthers) + RemoveEventFunc(CheckDamage) + RemoveEventFunc(CheckDamagedOthers) + FinishThem() + ShowMission(loc("First Blood"), loc("The wasted youth"), loc("Leaks A Lot gave his life for his tribe! He should have survived!"), 2, 4000) +end + +function CheckDamagedOthers() + return (princessDamaged and StoppedGear(princess)) or (elderDamaged and StoppedGear(elderh)) +end + +function CheckKilledOthers() + return princessKilled or elderKilled +end + +function DoOnDamagedOthers() + if princessDamaged then + AddAnim(princessDamagedAnim) + end + if elderDamaged then + AddAnim(elderDamagedAnim) + end + elderDamaged = false + princessDamaged = false + AddFunction({func = ResetTurnTime, args = {}}) +end + +function DoKilledOthers() + AddCaption(loc("After Leaks A Lot betrayed his tribe, he joined the cannibals...")) + FinishThem() +end + +function CheckMovedUntilJump() + return GetX(youngh) >= 2343 +end + +function DoMovedUntilJump() + ShowMission(loc("First Blood"), loc("Step By Step"), loc("Hint: Double Jump - Press [Backspace] twice"), -amSkip, 0) + AddEvent(CheckOnShroom, {}, DoOnShroom, {}, 0) +end + +function CheckOnShroom() + return GetX(youngh) >= 2461 and StoppedGear(youngh) +end + +function DoOnShroom() + ropeCrate1 = SpawnUtilityCrate(2751, 1194, amRope) + AddAnim(onShroomAnim) + AddEvent(CheckOnFlower, {}, DoOnFlower, {}, 0) +end + +function CheckOnFlower() + return rope1Taken and StoppedGear(youngh) +end + +function DoOnFlower() + AddAmmo(youngh, amRope, 100) + paraCrate = SpawnUtilityCrate(3245, 1758, amParachute) + AddAnim(onFlowerAnim) + AddEvent(CheckTookParaCrate, {}, DoTookParaCrate, {}, 0) +end + +function CheckTookParaCrate() + return paraTaken and StoppedGear(youngh) +end + +function DoTookParaCrate() + AddAmmo(youngh, amParachute, 100) + AddAnim(tookParaAnim) + AddEvent(CheckOnMoleHead, {}, DoOnMoleHead, {}, 0) + AddEvent(CheckPastMoleHead, {}, DoPastMoleHead, {}, 0) +end + +function CheckOnMoleHead() + x = GetX(youngh) + return x >= 3005 and x <= 3126 and StoppedGear(youngh) +end + +function CheckPastMoleHead() + x = GetX(youngh) + y = GetY(youngh) + return x < 3005 and y > StoppedGear(youngh) +end + +function DoPastMoleHead() + RemoveEventFunc(CheckOnMoleHead) + ropeCrate2 = SpawnUtilityCrate(2782, 1720, amRope) + AddAmmo(youngh, amRope, 0) + AddAnim(pastMoleHeadAnim) + AddEvent(CheckTookRope2, {}, DoTookRope2, {}, 0) +end + +function DoOnMoleHead() + RemoveEventFunc(CheckPastMoleHead) + ropeCrate2 = SpawnUtilityCrate(2782, 1720, amRope) + AddAmmo(youngh, amRope, 0) + AddAnim(onMoleHeadAnim) + AddEvent(CheckTookRope2, {}, DoTookRope2, {}, 0) +end + +function CheckTookRope2() + return rope2Taken and StoppedGear(youngh) +end + +function DoTookRope2() + AddAmmo(youngh, amRope, 100) + AddAnim(tookRope2Anim) + punchCrate = SpawnAmmoCrate(2460, 1321, amFirePunch) + AddEvent(CheckTookPunch, {}, DoTookPunch, {}) +end + +function CheckTookPunch() + return punchTaken and StoppedGear(youngh) +end + +function DoTookPunch() + AddAmmo(youngh, amFirePunch, 100) + AddAmmo(youngh, amRope, 0) + AddAnim(tookPunchAnim) + targets[1] = AddGear(1594, 1185, gtTarget, 0, 0, 0, 0) + targets[2] = AddGear(2188, 1314, gtTarget, 0, 0, 0, 0) + targets[3] = AddGear(1961, 1318, gtTarget, 0, 0, 0, 0) + targets[4] = AddGear(1961, 1200, gtTarget, 0, 0, 0, 0) + targets[5] = AddGear(1800, 900, gtTarget, 0, 0, 0, 0) + AddEvent(CheckTargDestroyed, {}, DoTargDestroyed, {}, 0) +end + +function CheckTargDestroyed() + return targetsDestroyed == 5 and StoppedGear(youngh) +end + +function DoTargDestroyed() + AddAnim(challengeAnim) + targetsDestroyed = 0 + AddFunction({func = SetChoice, args = {}}) + ropeCrate3 = SpawnAmmoCrate(2000, 1200, amRope) + AddEvent(CheckTookRope3, {}, AddAmmo, {youngh, amRope, 100}, 0) + AddEvent(CheckCratesColled, {}, DoCratesColled, {}, 0) + AddEvent(CheckChallengeWon, {}, DoChallengeWon, {}, 0) + AddEvent(CheckTimesUp, {}, DoTimesUp, {}, 1) +end + +function CheckChoice() + return difficulty ~= 0 +end + +function DoChoice() + difficultyChoice = false + SetInputMask(0xFFFFFFFF) + StartChallenge(120000 + chalTries * 20000) +end + +function CheckCratesColled() + return cratesCollected == crateNum[difficulty] +end + +function DoCratesColled() + RemoveEventFunc(CheckTimesUp) + TurnTimeLeft = -1 + AddCaption(loc("As the challenge was completed, Leaks A Lot set foot on the ground...")) +end + +function CheckChallengeWon() + return cratesCollected == crateNum[difficulty] and StoppedGear(youngh) +end + +function DoChallengeWon() + desertCrate = SpawnAmmoCrate(1240, 1212, amDEagle) + AddAnim(challengeCompletedAnim) + AddEvent(CheckDesertColled, {}, DoDesertColled, {}, 0) +end + +function CheckTookRope3() + return rope3Taken +end + +function CheckTimesUp() + return TurnTimeLeft == 100 +end + +function DoTimesUp() + challengeFailed = true + DeleteGear(crates[1]) + TurnTimeLeft = -1 + AddCaption(loc("And so happenned that Leaks A Lot failed to complete the challenge! He landed, pressured by shame...")) + AddEvent(CheckChallengeFailed, {}, DoChallengeFailed, {}, 0) +end + +function CheckChallengeFailed() + return challengeFailed and StoppedGear(youngh) +end + +function DoChallengeFailed() + challengeFailed = false + AddAnim(challengeFailedAnim) + chalTries = chalTries + 1 + difficulty = 0 + AddFunction({func = SetChoice, args = {}}) +end + +function CheckDesertColled() + return desertTaken and StoppedGear(youngh) +end + +function DoDesertColled() + AddAmmo(youngh, amDEagle, 100) + PutTargets(1) + AddEvent(CheckTargetsKilled, {}, DoTargetsKilled, {}, 1) + AddEvent(CheckCannibalKilled, {}, DoCannibalKilledEarly, {}, 0) + ShowMission(loc("First Blood"), loc("The Bull's Eye"), loc("[Up], [Down] to aim, [Space] to shoot!"), 1, 5000) +end + +function CheckTargetsKilled() + return targetsDestroyed == 3 and StoppedGear(youngh) +end + +function DoTargetsKilled() + targetsDestroyed = 0 + targsWave = targsWave + 1 + if targsWave > 3 then + RemoveEventFunc(CheckTargetsKilled) + SetState(cannibal, gstVisible) + cannibalVisible = true + AddAnim(beforeKillAnim) + AddEvent(CheckCloseToCannibal, {}, DoCloseToCannibal, {}, 0) + AddEvent(CheckCannibalKilled, {}, DoCannibalKilled, {}, 0) + else + PutTargets(targsWave) + end +end + +function CheckCloseToCannibal() + if CheckCannibalKilled() then + return false + end + return math.abs(GetX(cannibal) - GetX(youngh)) <= 400 and StoppedGear(youngh) +end + +function DoCloseToCannibal() + AddAnim(closeCannim) + AddFunction({func = SpawnAmmoCrate, args = {targetPosX[1][1], targetPosY[1][1], amWhip}}) + AddFunction({func = SpawnAmmoCrate, args = {targetPosX[1][2], targetPosY[1][2], amBaseballBat}}) + AddFunction({func = SpawnAmmoCrate, args = {targetPosX[1][3], targetPosY[1][3], amHammer}}) +end + +function CheckCannibalKilled() + return cannibalKilled and StoppedGear(youngh) +end + +function DoCannibalKilled() + AddAnim(cannKilledAnim) + SaveCampaignVar("Progress", "1") +end + +function DoCannibalKilledEarly() + AddAnim(cannKilledEarlyAnim) + DoCannibalKilled() +end + +-----------------------------Misc-------------------------------------- +function StartChallenge(time) + cratesCollected = 0 + PutCrate(1) + TurnTimeLeft = time + ShowMission(loc("First Blood"), loc("The Crate Frenzy"), loc("Collect the crates within the time limit!|If you fail, you'll have to try again."), 1, 5000) +end + +function SetChoice() + SetInputMask(band(0xFFFFFFFF, bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLJump+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon))) + difficultyChoice = true + ShowMission(loc("First Blood"), loc("The Torment"), loc("Select difficulty: [Left] - easier or [Right] - harder"), 0, 4000) + AddEvent(CheckChoice, {}, DoChoice, {}, 0) +end + +function SetTime(time) + TurnTimeLeft = time +end + +function ResetTurnTime() + TurnTimeLeft = tTime + tTime = -1 +end + +function PutCrate(i) + if i > crateNum[difficulty] then + return + end + if difficulty == 1 then + crates[1] = SpawnAmmoCrate(targXdif1[i], targYdif1[i], amRope) + else + crates[1] = SpawnAmmoCrate(targXdif2[i], targYdif2[i], amRope) + end +end + +function PutTargets(i) + targets[1] = AddGear(targetPosX[i][1], targetPosY[i][1], gtTarget, 0, 0, 0, 0) + targets[2] = AddGear(targetPosX[i][2], targetPosY[i][2], gtTarget, 0, 0, 0, 0) + targets[3] = AddGear(targetPosX[i][3], targetPosY[i][3], gtTarget, 0, 0, 0, 0) +end + +function FinishThem() + SetHealth(elderh, 0) + SetHealth(youngh, 0) + SetHealth(princess, 0) +end +-----------------------------Main Functions---------------------------- + +function onGameInit() + Seed = 69 + GameFlags = gfInfAttack + gfSolidLand + gfDisableWind + TurnTime = 100000 + CaseFreq = 0 + MinesNum = 0 + MinesTime = 3000 + Explosives = 0 + Delay = 10 + MapGen = 0 + Theme = "Nature" + + + AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy") + youngh = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo") + elderh = AddHog(loc("Righteous Beard"), 0, 99, "IndianChief") + princess = AddHog(loc("Fell From Heaven"), 0, 300, "tiara") + SetGearPosition(princess, 1911, 1361) + HogTurnLeft(princess, true) + SetGearPosition(elderh, 2667, 1208) + HogTurnLeft(elderh, true) + SetGearPosition(youngh, 1862, 1362) + HogTurnLeft(youngh, false) + + AddTeam(loc("Cannibals"), 14483456, "Skull", "Island", "Pirate","cm_vampire") + cannibal = AddHog(loc("Brainiac"), 0, 5, "Zombi") + SetGearPosition(cannibal, 525, 1256) + HogTurnLeft(cannibal, false) + + AnimInit() + AnimationSetup() +end + +function onGameStart() + TurnTimeLeft = -1 + FollowGear(youngh) + ShowMission(loc("A Classic Fairytale"), loc("First Blood"), loc("Finish your training|Hint: Animations can be skipped with the [Precise] key."), -amSkip, 0) + SetState(cannibal, gstInvisible) + + AddAnim(startDialogue) + princessFace = "Right" + AddEvent(CheckNeedToTurn, {princess}, DoNeedToTurn, {princess}, 1) + AddEvent(CheckNeedToTurn, {elderh}, DoNeedToTurn, {elderh}, 1) + AddEvent(CheckDamage, {}, DoOnDamage, {}, 1) + AddEvent(CheckDeath, {}, DoDeath, {}, 0) + AddEvent(CheckDamagedOthers, {}, DoOnDamagedOthers, {}, 1) + AddEvent(CheckKilledOthers, {}, DoKilledOthers, {}, 0) + AddEvent(CheckMovedUntilJump, {}, DoMovedUntilJump, {}, 0) +end + +function onGameTick() + AnimUnWait() + if ShowAnimation() == false then + return + end + ExecuteAfterAnimations() + CheckEvents() +end + +function onGearDelete(gear) + if gear == ropeCrate1 then + rope1Taken = true + elseif gear == paraCrate then + paraTaken = true + elseif gear == ropeCrate2 then + rope2Taken = true + elseif gear == ropeCrate3 then + rope3Taken = true + elseif gear == crates[1] and challengeFailed == false then + crates[1] = nil + cratesCollected = cratesCollected + 1 + PutCrate(cratesCollected + 1) + elseif gear == punchCrate then + punchTaken = true + elseif gear == desertCrate then + desertTaken = true + elseif GetGearType(gear) == gtTarget then + i = 1 + while targets[i] ~= gear do + i = i + 1 + end + targets[i] = nil + targetsDestroyed = targetsDestroyed + 1 + elseif gear == cannibal then + cannibalKilled = true + elseif gear == princess then + princessKilled = true + elseif gear == elderh then + elderKilled = true + elseif gear == youngh then + youngKilled = true + end +end + +function onGearAdd(gear) +end + +function onAmmoStoreInit() + SetAmmo(amWhip, 0, 0, 0, 8) + SetAmmo(amBaseballBat, 0, 0, 0, 8) + SetAmmo(amHammer, 0, 0, 0, 8) +end + +function onNewTurn() + if CurrentHedgehog == cannibal and cannibalVisible == false then + SetState(cannibal, gstInvisible) + end + SwitchHog(youngh) + FollowGear(youngh) + TurnTimeLeft = -1 +end + +function onGearDamage(gear, damage) + if gear == youngh then + youngdamaged = true + tTime = TurnTimeLeft + elseif gear == princess then + princessDamaged = true + tTime = TurnTimeLeft + elseif gear == elderh then + elderDamaged = true + tTime = TurnTimeLeft + elseif gear == cannibal then + cannibalVisible = true + cannibalDamaged = true + SetState(cannibal, 0) + end +end + +function onPrecise() + if GameTime > 2000 then + SetAnimSkip(true) + end +end + +function onLeft() + if difficultyChoice == true then + difficulty = 1 + end +end + +function onRight() + if difficultyChoice == true then + difficulty = 2 + end +end + diff -r fd91aa100ce0 -r efc75c2d3be9 share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/journey.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/journey.lua Thu Aug 30 12:13:24 2012 -0400 @@ -0,0 +1,1067 @@ +loadfile(GetDataPath() .. "Scripts/Locale.lua")() +loadfile(GetDataPath() .. "Scripts/Animate.lua")() + +--///////////////////////////////CONSTANTS/////////////////////////// + +choiceAccepted = 1 +choiceRefused = 2 +choiceAttacked = 3 + +endStage = 1 + +cannibalNum = 8 +cannibalNames = {loc("John"), loc("Flesh for Brainz"), loc("Eye Chewer"), loc("Torn Muscle"), + loc("Nom-Nom"), loc("Vedgies"), loc("Brain Blower"), loc("Gorkij")} +cannibalPos = {{2471, 1174}, {939, 1019}, {1953, 902}, {3055, 1041}, + {1121, 729}, {1150, 718}, {1149, 680}, {1161, 773}} + +startLeaksPosDuo = {3572, 1426} +startEventXDuo = 3300 +startDensePosDuo = {3454, 1471} +startCyborgPosDuo = {3202, 1307} +midDensePosDuo = {1464, 1408} +midCyborgPosDuo = {1264, 1390} + +--///////////////////////////////VARIABLES/////////////////////////// + +m2Choice = 0 +m2DenseDead = 0 +m2RamonDead = 0 +m2SpikyDead = 0 + +TurnsLeft = 0 +stage = 0 + +cyborgHidden = false +princessHidden = false +blowTaken = false +fireTaken = false +gravityTaken = false +sniperTaken = false +girderTaken = false +girder1Taken = false +girder2Taken = false +leaksDead = false +denseDead = false +princessDead = false +cyborgDead = false +cannibalDead = {} + +startAnim = {} +startAnimAD = {} +startAnimAL = {} +startAnimRL = {} + +pastFlowerAnimAL = {} +pastFlowerAnimRL = {} +pastFlowerAnim = {} + +outPitAnimAL = {} +outPitAnimRL = {} +outPitAnim = {} + +midAnim = {} +midAnimAD = {} + +failAnim = {} +failAnimAD = {} + +endAnim = {} +endAnimAD = {} +endAnimAL = {} +endAnimRL = {} + +endFailAnim = {} +endFailAnimAD = {} + +winAnim = {} +winAnimAD = {} + +--/////////////////////////Animation Functions/////////////////////// +function AfterMidFailAnim() + ParseCommand("teamgone " .. loc("Natives")) + TurnTimeLeft = 0 +end + +function AfterMidAnimAlone() + SetupCourse() + for i = 5, 8 do + RestoreHog(cannibals[i]) + SetGearPosition(cannibals[i], unpack(cannibalPos[i])) + end + + AddAmmo(cannibals[5], amDEagle, 0) + + AddEvent(CheckGirderTaken, {}, DoGirderTaken, {}, 0) + AddEvent(CheckOnFirstGirder, {}, DoOnFirstGirder, {}, 0) + AddEvent(CheckTookSniper, {}, DoTookSniper, {}, 0) + AddEvent(CheckFailedCourse, {}, DoFailedCourse, {}, 0) + SetGearMessage(leaks, 0) + TurnsLeft = 12 + TurnTimeLeft = TurnTime + ShowMission(loc("The Journey Back"), loc("Collateral Damage"), loc("Save the princess by collecting the crate in under 12 turns!"), 0, 6000) + -----------------------///////////////------------ + --SetGearPosition(leaks, 417, 1800) +end + +function SkipEndAnimAlone() + if cyborgHidden then + RestoreHog(cyborg) + cyborgHidden = false + end + if princessHidden then + RestoreHog(princess) + princessHidden = false + end + SetGearPosition(cyborg, 437, 1700) + SetGearPosition(princess, 519, 1722) +end + +function SkipEndAnimDuo() + if cyborgHidden then + RestoreHog(cyborg) + cyborgHidden = false + end + if princessHidden then + RestoreHog(princess) + princessHidden = false + end + SetGearPosition(cyborg, 437, 1700) + SetGearPosition(princess, 519, 1722) + SetGearPosition(leaks, 763, 1760) + SetGearPosition(dense, 835, 1519) + HogTurnLeft(leaks, true) + HogTurnLeft(dense, true) +end + +function AfterEndAnimAlone() + stage = endStage + SwitchHog(leaks) + SetGearMessage(leaks, 0) + TurnTimeLeft = -1 + ShowMission(loc("The Journey Back"), loc("Collateral Damage II"), loc("Save Fell From Heaven!"), 1, 4000) + AddEvent(CheckLost, {}, DoLost, {}, 0) + AddEvent(CheckWon, {}, DoWon, {}, 0) + RemoveEventFunc(CheckFailedCourse) +end + +function AfterEndAnimDuo() + stage = endStage + SwitchHog(leaks) + SetGearMessage(leaks, 0) + SetGearMessage(dense, 0) + TurnTimeLeft = -1 + ShowMission(loc("The Journey Back"), loc("Collateral Damage II"), loc("Save Fell From Heaven!"), 1, 4000) + AddEvent(CheckLost, {}, DoLost, {}, 0) + AddEvent(CheckWon, {}, DoWon, {}, 0) +end + +function SkipMidAnimAlone() + SetGearPosition(leaks, 2656, 1842) + AnimSwitchHog(leaks) + SetInputMask(0xFFFFFFFF) + if princessHidden == false then + HideHog(princess) + princessHidden = true + end + if cyborgHidden == false then + HideHog(cyborg) + cyborgHidden = true + end +end + +function AfterStartAnim() + SetGearMessage(leaks, 0) + TurnTimeLeft = TurnTime + local goal = loc("Get the crate on the other side of the island!|") + local hint = loc("Hint: you might want to stay out of sight and take all the crates...|") + local stuck = loc("If you get stuck, use your Desert Eagle or restart the mission!|") + local conds = loc("Leaks A Lot must survive!") + if m2DenseDead == 0 then + conds = loc("Your hogs must survive!") + end + ShowMission(loc("The Journey Back"), loc("Adventurous"), goal .. hint .. stuck .. conds, 0, 7000) +end + +function SkipStartAnim() + AnimSwitchHog(leaks) +end + +function PlaceCratesDuo() + SpawnAmmoCrate(3090, 827, amBaseballBat) + girderCrate1 = SpawnUtilityCrate(2466, 1814, amGirder) + girderCrate2 = SpawnUtilityCrate(2630, 1278, amGirder) + SpawnUtilityCrate(2422, 1810, amParachute) + SpawnUtilityCrate(3157, 1009, amLowGravity) + sniperCrate = SpawnAmmoCrate(784, 1715, amSniperRifle) +end + +function PlaceMinesDuo() + SetTimer(AddGear(2920, 1448, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2985, 1338, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(3005, 1302, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(3030, 1270, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(3046, 1257, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2954, 1400, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2967, 1385, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2849, 1449, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2811, 1436, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2773, 1411, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2732, 1390, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2700, 1362, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2642, 1321, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2172, 1417, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2190, 1363, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2219, 1332, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1201, 1207, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1247, 1205, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1295, 1212, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1356, 1209, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1416, 1201, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1466, 1201, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1678, 1198, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1738, 1198, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1796, 1198, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1637, 1217, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1519, 1213, gtMine, 0, 0, 0, 0), 5000) +end + +function AfterPastFlowerAnim() + PlaceMinesDuo() + AddEvent(CheckDensePit, {}, DoDensePit, {}, 0) + AddEvent(CheckTookGirder1, {}, DoTookGirder1, {}, 0) + AddEvent(CheckTookGirder2, {}, DoTookGirder2, {}, 0) + SetGearMessage(leaks, 0) + SetGearMessage(dense, 0) + TurnTimeLeft = 0 + ShowMission(loc("The Journey Back"), loc("The Savior"), loc("Get Dense Cloud out of the pit!"), 1, 5000) +end + +function SkipPastFlowerAnim() + SetGearPosition(dense, 2656, 1842) + AnimSwitchHog(dense) + if cyborgHidden == false then + HideHog(cyborg) + cyborgHidden = true + end +end + +function AfterOutPitAnim() + SetupCourseDuo() + RestoreHog(cannibals[5]) + AddAmmo(cannibals[5], amDEagle, 0) + HideHog(cannibals[5]) + AddEvent(CheckTookFire, {}, DoTookFire, {}, 0) + SetGearMessage(leaks, 0) + SetGearMessage(dense, 0) + TurnTimeLeft = 0 + ShowMission(loc("The Journey Back"), loc("They never learn"), loc("Free Dense Cloud and continue the mission!"), 1, 5000) +end + +function SkipOutPitAnim() + SetGearPosition(dense, unpack(midDensePosDuo)) + AnimSwitchHog(dense) + if cyborgHidden == false then + HideHog(cyborg) + cyborgHidden = true + end +end + +function RestoreCyborg(x, y, xx, yy) + RestoreHog(cyborg) + RestoreHog(princess) + cyborgHidden = false + princessHidden = false + AnimOutOfNowhere(cyborg, x, y) + AnimOutOfNowhere(princess, xx, yy) + HogTurnLeft(princess, false) + return true +end + +function RestoreCyborgOnly(x, y) + RestoreHog(cyborg) + cyborgHidden = false + SetState(cyborg, 0) + AnimOutOfNowhere(cyborg, x, y) + return true +end + +function TargetPrincess() + ParseCommand("setweap " .. string.char(amDEagle)) + SetGearMessage(cyborg, gmUp) + return true +end + +function HideCyborg() + if cyborgHidden == false then + HideHog(cyborg) + cyborgHidden = true + end + if princessHidden == false then + HideHog(princess) + princessHidden = true + end +end + +function HideCyborgOnly() + if cyborgHidden == false then + HideHog(cyborg) + cyborgHidden = true + end +end + +function SetupKillRoom() + PlaceGirder(2342, 1814, 2) + PlaceGirder(2294, 1783, 0) + PlaceGirder(2245, 1814, 2) +end + +function SetupCourseDuo() + PlaceGirder(1083, 1152, 6) + PlaceGirder(1087, 1150, 6) + PlaceGirder(1133, 1155, 0) + PlaceGirder(1135, 1152, 0) + PlaceGirder(1135, 1078, 0) + PlaceGirder(1087, 1016, 2) + PlaceGirder(1018, 921, 5) + PlaceGirder(1016, 921, 5) + PlaceGirder(962, 782, 6) + PlaceGirder(962, 662, 2) + PlaceGirder(962, 661, 2) + PlaceGirder(962, 650, 2) + PlaceGirder(962, 630, 2) + PlaceGirder(1033, 649, 0) + PlaceGirder(952, 650, 0) + + fireCrate = SpawnAmmoCrate(1846, 1100, amFirePunch) + SpawnUtilityCrate(1900, 1149, amPickHammer) + SpawnAmmoCrate(950, 674, amDynamite) + SpawnUtilityCrate(994, 825, amRope) + SpawnUtilityCrate(570, 1357, amLowGravity) +end + +function DumpMines() + SetTimer(AddGear(2261, 1835, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2280, 1831, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2272, 1809, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2290, 1815, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2278, 1815, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2307, 1811, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2286, 1820, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2309, 1813, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2303, 1822, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2317, 1827, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2312, 1816, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2316, 1812, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2307, 1802, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2276, 1818, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2284, 1816, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2292, 1811, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2295, 1814, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2306, 1811, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2292, 1815, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2314, 1815, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2286, 1813, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2275, 1813, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2269, 1814, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2273, 1812, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2300, 1808, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2322, 1812, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2323, 1813, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2311, 1811, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2303, 1809, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2287, 1808, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2282, 1808, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2277, 1809, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2296, 1809, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(2314, 1818, gtMine, 0, 0, 0, 0), 5000) +end + +function SetupAnimRefusedDied() + SetupAnimAcceptedDied() + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("I just wonder where Ramon and Spiky disappeared..."), SAY_THINK, 6000}}) +end + +function SetupAnimAttacked() + SetupAnimAcceptedDied() + startAnim = {} + table.insert(startAnim, {func = AnimWait, args = {leaks, 3000}}) + table.insert(startAnim, {func = AnimTurn, args = {leaks, "Left"}}) + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("I wonder where Dense Cloud is..."), SAY_THINK, 4000}}) + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("He must be in the village already."), SAY_THINK, 4000}}) + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("I'd better get going myself."), SAY_THINK, 4000}}) + + midAnim = {} + table.insert(midAnim, {func = AnimWait, args = {leaks, 500}}) + table.insert(midAnim, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {1300, 1200, 1390, 1200}}}) + table.insert(midAnim, {func = AnimSwitchHog, args = {cyborg}}) + table.insert(midAnim, {func = AnimCustomFunction, args = {cyborg, TargetPrincess, {}}}) + table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("Welcome, Leaks A Lot!"), SAY_SAY, 3000}}) + table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("I want to play a game..."), SAY_SAY, 3000}}) + table.insert(midAnim, {func = AnimSay, args = {princess, loc("Help me, please!!!"), SAY_SHOUT, 3000}}) + table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("If you can get that crate fast enough, your beloved \"princess\" may go free."), SAY_SAY, 7000}}) + table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("However, if you fail to do so, she dies a most violent death! Muahahaha!"), SAY_SAY, 8000}}) + table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("Good luck...or else!"), SAY_SAY, 4000}}) + table.insert(midAnim, {func = AnimTeleportGear, args = {leaks, 2656, 1842}}) + table.insert(midAnim, {func = AnimCustomFunction, args = {cyborg, HideCyborg, {}}, swh = false}) + table.insert(midAnim, {func = AnimSay, args = {leaks, loc("Hey! This is cheating!"), SAY_SHOUT, 4000}}) + AddSkipFunction(midAnim, SkipMidAnimAlone, {}) +end + +function SetupAnimAcceptedDied() + table.insert(startAnimAD, {func = AnimWait, args = {leaks, 3000}}) + table.insert(startAnimAD, {func = AnimTurn, args = {leaks, "Left"}}) + table.insert(startAnimAD, {func = AnimSay, args = {leaks, loc("I need to get to the other side of this island, fast!"), SAY_THINK, 5000}}) + table.insert(startAnimAD, {func = AnimSay, args = {leaks, loc("With Dense Cloud on the land of shadows, I'm the village's only hope..."), SAY_THINK, 7000}}) + + table.insert(midAnimAD, {func = AnimWait, args = {leaks, 500}}) + table.insert(midAnimAD, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {1300, 1200, 1390, 1200}}}) + table.insert(midAnimAD, {func = AnimSwitchHog, args = {cyborg}}) + table.insert(midAnimAD, {func = AnimCustomFunction, args = {cyborg, TargetPrincess, {}}}) + table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("Welcome, Leaks A Lot!"), SAY_SAY, 3000}}) + table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("I want to play a game..."), SAY_SAY, 3000}}) + table.insert(midAnimAD, {func = AnimSay, args = {princess, loc("Help me, please!!!"), SAY_SHOUT, 3000}}) + table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("If you can get that crate fast enough, your beloved \"princess\" may go free."), SAY_SAY, 7000}}) + table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("However, if you fail to do so, she dies a most violent death, just like your friend! Muahahaha!"), SAY_SAY, 8000}}) + table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("Good luck...or else!"), SAY_SAY, 4000}}) + table.insert(midAnimAD, {func = AnimTeleportGear, args = {leaks, 2656, 1842}}) + table.insert(midAnimAD, {func = AnimCustomFunction, args = {cyborg, HideCyborg, {}}, swh = false}) + table.insert(midAnimAD, {func = AnimSay, args = {leaks, loc("Hey! This is cheating!"), SAY_SHOUT, 4000}}) + AddSkipFunction(midAnimAD, SkipMidAnimAlone, {}) + + table.insert(failAnimAD, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {2299, 1687, 2294, 1841}}}) + table.insert(failAnimAD, {func = AnimTeleportGear, args = {leaks, 2090, 1841}}) + table.insert(failAnimAD, {func = AnimCustomFunction, swh = false, args = {cyborg, SetupKillRoom, {}}}) + table.insert(failAnimAD, {func = AnimTurn, swh = false, args = {cyborg, "Left"}}) + table.insert(failAnimAD, {func = AnimTurn, swh = false, args = {princess, "Left"}}) + table.insert(failAnimAD, {func = AnimTurn, swh = false, args = {leaks, "Right"}}) + table.insert(failAnimAD, {func = AnimWait, args = {cyborg, 1000}}) + table.insert(failAnimAD, {func = AnimSay, args = {cyborg, loc("You have failed to complete your task, young one!"), SAY_SAY, 6000}}) + table.insert(failAnimAD, {func = AnimSay, args = {cyborg, loc("It's time you learned that your actions have consequences!"), SAY_SAY, 7000}}) + table.insert(failAnimAD, {func = AnimSay, args = {princess, loc("No! Please, help me!"), SAY_SAY, 4000}}) + table.insert(failAnimAD, {func = AnimSwitchHog, args = {cyborg}}) + table.insert(failAnimAD, {func = AnimCustomFunction, args = {cyborg, DumpMines, {}}}) + table.insert(failAnimAD, {func = AnimCustomFunction, args = {cyborg, KillPrincess, {}}}) + table.insert(failAnimAD, {func = AnimWait, args = {cyborg, 12000}}) + table.insert(failAnimAD, {func = AnimSay, args = {leaks, loc("No! What have I done?! What have YOU done?!"), SAY_SHOUT, 6000}}) + + table.insert(endAnimAD, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {437, 1700, 519, 1722}}}) + table.insert(endAnimAD, {func = AnimTurn, swh = false, args = {cyborg, "Right"}}) + table.insert(endAnimAD, {func = AnimTurn, swh = false, args = {princess, "Right"}}) + table.insert(endAnimAD, {func = AnimSay, args = {princess, loc("Help me, Leaks!"), SAY_SHOUT, 3000}}) + table.insert(endAnimAD, {func = AnimSay, args = {leaks, loc("But you said you'd let her go!"), SAY_SHOUT, 5000}}) + table.insert(endAnimAD, {func = AnimSay, args = {cyborg, loc("And you believed me? Oh, god, that's cute!"), SAY_SHOUT, 7000}}) + table.insert(endAnimAD, {func = AnimSay, args = {leaks, loc("I won't let you kill her!"), SAY_SHOUT, 4000}}) + AddSkipFunction(endAnimAD, SkipEndAnimAlone, {}) + + table.insert(endFailAnim, {func = AnimCaption, args = {leaks, loc("Leaks A Lot, depressed for killing his loved one, failed to save the village..."), 3000}}) + + table.insert(winAnimAD, {func = AnimCustomFunction, args = {princess, CondNeedToTurn, {leaks, princess}}}) + table.insert(winAnimAD, {func = AnimSay, args = {princess, loc("Thank you, oh, thank you, Leaks A Lot!"), SAY_SAY, 5000}}) + table.insert(winAnimAD, {func = AnimSay, args = {princess, loc("How can I ever repay you for saving my life?"), SAY_SAY, 6000}}) + table.insert(winAnimAD, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying for me than seeing you share your beauty with the world every morning, my princess!"), SAY_SAY, 10000}}) + table.insert(winAnimAD, {func = AnimSay, args = {leaks, loc("Let's go home!"), SAY_SAY, 3000}}) + table.insert(winAnimAD, {func = AnimCaption, args = {leaks, loc("And so they discovered that cyborgs weren't invulnerable..."), 2000}}) + + startAnim = startAnimAD + midAnim = midAnimAD + failAnim = failAnimAD + endAnim = endAnimAD + endFailAnim = endFailAnimAD + winAnim = winAnimAD +end + +function SetupAnimAcceptedLived() + table.insert(startAnimAL, {func = AnimWait, args = {leaks, 3000}}) + table.insert(startAnimAL, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {leaks, dense}}}) + table.insert(startAnimAL, {func = AnimSay, args = {leaks, loc("All right, we just need to get to the other side of the island!"), SAY_SAY, 8000}}) + table.insert(startAnimAL, {func = AnimSay, args = {dense, loc("We have no time to waste..."), SAY_SAY, 4000}}) + table.insert(startAnimAL, {func = AnimSwitchHog, args = {leaks}}) + AddSkipFunction(startAnimAL, SkipStartAnim, {}) + + table.insert(pastFlowerAnimAL, {func = AnimCustomFunction, args = {dense, RestoreCyborgOnly, {unpack(startCyborgPosDuo)}}, swh = false}) + table.insert(pastFlowerAnimAL, {func = AnimTurn, args = {cyborg, "Right"}}) + table.insert(pastFlowerAnimAL, {func = AnimSay, args = {cyborg, loc("Well, well! Isn't that the cutest thing you've ever seen?"), SAY_SAY, 7000}}) + table.insert(pastFlowerAnimAL, {func = AnimSay, args = {cyborg, loc("Two little hogs cooperating, getting past obstacles..."), SAY_SAY, 7000}}) + table.insert(pastFlowerAnimAL, {func = AnimSay, args = {cyborg, loc("Let me test your skills a little, will you?"), SAY_SAY, 6000}}) + table.insert(pastFlowerAnimAL, {func = AnimTeleportGear, args = {cyborg, 2456, 1842}}) + table.insert(pastFlowerAnimAL, {func = AnimTeleportGear, args = {dense, 2656, 1842}}) + table.insert(pastFlowerAnimAL, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {cyborg, dense}}}) + table.insert(pastFlowerAnimAL, {func = AnimSay, args = {dense, loc("Why are you doing this?"), SAY_SAY, 4000}}) + table.insert(pastFlowerAnimAL, {func = AnimSay, args = {cyborg, loc("To help you, of course!"), SAY_SAY, 4000}}) + table.insert(pastFlowerAnimAL, {func = AnimSwitchHog, args = {dense}}) + table.insert(pastFlowerAnimAL, {func = AnimDisappear, swh = false, args = {cyborg, 3781, 1583}}) + table.insert(pastFlowerAnimAL, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborgOnly, {}}}) + AddSkipFunction(pastFlowerAnimAL, SkipPastFlowerAnim, {}) + + table.insert(outPitAnimAL, {func = AnimCustomFunction, args = {dense, RestoreCyborgOnly, {unpack(midCyborgPosDuo)}}, swh = false}) + table.insert(outPitAnimAL, {func = AnimTurn, args = {cyborg, "Right"}}) + table.insert(outPitAnimAL, {func = AnimTeleportGear, args = {dense, unpack(midDensePosDuo)}}) + table.insert(outPitAnimAL, {func = AnimSay, args = {dense, loc("OH, COME ON!"), SAY_SHOUT, 3000}}) + table.insert(outPitAnimAL, {func = AnimSay, args = {cyborg, loc("Let's see what your comrade does now!"), SAY_SAY, 5000}}) + table.insert(outPitAnimAL, {func = AnimSwitchHog, args = {dense}}) + table.insert(outPitAnimAL, {func = AnimDisappear, swh = false, args = {cyborg, 3781, 1583}}) + table.insert(outPitAnimAL, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborgOnly, {}}}) + AddSkipFunction(outPitAnimAL, SkipOutPitAnim, {}) + + table.insert(endAnim, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {437, 1700, 519, 1722}}}) + table.insert(endAnim, {func = AnimTeleportGear, args = {leaks, 763, 1760}}) + table.insert(endAnim, {func = AnimTeleportGear, args = {dense, 835, 1519}}) + table.insert(endAnim, {func = AnimTurn, swh = false, args = {leaks, "Left"}}) + table.insert(endAnim, {func = AnimTurn, swh = false, args = {dense, "Left"}}) + table.insert(endAnim, {func = AnimTurn, swh = false, args = {cyborg, "Right"}}) + table.insert(endAnim, {func = AnimTurn, swh = false, args = {princess, "Right"}}) + table.insert(endAnim, {func = AnimSay, args = {princess, loc("Help me, please!"), SAY_SHOUT, 3000}}) + table.insert(endAnim, {func = AnimSay, args = {leaks, loc("What are you doing? Let her go!"), SAY_SHOUT, 5000}}) + table.insert(endAnim, {func = AnimSay, args = {cyborg, loc("Yeah? Watcha gonna do? Cry?"), SAY_SHOUT, 5000}}) + table.insert(endAnim, {func = AnimSay, args = {leaks, loc("We won't let you hurt her!"), SAY_SHOUT, 4000}}) + AddSkipFunction(endAnim, SkipEndAnimDuo, {}) + + table.insert(endFailAnim, {func = AnimCaption, args = {leaks, loc("Leaks A Lot, depressed for killing his loved one, failed to save the village..."), 3000}}) + + table.insert(winAnim, {func = AnimCustomFunction, args = {princess, CondNeedToTurn, {leaks, princess}}}) + table.insert(winAnim, {func = AnimSay, args = {princess, loc("Thank you, oh, thank you, my heroes!"), SAY_SAY, 5000}}) + table.insert(winAnim, {func = AnimSay, args = {princess, loc("How can I ever repay you for saving my life?"), SAY_SAY, 6000}}) + table.insert(winAnim, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying to us than seeing you share your beauty..."), SAY_SAY, 7000}}) + table.insert(winAnim, {func = AnimSay, args = {leaks, loc("... share your beauty with the world every morning, my princess!"), SAY_SAY, 7000}}) + table.insert(winAnim, {func = AnimSay, args = {leaks, loc("Let's go home!"), SAY_SAY, 3000}}) + table.insert(winAnim, {func = AnimCaption, args = {leaks, loc("And so they discovered that cyborgs weren't invulnerable..."), 2000}}) + + startAnim = startAnimAL + pastFlowerAnim = pastFlowerAnimAL + outPitAnim = outPitAnimAL +end + +function SetupAnimRefusedLived() + table.insert(startAnimRL, {func = AnimWait, args = {leaks, 3000}}) + table.insert(startAnimRL, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {leaks, dense}}}) + table.insert(startAnimRL, {func = AnimSay, args = {leaks, loc("All right, we just need to get to the other side of the island!"), SAY_SAY, 7000}}) + table.insert(startAnimRL, {func = AnimSay, args = {dense, loc("Dude, can you see Ramon and Spiky?"), SAY_SAY, 5000}}) + table.insert(startAnimRL, {func = AnimSay, args = {leaks, loc("No...I wonder where they disappeared?!"), SAY_SAY, 5000}}) + AddSkipFunction(startAnimRL, SkipStartAnim, {}) + + table.insert(pastFlowerAnimRL, {func = AnimCustomFunction, args = {dense, RestoreCyborgOnly, {unpack(startCyborgPosDuo)}}, swh = false}) + table.insert(pastFlowerAnimRL, {func = AnimTurn, args = {cyborg, "Right"}}) + table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("Well, well! Isn't that the cutest thing you've ever seen?"), SAY_SAY, 7000}}) + table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("Two little hogs cooperating, getting past obstacles..."), SAY_SAY, 7000}}) + table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("Let me test your skills a little, will you?"), SAY_SAY, 6000}}) + table.insert(pastFlowerAnimRL, {func = AnimTeleportGear, args = {cyborg, 2456, 1842}}) + table.insert(pastFlowerAnimRL, {func = AnimTeleportGear, args = {dense, 2656, 1842}}) + table.insert(pastFlowerAnimRL, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {cyborg, dense}}}) + table.insert(pastFlowerAnimRL, {func = AnimSay, args = {dense, loc("Why are you doing this?"), SAY_SAY, 4000}}) + table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("You couldn't possibly believe that after refusing my offer I'd just let you go!"), SAY_SAY, 9000}}) + table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("You're funny!"), SAY_SAY, 4000}}) + table.insert(pastFlowerAnimRL, {func = AnimSwitchHog, args = {dense}}) + table.insert(pastFlowerAnimRL, {func = AnimDisappear, swh = false, args = {cyborg, 3781, 1583}}) + table.insert(pastFlowerAnimRL, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborgOnly, {}}}) + AddSkipFunction(pastFlowerAnimRL, SkipPastFlowerAnim, {}) + + table.insert(outPitAnimRL, {func = AnimCustomFunction, args = {dense, RestoreCyborgOnly, {unpack(midCyborgPosDuo)}}, swh = false}) + table.insert(outPitAnimRL, {func = AnimTurn, args = {cyborg, "Right"}}) + table.insert(outPitAnimRL, {func = AnimTeleportGear, args = {dense, unpack(midDensePosDuo)}}) + table.insert(outPitAnimRL, {func = AnimSay, args = {dense, loc("OH, COME ON!"), SAY_SHOUT, 3000}}) + table.insert(outPitAnimRL, {func = AnimSay, args = {cyborg, loc("Let's see what your comrade does now!"), SAY_SAY, 5000}}) + table.insert(outPitAnimRL, {func = AnimSwitchHog, args = {dense}}) + table.insert(outPitAnimRL, {func = AnimDisappear, swh = false, args = {cyborg, 3781, 1583}}) + table.insert(outPitAnimRL, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborgOnly, {}}}) + AddSkipFunction(outPitAnimRL, SkipOutPitAnim, {}) + + table.insert(endAnim, {func = AnimCustomFunction, args = {leaks, RestoreCyborg, {437, 1700, 519, 1722}}}) + table.insert(endAnim, {func = AnimTeleportGear, args = {leaks, 763, 1760}}) + table.insert(endAnim, {func = AnimTeleportGear, args = {dense, 835, 1519}}) + table.insert(endAnim, {func = AnimTurn, swh = false, args = {leaks, "Left"}}) + table.insert(endAnim, {func = AnimTurn, swh = false, args = {dense, "Left"}}) + table.insert(endAnim, {func = AnimTurn, swh = false, args = {cyborg, "Right"}}) + table.insert(endAnim, {func = AnimTurn, swh = false, args = {princess, "Right"}}) + table.insert(endAnim, {func = AnimSay, args = {princess, loc("Help me, please!"), SAY_SHOUT, 3000}}) + table.insert(endAnim, {func = AnimSay, args = {leaks, loc("What are you doing? Let her go!"), SAY_SHOUT, 5000}}) + table.insert(endAnim, {func = AnimSay, args = {cyborg, loc("Yeah? Watcha gonna do? Cry?"), SAY_SHOUT, 5000}}) + table.insert(endAnim, {func = AnimSay, args = {leaks, loc("We won't let you hurt her!"), SAY_SHOUT, 4000}}) + AddSkipFunction(endAnim, SkipEndAnimDuo, {}) + + table.insert(endFailAnim, {func = AnimCaption, args = {leaks, loc("Leaks A Lot, depressed for killing his loved one, failed to save the village..."), 3000}}) + + table.insert(winAnim, {func = AnimCustomFunction, args = {princess, CondNeedToTurn, {leaks, princess}}}) + table.insert(winAnim, {func = AnimSay, args = {princess, loc("Thank you, oh, thank you, my heroes!"), SAY_SAY, 5000}}) + table.insert(winAnim, {func = AnimSay, args = {princess, loc("How can I ever repay you for saving my life?"), SAY_SAY, 6000}}) + table.insert(winAnim, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying to us than seeing you share your beauty with the world every morning, my princess!"), SAY_SAY, 10000}}) + table.insert(winAnim, {func = AnimSay, args = {leaks, loc("Let's go home!"), SAY_SAY, 3000}}) + table.insert(winAnim, {func = AnimCaption, args = {leaks, loc("And so they discovered that cyborgs weren't invulnerable..."), 2000}}) + + startAnim = startAnimRL + pastFlowerAnim = pastFlowerAnimRL + outPitAnim = outPitAnimRL +end + +function KillPrincess() + ParseCommand("teamgone " .. loc("Cannibal Sentry")) + TurnTimeLeft = 0 +end +--/////////////////////////////Misc Functions//////////////////////// + +function CondNeedToTurn(hog1, hog2) + xl, xd = GetX(hog1), GetX(hog2) + if xl > xd then + AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}}) + elseif xl < xd then + AnimInsertStepNext({func = AnimTurn, args = {hog2, "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {hog1, "Right"}}) + end +end + +function SetupPlaceAlone() + ------ AMMO CRATE LIST ------ + --SpawnAmmoCrate(3122, 994, amShotgun) + SpawnAmmoCrate(3124, 952, amBaseballBat) + SpawnAmmoCrate(2508, 1110, amFirePunch) + ------ UTILITY CRATE LIST ------ + blowCrate = SpawnUtilityCrate(3675, 1480, amBlowTorch) + gravityCrate = SpawnUtilityCrate(3448, 1349, amLowGravity) + SpawnUtilityCrate(3212, 1256, amGirder) + SpawnUtilityCrate(3113, 911, amParachute) + sniperCrate = SpawnAmmoCrate(784, 1715, amSniperRifle) + ------ MINE LIST ------ + SetTimer(AddGear(3328, 1399, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(3028, 1262, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2994, 1274, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2956, 1277, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2925, 1282, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2838, 1276, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2822, 1278, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2786, 1283, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2766, 1270, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2749, 1231, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2717, 1354, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2167, 1330, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2201, 1321, gtMine, 0, 0, 0, 0), 3000) + SetTimer(AddGear(2239, 1295, gtMine, 0, 0, 0, 0), 3000) + + SetGearPosition(leaks, 3781, 1583) + --SetGearPosition(leaks, 1650, 1583) + AddAmmo(cannibals[1], amShotgun, 100) + AddAmmo(leaks, amSwitch, 0) +end + +function SetupPlaceDuo() + PlaceCratesDuo() + SetGearPosition(leaks, unpack(startLeaksPosDuo)) + SetGearPosition(dense, unpack(startDensePosDuo)) +end + +function SetupEventsDuo() + AddEvent(CheckPastFlower, {}, DoPastFlower, {}, 0) + AddEvent(CheckLeaksDead, {}, DoLeaksDead, {}, 0) + AddEvent(CheckDenseDead, {}, DoDenseDead, {}, 0) + AddEvent(CheckTookSniper2, {}, DoTookSniper2, {}, 0) +end + +function SetupEventsAlone() + AddEvent(CheckLeaksDead, {}, DoLeaksDead, {}, 0) + AddEvent(CheckTookBlowTorch, {}, DoTookBlowTorch, {}, 0) + AddEvent(CheckTookLowGravity, {}, DoTookLowGravity, {}, 0) + AddEvent(CheckOnBridge, {}, DoOnBridge, {}, 0) +end + +function StartMission() + if m2DenseDead == 1 then + DeleteGear(dense) + if m2Choice == choiceAccepted then + SetupAnimAcceptedDied() + elseif m2Choice == choiceRefused then + SetupAnimRefusedDied() + else + SetupAnimAttacked() + end + SetupPlaceAlone() + SetupEventsAlone() + AddAnim(startAnim) + AddFunction({func = AfterStartAnim, args = {}}) + else + if m2Choice == choiceAccepted then + SetupAnimAcceptedLived() + else + SetupAnimRefusedLived() + end + SetupPlaceDuo() + SetupEventsDuo() + AddAnim(startAnim) + AddFunction({func = AfterStartAnim, args = {}}) + end + HideHog(cyborg) + HideHog(princess) + cyborgHidden = true + princessHidden = true + for i = 5, 8 do + HideHog(cannibals[i]) + end + +end + +function SetupCourse() + + ------ GIRDER LIST ------ + PlaceGirder(1091, 1150, 6) + PlaceGirder(1091, 989, 6) + PlaceGirder(1091, 829, 6) + PlaceGirder(1091, 669, 6) + PlaceGirder(1091, 668, 6) + PlaceGirder(1091, 669, 6) + PlaceGirder(1088, 667, 6) + PlaceGirder(1091, 658, 6) + PlaceGirder(1091, 646, 6) + PlaceGirder(1091, 607, 6) + PlaceGirder(1091, 571, 6) + PlaceGirder(1376, 821, 6) + PlaceGirder(1145, 1192, 1) + PlaceGirder(1169, 1076, 3) + PlaceGirder(1351, 1082, 4) + PlaceGirder(1469, 987, 3) + PlaceGirder(1386, 951, 0) + PlaceGirder(1465, 852, 3) + PlaceGirder(1630, 913, 0) + PlaceGirder(1733, 856, 7) + PlaceGirder(1688, 713, 5) + PlaceGirder(1556, 696, 2) + PlaceGirder(1525, 696, 2) + PlaceGirder(1457, 697, 2) + PlaceGirder(1413, 700, 3) + PlaceGirder(1270, 783, 2) + PlaceGirder(1207, 825, 2) + PlaceGirder(1135, 775, 1) + + ------ UTILITY CRATE LIST ------ + SpawnUtilityCrate(1590, 628, amParachute) + SpawnAmmoCrate(1540, 100, amDynamite) + SpawnUtilityCrate(2175, 1815, amLowGravity) + SpawnUtilityCrate(2210, 1499, amFirePunch) + girderCrate = SpawnUtilityCrate(2300, 1663, amGirder) + SpawnUtilityCrate(610, 1394, amPickHammer) + + ------ BARREL LIST ------ + SetHealth(AddGear(1148, 736, gtExplosives, 0, 0, 0, 0), 20) + +end + +function PlaceCourseMines() + SetTimer(AddGear(1215, 1193, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1259, 1199, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1310, 1198, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1346, 1196, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1383, 1192, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1436, 1196, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1487, 1199, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1651, 1209, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1708, 1209, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1759, 1190, gtMine, 0, 0, 0, 0), 5000) + SetTimer(AddGear(1815, 1184, gtMine, 0, 0, 0, 0), 5000) +end + + +--////////////////////////////Event Functions//////////////////////// +function CheckTookFire() + return fireTaken +end + +function DoTookFire() + AddAmmo(leaks, amFirePunch, 100) +end + +function CheckTookGirder1() + return girder1Taken +end + +function CheckTookGirder2() + return girder2Taken +end + +function DoTookGirder1() + AddAmmo(dense, amGirder, 2) +end + +function DoTookGirder2() + AddAmmo(dense, amGirder, 3) +end + +function CheckDensePit() + return GetY(dense) < 1250 and StoppedGear(dense) +end + +function DoDensePit() + AddAnim(outPitAnim) + AddFunction({func = AfterOutPitAnim, args = {}}) +end + +function CheckPastFlower() + if denseDead == true or leaksDead == true then + return false + end + return (GetX(dense) < startEventXDuo and StoppedGear(dense)) + or (GetX(leaks) < startEventXDuo and StoppedGear(leaks)) +end + +function DoPastFlower() + AddAnim(pastFlowerAnim) + AddFunction({func = AfterPastFlowerAnim, args = {}}) +end + + +function CheckLeaksDead() + return leaksDead +end + +function DoLeaksDead() + AddCaption(loc("The village, unprepared, was destroyed by the cyborgs...")) + ParseCommand("teamgone " .. loc("Natives")) +end + +function CheckDenseDead() + return denseDead +end + +function DoDenseDead() + AddCaption(loc("The village, unprepared, was destroyed by the cyborgs...")) + ParseCommand("teamgone " .. loc("Natives")) +end + +function CheckTookBlowTorch() + return blowTaken +end + +function DoTookBlowTorch() + ShowMission(loc("The Journey Back"), loc("The Tunnel Maker"), loc("Hint: Select the BlowTorch, aim and press [Fire]. Press [Fire] again to stop.|Don't blow up the crate."), 0, 6000) +end + +function CheckTookLowGravity() + return gravityTaken +end + +function DoTookLowGravity() + ShowMission(loc("The Journey Back"), loc("The Moonwalk"), loc("Hint: Select the LowGravity and press [Fire]."), 0, 6000) +end + +function CheckOnBridge() + return leaksDead == false and GetX(leaks) < 1651 and StoppedGear(leaks) +end + +function DoOnBridge() + AddAnim(midAnim) + AddFunction({func = AfterMidAnimAlone, args = {}}) +end + +function CheckGirderTaken() + return girderTaken +end + +function DoGirderTaken() + AddAmmo(leaks, amGirder, 2) +-- AddAmmo(leaks, amGirder, 3) +end + +function CheckOnFirstGirder() + return leaksDead == false and GetX(leaks) < 1160 and StoppedGear(leaks) +end + +function DoOnFirstGirder() + PlaceCourseMines() + ShowMission(loc("The Journey Back"), loc("Slippery"), loc("You'd better watch your steps..."), 0, 4000) +end + +function CheckTookSniper() + return sniperTaken and StoppedGear(leaks) +end + +function DoTookSniper() + AddAnim(endAnim) + AddFunction({func = AfterEndAnimAlone, args = {}}) +end + +function CheckTookSniper2() + return sniperTaken and StoppedGear(leaks) and StoppedGear(dense) +end + +function DoTookSniper2() + AddAnim(endAnim) + AddFunction({func = AfterEndAnimDuo, args = {}}) +end + +function CheckLost() + return princessDead +end + +function DoLost() + AddAnim(endFailAnim) + AddFunction({func = ParseCommand, args = {'teamgone ' .. loc('Natives')}}) +end + +function CheckWon() + return cyborgDead and not princessDead +end + +function DoWon() + SaveCampaignVar("Progress", "3") + AddAnim(winAnim) + AddFunction({func = FinishWon, args = {}}) +end + +function FinishWon() + SwitchHog(leaks) + ParseCommand("teamgone " .. loc("Cannibal Sentry")) + ParseCommand("teamgone " .. loc("011101001")) + TurnTimeLeft = 0 +end + +function CheckFailedCourse() + return TurnsLeft == 0 +end + +function DoFailedCourse() + AddAnim(failAnim) + AddFunction({func = AfterMidFailAnim, args = {}}) +end + +--////////////////////////////Main Functions///////////////////////// + +function onGameInit() + Seed = 0 + TemplateFilter = 3 + GameFlags = gfSolidLand + gfDisableWind + TurnTime = 40000 + CaseFreq = 0 + MinesNum = 0 + MinesTime = 3000 + Explosives = 0 + Delay = 5 + MapGen = 0 + Theme = "Nature" + SuddenDeathTurns = 3000 + + AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy") + leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo") + dense = AddHog(loc("Dense Cloud"), 0, 100, "RobinHood") + + AddTeam(loc("Cannibal Sentry"), 14483456, "Skull", "Island", "Pirate","cm_vampire") + cannibals = {} + for i = 1, 4 do + cannibals[i] = AddHog(cannibalNames[i], 3, 40, "Zombi") + SetGearPosition(cannibals[i], unpack(cannibalPos[i])) + end + + for i = 5, 8 do + cannibals[i] = AddHog(cannibalNames[i], 3, 40, "Zombi") + SetGearPosition(cannibals[i], 0, 0) + end + + AddTeam(loc("011101001"), 14483456, "ring", "UFO", "Robot", "cm_star") + cyborg = AddHog(loc("Y3K1337"), 0, 200, "cyborg1") + princess = AddHog(loc("Fell From Heaven"), 0, 200, "tiara") + + SetGearPosition(dense, 0, 0) + SetGearPosition(leaks, 0, 0) + SetGearPosition(cyborg, 0, 0) + SetGearPosition(princess, 0, 0) + + AnimInit() +end + +function onGameStart() + m2Choice = tonumber(GetCampaignVar("M2Choice")) + m2DenseDead = tonumber(GetCampaignVar("M2DenseDead")) + m2RamonDead = tonumber(GetCampaignVar("M2RamonDead")) + m2SpikyDead = tonumber(GetCampaignVar("M2SpikyDead")) + StartMission() +end + +function onGameTick() + AnimUnWait() + if ShowAnimation() == false then + return + end + ExecuteAfterAnimations() + CheckEvents() +end + +function onGearDelete(gear) + if gear == blowCrate then + blowTaken = true + elseif gear == fireCrate then + fireTaken = true + elseif gear == gravityCrate then + gravityTaken = true + elseif gear == leaks then + leaksDead = true + elseif gear == dense then + denseDead = true + elseif gear == cyborg then + cyborgDead = true + elseif gear == princess then + princessDead = true + elseif gear == girderCrate then + girderTaken = true + elseif gear == girderCrate1 then + girder1Taken = true + elseif gear == girderCrate2 then + girder2Taken = true + elseif gear == sniperCrate then + sniperTaken = true + else + for i = 1, 4 do + if gear == cannibals[i] then + cannibalDead[i] = true + end + end + end +end + +function onGearAdd(gear) +end + +function onAmmoStoreInit() + SetAmmo(amBlowTorch, 0, 0, 0, 1) + SetAmmo(amParachute, 0, 0, 0, 1) + SetAmmo(amGirder, 0, 0, 0, 3) + SetAmmo(amLowGravity, 0, 0, 0, 1) + SetAmmo(amBaseballBat, 0, 0, 0, 1) + SetAmmo(amFirePunch, 0, 0, 0, 1) + SetAmmo(amSkip, 9, 0, 0, 0) + SetAmmo(amSwitch, 9, 0, 0, 0) + SetAmmo(amDEagle, 9, 0, 0, 0) + SetAmmo(amRope, 0, 0, 0, 1) + SetAmmo(amSniperRifle, 0, 0, 0, 1) + SetAmmo(amDynamite, 0, 0, 0, 1) + SetAmmo(amPickHammer, 0, 0, 0, 1) +end + +function onNewTurn() + if AnimInProgress() then + TurnTimeLeft = -1 + elseif stage == endStage and CurrentHedgehog ~= leaks then + AnimSwitchHog(leaks) + SetGearMessage(leaks, 0) + TurnTimeLeft = -1 + elseif GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then + for i = 1, 4 do + if cannibalDead[i] ~= true then + if GetX(cannibals[i]) < GetX(leaks) then + HogTurnLeft(cannibals[i], false) + else + HogTurnLeft(cannibals[i], true) + end + end + end + SetInputMask(band(0xFFFFFFFF, bnot(gmLeft + gmRight + gmLJump + gmHJump))) + else + SetInputMask(0xFFFFFFFF) + TurnsLeft = TurnsLeft - 1 + end +end + +function onGearDamage(gear, damage) +end + +function onPrecise() + if GameTime > 2500 then + SetAnimSkip(true) + end +end + diff -r fd91aa100ce0 -r efc75c2d3be9 share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/shadow.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/shadow.lua Thu Aug 30 12:13:24 2012 -0400 @@ -0,0 +1,920 @@ +loadfile(GetDataPath() .. "Scripts/Locale.lua")() +loadfile(GetDataPath() .. "Scripts/Animate.lua")() + +-----------------------------Constants--------------------------------- +startStage = 0 +spyStage = 1 +wave1Stage = 2 +wave2Stage = 3 +cyborgStage = 4 +ramonStage = 5 +aloneStage = 6 +duoStage = 7 +interSpyStage = 8 +interWeakStage = 9 +acceptedReturnStage = 10 +refusedReturnStage = 11 +attackedReturnStage = 12 +loseStage = 13 + +ourTeam = 0 +weakTeam = 1 +strongTeam = 2 +cyborgTeam = 3 + +leaksNr = 0 +denseNr = 1 + +choiceAccept = 1 +choiceRefuse = 2 +choiceAttack = 3 + +HogNames = {loc("Brainiac"), loc("Corpsemonger"), loc("Femur Lover"), loc("Glark"), loc("Bonely"), loc("Rot Molester"), loc("Bloodrocutor"), loc("Muscle Dissolver"), loc("Bloodsucker")} + +---POSITIONS--- + +cannibalPos = {{3108, 1127}, + {2559, 1080}, {3598, 1270}, {3293, 1177}, {2623, 1336}, + {3418, 1336}, {3447, 1335}, {3481, 1340}, {3507, 1324}} +densePos = {2776, 1177} +leaksPos = {2941, 1172} +cyborgPos = {1113, 1818} + +---Animations + +startDialogue = {} +weaklingsAnim = {} +stronglingsAnim = {} +acceptedAnim = {} +acceptedSurvivedFinalAnim = {} +acceptedDiedFinalAnim = {} +refusedAnim = {} +refusedFinalAnim = {} +attackedAnim = {} +attackedFinalAnim = {} + +-----------------------------Variables--------------------------------- +lastHogTeam = ourTeam +lastOurHog = leaksNr +lastEnemyHog = 0 +stage = 0 +choice = 0 + +brainiacDead = false +cyborgHidden = false +leaksHidden = false +denseHidden = false +cyborgAttacked = false +retryReturn = false +shotgunTaken = false +grenadeTaken = false +spikyDead = false +ramonDead = false +denseDead = false +leaksDead = false +ramonHidden = false +spikyHidden = false +grenadeUsed = false +shotgunUsed = false + + +hogNr = {} +cannibalDead = {} +isHidden = {} + + +--------------------------Anim skip functions-------------------------- +function AfterRefusedAnim() + SpawnUtilityCrate(2045, 1575, amSwitch) + SpawnUtilityCrate(2365, 1495, amShotgun) + SpawnUtilityCrate(2495, 1519, amGrenade) + SpawnUtilityCrate(2620, 1524, amRope) + ShowMission(loc("The Shadow Falls"), loc("The Showdown"), loc("Save Leaks A Lot!|Hint: The Switch utility might be of help to you."), 1, 6000) + RemoveEventFunc(CheckDenseDead) + AddEvent(CheckStronglingsDead, {}, DoStronglingsDeadRefused, {}, 0) + AddAmmo(cannibals[6], amGrenade, 5) + stage = ramonStage + SwitchHog(cannibals[9]) + FollowGear(ramon) + TurnTimeLeft = 0 + SetGearMessage(ramon, 0) + HideHog(cyborg) + cyborgHidden = true + SetGearMessage(leaks, 0) +end + +function SkipRefusedAnim() + RefusedStart() + SetGearPosition(dense, 2645, 1146) + SetGearPosition(ramon, 2218, 1675) + SetGearPosition(spiky, 2400, 1675) +end + +function AfterStartDialogue() + stage = spyStage + ShowMission(loc("The Shadow Falls"), loc("Play with me!"), loc("Defend yourself!|Hint: You can get tips on using weapons by moving your mouse over them in the weapon selection menu"), 1, 6000) + TurnTimeLeft = TurnTime +end + + +function StartSkipFunc() + SetState(cannibals[1], 0) + AnimTurn(leaks, "Right") + AnimSwitchHog(leaks) + SetInputMask(0xFFFFFFFF) +end + +function AfterWeaklingsAnim() + AddAmmo(cannibals[2], amShotgun, 4) + AddAmmo(cannibals[2], amGrenade, 3) + AddAmmo(leaks, amSkip, 4) + AddEvent(CheckWeaklingsKilled, {}, DoWeaklingsKilled, {}, 0) + SetHealth(SpawnHealthCrate(2757, 1030), 50) + SetHealth(SpawnHealthCrate(2899, 1009), 50) + stage = wave1Stage + SwitchHog(dense) + SetGearMessage(dense, 0) + SetGearMessage(leaks, 0) + TurnTimeLeft = TurnTime + ShowMission(loc("The Shadow Falls"), loc("Why do you not like me?"), loc("Obliterate them!|Hint: You might want to take cover..."), 1, 6000) +end + +function SkipWeaklingsAnim() + for i = 2, 5 do + if isHidden[cannibals[i]] == true then + RestoreHog(cannibals[i]) + isHidden[cannibals[i]] = false + end + SetGearPosition(cannibals[i], unpack(cannibalPos[i])) + SetState(cannibals[i], 0) + end + SetInputMask(0xFFFFFFFF) +end + +function AfterStronglingsAnim() + stage = cyborgStage + TurnTimeLeft = 0 + ShowMission(loc("The Shadow Falls"), loc("The Dilemma"), loc("Choose your side! If you want to join the strange man, walk up to him.|Otherwise, walk away from him. If you decide to att...nevermind..."), 1, 8000) + AddEvent(CheckChoice, {}, DoChoice, {}, 0) + AddEvent(CheckRefuse, {}, DoRefuse, {}, 0) + AddEvent(CheckAccept, {}, DoAccept, {}, 0) + AddEvent(CheckConfront, {}, DoConfront, {}, 0) + AddAmmo(dense, amSwitch, 0) + AddAmmo(dense, amSkip, 0) + SetHealth(SpawnHealthCrate(2557, 1030), 50) + SetHealth(SpawnHealthCrate(3599, 1009), 50) +end + +function SkipStronglingsAnim() + for i = 6, 9 do + if isHidden[cannibals[i]] == true then + RestoreHog(cannibals[i]) + isHidden[cannibals[i]] = false + end + SetGearPosition(cannibals[i], unpack(cannibalPos[i])) + SetState(cannibals[i], 0) + end + if cyborgHidden == true then + RestoreHog(cyborg) + cyborgHidden = false + end + SetState(cyborg, 0) + SetState(dense, 0) + SetGearPosition(dense, 1350, 1310) + FollowGear(dense) + HogTurnLeft(dense, true) + SetGearPosition(cyborg, 1250, 1310) + SwitchHog(dense) + SetInputMask(0xFFFFFFFF) +end + +function RestartReturnAccepted() + retryReturn = false + SetGearPosition(dense, 1350, 1310) + AddAmmo(dense, amGirder, 2) + AddAmmo(dense, amParachute, 2) + ShowMission(loc("The Shadow Falls"), loc("The walk of Fame"), loc("Return to Leaks A Lot! If you get stuck, press [Precise] to try again!"), 1, 6000) + RemoveEventFunc(CheckNeedGirder) + RemoveEventFunc(CheckNeedWeapons) + AddEvent(CheckNeedGirder, {}, DoNeedGirder, {}, 0) + AddEvent(CheckNeedWeapons, {}, DoNeedWeapons, {}, 0) +end + + +function AfterAcceptedAnim() + stage = acceptedReturnStage + SpawnAmmoCrate(1370, 810, amGirder) + SpawnAmmoCrate(1300, 810, amParachute) + ShowMission(loc("The Shadow Falls"), loc("The walk of Fame"), loc("Return to Leaks A Lot! If you get stuck, press [Precise] to try again!"), 1, 6000) + HideHog(cyborg) + AddEvent(CheckTookWeapons, {}, DoTookWeapons, {}, 0) + AddEvent(CheckNeedGirder, {}, DoNeedGirder, {}, 0) + AddEvent(CheckNeedWeapons, {}, DoNeedWeapons, {}, 0) + AddEvent(CheckRestartReturnAccepted, {}, RestartReturnAccepted, {}, 1) + RemoveEventFunc(CheckDenseDead) +end + +function SkipAcceptedAnim() + SetGearPosition(cyborg, unpack(cyborgPos)) + SetState(cyborg, gstInvisible) + AnimSwitchHog(dense) + SetInputMask(0xFFFFFFFF) +end + +function AfterAttackedAnim() + stage = aloneStage + HideHog(cyborg) + ShowMission(loc("The Shadow Falls"), loc("The Individualist"), loc("Defeat the cannibals!|Grenade hint: set the timer with [1-5], aim with [Up]/[Down] and hold [Space] to set power"), 1, 8000) + AddAmmo(cannibals[6], amGrenade, 5) + AddAmmo(cannibals[6], amFirePunch, 0) + AddAmmo(cannibals[6], amBaseballBat, 0) + SetGearMessage(leaks, 0) + TurnTimeLeft = TurnTime + AddEvent(CheckStronglingsDead, {}, DoStronglingsDeadAttacked, {}, 0) +end + +function SkipAttackedAnim() + if denseDead == false then + DeleteGear(dense) + end + SpawnAmmoCrate(2551, 994, amGrenade) + SpawnAmmoCrate(3551, 994, amGrenade) + SpawnAmmoCrate(3392, 1101, amShotgun) + SpawnAmmoCrate(3192, 1101, amShotgun) + SetGearPosition(cyborg, unpack(cyborgPos)) + SetState(cyborg, gstInvisible) + AnimSwitchHog(leaks) + SetInputMask(0xFFFFFFFF) +end + + +-----------------------------Animations-------------------------------- + +function SpawnCrates() + SpawnAmmoCrate(2551, 994, amGrenade) + SpawnAmmoCrate(3551, 994, amGrenade) + SpawnAmmoCrate(3392, 1101, amShotgun) + SpawnAmmoCrate(3192, 1101, amShotgun) + return true +end + +function EmitDenseClouds(anim, dir) + local dif + if dir == "Left" then + dif = 10 + else + dif = -10 + end + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {dense, 800}}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {dense, 800}}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) +end + +function BlowDenseCloud() + AnimInsertStepNext({func = DeleteGear, args = {dense}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense), GetY(dense), vgtBigExplosion, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {dense, 1200}}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + 20, GetY(dense), vgtExplosion, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {dense, 100}}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + 10, GetY(dense), vgtExplosion, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {dense, 100}}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) - 10, GetY(dense), vgtExplosion, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {dense, 100}}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) - 20, GetY(dense), vgtExplosion, 0, true}, swh = false}) +end + +function SetupAcceptedSurvivedFinalAnim() + table.insert(acceptedSurvivedFinalAnim, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {leaks, dense}}}) + table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {leaks, loc("Pfew! That was close!"), SAY_SAY, 3000}}) + if grenadeUsed and shotgunUsed then + table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {leaks, loc("Where did you get the exploding apples and the magic bow that shoots many arrows?"), SAY_SAY, 9000}}) + elseif grenadeUsed then + table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {leaks, loc("Where did you get the exploding apples?"), SAY_SAY, 6000}}) + elseif shotgunUsed then + table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {leaks, loc("Where did you get the magic bow that shoots many arrows?"), SAY_SAY, 8000}}) + else + table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {leaks, loc("Did you warn the village?"), SAY_SAY, 4000}}) + table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {dense, loc("No, I came back to help you out..."), SAY_SAY, 5000}}) + end + if grenadeUsed or shotgunUsed then + table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {dense, loc("Uhm...I met one of them and took his weapons."), SAY_SAY, 5000}}) + end + table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {dense, loc("We should head back to the village now."), SAY_SAY, 5000}}) +end + +function AnimationSetup() + table.insert(startDialogue, {func = AnimWait, args = {dense, 4000}}) + table.insert(startDialogue, {func = AnimCaption, args = {leaks, loc("After the shock caused by the enemy spy, Leaks A Lot and Dense Cloud went hunting to relax."), 6000}}) + table.insert(startDialogue, {func = AnimCaption, args = {leaks, loc("Little did they know that this hunt will mark them forever..."), 4000}}) + table.insert(startDialogue, {func = AnimSay, args = {leaks, loc("I have no idea where that mole disappeared...Can you see it?"), SAY_SAY, 9000}}) + table.insert(startDialogue, {func = AnimSay, args = {dense, loc("Nope. It was one fast mole, that's for sure."), SAY_SAY, 5000}}) + table.insert(startDialogue, {func = AnimCustomFunction, args = {dense, EmitDenseClouds, {startDialogue, "Right"}}}) + table.insert(startDialogue, {func = AnimWait, args = {dense, 2000}}) + table.insert(startDialogue, {func = AnimSay, args = {leaks, loc("Please, stop releasing your \"smoke signals\"!"), SAY_SAY, 5000}}) + table.insert(startDialogue, {func = AnimSay, args = {leaks, loc("You're terrorizing the forest...We won't catch anything like this!"), SAY_SAY, 6000}}) + table.insert(startDialogue, {func = AnimSay, args = {leaks, loc("..."), SAY_THINK, 1000}}) + table.insert(startDialogue, {func = AnimGiveState, args = {cannibals[1], 0}, swh = false}) + table.insert(startDialogue, {func = AnimOutOfNowhere, args = {cannibals[1], unpack(cannibalPos[1])}, swh = false}) + table.insert(startDialogue, {func = AnimTurn, args = {leaks, "Right"}}) + table.insert(startDialogue, {func = AnimTurn, args = {cannibals[1], "Right"}}) + table.insert(startDialogue, {func = AnimWait, args = {cannibals[1], 1000}}) + table.insert(startDialogue, {func = AnimTurn, args = {cannibals[1], "Left"}}) + table.insert(startDialogue, {func = AnimWait, args = {cannibals[1], 1000}}) + table.insert(startDialogue, {func = AnimTurn, args = {cannibals[1], "Right"}}) + table.insert(startDialogue, {func = AnimSay, args = {cannibals[1], loc("I can't believe it worked!"), SAY_THINK, 3500}}) + table.insert(startDialogue, {func = AnimSay, args = {cannibals[1], loc("That shaman sure knows what he/she's doing!"), SAY_THINK, 6000}}) + table.insert(startDialogue, {func = AnimSay, args = {leaks, loc("It wants our brains!"), SAY_SHOUT, 3000}}) + table.insert(startDialogue, {func = AnimTurn, args = {cannibals[1], "Left"}}) + table.insert(startDialogue, {func = AnimSay, args = {cannibals[1], loc("Not you again! My head still hurts from last time!"), SAY_SHOUT, 6000}}) + table.insert(startDialogue, {func = AnimSwitchHog, args = {leaks}}) + AddSkipFunction(startDialogue, StartSkipFunc, {}) + + table.insert(weaklingsAnim, {func = AnimGearWait, args = {leaks, 1000}}) + table.insert(weaklingsAnim, {func = AnimCustomFunction, args = {leaks, CondNeedToTurn, {leaks, dense}}}) + table.insert(weaklingsAnim, {func = AnimSay, args = {leaks, loc("Did you see him coming?"), SAY_SAY, 3500}}) + table.insert(weaklingsAnim, {func = AnimSay, args = {dense, loc("No. Where did he come from?"), SAY_SAY, 3500}}) + table.insert(weaklingsAnim, {func = AnimCustomFunction, args = {leaks, UnHideWeaklings, {}}}) + table.insert(weaklingsAnim, {func = AnimOutOfNowhere, args = {cannibals[2], unpack(cannibalPos[2])}}) + table.insert(weaklingsAnim, {func = AnimGiveState, args = {cannibals[2], 0}}) + table.insert(weaklingsAnim, {func = AnimWait, args = {leaks, 400}}) + table.insert(weaklingsAnim, {func = AnimGiveState, args = {cannibals[3], 0}}) + table.insert(weaklingsAnim, {func = AnimOutOfNowhere, args = {cannibals[3], unpack(cannibalPos[3])}}) + table.insert(weaklingsAnim, {func = AnimWait, args = {leaks, 400}}) + table.insert(weaklingsAnim, {func = AnimGiveState, args = {cannibals[4], 0}}) + table.insert(weaklingsAnim, {func = AnimOutOfNowhere, args = {cannibals[4], unpack(cannibalPos[4])}}) + table.insert(weaklingsAnim, {func = AnimWait, args = {leaks, 400}}) + table.insert(weaklingsAnim, {func = AnimGiveState, args = {cannibals[5], 0}}) + table.insert(weaklingsAnim, {func = AnimOutOfNowhere, args = {cannibals[5], unpack(cannibalPos[5])}}) + table.insert(weaklingsAnim, {func = AnimWait, args = {leaks, 400}}) + table.insert(weaklingsAnim, {func = AnimSay, args = {cannibals[3], loc("Are we there yet?"), SAY_SAY, 4000}}) + table.insert(weaklingsAnim, {func = AnimSay, args = {dense, loc("This must be some kind of sorcery!"), SAY_SHOUT, 3500}}) + table.insert(weaklingsAnim, {func = AnimSwitchHog, args = {leaks}}) + AddSkipFunction(weaklingsAnim, SkipWeaklingsAnim, {}) + + table.insert(stronglingsAnim, {func = AnimGearWait, args = {leaks, 1000}}) + table.insert(stronglingsAnim, {func = AnimCustomFunction, args = {leaks, UnHideStronglings, {}}}) + table.insert(stronglingsAnim, {func = AnimCustomFunction, args = {leaks, CondNeedToTurn, {leaks, dense}}}) + table.insert(stronglingsAnim, {func = AnimGiveState, args = {leaks, 0}}) + table.insert(stronglingsAnim, {func = AnimGiveState, args = {dense, 0}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, loc("I thought their shaman died when he tried our medicine!"), SAY_SAY, 7000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {dense, loc("I saw it with my own eyes!"), SAY_SAY, 4000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, loc("Then how do they keep appearing?"), SAY_SAY, 4000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, loc("It's impossible to communicate with the spirits without a shaman."), SAY_SAY, 7000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {dense, loc("We need to warn the village."), SAY_SAY, 3500}}) + table.insert(stronglingsAnim, {func = AnimGiveState, args = {cannibals[6], 0}}) + table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cannibals[6], unpack(cannibalPos[6])}}) + table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 400}}) + table.insert(stronglingsAnim, {func = AnimGiveState, args = {cannibals[7], 0}}) + table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cannibals[7], unpack(cannibalPos[7])}}) + table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 400}}) + table.insert(stronglingsAnim, {func = AnimGiveState, args = {cannibals[8], 0}}) + table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cannibals[8], unpack(cannibalPos[8])}}) + table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 400}}) + table.insert(stronglingsAnim, {func = AnimGiveState, args = {cannibals[9], 0}}) + table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cannibals[9], unpack(cannibalPos[9])}}) + table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 400}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {cannibals[7], loc("What a ride!"), SAY_SHOUT, 2000}}) + table.insert(stronglingsAnim, {func = AnimTurn, args = {leaks, "Right"}}) + table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 700}}) + table.insert(stronglingsAnim, {func = AnimTurn, args = {leaks, "Left"}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, loc("We can't defeat them!"), SAY_THINK, 3000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, loc("I'll hold them up while you return to the village!"), SAY_SAY, 6000}}) + table.insert(stronglingsAnim, {func = AnimFollowGear, args = {cyborg}, swh = false}) + table.insert(stronglingsAnim, {func = AnimCaption, args = {cyborg, loc("30 minutes later...")}, swh = false}) + table.insert(stronglingsAnim, {func = AnimWait, args = {cyborg, 2000}}) + table.insert(stronglingsAnim, {func = AnimSetGearPosition, args = {dense, 1420, 1315}}) + table.insert(stronglingsAnim, {func = AnimMove, args = {dense, "Left", 1400, 0}}) + table.insert(stronglingsAnim, {func = AnimCustomFunction, args = {dense, EmitDenseClouds, {stronglingsAnim, "Left"}}}) + table.insert(stronglingsAnim, {func = AnimMove, args = {dense, "Left", 1350, 0}}) + table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cyborg, 1250, 1320}}) + table.insert(stronglingsAnim, {func = AnimRemoveState, args = {cyborg, gstInvisible}}) + table.insert(stronglingsAnim, {func = AnimGearWait, args = {cyborg, 2000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, loc("Greetings, cloudy one!"), SAY_SAY, 3000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, loc("I have come to make you an offering..."), SAY_SAY, 6000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, loc("You are given the chance to turn your life around..."), SAY_SAY, 6000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, loc("If you agree to provide the information we need, you will be spared!"), SAY_SAY, 7000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, loc("Have no illusions, your tribe is dead, indifferent of your choice."), SAY_SAY, 7000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, loc("If you decide to help us, though, we will no longer need to find a new governor for the island."), SAY_SAY, 8000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, loc("If you know what I mean..."), SAY_SAY, 3000}}) + table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, loc("So? What will it be?"), SAY_SAY, 3000}}) + table.insert(stronglingsAnim, {func = AnimSwitchHog, args = {dense}}) + AddSkipFunction(stronglingsAnim, SkipStronglingsAnim, {}) + + table.insert(acceptedAnim, {func = AnimSay, args = {cyborg, loc("Great choice, Steve! Mind if I call you that?"), SAY_SAY, 7000}}) + table.insert(acceptedAnim, {func = AnimSay, args = {dense, loc("Whatever floats your boat..."), SAY_SAY, 4500}}) + table.insert(acceptedAnim, {func = AnimSay, args = {cyborg, loc("Great! You will be contacted soon for assistance."), SAY_SAY, 6000}}) + table.insert(acceptedAnim, {func = AnimSay, args = {cyborg, loc("In the meantime, take these and return to your \"friend\"!"), SAY_SAY, 6000}}) + table.insert(acceptedAnim, {func = AnimGiveState, args = {cyborg, gstInvisible}}) + table.insert(acceptedAnim, {func = AnimDisappear, args = {cyborg, unpack(cyborgPos)}}) + table.insert(acceptedAnim, {func = AnimSwitchHog, args = {dense}}) + AddSkipFunction(acceptedAnim, SkipAcceptedAnim, {}) + + table.insert(acceptedDiedFinalAnim, {func = AnimSay, args = {leaks, loc("Pfew! That was close!"), SAY_THINK, 3000}}) + table.insert(acceptedDiedFinalAnim, {func = AnimSay, args = {leaks, loc("Your death will not be in vain, Dense Cloud!"), SAY_THINK, 5000}}) + table.insert(acceptedDiedFinalAnim, {func = AnimSay, args = {dense, loc("You will be avenged!"), SAY_SAY, 3000}}) + + table.insert(refusedAnim, {func = AnimSay, args = {cyborg, loc("I see..."), SAY_SAY, 2000}}) + table.insert(refusedAnim, {func = AnimSay, args = {cyborg, loc("Remember this, pathetic animal: when the day comes, you will regret your blind loyalty!"), SAY_SAY, 8000}}) + table.insert(refusedAnim, {func = AnimSay, args = {cyborg, loc("You just committed suicide..."), SAY_SAY, 5000}}) + table.insert(refusedAnim, {func = AnimDisappear, args = {cyborg, unpack(cyborgPos)}}) + table.insert(refusedAnim, {func = AnimGiveState, args = {cyborg, gstInvisible}}) + table.insert(refusedAnim, {func = AnimSay, args = {dense, loc("If you say so..."), SAY_THINK, 3000}}) + table.insert(refusedAnim, {func = AnimFollowGear, args = {cyborg}, swh = false}) + table.insert(refusedAnim, {func = AnimWait, args = {cyborg, 700}}) + table.insert(refusedAnim, {func = AnimCustomFunction, args = {dense, RefusedStart, {}}}) + table.insert(refusedAnim, {func = AnimOutOfNowhere, args = {dense, 2645, 1146}}) + table.insert(refusedAnim, {func = AnimOutOfNowhere, args = {ramon, 2218, 1675}}) + table.insert(refusedAnim, {func = AnimOutOfNowhere, args = {spiky, 2400, 1675}}) + table.insert(refusedAnim, {func = AnimTurn, args = {spiky, "Left"}}) + table.insert(refusedAnim, {func = AnimWait, args = {cyborg, 1700}}) + table.insert(refusedAnim, {func = AnimTurn, args = {spiky, "Right"}}) + table.insert(refusedAnim, {func = AnimWait, args = {cyborg, 1700}}) + table.insert(refusedAnim, {func = AnimTurn, args = {spiky, "Left"}}) + table.insert(refusedAnim, {func = AnimSay, args = {spiky, loc("Dude, we really need a new shaman..."), SAY_SAY, 4000}}) + AddSkipFunction(refusedAnim, SkipRefusedAnim, {}) + + table.insert(refusedFinalAnim, {func = AnimSay, args = {leaks, loc("It's over..."), SAY_SAY, 2000}}) + table.insert(refusedFinalAnim, {func = AnimSay, args = {leaks, loc("Let's head back to the village!"), SAY_SAY, 4000}}) + + table.insert(attackedAnim, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {cyborg, dense}}}) + table.insert(attackedAnim, {func = AnimCustomFunction, args = {cyborg, SetHealth, {cyborg, 200}}}) + table.insert(attackedAnim, {func = AnimWait, args = {cyborg, 2000}}) + table.insert(attackedAnim, {func = AnimSay, args = {cyborg, loc("Really?! You thought you could harm me with your little toys?"), SAY_SAY, 7000}}) + table.insert(attackedAnim, {func = AnimSay, args = {cyborg, loc("You're pathetic! You are not worthy of my attention..."), SAY_SAY, 6000}}) + table.insert(attackedAnim, {func = AnimSay, args = {cyborg, loc("Actually, you aren't worthy of life! Take this..."), SAY_SAY, 5000}}) + table.insert(attackedAnim, {func = AnimCustomFunction, args = {dense, BlowDenseCloud, {}}, swh = false}) + table.insert(attackedAnim, {func = AnimWait, args = {cyborg, 2000}}) + table.insert(attackedAnim, {func = AnimSay, args = {cyborg, loc("Incredible..."), SAY_SAY, 3000}}) + table.insert(attackedAnim, {func = AnimDisappear, args = {cyborg, unpack(cyborgPos)}}) + table.insert(attackedAnim, {func = AnimGiveState, args = {cyborg, gstInvisible}}) + table.insert(attackedAnim, {func = AnimSwitchHog, args = {leaks}}) + table.insert(attackedAnim, {func = AnimSay, args = {leaks, loc("I wonder where Dense Cloud is..."), SAY_THINK, 4000}}) + table.insert(attackedAnim, {func = AnimSay, args = {leaks, loc("I can't wait any more, I have to save myself!"), SAY_THINK, 5000}}) + table.insert(attackedAnim, {func = AnimCustomFunction, args = {leaks, SpawnCrates, {}}}) + table.insert(attackedAnim, {func = AnimWait, args = {leaks, 1500}}) + table.insert(attackedAnim, {func = AnimSay, args = {leaks, loc("Where are all these crates coming from?!"), SAY_THINK, 5500}}) + AddSkipFunction(attackedAnim, SkipAttackedAnim, {}) + + table.insert(attackedFinalAnim, {func = AnimWait, args = {leaks, 2000}}) + table.insert(attackedFinalAnim, {func = AnimSay, args = {leaks, loc("I have to get back to the village!"), SAY_THINK, 5000}}) + table.insert(attackedFinalAnim, {func = AnimSay, args = {leaks, loc("Dense Cloud must have already told them everything..."), SAY_THINK, 7000}}) + +end + + +-----------------------------Misc-------------------------------------- + + +function RefusedStart() + if ramonHidden == true then + RestoreHog(ramon) + ramonHidden = false + end + if spikyHidden == true then + RestoreHog(spiky) + spikyHidden = false + end + SetState(ramon, 0) + SetState(spiky, 0) + SetGearMessage(dense, 0) + SetGearMessage(ramon, 0) + SetGearMessage(spiky, 0) +end + +function AddHogs() + AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy") + ramon = AddHog(loc("Ramon"), 0, 100, "rasta") + leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo") + dense = AddHog(loc("Dense Cloud"), 0, 100, "RobinHood") + spiky = AddHog(loc("Spiky Cheese"), 0, 100, "hair_yellow") + + AddTeam(loc("Weaklings"), 14483456, "Skull", "Island", "Pirate","cm_vampire") + cannibals = {} + cannibals[1] = AddHog(loc("Brainiac"), 5, 20, "Zombi") + + for i = 2, 5 do + cannibals[i] = AddHog(HogNames[i], 1, 20, "Zombi") + hogNr[cannibals[i]] = i - 2 + end + + AddTeam(loc("Stronglings"), 14483456, "Skull", "Island", "Pirate","cm_vampire") + + for i = 6, 9 do + cannibals[i] = AddHog(HogNames[i], 2, 30, "vampirichog") + hogNr[cannibals[i]] = i - 2 + end + + AddTeam(loc("011101001"), 14483456, "ring", "UFO", "Robot", "cm_star") + cyborg = AddHog(loc("Y3K1337"), 0, 200, "cyborg1") +end + +function PlaceHogs() + HogTurnLeft(leaks, true) + + for i = 2, 9 do + SetGearPosition(cannibals[i], unpack(cyborgPos)) + AnimTurn(cannibals[i], "Left") + cannibalDead[i] = false + end + + SetGearPosition(cannibals[1], cannibalPos[1][1], cannibalPos[1][2]) + AnimTurn(cannibals[1], "Left") + + SetGearPosition(cyborg, cyborgPos[1], cyborgPos[2]) + SetGearPosition(ramon, 2218, 1675) + SetGearPosition(skiky, 2400, 1675) + SetGearPosition(dense, densePos[1], densePos[2]) + SetGearPosition(leaks, leaksPos[1], leaksPos[2]) +end + +function VisiblizeHogs() + for i = 1, 9 do + SetState(cannibals[i], gstInvisible) + end + SetState(cyborg, gstInvisible) + SetState(ramon, gstInvisible) + SetState(spiky, gstInvisible) +end + +function CondNeedToTurn(hog1, hog2) + xl, xd = GetX(hog1), GetX(hog2) + if xl > xd then + AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}}) + elseif xl < xd then + AnimInsertStepNext({func = AnimTurn, args = {hog2, "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {hog1, "Right"}}) + end +end + +function HideHogs() + for i = 2, 9 do + HideHog(cannibals[i]) + isHidden[cannibals[i]] = true + end + HideHog(cyborg) + cyborgHidden = true + HideHog(ramon) + HideHog(spiky) + ramonHidden = true + spikyHidden = true +end + +function HideStronglings() + for i = 6, 9 do + HideHog(cannibals[i]) + isHidden[cannibals[i]] = true + end +end + +function UnHideWeaklings() + for i = 2, 5 do + RestoreHog(cannibals[i]) + isHidden[cannibals[i]] = false + SetState(cannibals[i], gstInvisible) + end +end + +function UnHideStronglings() + for i = 6, 9 do + RestoreHog(cannibals[i]) + isHidden[cannibals[i]] = false + SetState(cannibals[i], gstInvisible) + end + RestoreHog(cyborg) + cyborgHidden = false + SetState(cyborg, gstInvisible) +end + +function ChoiceTaken() + if choice == choiceAccept then + AddAnim(acceptedAnim) + AddFunction({func = AfterAcceptedAnim, args = {}}) + elseif choice == choiceRefuse then + AddAnim(refusedAnim) + AddFunction({func = AfterRefusedAnim, args = {}}) + else + AddAnim(attackedAnim) + AddFunction({func = AfterAttackedAnim, args = {}}) + end +end + +function KillCyborg() + RestoreHog(cyborg) + DeleteGear(cyborg) + TurnTimeLeft = 0 +end +-----------------------------Events------------------------------------ + +function CheckBrainiacDead() + return brainiacDead +end + +function DoBrainiacDead() + TurnTimeLeft = 0 + AddAnim(weaklingsAnim) + AddFunction({func = AfterWeaklingsAnim, args = {}}) + stage = interSpyStage +end + +function CheckWeaklingsKilled() + for i = 2, 5 do + if cannibalDead[i] == false then + return false + end + end + return true +end + +function DoWeaklingsKilled() + TurnTimeLeft = 0 + AddAnim(stronglingsAnim) + AddFunction({func = AfterStronglingsAnim, args = {}}) + stage = interWeakStage + ParseCommand("teamgone " .. loc("Weaklings")) +end + +function CheckRefuse() + return GetX(dense) > 1400 and StoppedGear(dense) +end + +function DoRefuse() + choice = choiceRefuse +end + +function CheckAccept() + return GetX(dense) < 1300 and StoppedGear(dense) +end + +function DoAccept() + choice = choiceAccept +end + +function CheckConfront() + return cyborgAttacked and StoppedGear(dense) +end + +function DoConfront() + choice = choiceAttack +end + +function CheckChoice() + return choice ~= 0 +end + +function DoChoice() + RemoveEventFunc(CheckConfront) + RemoveEventFunc(CheckAccept) + RemoveEventFunc(CheckRefuse) + ChoiceTaken() +end + +function CheckNeedGirder() + return GetX(dense) > 1640 and StoppedGear(dense) +end + +function DoNeedGirder() + ShowMission(loc("The Shadow Falls"), loc("Under Construction"), loc("To place a girder, select it, use [Left] and [Right] to select angle and length, place with [Left Click]"), 1, 6000) +end + +function CheckNeedWeapons() + return GetX(dense) > 2522 and StoppedGear(dense) +end + +function DoNeedWeapons() + grenadeCrate = SpawnAmmoCrate(2550, 800, amGrenade) + shotgunCrate = SpawnAmmoCrate(2610, 850, amShotgun) + AddCaption(loc("A little gift from the cyborgs")) +end + +function CheckTookWeapons() + return shotgunTaken and grenadeTaken +end + +function DoTookWeapons() + ShowMission(loc("The Shadow Falls"), loc("The guardian"), loc("Protect yourselves!|Grenade hint: set the timer with [1-5], aim with [Up]/[Down] and hold [Space] to set power"), 1, 8000) + AddAmmo(dense, amSkip, 100) + AddAmmo(dense, amSwitch, 100) + stage = duoStage + RemoveEventFunc(CheckNeedGirder) + RemoveEventFunc(CheckNeedWeapons) + RemoveEventFunc(CheckRestartReturnAccepted) + AddEvent(CheckStronglingsDead, {}, DoStronglingsDead, {}, 0) + AddAmmo(cannibals[6], amGrenade, 7) + AddAmmo(cannibals[6], amShotgun, 7) + SetGearMessage(leaks, 0) + SetGearMessage(dense, 0) + TurnTimeLeft = TurnTime +end + +function DoStronglingsDead() + if denseDead == true then + AddAnim(acceptedDiedFinalAnim) + SaveCampaignVar("M2DenseDead", "1") + else + SetupAcceptedSurvivedFinalAnim() + AddAnim(acceptedSurvivedFinalAnim) + SaveCampaignVar("M2DenseDead", "0") + end + SaveCampaignVar("M2RamonDead", "0") + SaveCampaignVar("M2SpikyDead", "0") + AddFunction({func = KillCyborg, args = {}}) + SaveCampaignVar("Progress", "2") + SaveCampaignVar("M2Choice", "" .. choice) +end + +function DoStronglingsDeadRefused() + if denseDead == true then + SaveCampaignVar("M2DenseDead", "1") + else + SaveCampaignVar("M2DenseDead", "0") + end + if ramonDead == true then + SaveCampaignVar("M2RamonDead", "1") + else + SaveCampaignVar("M2RamonDead", "0") + end + if spikyDead == true then + SaveCampaignVar("M2SpikyDead", "1") + else + SaveCampaignVar("M2SpikyDead", "0") + end + AddAnim(refusedFinalAnim) + AddFunction({func = KillCyborg, args = {}}) + SaveCampaignVar("Progress", "2") + SaveCampaignVar("M2Choice", "" .. choice) +end + +function DoStronglingsDeadAttacked() + SaveCampaignVar("M2DenseDead", "1") + SaveCampaignVar("M2RamonDead", "0") + SaveCampaignVar("M2SpikyDead", "0") + SaveCampaignVar("Progress", "2") + SaveCampaignVar("M2Choice", "" .. choice) + AddAnim(attackedFinalAnim) + AddFunction({func = KillCyborg, args = {}}) +end + +function CheckStronglingsDead() + if leaksDead == true then + return false + end + for i = 6, 9 do + if cannibalDead[i] == false then + return false + end + end + return true +end + +function CheckLeaksDead() + return leaksDead +end + +function DoDead() + AddCaption(loc("...and so the cyborgs took over the world...")) + stage = loseStage + TurnTimeLeft = 0 + ParseCommand("teamgone " .. loc("Natives")) +end + +function CheckDenseDead() + return denseDead and choice ~= choiceAttack +end + +function CheckRestartReturnAccepted() + return retryReturn +end + +-----------------------------Main Functions---------------------------- + +function onGameInit() + Seed = 334 + TemplateFilter = 3 + GameFlags = gfSolidLand + gfDisableWind + TurnTime = 50000 + CaseFreq = 0 + MinesNum = 0 + MinesTime = 3000 + Explosives = 0 + Delay = 10 + MapGen = 0 + Theme = "Nature" + SuddenDeathTurns = 3000 + + AddHogs() + PlaceHogs() + VisiblizeHogs() + + AnimInit() + AnimationSetup() +end + +function onGameStart() + HideHogs() + AddAmmo(leaks, amSwitch, 100) + AddEvent(CheckLeaksDead, {}, DoDead, {}, 0) + AddEvent(CheckDenseDead, {}, DoDead, {}, 0) + AddAnim(startDialogue) + AddFunction({func = AfterStartDialogue, args = {}}) + AddEvent(CheckBrainiacDead, {}, DoBrainiacDead, {}, 0) + ShowMission(loc("The Shadow Falls"), loc("The First Encounter"), loc("Survive!|Hint: Cinematics can be skipped with the [Precise] key."), 1, 0) +end + +function onGameTick() + AnimUnWait() + if ShowAnimation() == false then + return + end + ExecuteAfterAnimations() + CheckEvents() +end + +function onGearDelete(gear) + if gear == cannibals[1] then + brainiacDead = true + elseif gear == grenadeCrate then + grenadeTaken = true + elseif gear == shotgunCrate then + shotgunTaken = true + elseif gear == dense then + denseDead = true + elseif gear == leaks then + leaksDead = true + elseif gear == ramon then + ramonDead = true + elseif gear == spiky then + spikyDead = true + else + for i = 2, 9 do + if gear == cannibals[i] then + cannibalDead[i] = true + end + end + end +end + +function onGearAdd(gear) + if GetGearType(gear) == gtGrenade and GetHogTeamName(CurrentHedgehog) == loc("Natives") then + grenadeUsed = true + elseif GetGearType(gear) == gtShotgunShot and GetHogTeamName(CurrentHedgehog) == loc("Natives") then + shotgunUsed = true + end +end + +function onAmmoStoreInit() + SetAmmo(amDEagle, 9, 0, 0, 0) + SetAmmo(amSniperRifle, 6, 0, 0, 0) + SetAmmo(amFirePunch, 3, 0, 0, 0) + SetAmmo(amWhip, 4, 0, 0, 0) + SetAmmo(amBaseballBat, 4, 0, 0, 0) + SetAmmo(amHammer, 2, 0, 0, 0) + SetAmmo(amLandGun, 1, 0, 0, 0) + SetAmmo(amSnowball, 7, 0, 0, 0) + SetAmmo(amGirder, 0, 0, 0, 2) + SetAmmo(amParachute, 0, 0, 0, 2) + SetAmmo(amGrenade, 0, 0, 0, 3) + SetAmmo(amShotgun, 0, 0, 0, 3) + SetAmmo(amSwitch, 0, 0, 0, 8) + SetAmmo(amRope, 0, 0, 0, 6) +end + +function onNewTurn() + if AnimInProgress() then + TurnTimeLeft = -1 +-- elseif stage == interSpyStage and GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then +-- TurnTimeLeft = 0 +-- SetState(CurrentHedgehog, gstInvisible) + elseif stage == cyborgStage then + if CurrentHedgehog ~= dense then + TurnTimeLeft = 0 + else + TurnTimeLeft = -1 + end + elseif stage == acceptedReturnStage then + SwitchHog(dense) + FollowGear(dense) + TurnTimeLeft = -1 + end +end + +function onGearDamage(gear, damage) + if gear == cyborg and stage == cyborgStage then + cyborgAttacked = true + end +end + +function onPrecise() + if GameTime > 2500 then + SetAnimSkip(true) + end + if stage == acceptedReturnStage then + retryReturn = true + end +end + diff -r fd91aa100ce0 -r efc75c2d3be9 share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/united.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/united.lua Thu Aug 30 12:13:24 2012 -0400 @@ -0,0 +1,527 @@ +loadfile(GetDataPath() .. "Scripts/Locale.lua")() +loadfile(GetDataPath() .. "Scripts/Animate.lua")() + +-----------------------------Constants--------------------------------- +choiceAccept = 1 +choiceRefuse = 2 +choiceAttack = 3 + +leaksPos = {2067, 509} +densePos = {1882, 503} +waterPos = {3100, 930} +buffaloPos = {2609, 494} +chiefPos = {2538, 617} +cannibalPos = {{2219, 1339}, {2322, 1357}, {805, 784}, {3876, 1048}, + {1101, 916}, {2854, 1408}, {1974, 486}, {1103, 961}} + +HogNames = {loc("Olive"), loc("Brain Stu"), loc("Brainila"), loc("Salivaslurper"), + loc("Spleenlover"), loc("Tighlicker"), loc("NomNom"), loc("Mindy")} + +natives = {} +-----------------------------Variables--------------------------------- +cannibals = {} +cannibalDead = {} +cannibalHidden = {} +cratesSpawned = {} +healthCratesSpawned = {} + +sdrmv = 0 +denseDead = false +leaksDead = false +waterDead = false +buffaloDead = false +chiefDead = false +nativesDead = {} + +m2Choice = 0 +m2DenseDead = 0 + +startAnim = {} +wave2Anim = {} +finalAnim = {} +--------------------------Anim skip functions-------------------------- +function AfterHogDeadAnim() + freshDead = nil + TurnTimeLeft = TurnTime +end + +function AfterStartAnim() + local goal = loc("Defeat the cannibals!|") + local chiefgoal = loc("Try to protect the chief! You won't lose if he dies, but it is advised that he survives.") + TurnTimeLeft = TurnTime + ShowMission(loc("United We Stand"), loc("Invasion"), goal .. chiefgoal, 1, 6000) +end + +function SkipStartAnim() + SetGearPosition(water, 2467, 754) + if cratesSpawned[1] ~= true then + SpawnCrates(1) + end + if healthCratesSpawned[1] ~= true then + SpawnHealthCrates(1) + end + if cannibalHidden[1] == true then + RestoreWave(1) + end + AnimSwitchHog(leaks) +end + +function SkipWave2Anim() + if cratesSpawned[2] ~= true then + SpawnCrates(2) + end + if healthCratesSpawned[2] ~= true then + SpawnHealthCrates(2) + end + if cannibalHidden[5] == true then + RestoreWave(2) + end + AnimSwitchHog(cannibals[5]) +end + +function AfterWave2Anim() + TurnTimeLeft = 0 +end + +function AfterFinalAnim() + if leaksDead == true then + SaveCampaignVar("M4LeaksDead", "1") + else + SaveCampaignVar("M4LeaksDead", "0") + end + if chiefDead == true then + SaveCampaignVar("M4ChiefDead", "1") + else + SaveCampaignVar("M4ChiefDead", "0") + end + if buffaloDead == true then + SaveCampaignVar("M4BuffaloDead", "1") + else + SaveCampaignVar("M4BuffaloDead", "0") + end + if waterDead == true then + SaveCampaignVar("M4WaterDead", "1") + else + SaveCampaignVar("M4WaterDead", "0") + end + if denseDead == true then + SaveCampaignVar("M4DenseDead", "1") + else + SaveCampaignVar("M4DenseDead", "0") + end + SaveCampaignVar("Progress", "4") + ParseCommand("teamgone " .. loc("011101001")) + TurnTimeLeft = 0 +end +-----------------------------Animations-------------------------------- +function Wave2Reaction() + local i = 1 + local gearr = nil + while nativesDead[i] == true do + i = i + 1 + end + gearr = natives[i] + if denseDead ~= true and band(GetState(dense), gstDrowning) == 0 then + AnimInsertStepNext({func = AnimSay, args = {dense, loc("I'm so scared!"), SAY_SAY, 3000}}) + AnimInsertStepNext({func = AnimCustomFunction, args = {dense, EmitDenseClouds, {"Left"}}}) + AnimInsertStepNext({func = AnimTurn, args = {dense, "Left"}}) + end + AnimInsertStepNext({func = AnimSay, args = {gearr, loc("There's more of them? When did they become so hungry?"), SAY_SHOUT, 8000}}) +end + +function EmitDenseClouds(dir) + local dif + if dir == "Left" then + dif = 10 + else + dif = -10 + end + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {dense, 800}}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) + AnimInsertStepNext({func = AnimWait, args = {dense, 800}}) + AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false}) +end + +function AnimationSetup() + table.insert(startAnim, {func = AnimWait, args = {leaks, 4000}}) + table.insert(startAnim, {func = AnimCaption, args = {leaks, loc("Back in the village, after telling the villagers about the threat..."), 5000}}) + table.insert(startAnim, {func = AnimCaption, args = {leaks, loc("Their buildings were very primitive back then, even for an uncivilised island."), 7000}}) + table.insert(startAnim, {func = AnimSay, args = {chief, loc("Young one, you are telling us that they can instantly change location without a shaman?"), SAY_SAY, 8000}}) + table.insert(startAnim, {func = AnimSay, args = {chief, loc("That is, indeed, very weird..."), SAY_SAY, 3500}}) + table.insert(startAnim, {func = AnimSay, args = {buffalo, loc("If they try coming here, they can have a taste of my delicious knuckles!"), SAY_SHOUT, 8000}}) + table.insert(startAnim, {func = AnimSay, args = {buffalo, loc("Haha!"), SAY_SHOUT, 2000}}) + if denseDead == false then + table.insert(startAnim, {func = AnimSay, args = {dense, loc("I'm not sure about that!"), SAY_SAY, 3400}}) + table.insert(startAnim, {func = AnimSay, args = {dense, loc("They have weapons we've never seen before!"), SAY_SAY, 5000}}) + table.insert(startAnim, {func = AnimSay, args = {dense, loc("Luckily, I've managed to snatch some of them."), SAY_SAY, 5000}}) + table.insert(startAnim, {func = AnimCustomFunction, args = {dense, SpawnCrates, {1}}}) + table.insert(startAnim, {func = AnimSay, args = {dense, loc("Oops...I dropped them."), SAY_SAY, 3000}}) + else + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("I'm not sure about that!"), SAY_SAY, 3400}}) + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("They have weapons we've never seen before!"), SAY_SAY, 5000}}) + table.insert(startAnim, {func = AnimCustomFunction, args = {leaks, SpawnCrates, {1}}}) + table.insert(startAnim, {func = AnimWait, args = {leaks, 1000}}) + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("They keep appearing like this. It's weird!"), SAY_SAY, 5000}}) + end + table.insert(startAnim, {func = AnimSay, args = {chief, loc("Did anyone follow you?"), SAY_SAY, 3000}}) + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("No, we made sure of that!"), SAY_SAY, 3500}}) + table.insert(startAnim, {func = AnimCustomFunction, args = {leaks, SpawnHealthCrates, {1}}}) + table.insert(startAnim, {func = AnimWait, args = {leaks, 1000}}) + table.insert(startAnim, {func = AnimSay, args = {chief, loc("First aid kits?!"), SAY_SAY, 3000}}) + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("I've seen this before. They just appear out of thin air."), SAY_SAY, 7000}}) + table.insert(startAnim, {func = AnimMove, args = {water, "Left", 3000, 0}}) + table.insert(startAnim, {func = AnimJump, args = {water, "long"}}) + table.insert(startAnim, {func = AnimMove, args = {water, "Left", 2655, 0}}) + table.insert(startAnim, {func = AnimTurn, args = {water, "Right"}}) + table.insert(startAnim, {func = AnimJump, args = {water, "back"}}) + table.insert(startAnim, {func = AnimJump, args = {water, "back"}}) + table.insert(startAnim, {func = AnimTurn, args = {water, "Left"}}) + table.insert(startAnim, {func = AnimMove, args = {water, "Left", 2467, 754}}) + table.insert(startAnim, {func = AnimSay, args = {water, loc("Hey guys!"), SAY_SAY, 2500}}) + table.insert(startAnim, {func = AnimSay, args = {chief, loc("..."), SAY_THINK, 1500}}) + table.insert(startAnim, {func = AnimSay, args = {chief, loc("Where have you been?"), SAY_SAY, 4000}}) + table.insert(startAnim, {func = AnimSay, args = {water, loc("Just on a walk."), SAY_SAY, 3000}}) + table.insert(startAnim, {func = AnimSay, args = {chief, loc("You have chosen the perfect moment to leave."), SAY_SAY, 6000}}) + table.insert(startAnim, {func = AnimCustomFunction, args = {chief, RestoreWave, {1}}}) + for i = 1, 4 do + table.insert(startAnim, {func = AnimOutOfNowhere, args = {cannibals[i], unpack(cannibalPos[i])}}) + end + table.insert(startAnim, {func = AnimWait, args = {chief, 1500}}) + table.insert(startAnim, {func = AnimSay, args = {leaks, loc("HOW DO THEY KNOW WHERE WE ARE???"), SAY_SHOUT, 5000}}) + table.insert(startAnim, {func = AnimSay, args = {chief, loc("We have to protect the village!"), SAY_SAY, 5000}}) + table.insert(startAnim, {func = AnimSwitchHog, args = {leaks}}) + AddSkipFunction(startAnim, SkipStartAnim, {}) + + table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, RestoreWave, {2}}, swh = false}) + for i = 5, 8 do + table.insert(wave2Anim, {func = AnimOutOfNowhere, args = {cannibals[i], unpack(cannibalPos[i])}}) + end + table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, Wave2Reaction, {}}, swh = false}) + table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, SpawnCrates, {2}}, swh = false}) + table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, SpawnHealthCrates, {2}}, swh = false}) + table.insert(wave2Anim, {func = AnimSwitchHog, args = {cannibals[5]}}) + AddSkipFunction(wave2Anim, SkipWave2Anim, {}) +end + +function SetupHogDeadAnim(gear) + hogDeadAnim = {} + if nativesNum == 0 then + return + end + local hogDeadStrings = {"They killed " .. gear .."! You bastards!", + gear .. "! Why?!", + "That was just mean!", + "Oh no, not " .. gear .. "!"} + table.insert(hogDeadAnim, {func = AnimSay, args = {CurrentHedgehog, hogDeadStrings[nativesNum], SAY_SHOUT, 4000}}) +end + +function SetupFinalAnim() + local found = 0 + local hogs = {} + local i = 1 + if nativesNum >= 2 then + while found < 2 do + if nativesDead[i] ~= true then + found = found + 1 + hogs[found] = natives[i] + end + i = i + 1 + end + if chiefDead ~= true then + hogs[2] = chief + end + table.insert(finalAnim, {func = AnimCustomFunction, args = {hogs[1], CondNeedToTurn, {hogs[1], hogs[2]}}}) + table.insert(finalAnim, {func = AnimSay, args = {hogs[1], loc("We can't hold them up much longer!"), SAY_SAY, 5000}}) + table.insert(finalAnim, {func = AnimSay, args = {hogs[1], loc("We need to move!"), SAY_SAY, 3000}}) + table.insert(finalAnim, {func = AnimSay, args = {hogs[2], loc("But where can we go?"), SAY_SAY, 3000}}) + table.insert(finalAnim, {func = AnimSay, args = {hogs[1], loc("To the caves..."), SAY_SAY, 2500}}) + table.insert(finalAnim, {func = AnimSay, args = {hogs[2], loc("Good idea, they'll never find us there!"), SAY_SAY, 5000}}) + else + for i = 1, 5 do + if nativesDead[i] ~= true then + hogs[1] = natives[i] + end + end + table.insert(finalAnim, {func = AnimSay, args = {hogs[1], loc("I need to move the tribe!"), SAY_THINK, 4000}}) + table.insert(finalAnim, {func = AnimSay, args = {hogs[1], loc("The caves are well hidden, they won't find us there!"), SAY_THINK, 7000}}) + end +end +-----------------------------Misc-------------------------------------- +function RestoreWave(index) + for i = (index - 1) * 4 + 1, index * 4 do + RestoreHog(cannibals[i]) + cannibalHidden[i] = false + end +end + +function GetVariables() + m2DenseDead = tonumber(GetCampaignVar("M2DenseDead")) + if m2DenseDead == 1 then + denseDead = true + end + m2Choice = tonumber(GetCampaignVar("M2Choice")) +end + +function SetupPlace() + if m2DenseDead == 1 then + sdrmv = 1 + DeleteGear(dense) + end + for i = 1, 8 do + HideHog(cannibals[i]) + cannibalHidden[i] = true + end + HideHog(cyborg) +end + +function SetupEvents() + AddEvent(CheckWaveDead, {1}, DoWaveDead, {1}, 0) + AddEvent(CheckWaveDead, {2}, DoWaveDead, {2}, 0) +end + +function SetupAmmo() + AddAmmo(cannibals[1], amGrenade, 4) + AddAmmo(cannibals[1], amBazooka, 4) + AddAmmo(cannibals[1], amShotgun, 4) + AddAmmo(cannibals[1], amMine, 2) + AddAmmo(cannibals[5], amGrenade, 4) + AddAmmo(cannibals[5], amBazooka, 4) + AddAmmo(cannibals[5], amShotgun, 4) + AddAmmo(cannibals[5], amMine, 2) + AddAmmo(cannibals[5], amMolotov, 2) + AddAmmo(cannibals[5], amFlamethrower, 3) +end + +function AddHogs() + AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy") + leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo") + dense = AddHog(loc("Dense Cloud"), 0, 100, "RobinHood") + water = AddHog(loc("Fiery Water"), 0, 100, "pirate_jack") + buffalo = AddHog(loc("Raging Buffalo"), 0, 100, "zoo_Bunny") + chief = AddHog(loc("Righteous Beard"), 0, 100, "IndianChief") + natives = {leaks, dense, water, buffalo, chief} + nativesNum = 5 + + AddTeam(loc("Light Cannfantry"), 14483456, "Skull", "Island", "Pirate", "cm_vampire") + for i = 1, 4 do + cannibals[i] = AddHog(HogNames[i], 2, 40, "Zombi") + end + + AddTeam(loc("Heavy Cannfantry"), 14483456, "Skull", "Island", "Pirate", "cm_vampire") + for i = 5, 8 do + cannibals[i] = AddHog(HogNames[i], 2, 55, "vampirichog") + end + + AddTeam(loc("011101001"), 14483456, "ring", "UFO", "Robot", "cm_star") + cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1") + + SetGearPosition(leaks, unpack(leaksPos)) + SetGearPosition(dense, unpack(densePos)) + SetGearPosition(water, unpack(waterPos)) + HogTurnLeft(water, true) + SetGearPosition(buffalo, unpack(buffaloPos)) + HogTurnLeft(buffalo, true) + SetGearPosition(chief, unpack(chiefPos)) + HogTurnLeft(chief, true) + SetGearPosition(cyborg, 0, 0) + for i = 1, 8 do + SetGearPosition(cannibals[i], unpack(cannibalPos[i])) + end +end + +function CondNeedToTurn(hog1, hog2) + xl, xd = GetX(hog1), GetX(hog2) + if xl > xd then + AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}}) + elseif xl < xd then + AnimInsertStepNext({func = AnimTurn, args = {hog2, "Left"}}) + AnimInsertStepNext({func = AnimTurn, args = {hog1, "Right"}}) + end +end + +function SpawnHealthCrates(index) + SetHealth(SpawnHealthCrate(0, 0), 25) + SetHealth(SpawnHealthCrate(0, 0), 25) + SetHealth(SpawnHealthCrate(0, 0), 25) + healthCratesSpawned[index] = true +end + +function SpawnCrates(index) + if index == 1 then + SpawnAmmoCrate(1943, 408, amBazooka) + SpawnAmmoCrate(1981, 464, amGrenade) + SpawnAmmoCrate(1957, 459, amShotgun) + SpawnAmmoCrate(1902, 450, amDynamite) + SpawnUtilityCrate(1982, 405, amPickHammer) + SpawnUtilityCrate(2028, 455, amRope) + SpawnUtilityCrate(2025, 464, amTeleport) + else + SpawnUtilityCrate(1982, 405, amBlowTorch) + SpawnAmmoCrate(2171, 428, amMolotov) + SpawnAmmoCrate(2364, 346, amFlamethrower) + SpawnAmmoCrate(2521, 303, amBazooka) + SpawnAmmoCrate(2223, 967, amGrenade) + SpawnAmmoCrate(1437, 371, amShotgun) + end + cratesSpawned[index] = true +end + +-----------------------------Events------------------------------------ + +function CheckWaveDead(index) + for i = (index - 1) * 4 + 1, index * 4 do + if cannibalDead[i] ~= true then + return false + end + end + return true +end + +function DoWaveDead(index) + SetGearMessage(CurrentHedgehog, 0) + SetState(CurrentHedgehog, 0) + if index == 1 then + AddAnim(wave2Anim) + AddFunction({func = AfterWave2Anim, args = {}}) + elseif index == 2 then + SetupFinalAnim() + AddAnim(finalAnim) + AddFunction({func = AfterFinalAnim, args = {}}) + end +end + + +-----------------------------Main Functions---------------------------- + +function onGameInit() + Seed = 1 + GameFlags = 0 + TurnTime = 60000 + CaseFreq = 0 + MinesNum = 0 + MinesTime = 3000 + Explosives = 2 + Delay = 10 + Map = "Hogville" + Theme = "Nature" + SuddenDeathTurns = 3000 + + AddHogs() + AnimInit() +end + +function onGameStart() + GetVariables() + SetupAmmo() + SetupPlace() + AnimationSetup() + SetupEvents() + AddAnim(startAnim) + AddFunction({func = AfterStartAnim, args = {}}) +end + +function onGameTick() + AnimUnWait() + if ShowAnimation() == false then + return + end + ExecuteAfterAnimations() + CheckEvents() +end + +function onGearDelete(gear) + if gear == dense then + denseDead = true + nativesNum = nativesNum - 1 + nativesDead[2] = true + if sdrmv == 1 then + freshDead = nil + else + freshDead = loc("Dense Cloud") + end + elseif gear == leaks then + leaksDead = true + nativesNum = nativesNum - 1 + nativesDead[1] = true + freshDead = loc("Leaks A Lot") + elseif gear == chief then + chiefDead = true + nativesNum = nativesNum - 1 + nativesDead[5] = true + freshDead = loc("Righteous Beard") + elseif gear == water then + waterDead = true + nativesNum = nativesNum - 1 + nativesDead[3] = true + freshDead = loc("Fiery Water") + elseif gear == buffalo then + buffaloDead = true + nativesNum = nativesNum - 1 + nativesDead[4] = true + freshDead = loc("Raging Buffalo") + else + for i = 1, 8 do + if gear == cannibals[i] then + cannibalDead[i] = true + end + end + end +end + +function onGearAdd(gear) +end + +function onAmmoStoreInit() + SetAmmo(amDEagle, 9, 0, 0, 0) + SetAmmo(amSniperRifle, 4, 0, 0, 0) + SetAmmo(amFirePunch, 9, 0, 0, 0) + SetAmmo(amWhip, 9, 0, 0, 0) + SetAmmo(amBaseballBat, 9, 0, 0, 0) + SetAmmo(amHammer, 9, 0, 0, 0) + SetAmmo(amLandGun, 9, 0, 0, 0) + SetAmmo(amSnowball, 8, 0, 0, 0) + SetAmmo(amGirder, 4, 0, 0, 2) + SetAmmo(amParachute, 4, 0, 0, 2) + SetAmmo(amSwitch, 8, 0, 0, 2) + SetAmmo(amSkip, 8, 0, 0, 0) + SetAmmo(amRope, 5, 0, 0, 3) + SetAmmo(amBlowTorch, 3, 0, 0, 3) + SetAmmo(amPickHammer, 0, 0, 0, 3) + SetAmmo(amLowGravity, 0, 0, 0, 2) + SetAmmo(amDynamite, 0, 0, 0, 3) + SetAmmo(amBazooka, 0, 0, 0, 4) + SetAmmo(amGrenade, 0, 0, 0, 5) + SetAmmo(amMine, 0, 0, 0, 2) + SetAmmo(amMolotov, 0, 0, 0, 3) + SetAmmo(amFlamethrower, 0, 0, 0, 3) + SetAmmo(amShotgun, 0, 0, 0, 3) + SetAmmo(amTeleport, 0, 0, 0, 2) + SetAmmo(amFlamethrower, 0, 0, 0, 3) +end + +function onNewTurn() + if AnimInProgress() then + TurnTimeLeft = -1 + return + end + if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == loc("Natives") then + SetupHogDeadAnim(freshDead) + AddAnim(hogDeadAnim) + AddFunction({func = AfterHogDeadAnim, args = {}}) + end +end + +function onGearDamage(gear, damage) +end + +function onPrecise() + if GameTime > 2500 then + SetAnimSkip(true) + end +end + diff -r fd91aa100ce0 -r efc75c2d3be9 share/hedgewars/Data/Scripts/Animate.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Scripts/Animate.lua Thu Aug 30 12:13:24 2012 -0400 @@ -0,0 +1,376 @@ +local animPos, lastx, lasty, jumpTypes, jumpTimes, moveDirs, jumpStarted +local backJumped, jTimer, awTime, globalWait, stageEvents, seNum +local AnimList, AnimListNum +local FunctionList, FunctionListNum +local skipFuncList +local skipping +--------------------------------Animation--------------------------------- +--------------------------(In-game cinematics)---------------------------- + +function AddSkipFunction(anim, func, args) + skipFuncList[anim] = {sfunc = func, sargs = args} +end + +function RemoveSkipFunction(anim) + skipFuncList[anim] = nil +end + +function SetAnimSkip(bool) + skipping = bool +end + +function AnimInProgress() + return AnimListNum ~= 0 +end + +function SkipAnimation(anim) + if skipFuncList[anim] == nil then + return + else + skipFuncList[anim].sfunc(unpack(skipFuncList[anim].sargs)) + end +end + +function AddFunction(element) + table.insert(FunctionList, element) + FunctionListNum = FunctionListNum + 1 +end + +function RemoveFunction() + table.remove(FunctionList, 1) + FunctionListNum = FunctionListNum - 1 +end + +function ExecuteAfterAnimations() + if FunctionListNum == 0 then + return + end + FunctionList[1].func(unpack(FunctionList[1].args)) + RemoveFunction() +end + +function AnimInit() + animPos = 1 + lastx = 0 + lasty = 0 + jumpTypes = {long = gmLJump, high = gmHJump, back = gmHJump} + jumpTimes = {long = 500, high = 500, back = 300, backback = 500} + moveDirs = {Right = gmRight, Left = gmLeft} + jumpStarted = false + backJumped = false + jTimer = 0 + awTime = 0 + globalWait = 0 + stageEvents = {} + seNum = 0 + AnimList = {} + AnimListNum = 0 + FunctionList = {} + FunctionListNum = 0 + skipping = false + skipFuncList = {} +end + +function AnimSwitchHog(gear) + --SetGearMessage(gear, 0) + --SetState(gear, 0) + SwitchHog(gear) + FollowGear(gear) + return true +end + +function AnimGiveState(gear, state) + SetState(gear, state) + return true +end + +function AnimRemoveState(gear, state) + SetState(gear, band(GetState(gear), bnot(state))) + return true +end + +function AnimGearWait(gear, time) + AnimWait(gear, time) + return true +end + +function AnimUnWait() + if globalWait > 0 then + globalWait = globalWait - 1 + end +end + +function AnimWait(gear, time) -- gear is for compatibility with Animate + globalWait = globalWait + time + return true +end + +function AnimWaitLeft() + return globalWait +end + +function AnimSay(gear, text, manner, time) + HogSay(gear, text, manner, 2) + if time ~= nil then + AnimWait(gear, time) + end + return true +end + +function AnimSound(gear, sound, time) + PlaySound(sound, gear) + AnimWait(gear, time) + return true +end + +function AnimTurn(gear, dir) + if dir == "Right" then + HogTurnLeft(gear, false) + else + HogTurnLeft(gear, true) + end + return true +end + +function AnimFollowGear(gear) + FollowGear(gear) + return true +end + +function AnimMove(gear, dir, posx, posy) + dirr = moveDirs[dir] + SetGearMessage(gear, dirr) + if GetX(gear) == posx or GetY(gear) == posy then + SetGearMessage(gear, 0) + lastx = GetX(gear) + lasty = GetY(gear) + return true + end + return false +end + +function AnimJump(gear, jumpType) + if jumpStarted == false then + lastx = GetX(gear) + lasty = GetY(gear) + backJumped = false + jumpStarted = true + SetGearMessage(gear, jumpTypes[jumpType]) + AnimGearWait(gear, jumpTimes[jumpType]) + elseif jumpType == "back" and backJumped == false then + backJumped = true + SetGearMessage(gear, jumpTypes[jumpType]) + AnimGearWait(gear, jumpTimes["backback"]) + else + curx = GetX(gear) + cury = GetY(gear) + if curx == lastx and cury == lasty then + jumpStarted = false + backJumped = false + AnimGearWait(gear, 100) + return true + else + lastx = curx + lasty = cury + AnimGearWait(gear, 100) + end + end + return false +end + +function AnimDisappear(gear, destX, destY) + AddVisualGear(GetX(gear)-5, GetY(gear)-5, vgtSmoke, 0, false) + AddVisualGear(GetX(gear)+5, GetY(gear)+5, vgtSmoke, 0, false) + AddVisualGear(GetX(gear)-5, GetY(gear)+5, vgtSmoke, 0, false) + AddVisualGear(GetX(gear)+5, GetY(gear)-5, vgtSmoke, 0, false) + PlaySound(sndExplosion) + SetGearPosition(gear, destX, destY) + return true +end + +function AnimOutOfNowhere(gear, destX, destY) + SetGearPosition(gear, destX, destY) + AddVisualGear(destX, destY, vgtBigExplosion, 0, false) + PlaySound(sndExplosion) + AnimGearWait(gear, 50) + return true +end + +function AnimTeleportGear(gear, destX, destY) + AddVisualGear(GetX(gear)-5, GetY(gear)-5, vgtSmoke, 0, false) + AddVisualGear(GetX(gear)+5, GetY(gear)+5, vgtSmoke, 0, false) + AddVisualGear(GetX(gear)-5, GetY(gear)+5, vgtSmoke, 0, false) + AddVisualGear(GetX(gear)+5, GetY(gear)-5, vgtSmoke, 0, false) + SetGearPosition(gear, destX, destY) + AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) + PlaySound(sndExplosion) + FollowGear(gear) + AnimGearWait(gear, 50) + return true +end + +function AnimSetGearPosition(gear, x, y) + SetGearPosition(gear, x, y) + return true +end + +function AnimVisualGear(gear, x, y, vgType, state, critical, follow) + local vgear = AddVisualGear(x, y, vgType, state, critical) + if follow == true then + FollowGear(vgear) + end + return true +end + +function AnimCaption(gear, text, time) + AddCaption(text) + if time == nil then + return true + end + AnimWait(gear, time) + return true +end + +function AnimCustomFunction(gear, func, args) + if args == nil then + args = {} + end + retval = func(unpack(args)) + if retval == false then + return false + else + return true + end +end + +function AnimInsertStepNext(step) + table.insert(AnimList[1], animPos + 1, step) + return true +end + +function AnimShowMission(gear, caption, subcaption, text, icon, time) + ShowMission(caption, subcaption, text, icon, time) + return true +end + +function RemoveAnim() + table.remove(AnimList, 1) + AnimListNum = AnimListNum - 1 +end + +function AddAnim(animation) + table.insert(AnimList, animation) + AnimListNum = AnimListNum + 1 + if AnimListNum == 1 then + skipping = false + end +end + +function ShowAnimation() + if AnimListNum == 0 then + skipping = false + return true + else + TurnTimeLeft = -1 + if Animate(AnimList[1]) == true then + RemoveAnim() + end + end + return false +end + +function Animate(steps) + if skipping == true then + animPos = 1 + SetInputMask(0xFFFFFFFF) + SkipAnimation(steps) + return true + end + + if globalWait ~= 0 then + return false + end + + if steps[animPos] == nil then + animPos = 1 + SetInputMask(0xFFFFFFFF) + return true + end + + if steps[animPos].args[1] ~= CurrentHedgehog and steps[animPos].func ~= AnimWait + and (steps[animPos].swh == nil or steps[animPos].swh == true) then + AnimSwitchHog(steps[animPos].args[1]) + end + + SetInputMask(band(0xFFFFFFFF, bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon))) + retVal = steps[animPos].func(unpack(steps[animPos].args)) + if (retVal ~= false) then + animPos = animPos + 1 + end + + return false +end + +------------------------------Event Handling------------------------------ + +function AddEvent(condFunc, condArgs, doFunc, doArgs, evType) + seNum = seNum + 1 + stageEvents[seNum] = {} + stageEvents[seNum].cFunc = condFunc + stageEvents[seNum].cArgs = condArgs + stageEvents[seNum].dFunc = doFunc + stageEvents[seNum].dArgs = doArgs + stageEvents[seNum].evType = evType +end + +function AddNewEvent(condFunc, condArgs, doFunc, doArgs, evType) + local i + for i = 1, seNum do + if stageEvents[i].cFunc == condFunc and stageEvents[i].cArgs == condArgs and + stageEvents[i].dFunc == doFunc and stageEvents[i].dArgs == doArgs and + stageEvents[seNum].evType == evType then + return + end + end + AddEvent(condFunc, condArgs, doFunc, doArgs, evType) +end + +function RemoveEvent(evNum) + if stageEvents[evNum] ~= nil then + seNum = seNum - 1 + table.remove(stageEvents, evNum) + end +end + +function RemoveEventFunc(cFunc) + local i = 1 + while i <= seNum do + if stageEvents[i].cFunc == cFunc then + RemoveEvent(i) + i = i - 1 + end + i = i + 1 + end +end + + +function CheckEvents() + local i = 1 + while i <= seNum do + if stageEvents[i].cFunc(unpack(stageEvents[i].cArgs)) then + stageEvents[i].dFunc(unpack(stageEvents[i].dArgs)) + if stageEvents[i].evType ~= 1 then + RemoveEvent(i) + i = i - 1 + end + end + i = i + 1 + end +end + +-------------------------------------Misc--------------------------------- + +function StoppedGear(gear) + dx,dy = GetGearVelocity(gear) + return math.abs(dx) <= 1 and math.abs(dy) <= 1 +end