2 Copyright (C) 2004 Parallel Realities
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * Checks against various objects (Train, SpawnPoint, Teleporter, Trap)
25 * to see if they should be activated. If the
26 * object name matches the link name, it's active status is changed.
27 * @param linkName The name of the link to check against
28 * @param activateMessage The message to display on successful trigger
29 * @param active The new status of the object
31 void activateTrigger(const char *linkName, const char *activateMessage, bool active)
33 if (strcmp(linkName, "@none@") == 0)
36 if (strcmp(linkName, "WATERLEVEL") == 0)
38 int newLevel = atoi(activateMessage);
40 // only if the new level is less than our current level
41 // (ie - raising water up!)
42 if (newLevel < map.waterLevel)
44 map.requiredWaterLevel = atoi(activateMessage);
45 engine.setInfoMessage("Water level is rising", 1, INFO_ACTIVATE);
50 if (strcmp(linkName, "OBSTACLERESET") == 0)
55 Entity *obstacle = (Entity*)map.obstacleList.getHead();
57 while (obstacle->next != NULL)
59 obstacle = (Entity*)obstacle->next;
61 if (strcmp(obstacle->name, activateMessage) == 0)
63 addTeleportParticles(obstacle->x + (obstacle->width / 2), obstacle->y + (obstacle->height / 2), 50, SND_TELEPORT2);
64 obstacle->place(obstacle->tx, obstacle->ty);
65 Math::removeBit(&obstacle->flags, ENT_TELEPORTING);
66 obstacle->dx = obstacle->dy = 0;
67 obstacle->environment = ENV_AIR;
68 addTeleportParticles(obstacle->x + (obstacle->width / 2), obstacle->y + (obstacle->height / 2), 50, SND_TELEPORT2);
72 engine.setInfoMessage("Obstacles Reset", 0, INFO_ACTIVATE);
77 bool linkOkay = false;
79 Train *train = (Train*)map.trainList.getHead();
80 SpawnPoint *sp = (SpawnPoint*)map.spawnList.getHead();
81 Teleporter *tele = (Teleporter*)map.teleportList.getHead();
82 Trap *trap = (Trap*)map.trapList.getHead();
84 while (train->next != NULL)
86 train = (Train*)train->next;
88 if (strcmp(linkName, train->name) == 0)
90 train->active = active;
91 if ((train->active) && (strcmp(activateMessage, "@none@")))
92 engine.setInfoMessage(activateMessage, 1, INFO_ACTIVATE);
94 if (train->type != TR_TRAIN)
95 audio.playSound(SND_OPENDOOR, CH_TOUCH);
101 while (sp->next != NULL)
103 sp = (SpawnPoint*)sp->next;
105 if (strcmp(linkName, sp->name) == 0)
107 sp->active = !sp->active;
108 if ((sp->active) && (strcmp(activateMessage, "@none@")))
109 engine.setInfoMessage(activateMessage, 1, INFO_ACTIVATE);
115 while (tele->next != NULL)
117 tele = (Teleporter*)tele->next;
119 if (strcmp(linkName, tele->name) == 0)
121 tele->active = active;
122 if ((tele->active) && (strcmp(activateMessage, "@none@")))
123 engine.setInfoMessage(activateMessage, 1, INFO_ACTIVATE);
129 while (trap->next != NULL)
131 trap = (Trap*)trap->next;
133 if (strcmp(linkName, trap->name) == 0)
136 if (strcmp(activateMessage, "@none@"))
137 engine.setInfoMessage(activateMessage, 1, INFO_ACTIVATE);
144 showMessageLineDef(linkName, active);
148 debug(("WARNING : No such object '%s'!\n", linkName));