static void spinAttack() { self->thinkTime--; checkToMap(self); if (self->dirX == 0 || isAtEdge(self)) { shakeScreen(MEDIUM, 15); self->dirX = self->face == LEFT ? 3 : -3; self->dirY = -6; self->action = &spinAttackEnd; self->thinkTime = 0; playSoundToMap("sound/common/crash", -1, self->x, self->y, 0); facePlayer(); } else if (self->thinkTime <= 0) { self->action = &spinAttackEnd; self->thinkTime = 0; } }
static void spinAttack() { checkToMap(self); if (self->dirX == 0 || isAtEdge(self)) { if (self->dirX == 0) { self->dirX = self->face == LEFT ? 5 : -5; } else { self->dirX = self->dirX < 0 ? 5 : -5; } self->dirY = -6; self->action = &spinAttackEnd; self->thinkTime = 0; playSoundToMap("sound/enemy/red_grub/thud", -1, self->x, self->y, 0); self->face = self->face == LEFT ? RIGHT : LEFT; } else if (self->thinkTime <= 0) { self->action = &spinAttackEnd; self->thinkTime = 0; } }
static void spinAttack() { checkToMap(self); if (self->dirX == 0 || isAtEdge(self)) { self->endX--; if (self->endX <= 0) { if (self->dirX == 0) { self->dirX = self->face == LEFT ? 3 : -3; } else { self->dirX = self->dirX < 0 ? 3 : -3; } self->dirY = -6; self->action = &spinAttackEnd; } else { self->face = self->face == LEFT ? RIGHT : LEFT; self->dirX = self->face == LEFT ? -self->speed : self->speed; } playSoundToMap("sound/enemy/red_grub/thud", -1, self->x, self->y, 0); } }
void moveLeftToRight() { if (self->dirX == 0) { self->x += self->face == LEFT ? self->box.x : -self->box.x; self->face = self->face == RIGHT ? LEFT : RIGHT; } if (self->standingOn == NULL || self->standingOn->dirX == 0) { self->dirX = (self->face == RIGHT ? self->speed : -self->speed); } else { self->dirX += (self->face == RIGHT ? self->speed : -self->speed); } if (isAtEdge(self) == TRUE) { self->dirX = 0; } checkToMap(self); if (self->dirX == 0) { self->dirX = (self->face == RIGHT ? -self->speed : self->speed); self->face = (self->face == RIGHT ? LEFT : RIGHT); } }
static void moveAndJump() { if (self->dirX == 0) { self->x += self->face == LEFT ? self->box.x : -self->box.x; self->face = self->face == RIGHT ? LEFT : RIGHT; } if (self->standingOn == NULL || self->standingOn->dirX == 0) { self->dirX = (self->face == RIGHT ? self->speed : -self->speed); } else { self->dirX += (self->face == RIGHT ? self->speed : -self->speed); } if (isAtEdge(self) == TRUE) { if (isGapJumpable() == TRUE) { self->action = &jumpOverGap; setEntityAnimation(self, "STAND"); } else if (canDropDown() == FALSE) { self->dirX = 0; } } checkToMap(self); if (self->dirX == 0) { if (canJumpUp() == TRUE) { self->action = &jumpUp; } else { self->dirX = (self->face == RIGHT ? -self->speed : self->speed); self->face = (self->face == RIGHT ? LEFT : RIGHT); } } }
static void moveToFood() { if (self->target->health <= 3 || self->target->inUse == FALSE) { self->target = NULL; self->action = &wander; } else if (abs(self->x + (self->face == RIGHT ? self->w : 0) - self->target->x) > self->speed) { self->dirX = self->target->x < self->x ? -self->speed : self->speed; self->face = (self->dirX < 0 ? LEFT : RIGHT); if (self->dirX != 0 && isAtEdge(self) == 1) { self->dirX = 0; setEntityAnimation(self, "STAND"); } else { setEntityAnimation(self, "WALK"); } } else if (self->target->flags & ON_GROUND) { if (strcmpignorecase(self->target->name, "item/chicken_feed") == 0) { self->target->thinkTime = 600; } self->mental = 1; self->action = &doNothing; setEntityAnimation(self, "ATTACK_1"); self->animationCallback = &finishEating; } checkToMap(self); }
static void lookForPlayer() { checkToMap(self); if (self->dirX == 0 || isAtEdge(self) == TRUE) { self->dirX = (self->face == RIGHT ? -self->speed : self->speed); self->face = (self->face == RIGHT ? LEFT : RIGHT); } if (player.health > 0 && prand() % 30 == 0) { if (collision(self->x + (self->face == RIGHT ? self->w : -320), self->y, 320, self->h, player.x, player.y, player.w, player.h) == 1) { self->action = &spitAttackInit; self->dirX = 0; } } }
static void smallBounceAround() { int y; if (self->flags & ON_GROUND) { self->dirX = self->standingOn == NULL ? 0 : self->standingOn->dirX; if (self->mental <= 0) { y = self->y + self->h; loadProperties("enemy/splitter_medium", self); setEntityAnimation(self, "CUSTOM_1"); self->y = y - self->h; self->action = &smallBecomeMedium; self->touch = &entityTouch; self->thinkTime = 120; setCustomAction(self, &invulnerableNoFlash, 120, 0, 0); } else if (self->thinkTime <= 0) { if (prand() % 3 == 0) { playSoundToMap("sound/enemy/jumping_slime/baby_jump2", -1, self->x, self->y, 0); } else { playSoundToMap("sound/enemy/jumping_slime/baby_jump1", -1, self->x, self->y, 0); } self->dirY = -(6 + prand() % 2); self->thinkTime = 30 + prand() % 60; if (prand() % 2 == 0) { self->face = LEFT; if (isAtEdge(self) == TRUE) { self->face = RIGHT; } } else { self->face = RIGHT; if (isAtEdge(self) == TRUE) { self->face = LEFT; } } self->dirX = (prand() % 2 + 2) * (self->face == LEFT ? -1 : 1); } else { self->thinkTime--; self->mental--; } } checkToMap(self); }
static void bounceAround() { if (self->flags & ON_GROUND) { self->dirX = self->standingOn == NULL ? 0 : self->standingOn->dirX; if (self->thinkTime == 0) { if (prand() % 3 == 0) { playSoundToMap("sound/enemy/jumping_slime/jump2", -1, self->x, self->y, 0); } else { playSoundToMap("sound/enemy/jumping_slime/jump1", -1, self->x, self->y, 0); } self->thinkTime = 30 + prand() % 60; self->dirY = -(6 + prand() % 2); if (prand() % 2 == 0) { self->face = LEFT; if (isAtEdge(self) == TRUE) { self->face = RIGHT; } } else { self->face = RIGHT; if (isAtEdge(self) == TRUE) { self->face = LEFT; } } self->dirX = (prand() % 2 + 2) * (self->face == LEFT ? -1 : 1); } else { self->thinkTime--; } } else { if (self->dirX == 0) { self->dirX = self->face == LEFT ? 2 : -2; } } checkToMap(self); }
static void wander() { float dirX; self->thinkTime--; if (self->thinkTime <= 0) { if (self->dirX == 0) { self->dirX = self->speed * (prand() % 2 == 0 ? -1 : 1); setEntityAnimation(self, "WALK"); } else { self->dirX = 0; setEntityAnimation(self, "STAND"); } self->thinkTime = 180 + prand() % 120; } if (prand() % 2400 == 0) { playSoundToMap("sound/enemy/chicken/cluck", -1, self->x, self->y, 0); } if (prand() % 30 == 0) { lookForFood(); } if (self->dirX < 0) { self->face = LEFT; } else if (self->dirX > 0) { self->face = RIGHT; } dirX = self->dirX; if (self->dirX != 0 && isAtEdge(self) == 1) { self->dirX = 0; } checkToMap(self); if (self->dirX == 0 && dirX != 0) { self->face = (self->face == RIGHT ? LEFT : RIGHT); self->dirX = -dirX; } }
static void walk() { if (self->maxThinkTime == 1) { self->dirX = (self->face == RIGHT ? self->speed : -self->speed); } if (self->offsetX != 0) { if (self->maxThinkTime == 0) { self->maxThinkTime = 1; playSoundToMap("sound/enemy/rampaging_master_tortoise/stomp", -1, self->x, self->y, 0); } self->dirX = self->standingOn == NULL ? 0 : self->standingOn->dirX; } else { self->maxThinkTime = 0; } if (self->maxThinkTime == 0 && (self->dirX == 0 || isAtEdge(self) == TRUE)) { self->dirX = (self->face == RIGHT ? -self->speed : self->speed); self->face = (self->face == RIGHT ? LEFT : RIGHT); } checkToMap(self); if (player.health > 0) { if (self->mental != -1 && prand() % 60 == 0) { self->dirX = 0; self->action = &riftAttackInit; self->thinkTime = 30; } else if (prand() % 60 == 0 && collision(self->x + (self->face == RIGHT ? self->w : -320), self->y, 320, self->h, player.x, player.y, player.w, player.h) == 1) { switch (prand() % 3) { case 0: self->dirX = 0; self->thinkTime = 60; self->action = &spinAttackInit; break; case 1: self->dirX = 0; self->thinkTime = 15; self->action = &castIce; break; default: self->thinkTime = 15; self->action = &breatheFireInit; self->dirX = 0; break; } } } }