예제 #1
0
파일: azriel.c 프로젝트: LibreGames/edgar
static void raiseDeadFinish()
{
	Entity *e;

	self->thinkTime--;

	if (self->thinkTime <= 0)
	{
		e = getEntityByName("enemy/zombie");

		if (e == NULL)
		{
			self->action = &attackFinished;
		}

		else
		{
			self->thinkTime = 30;
		}
	}

	checkToMap(self);

	becomeTransparent();
}
예제 #2
0
파일: MScene.cpp 프로젝트: Keedu/maratis
void MScene::prepareConstraints(MOEntity * entity)
{
	MPhysicsContext * physics = MEngine::getInstance()->getPhysicsContext();
	MPhysicsProperties * phyProps = entity->getPhysicsProperties();

	if(! phyProps)
		return;

	unsigned int objectId = phyProps->getCollisionObjectId();
	MPhysicsConstraint * constraint = phyProps->getConstraint();

	if((! constraint) || (objectId == 0) || phyProps->isGhost())
		return;

	if(! entity->getParent())
	{
		MOEntity * constraintParent = getEntityByName(constraint->parentName.getSafeString());
		if(constraintParent)
		{
			MPhysicsProperties * parentPhyProps = constraintParent->getPhysicsProperties();
			if(parentPhyProps)
			{
				unsigned int parentObjectId = parentPhyProps->getCollisionObjectId();
				if(parentObjectId != 0)
				{
					physics->createConstraint(
											  &constraint->constraintId,
											  parentObjectId,
											  objectId,
											  constraint->pivot,
											  constraint->disableParentCollision
											  );

					constraint->parentObjectId = parentObjectId;
					physics->setLinearLimit(constraint->constraintId, constraint->lowerLinearLimit, constraint->upperLinearLimit);
					physics->setAngularLimit(constraint->constraintId, constraint->lowerAngularLimit, constraint->upperAngularLimit);
				}
			}
		}
	}
}
예제 #3
0
static void entityWait()
{
	int action;

	if (self->startX == 0)
	{
		if (self->endX == 0)
		{
			self->action = &changeToFireInit;
		}

		else if (self->endX == 1)
		{
			self->action = &changeToIceInit;
		}

		else
		{
			self->startX = -1;
		}

		checkToMap(self);
	}

	else
	{
		self->thinkTime--;

		if (self->thinkTime <= 0 && player.health > 0)
		{
			switch ((int)self->endX)
			{
				case 1: /* Fire */
					/* If the player is above then burn the roof */

					if (player.y < self->y)
					{
						self->action = &ceilingBurnInit;
					}

					else
					{
						action = prand() % 7;

						switch (action)
						{
							case 0:
							case 1:
							case 2:
								self->action = &spitInit;
							break;

							case 3:
							case 4:
							case 5:
								self->action = &fireDropInit;
							break;

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

				case 2: /* Ice */
					/* If the player has no arrows then drop some eggs */

					if (getInventoryItemByName("weapon/normal_arrow") == NULL && getInventoryItemByName("weapon/flaming_arrow") == NULL
						&& getEntityByName("enemy/baby_salamander") == NULL)
					{
						self->action = &eggDropInit;
					}

					else
					{
						action = prand() % 7;

						switch (action)
						{
							case 0:
							case 1:
							case 2:
								self->action = &spitInit;
							break;

							case 3:
							case 4:
							case 5:
								self->action = &icicleDropInit;
							break;

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

				default: /* Standard */
					action = prand() % 3;

					switch (action)
					{
						case 0:
							self->action = &groundChargeInit;
						break;

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

						default:
							self->action = &acidStreamInit;
						break;
					}
				break;
			}
		}
	}
}
예제 #4
0
파일: sorceror_2.c 프로젝트: revcozmo/edgar
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();
}