static void lookForPlayer() { int frame; float timer; if (self->active == TRUE) { self->flags &= ~NO_DRAW; moveLeftToRight(); if (self->currentFrame == 3) { if (self->health == 0) { playSoundToMap("sound/enemy/gazer/flap", -1, self->x, self->y, 0); self->health = 1; } } else { self->health = 0; } if (player.health > 0 && player.alpha == 255 && collision(self->x + self->w / 2 - 10, self->y, 20, self->endY, player.x, player.y, player.w, player.h) == 1) { playSoundToMap("sound/enemy/gazer/growl", -1, self->x, self->y, 0); setInfoBoxMessage(120, 255, 255, 255, _("INTRUDER!")); self->thinkTime = 300; activateEntitiesWithRequiredName(self->objectiveName, FALSE); if (self->mental == 1) { summonEnemies(); } frame = self->currentFrame; timer = self->frameTimer; setEntityAnimation(self, "ATTACK_1"); self->currentFrame = frame; self->frameTimer = timer; self->target = &player; self->action = &followPlayer; } } else { self->flags |= NO_DRAW; } }
static void blueDieInit() { Target *t; self->touch = NULL; self->maxThinkTime++; switch (self->maxThinkTime) { case 2: t = getTargetByName("BLUE_BOOK_TARGET_1"); activateEntitiesWithRequiredName("BLUE_BOOK_STAGE_1", TRUE); self->action = &blueDie; break; default: t = getTargetByName("BLUE_BOOK_TARGET_2"); activateEntitiesWithRequiredName("BLUE_BOOK_STAGE_2", TRUE); self->action = &blueDie; break; } if (t == NULL) { showErrorAndExit("Blue Book cannot find target"); } self->startX = self->x; self->startY = 0; self->targetX = t->x; self->targetY = t->y; self->thinkTime = 60; }
static void entityWait() { if (self->maxHealth != self->health) { self->thinkTime--; if (self->thinkTime <= 0) { self->health += (self->maxThinkTime == 1 ? 1 : -1); setEntityAnimationByID(self, self->health); if (self->health == self->maxHealth || self->health == 0) { if (self->health == 14) { activateEntitiesWithRequiredName(self->objectiveName, TRUE); playSoundToMap("sound/item/striker_top", -1, self->x, self->y, 0); } else { self->maxHealth = 0; self->thinkTime = 90; if (self->health == 0) { self->maxThinkTime = 0; self->thinkTime = 0; } else { self->maxThinkTime = self->maxThinkTime == 1 ? -1 : 1; } } } else { self->thinkTime = 4; } } } checkToMap(self); }
static void entityWait() { if (self->mental == -1) { if (self->dirY == 0) { self->dirY = self->speed; } self->y += self->dirY; if (self->y >= self->endY) { self->y = self->endY; self->dirY = -self->dirY; } else if (self->y <= self->startY) { self->y = self->startY; self->dirY = -self->dirY; } } if (self->thinkTime > 0) { self->thinkTime--; if (self->thinkTime <= 0) { self->thinkTime = 0; self->active = self->active == TRUE ? FALSE : TRUE; setEntityAnimation(self, self->active == FALSE ? "STAND" : "WALK"); if (self->mental != 1) { activateEntitiesWithRequiredName(self->objectiveName, self->active); } playSoundToMap("sound/common/switch", -1, self->x, self->y, 0); stopSound(self->endX); } } }
static void followPlayer() { int frame; float timer; self->targetX = self->target->x - self->w / 2 + self->target->w / 2; if (self->speed != 0) { /* Position under the player */ if (abs(self->x - self->targetX) <= self->speed * 3) { self->dirX = 0; } else { self->dirX = self->targetX < self->x ? -self->target->speed * 3 : self->target->speed * 3; } } checkToMap(self); if (player.health <= 0 || collision(self->x, self->y, self->w, self->endY, player.x, player.y, player.w, player.h) == 0) { self->thinkTime--; if (self->thinkTime <= 0) { activateEntitiesWithRequiredName(self->objectiveName, TRUE); frame = self->currentFrame; timer = self->frameTimer; setEntityAnimation(self, "STAND"); self->currentFrame = frame; self->frameTimer = timer; self->action = strcmpignorecase("enemy/blue_scanner", self->name) == 0 ? &closedEyeMove : &lookForPlayer; } } }
static void instructionMove() { checkToMap(self); setCustomAction(&player, &helpless, 5, 0, 0); if (self->dirX == 0 && self->dirY == 0) { processNextInstruction(); } else if (self->x == self->endX && self->y == self->endY) { runScript("robot_end"); self->dirX = 0; self->dirY = 0; self->action = &entityWait; setEntityAnimation(self, "STAND"); activateEntitiesWithRequiredName(self->objectiveName, TRUE); centerMapOnEntity(&player); setPlayerLocked(FALSE); self->health = 2; self->target->inUse = FALSE; self->target = NULL; self->touch = NULL; self->activate = NULL; } }
void fireMapTrigger(char *name) { int i; char message[MAX_MESSAGE_LENGTH]; if (strlen(name) == 0) { return; } for (i=0;i<MAX_TRIGGERS;i++) { if (trigger[i].inUse == TRUE && strcmpignorecase(trigger[i].triggerName, name) == 0) { trigger[i].count++; if (trigger[i].targetType == UPDATE_OBJECTIVE) { snprintf(message, MAX_MESSAGE_LENGTH, "%s (%d / %d)", _(trigger[i].targetName), trigger[i].count, trigger[i].total); freeMessageQueue(); setInfoBoxMessage(60, 255, 255, 255, message); } if (trigger[i].count == trigger[i].total) { switch (trigger[i].targetType) { case UPDATE_OBJECTIVE: updateObjective(trigger[i].targetName); break; case ACTIVATE_ENTITY: activateEntitiesWithRequiredName(trigger[i].targetName, TRUE); break; case DEACTIVATE_ENTITY: activateEntitiesWithRequiredName(trigger[i].targetName, FALSE); break; case RUN_SCRIPT: runScript(trigger[i].targetName); break; case KILL_ENTITY: killEntity(trigger[i].targetName); break; case REMOVE_INVENTORY_ITEM: removeInventoryItemByObjectiveName(trigger[i].targetName); break; default: break; } trigger[i].inUse = FALSE; } } } }
static void closedEyeMove() { int frame; float timer; moveLeftToRight(); if (self->currentFrame == 3) { if (self->health == 0) { playSoundToMap("sound/enemy/gazer/flap", -1, self->x, self->y, 0); self->health = 1; } } else { self->health = 0; } self->thinkTime--; if (self->thinkTime <= 0) { self->mental = 1 - self->mental; frame = self->currentFrame; timer = self->frameTimer; setEntityAnimation(self, self->mental == 0 ? "STAND" : "WALK"); self->currentFrame = frame; self->frameTimer = timer; self->thinkTime = self->maxThinkTime; } if (player.health > 0 && self->mental == 0 && collision(self->x + self->w / 2 - 10, self->y, 20, self->endY, player.x, player.y, player.w, player.h) == 1) { playSoundToMap("sound/enemy/gazer/growl", -1, self->x, self->y, 0); setInfoBoxMessage(120, 255, 255, 255, _("INTRUDER!")); self->thinkTime = 300; activateEntitiesWithRequiredName(self->objectiveName, FALSE); if (self->damage == 1) { summonEnemies(); } frame = self->currentFrame; timer = self->frameTimer; setEntityAnimation(self, "ATTACK_1"); self->currentFrame = frame; self->frameTimer = timer; self->target = &player; if (self->damage == 2) { self->thinkTime = 120; self->action = &teleportPlayer; } else { self->action = &followPlayer; } } }
static void readInputCode() { int val; if (input.up == 1) { input.up = 0; val = 1; } else if (input.down == 1) { input.down = 0; val = 2; } else if (input.left == 1) { input.left = 0; val = 3; } else if (input.right == 1) { input.right = 0; val = 4; } else { val = -1; } if (val != -1) { setEntityAnimationByID(self->target, val); if ((int)self->target->requires[self->mental] == val) { playSoundToMap("sound/item/charge_beep", -1, self->x, self->y, 0); self->mental++; if (self->target->requires[self->mental] == '\0') { setPlayerLocked(FALSE); activateEntitiesWithRequiredName(self->objectiveName, TRUE); setInfoBoxMessage(60, 255, 255, 255, _("Correct Sequence")); self->active = TRUE; self->touch = NULL; self->action = &entityWait; } } else { playSoundToMap("sound/item/buzzer", -1, self->x, self->y, 0); self->mental = 0; self->action = &entityWait; self->thinkTime = self->maxThinkTime; self->activate = &activate; self->touch = &touch; setInfoBoxMessage(60, 255, 255, 255, _("Incorrect Sequence")); setPlayerLocked(FALSE); } self->thinkTime = self->maxThinkTime; } self->thinkTime--; if (self->thinkTime <= 0) { self->thinkTime = 0; setEntityAnimationByID(self->target, 0); } }
static void touch(Entity *other) { int remaining, total; Entity *temp; if (strcmpignorecase(other->name, self->requires) == 0) { if (other->type == PROJECTILE) { temp = self; self = other; self->die(); self = temp; } /* Don't toggle if a timer */ if (self->maxThinkTime != 0 && self->thinkTime != 0) { self->thinkTime = self->maxThinkTime; return; } total = 0; remaining = self->maxThinkTime == 0 ? countSiblings(self, &total) : 0; self->active = self->active == TRUE ? FALSE : TRUE; if (remaining == 0) { setEntityAnimation(self, self->active == FALSE ? "STAND" : "WALK"); activateEntitiesWithRequiredName(self->objectiveName, self->active); self->thinkTime = self->maxThinkTime; if (self->maxThinkTime != 0) { self->endX = playSoundToMap("sound/common/tick", -1, self->x, self->y, -1); } else if (total > 0) { setInfoBoxMessage(30, 255, 255, 255, _("Complete"), remaining); } } else { setEntityAnimation(self, self->active == FALSE ? "STAND" : "WALK"); setInfoBoxMessage(30, 255, 255, 255, _("%d more to go..."), remaining); } playSoundToMap("sound/common/switch", -1, self->x, self->y, 0); } }