2 Copyright (C) 2004-2011 Parallel Realities
3 Copyright (C) 2011-2015 Perpendicular Dimensions
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 strlcpy(mia_scared[0], "help me...", sizeof mia_scared[0]);
27 strlcpy(mia_scared[1], "i don't wanna die...", sizeof mia_scared[1]);
28 strlcpy(mia_scared[2], "please... someone help...", sizeof mia_scared[2]);
29 strlcpy(mia_scared[3], "i... i'm scared...", sizeof mia_scared[3]);
30 strlcpy(mia_scared[4], "i wanna go home...", sizeof mia_scared[4]);
31 strlcpy(mia_scared[5], "what was that?!", sizeof mia_scared[5]);
32 strlcpy(mia_scared[6], "i don't like it here...", sizeof mia_scared[6]);
35 void addMIA(const char *name, int x, int y, int type)
37 Entity *mia = new Entity();
39 strlcpy(mia->name, name, sizeof mia->name);
44 mia->value = Math::rrand(0, 5);
45 mia->flags = ENT_INANIMATE; // MIAs don't drown
50 mia->setSprites(graphics.getSprite("ScaredMIA", true), graphics.getSprite("ScaredMIA", true), graphics.getSprite("ScaredMIA", true));
53 mia->setSprites(graphics.getSprite("AquaMIA", true), graphics.getSprite("AquaMIA", true), graphics.getSprite("AquaMIA", true));
62 Entity *mia = (Entity*)map.miaList.getHead();
68 while (mia->next != NULL)
70 mia = (Entity*)mia->next;
77 if (mia->flags & ENT_TELEPORTING)
83 x = (int)(mia->x - engine.playerPosX);
84 y = (int)(mia->y - engine.playerPosY);
86 if ((abs(x) <= 2048) && (abs(y) <= 768))
92 if ((Math::prand() % 250) == 0)
97 if ((Math::prand() % 250) == 0)
98 mia->value = Math::rrand(0, 6);
101 if ((mia->value != 100) && (!(mia->flags & ENT_DYING)))
103 static Graphics::SurfaceCache cache;
104 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
105 graphics.drawString(_((char*)mia_scared[mia->value]), x + 10, y - 10, true, graphics.screen, cache);
108 graphics.blit(mia->getFaceImage(), x, y, graphics.screen, false);
113 if ((Collision::collision(&player, mia)) && (player.health > 0) && (!(player.flags & ENT_TELEPORTING)))
115 if (!(mia->flags & ENT_DYING))
117 Math::addBit(&mia->flags, ENT_WEIGHTLESS);
118 Math::addBit(&mia->flags, ENT_DYING);
119 audio.playSound(SND_TELEPORT1, CH_ANY);
123 if ((mia->id == MIA_NORMAL) && (mia->environment == ENV_WATER))
126 mia->setSprites(graphics.getSprite("AquaMIA", true), graphics.getSprite("AquaMIA", true), graphics.getSprite("AquaMIA", true));
127 debug(("MIA '%s' fell into water. Became Aqua Mia\n", mia->name));
130 if (mia->flags & ENT_DYING)
132 for (int i = 0 ; i < 2 ; i++)
133 map.addParticle(mia->x + Math::rrand(-2, 15), mia->y + Math::prand() % mia->height, 0, Math::rrand(-5, -1), Math::rrand(30, 60), graphics.red, graphics.getSprite("TeleportStar", true), PAR_WEIGHTLESS);
135 if (mia->health <= 100)
138 if (mia->health <= 0)
141 game.totalMIAsRescued++;
143 if ((map.foundMIAs == (map.requiredMIAs / 2)) || (game.skill == 0))
145 snprintf(message, sizeof message, _("Rescued %s - Checkpoint Reached!"), mia->name);
146 game.setObjectiveCheckPoint();
150 snprintf(message, sizeof message, _("Rescued %s!"), mia->name);
153 if (map.foundMIAs == map.requiredMIAs)
155 snprintf(message, sizeof message, _("Rescue %d MIAs - Objective Complete - Checkpoint Reached!"), map.requiredMIAs);
156 game.setObjectiveCheckPoint();
160 if (game.totalMIAsRescued == 50)
162 presentPlayerMedal("50_MIA");
164 else if (game.totalMIAsRescued == 100)
166 presentPlayerMedal("100_MIA");
168 else if (game.totalMIAsRescued == 200)
170 presentPlayerMedal("200_MIA");
172 else if (game.totalMIAsRescued == 227)
174 presentPlayerMedal("ALL_MIA");
177 engine.setInfoMessage(message, 1, INFO_OBJECTIVE);