void navigateToWaypoint(float xtarget, float ytarget) { while(!atTarget(xtarget, x) || (!atTarget(ytarget, y))) { float distance = calcDistance(xtarget, ytarget); float angle = calcAngle(xtarget, ytarget); float driveDistance = 0; //initialise if (distance < stepDistance) { driveDistance = distance; } else { driveDistance = stepDistance; } // co-ordinate system is different so cos and sin are swapped - take from current location not origin float tempWaypointX = x + (driveDistance * cos(angle)); float tempWaypointY = y + (driveDistance * sin(angle)); driveToWaypoint(tempWaypointX, tempWaypointY); monteCarlo(); eraseDisplay(); drawMap(); drawParticles(); wait1Msec(100); } PlayTone(784, 15); }
static void headButtMoveToPosition() { checkToMap(self); facePlayer(); if (atTarget()) { self->flags &= ~(FLY|UNBLOCKABLE); setEntityAnimation(self, "ATTACK_2"); self->thinkTime = 60; self->x = self->targetX; self->y = self->targetY; self->dirX = 0; self->dirY = 0; self->startX = 0; self->startY = self->y; self->action = &moveToHeadButtRange; } }
static void stingAttackMoveToPosition() { int bottomY; checkToMap(self); facePlayer(); if (atTarget()) { self->dirY = 0; self->dirX = 0; bottomY = self->y + self->h - 1; setEntityAnimation(self, "ATTACK_3"); self->y = bottomY - self->h; self->frameSpeed = 12; self->thinkTime = 120; self->action = &stingAttackWindUp; } }
static void moveToTarget() { checkToMap(self); if (self->x < self->startX || self->x > self->endX) { self->x = self->x < self->startX ? self->startX : self->endX; self->dirX = 0; self->dirY = 0; } if (self->y < self->startY || self->y > self->endY) { self->y = self->y < self->startY ? self->startY : self->endY; self->dirX = 0; self->dirY = 0; } if (atTarget() || (self->dirX == 0 && self->dirY == 0)) { self->dirX = 0; self->dirY = 0; self->thinkTime = 60 + prand() % 180; self->action = &entityWait; } lookForPlayer(); }
static void raiseDeadMoveToTopTarget() { char c; int i, j; if (atTarget()) { setEntityAnimation(self, "PHANTASMAL_BOLT_FIRE"); self->thinkTime = 30; self->action = &raiseDead; self->mental = 2 + prand() % 4; STRNCPY(self->description, "123456", sizeof(self->description)); for (i=0;i<6;i++) { j = prand() % 6; c = self->description[i]; self->description[i] = self->description[j]; self->description[j] = c; } } checkToMap(self); becomeTransparent(); }
static void headBiteReturn() { float dirX, dirY; dirX = self->dirX; dirY = self->dirY; checkToMap(self); if (atTarget() || self->dirX != dirX || self->dirY != dirY) { self->flags &= ~UNBLOCKABLE; self->x = self->startX; self->y = self->startY; self->maxThinkTime--; if (self->maxThinkTime <= 0) { self->dirX = self->face == LEFT ? -self->head->speed : self->head->speed; self->head->thinkTime = 120; self->head->mental = 0; self->action = &headWait; self->reactToBlock = &headChangeDirection; } else { self->action = &headBiteInit; } } if (self->head->health <= 0) { self->die(); } alignBodyToHead(); self->damage = self->head->damage; self->face = self->head->face; if (self->head->flags & FLASH) { self->flags |= FLASH; } else { self->flags &= ~FLASH; } }
static void energyMoveToRift() { self->x += self->dirX; self->y += self->dirY; if (atTarget()) { self->inUse = FALSE; } }
static void scytheThrowMoveToTarget() { if (atTarget()) { self->mental = 3; self->action = &scytheThrowReady; } checkToMap(self); becomeTransparent(); }
static void spikeAttackMoveToTopTarget() { Entity *e; if (atTarget()) { self->thinkTime--; if (self->thinkTime <= 0) { e = getFreeEntity(); loadProperties("boss/azriel_light_beam", e); setEntityAnimation(e, "APPEAR"); e->animationCallback = &beamAppearFinish; e->head = self; e->x = getMapStartX() + prand() % (SCREEN_WIDTH - e->w); e->y = getMapFloor(self->x + self->w / 2, self->y) - e->h; e->startY = e->y; e->action = &beamWait; e->draw = &drawBeam; e->touch = &entityTouch; e->face = RIGHT; e->type = ENEMY; e->thinkTime = 240; e->mental = prand() % 3 == 0 ? 1 : 0; e->targetX = playSoundToMap("sound/boss/grimlore/grimlore_summon", -1, e->x, e->y, -1); self->action = &spikeAttackWait; self->mental = 1; } } checkToMap(self); becomeTransparent(); }
static void phantasmalBoltMoveToTarget() { Entity *e; if (atTarget()) { setEntityAnimation(self, "PHANTASMAL_BOLT_READY"); e = getFreeEntity(); if (e == NULL) { showErrorAndExit("No free slots to add Azriel's Phantasmal Bolt"); } loadProperties("boss/azriel_phantasmal_bolt", e); setEntityAnimationByID(e, 0); e->face = self->face; if (e->face == LEFT) { e->x = self->x + self->w - e->w - e->offsetX; } else { e->x = self->x + e->offsetX; } e->y = self->y + e->offsetY; e->action = &phantasmalBoltWait; e->draw = &drawLoopingAnimationToMap; e->thinkTime = 30; e->head = self; self->mental = 1; self->action = &phantasmalBolt; } checkToMap(self); becomeTransparent(); }
static void shotAttackWindUp() { checkToMap(self); if (atTarget()) { self->maxThinkTime = 5; self->thinkTime = 0; self->action = &shotAttack; } alignBodyToHead(); }
static void die() { long onGround = self->flags & ON_GROUND; self->action = ¨ checkToMap(self); if (self->flags & FLY) { if (atTarget()) { self->dirX = self->dirY = 0; self->thinkTime = 120; self->action = &fallToGround; } } else { if (self->flags & ON_GROUND) { self->dirX = 0; if (onGround == 0) { addSmokeAlongBody(); } self->thinkTime--; if (self->thinkTime <= 0) { calculatePath(self->x, self->y, self->targetX, self->targetY, &self->dirX, &self->dirY); self->dirX *= 2; self->dirY *= 2; self->flags |= FLY; } } } alignBodyToHead(); }
static void biteAttackWindUp() { checkToMap(self); if (atTarget()) { self->targetX = self->face == RIGHT ? self->x + 320 - self->w - 1 : self->x - 320; self->action = &biteAttack; self->reactToBlock = &biteReactToBlock; self->dirX = (self->targetX < self->x ? -self->speed * 2 : self->speed * 2); } alignBodyToHead(); }
static void returnToStart() { checkToMap(self); if (atTarget()) { self->y = self->targetY; self->targetX = self->x; self->dirX = 0; self->thinkTime = 120; self->action = &headWait; } alignBodyToHead(); }
static void slideToTarget() { self->x += self->dirX; self->y += self->dirY; if (atTarget()) { self->x = self->targetX; self->y = self->targetY; self->dirX = 0; self->dirY = 0; self->head->activate = &activate; self->head->mental = -3; self->action = &entityWait; } }
static void headBite() { checkToMap(self); if (atTarget() || self->dirX == 0 || self->dirY == 0) { self->targetX = self->startX; self->targetY = self->startY; calculatePath(self->x, self->y, self->targetX, self->targetY, &self->dirX, &self->dirY); self->dirX *= 16; self->dirY *= 16; self->flags |= UNBLOCKABLE; self->action = &headBiteReturn; } if (self->head->health <= 0) { self->die(); } alignBodyToHead(); self->damage = self->head->damage; self->face = self->head->face; if (self->head->flags & FLASH) { self->flags |= FLASH; } else { self->flags &= ~FLASH; } }
static void moveToTarget() { checkToMap(self); facePlayer(); if (atTarget()) { self->thinkTime = 120; self->x = self->targetX; self->y = self->targetY; self->dirX = 0; self->dirY = 0; self->startX = 0; self->startY = self->y; self->action = &entityWait; } }
static void bulletFireMoveToPosition() { checkToMap(self); facePlayer(); if (atTarget()) { self->maxThinkTime = 5 + prand() % 15; self->x = self->targetX; self->y = self->targetY; self->dirX = 0; self->dirY = 0; self->startX = 0; self->startY = self->y; self->action = &fireBullets; } }
static void slimeFireMoveToPosition() { checkToMap(self); facePlayer(); if (atTarget()) { self->maxThinkTime = 1 + prand() % 4; self->x = self->targetX; self->y = self->targetY; self->dirX = 0; self->dirY = 0; self->startX = 0; self->startY = self->y; self->action = &fireSlime; } }
static void crushAttackMoveToPosition() { calculatePath(self->x, self->y, self->targetX, self->targetY, &self->dirX, &self->dirY); self->dirX *= 9; self->dirY *= 9; checkToMap(self); if (atTarget()) { self->y = self->targetY; self->x = self->targetX; self->dirY = 0; self->dirX = 0; self->action = &crushAttack; } alignBodyToHead(); }
static void changeSides() { int side; Entity *e, *smoke; Target *t; self->x += self->dirX; self->y += self->dirY; if (atTarget()) { self->flags |= NO_DRAW; self->takeDamage = NULL; self->targetX = self->x; self->dirX = 0; self->thinkTime = 120; side = prand() % 2; if (side == 0) { t = getTargetByName("SNAKE_BOSS_TARGET_LEFT"); self->face = RIGHT; } else { t = getTargetByName("SNAKE_BOSS_TARGET_RIGHT"); self->face = LEFT; } if (t == NULL) { showErrorAndExit("Snake boss cannot find target"); } self->damage = 0; setSnakePosition(t->x, t->y); self->targetX = self->x; self->targetY = self->y - 64; self->thinkTime = 120; self->action = &riseUpWait; } else { e = self->target; while (e != NULL) { if (e->target == NULL) { smoke = addSmoke(e->x + (prand() % self->w) * (prand() % 2 == 0 ? -1 : 1), e->y + prand() % e->h, "decoration/dust"); if (smoke != NULL) { smoke->dirY = 0; } } e = e->target; } } alignBodyToHead(); }