Ejemplo n.º 1
0
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));
		}
	}
}
Ejemplo n.º 2
0
static void trap(Entity *other)
{
	int x;

	if (other->type == PLAYER)
	{
		x = self->x;

		x += other->face == RIGHT ? -other->w : self->w;

		setCheckpoint(x, other->y);

		other->flags |= NO_DRAW;

		other->fallout();

		if (other->health == 1 && getInventoryItemByObjectiveName("Amulet of Resurrection") == NULL)
		{
			self->health = 5;

			other->flags |= FLY;
		}

		game.timesEaten++;

		if (game.timesEaten == 5)
		{
			addMedal("eaten_5");
		}
	}
}
Ejemplo n.º 3
0
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);
	}
}
Ejemplo n.º 4
0
static void activate(int val)
{
	Entity *e;

	if (self->health == 3)
	{
		e = addTeslaPack(0, 0, "item/tesla_pack_full");

		addToInventory(e);

		self->health = -1;
	}

	else
	{
		e = getInventoryItemByObjectiveName("Tesla Pack");

		if (e != NULL && e->health == 0)
		{
			removeInventoryItemByObjectiveName(e->objectiveName);

			self->health = 0;

			self->thinkTime = 180;
		}
	}

	setChargeState();
}
Ejemplo n.º 5
0
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;
	}
}
Ejemplo n.º 6
0
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"));
		}
	}
}
Ejemplo n.º 7
0
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);
	}
}
Ejemplo n.º 8
0
static void collectBomb(Entity *other)
{
	Entity *bomb = NULL;

	if (other->type == PLAYER && self->thinkTime <= 0 && other->health > 0)
	{
		if (getInventoryItemByObjectiveName("Bomb") == NULL)
		{
			bomb = addBomb(other->x, other->y, "item/bomb");

			STRNCPY(bomb->objectiveName, "Bomb", sizeof(bomb->objectiveName));

			addToInventory(bomb);
		}

		self->thinkTime = self->maxThinkTime;
	}
}
Ejemplo n.º 9
0
static void collectSpore(Entity *other)
{
	Entity *spore = NULL;

	if (self->thinkTime <= 0 && other->health > 0)
	{
		if (getInventoryItemByObjectiveName("Spore") == NULL)
		{
			spore = addSpore(other->x, other->y, "item/spores");

			STRNCPY(spore->objectiveName, "Spore", sizeof(spore->objectiveName));

			addToInventory(spore);
		}

		self->thinkTime = self->maxThinkTime;
	}
}
Ejemplo n.º 10
0
void useInventoryItemFromScript(char *itemName)
{
	Entity *item, *temp;

	item = getInventoryItemByObjectiveName(itemName);

	if (item == NULL)
	{
		showErrorAndExit("Could not find Inventory Item %s", itemName);
	}

	temp = self;

	self = item;

	self->activate(0);

	self = temp;
}
Ejemplo n.º 11
0
static void activate(int val)
{
	Entity *e, *temp;

	if (!(self->flags & NO_DRAW))
	{
		e = getInventoryItemByObjectiveName("Tesla Pack");

		if (e != NULL && e->health != 0)
		{
			temp = self;

			self = e;

			self->target = temp;

			self->activate(val);

			self = temp;
		}
	}
}
Ejemplo n.º 12
0
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));
	}
}
Ejemplo n.º 13
0
static void die()
{
	Entity *e;

	playSoundToMap("sound/enemy/tortoise/tortoise_die", -1, self->x, self->y, 0);

	if (getInventoryItemByObjectiveName("Tortoise Shell") == NULL)
	{
		e = dropCollectableItem("item/tortoise_shell", self->x + self->w / 2, self->y, self->face);

		e->x -= e->w / 2;
	}

	addMedal("kill_rampaging");

	if (self->startX == -1)
	{
		fadeBossMusic();
	}

	entityDie();
}
Ejemplo n.º 14
0
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"));
			}
		}
	}
}
Ejemplo n.º 15
0
static void trap(Entity *other)
{
	if (other->type == PLAYER)
	{
		other->flags |= NO_DRAW;

		other->fallout();

		if (other->health == 1 && getInventoryItemByObjectiveName("Amulet of Resurrection") == NULL)
		{
			self->health = 5;

			other->flags |= FLY;
		}

		game.timesEaten++;

		if (game.timesEaten == 5)
		{
			addMedal("eaten_5");
		}
	}
}
Ejemplo n.º 16
0
static void entityWait()
{
	int rand;
	Entity *disintegrationShield;

	self->thinkTime--;

	if (self->thinkTime <= 0 && player.health > 0)
	{
		if (self->startX == 0)
		{
			switch ((int)self->startY)
			{
				case 0:
					self->action = &callSummonersInit;
				break;

				case 3:
					self->action = &disintegrationAttackInit;
				break;

				default:
					self->action = &createShieldInit;
				break;
			}
		}

		else
		{
			disintegrationShield = getInventoryItemByObjectiveName("Disintegration Shield");

			if (disintegrationShield == NULL)
			{
				disintegrationShield = getEntityByObjectiveName("Disintegration Shield");
			}

			switch (disintegrationShield->health)
			{
				case 1:
					rand = prand() % 3;
				break;

				case 2:
					rand = prand() % 5;
				break;

				case 3:
					rand = prand() % 6;
				break;

				default:
					rand = 6;
				break;
			}

			if (getEntityByName("enemy/flame_statue") != NULL)
			{
				switch (rand)
				{
					case 0:
						self->action = &plasmaAttackInit;
					break;

					case 1:
						self->action = &flameWaveDropInit;
					break;

					case 2:
						self->action = &destroyFloorInit;
					break;

					case 3:
						self->action = &riftAttackInit;
					break;

					case 6:
						self->action = &finalAttackInit;
					break;

					default:
						self->action = &holdPersonInit;
					break;
				}
			}

			else
			{
				switch (rand)
				{
					case 0:
						self->action = &plasmaAttackInit;
					break;

					case 1:
						self->action = &flameWaveDropInit;
					break;

					case 2:
						self->action = &destroyFloorInit;
					break;

					case 3:
						self->action = &riftAttackInit;
					break;

					case 4:
						self->action = &holdPersonInit;
					break;

					case 6:
						self->action = &finalAttackInit;
					break;

					default:
						self->action = &statueAttackInit;
					break;
				}
			}
		}
	}

	hover();
}
Ejemplo n.º 17
0
static void readInputCode()
{
	char c;
	int val;
	Entity *e;

	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 if (input.attack == 1)
	{
		input.attack = 0;

		val = 5;
	}

	else
	{
		val = -1;
	}

	if (val == 5 || self->mental > 30)
	{
		e = getInventoryItemByObjectiveName(self->requires);

		setPlayerLocked(FALSE);

		STRNCPY(e->requires, self->target->requires, sizeof(self->target->requires));

		self->action = &entityWait;

		if (self->mental > 30)
		{
			setInfoBoxMessage(300, 255, 255, 255, _("Out of space for instructions"));
		}

		self->touch = &touch;
		self->activate = &activate;

		self->action = &entityWait;
	}

	else if (val != -1)
	{
		setEntityAnimationByID(self->target, val);

		playSoundToMap("sound/item/charge_beep", -1, self->x, self->y, 0);

		switch (val)
		{
			case 1:
				c = 'u';
			break;

			case 2:
				c = 'd';
			break;

			case 3:
				c = 'l';
			break;

			default:
				c = 'r';
			break;
		}

		self->target->requires[self->mental] = c;

		self->target->requires[self->mental + 1] = '\0';

		self->mental++;

		self->thinkTime = self->maxThinkTime;
	}

	self->thinkTime--;

	if (self->thinkTime <= 0)
	{
		self->thinkTime = 0;

		setEntityAnimationByID(self->target, 0);
	}
}