static void activate(int val) { if (strlen(self->requires) != 0) { if (removeInventoryItemByObjectiveName(self->requires) == TRUE) { self->requires[0] = '\0'; setEntityAnimation(self, "WALK"); } else { setInfoBoxMessage(90, 255, 255, 255, _("%s is required"), _(self->requires)); return; } } generateInputCode(); self->mental = 0; self->thinkTime = 120; setInfoBoxMessage(300, 255, 255, 255, _("Repeat the sequence")); self->action = &displayInputCode; self->touch = NULL; self->activate = NULL; setPlayerLocked(TRUE); }
void addRequiredToInventory(Entity *other) { Entity *item; if (!(self->flags & INVULNERABLE) && other->type == PLAYER) { item = getInventoryItemByObjectiveName(self->requires); if (item != NULL) { item->health++; self->inUse = FALSE; setInfoBoxMessage(60, 255, 255, 255, _("Picked up %s"), _(self->objectiveName)); fireTrigger(self->objectiveName); fireGlobalTrigger(self->objectiveName); } else { setInfoBoxMessage(60, 255, 255, 255, _("%s is required to carry this item"), _(self->requires)); } } }
static void activate(int val) { Entity *e = getInventoryItemByObjectiveName(self->requires); if (e == NULL) { setInfoBoxMessage(60, 255, 255, 255, _("%s is required"), _(self->requires)); } else { self->mental = 0; setInfoBoxMessage(300, 255, 255, 255, _("Enter the directions")); self->target->requires[0] = '\0'; self->action = &readInputCode; self->touch = NULL; self->activate = NULL; setPlayerLocked(TRUE); } }
static void activate(int val) { if (self->active == FALSE) { if (removeInventoryItemByObjectiveName(self->requires) == TRUE) { self->active = TRUE; self->thinkTime = 60; fireTrigger(self->objectiveName); fireGlobalTrigger(self->objectiveName); setEntityAnimation(self, "WALK"); self->action = &sink; setInfoBoxMessage(60, 255, 255, 255, _("Used %s"), _(self->requires)); } else { setInfoBoxMessage(60, 255, 255, 255, _("%s is required"), _(self->requires)); } } }
static void touch(Entity *other) { pushEntity(other); if (self->type == MANUAL_DOOR) { if (other->type == PLAYER && self->active == FALSE) { /* Look through the player's inventory */ if (removeInventoryItemByObjectiveName(self->requires) == TRUE) { setInfoBoxMessage(60, 255, 255, 255, _("Used %s"), _(self->requires)); self->action = &moveToTarget; self->active = TRUE; } else { setInfoBoxMessage(60, 255, 255, 255, _("%s is needed to open this door"), _(self->requires)); } } } else if (other->type == PLAYER && self->active == FALSE && self->mental == 0) { setInfoBoxMessage(60, 255, 255, 255, _("This door is locked")); } }
static void takeDamage(Entity *other, int damage) { Entity *temp; if (!(self->flags & INVULNERABLE)) { if (strcmpignorecase(other->name, "weapon/wood_axe") == 0) { playSoundToMap("sound/item/chop", -1, self->x, self->y, 0); self->health -= damage; if (self->health > 0) { setCustomAction(self, &flashWhite, 6, 0, 0); } else { if (self->mental > 0) { self->health = self->maxHealth; self->mental--; } else { setInfoBoxMessage(60, 255, 255, 255, _("It's out of apples...")); } } } else { playSoundToMap("sound/common/dink", -1, self->x, self->y, 0); if (other->reactToBlock != NULL) { temp = self; self = other; self->reactToBlock(temp); self = temp; } damage = 0; if (other->type != PROJECTILE && prand() % 10 == 0) { setInfoBoxMessage(60, 255, 255, 255, _("This weapon is not having any effect...")); } } setCustomAction(self, &invulnerableNoFlash, HIT_INVULNERABLE_TIME, 0, 0); } }
static void touch(Entity *other) { if (self->active == TRUE) { if (self->target != NULL) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to retrieve %s"), self->target->objectiveName); } else { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to interact")); } } }
static void touch(Entity *other) { Entity *temp; if (other->type == PLAYER && self->health > 0) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to retrieve the Purple Gem")); } else if (other->type == WEAPON && (other->flags & ATTACKING)) { if (self->takeDamage != NULL && !(self->flags & INVULNERABLE)) { self->takeDamage(other, other->damage); } } else if (other->type == PROJECTILE && other->parent != self) { if (self->takeDamage != NULL && !(self->flags & INVULNERABLE)) { self->takeDamage(other, other->damage); } temp = self; self = other; self->die(); self = temp; } }
static void touch(Entity *other) { if (self->damage == 1 && self->mental == 0 && self->thinkTime == 0) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to reprogram the Soul Merger")); } }
static void bucketTouch(Entity *other) { if (other->type == PLAYER) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to interact")); } }
static void touch(Entity *other) { if (other->type == PLAYER && game.showHints == TRUE) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to talk to %s"), _(self->objectiveName)); } }
static void takeDamage(Entity *other, int damage) { Entity *temp; setCustomAction(self, &invulnerableNoFlash, HIT_INVULNERABLE_TIME, 0, 0); playSoundToMap("sound/common/dink", -1, self->x, self->y, 0); if (other->reactToBlock != NULL) { temp = self; self = other; self->reactToBlock(temp); self = temp; } if (other->type != PROJECTILE && prand() % 10 == 0) { setInfoBoxMessage(60, 255, 255, 255, _("This weapon is not having any effect...")); } damage = 0; }
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; } }
void scriptAddToInventory(char *name, int quiet) { int i; Entity *e; e = addPermanentItem(name, 0, 0); for (i=0;i<MAX_INVENTORY_ITEMS;i++) { if (inventory.item[i].inUse == FALSE) { inventory.item[i] = *e; inventory.item[i].face = RIGHT; inventory.item[i].thinkTime = 0; setEntityAnimationByID(&inventory.item[i], 0); if (quiet == FALSE) { setInfoBoxMessage(60, 255, 255, 255, _("Picked up %s"), _(inventory.item[i].objectiveName)); } break; } } e->inUse = FALSE; }
static void activate(int val) { if (self->active == TRUE) { if (self->health == 0) { runScript("puzzle_pieces"); } if (self->health == 1) { if (self->target->mental == 0) { self->target->mental = -2; } self->mental = 0; setInfoBoxMessage(300, 255, 255, 255, _("Solve the jigsaw puzzle")); self->target->requires[0] = '\0'; self->action = &readInputCode; self->touch = NULL; self->activate = NULL; setPlayerLocked(TRUE); } } }
static void touch(Entity *other) { if (other->type == PLAYER && self->active == FALSE) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to interact")); } }
void activateEntitiesValueWithObjectiveName(char *name, int value) { EntityList *el; Entity *temp; for (el=entities->next;el!=NULL;el=el->next) { if (el->entity->inUse == TRUE && el->entity->activate != NULL && strcmpignorecase(el->entity->objectiveName, name) == 0) { temp = self; self = el->entity; if (self->type == MANUAL_LIFT && self->active == FALSE) { setInfoBoxMessage(90, 255, 255, 255, _("This lift is not active")); } else { self->activate(value - self->health); } self = temp; } } }
static int checkSolution() { int i, total; char solution[6], c[2]; Entity *e; e = self->target; while (e != NULL) { if (e->y == self->endY && e->x == self->x) { break; } e = e->target; } if (e == NULL) { showErrorAndExit("Could not find starting peg for row"); } for (i=0;i<4;i++) { if (e->health == 0) { setInfoBoxMessage(180, 255, 255, 255, _("Select a colour for every peg in the row")); return -1; } snprintf(c, 2, "%d", e->health); solution[i] = c[0]; e = e->target; } solution[i] = '\0'; total = 0; for (i=0;i<4;i++) { if (solution[i] == self->requires[i]) { total++; } } e->health = total + 1; setEntityAnimationByID(e, e->health); return strcmpignorecase(solution, self->requires) == 0 ? TRUE : FALSE; }
static void touch(Entity *other) { float dirX, dirY; if (self->active == FALSE && other->type == PLAYER) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to interact")); } else if (self->health == 1 && fabs(self->x - other->x) <= fabs(self->dirX) && fabs(self->y - other->y) <= fabs(self->dirY)) { if (strcmpignorecase(other->name, "item/robot_direction") == 0) { dirY = dirX = 0; switch (other->health) { case 0: dirY = -self->speed; setEntityAnimation(self, "JUMP"); break; case 1: dirY = self->speed; setEntityAnimation(self, "JUMP"); break; case 2: dirX = -self->speed; setEntityAnimation(self, "WALK"); self->face = LEFT; break; default: dirX = self->speed; setEntityAnimation(self, "WALK"); self->face = RIGHT; break; } if (dirY != self->dirY || dirX != self->dirX) { self->x = other->x; self->y = other->y; } self->dirY = dirY; self->dirX = dirX; } } }
static void saveGameInSlot() { saveGame(menu.index - 1); freeMessageQueue(); setInfoBoxMessage(60, 255, 255, 255, _("Game Saved")); pauseGame(); }
void getInventoryItemFromScript(char *line) { char command[15], itemName[MAX_VALUE_LENGTH], entityName[MAX_VALUE_LENGTH], quiet[MAX_VALUE_LENGTH]; int quantity, success, failure, quantityToRemove, read; Entity *e, *item; read = sscanf(line, "%s \"%[^\"]\" %d %d %s %d %d %s", command, itemName, &quantity, &quantityToRemove, entityName, &success, &failure, quiet); if (read < 7) { showErrorAndExit("HAS_ITEM or REMOVE command has wrong number of arguments"); } e = getEntityByObjectiveName(entityName); if (e == NULL) { showErrorAndExit("Could not find Entity %s to give item %s to", entityName, itemName); } item = getInventoryItemByObjectiveName(itemName); if (item != NULL && (item->health >= quantity || quantity == 1)) { if (strcmpignorecase(command, "REMOVE") == 0) { item->health -= quantityToRemove; updateTrigger(itemName, quantityToRemove); updateGlobalTrigger(itemName, quantityToRemove); if (item->health <= 0 || quantityToRemove == -1) { item->health = 0; removeInventoryItemByObjectiveName(itemName); if (read == 7) { setInfoBoxMessage(90, 255, 255, 255, _("Removed %s"), _(itemName)); } } } e->health = success; } else { e->health = failure; } }
static void touch(Entity *other) { if (other->type == PLAYER && self->mental > 0) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to interact")); } else { entityTouch(other); } }
static void activate(int val) { if (self->active == TRUE) { runScript("blender"); } else { setInfoBoxMessage(60, 255, 255, 255, _("This machine is not active")); } }
static void activate(int val) { Entity *e; if (getInventoryItemByObjectiveName(self->requires) != NULL) { e = addKeyItem(self->objectiveName, 0, 0); replaceInventoryItem(self->requires, e); playSoundToMap("sound/item/fill_potion", EDGAR_CHANNEL, self->x, self->y, 0); setInfoBoxMessage(60, 255, 255, 255, _("Obtained %s"), _(e->objectiveName)); e->inUse = FALSE; } else { setInfoBoxMessage(60, 255, 255, 255, _("%s is required"), _(self->requires)); } }
static void touch(Entity *other) { Entity *e; if (other->type == PLAYER) { if (self->health == 3) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to retrieve Tesla Pack")); } else if (self->health == -1) { e = getInventoryItemByObjectiveName("Tesla Pack"); if (e != NULL && e->health == 0) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to replace Tesla Pack")); } } } }
static void stunnedTouch(Entity *other) { Entity *e; if (!(self->flags & NO_DRAW)) { e = getInventoryItemByObjectiveName("Tesla Pack"); if (e != NULL && e->health != 0) { setInfoBoxMessage(0, 255, 255, 255, _("Press Action to attach the Tesla Pack")); } } }
static void touch(Entity *other) { Entity *temp; if (!(self->flags & INVULNERABLE) && other->type == ITEM && strcmpignorecase(other->name, "item/repellent_spray") == 0) { self->mental++; if (self->mental == 50) { self->action = &shudder; self->targetX = self->x; self->thinkTime = 300; if (player.health > 0) { setInfoBoxMessage(180, 255, 255, 255, _("Now! Run while it's stunned!")); } self->health = 0; } else if (self->mental > 50) { self->thinkTime = 300; } setCustomAction(self, &invulnerableNoFlash, HIT_INVULNERABLE_TIME, 0, 0); setCustomAction(self, &flashWhite, 6, 0, 0); } else if (other->type == PLAYER && self->action == &attack) { temp = self; self = other; freeEntityList(playerGib()); self = temp; } else { entityTouch(other); } }
static void takeDamage(Entity *other, int damage) { Entity *temp; if (!(self->flags & INVULNERABLE)) { /* Can't be hurt if not facing the player unless using pickaxe */ if (self->face == other->face) { if (strcmpignorecase(other->name, "weapon/pickaxe") != 0) { playSoundToMap("sound/common/dink", -1, self->x, self->y, 0); setCustomAction(self, &invulnerableNoFlash, HIT_INVULNERABLE_TIME, 0, 0); if (other->reactToBlock != NULL) { temp = self; self = other; self->reactToBlock(temp); self = temp; } if (prand() % 10 == 0) { setInfoBoxMessage(60, 255, 255, 255, _("This weapon is not having any effect...")); } damage = 0; } else { entityTakeDamageNoFlinch(other, damage * 5); } } else { entityTakeDamageNoFlinch(other, damage); } } }
static void reprogram() { Entity *temp; if (input.interact == 1 || isPlayerLocked() == FALSE || self->health <= 0) { self->action = &entityWait; self->activate = &activate; self->touch = &touch; setPlayerLocked(FALSE); input.interact = 0; } else { self->health--; if (self->health <= 0) { self->activate = NULL; self->health = 0; self->mental = 1; self->target->mental = 1 - self->target->mental; temp = self; self = self->target; self->activate(-1); self = temp; } self->thinkTime = 5; setInfoBoxMessage(0, 255, 255, 255, _("Press Action to Cancel")); } }
static void activate(int val) { if (getInventoryItemByObjectiveName("Spanner") == NULL) { setInfoBoxMessage(120, 255, 255, 255, _("Spanner is required")); } else { self->action = &reprogram; self->touch = NULL; self->activate = NULL; setPlayerLocked(TRUE); } }