static void appleWait() { Entity *e; self->thinkTime--; if (self->thinkTime <= 0) { self->x += self->dirX; if (abs(self->startX - self->x) > 1) { self->dirX *= -1; } self->thinkTime = 20; } if (self->mental > self->head->mental) { e = addKeyItem("item/apple", self->x, self->y); e->dirX = 10 + prand() % 10; e->dirX *= prand() % 2 == 0 ? -0.1 : 0.1; e->dirY = -10; self->inUse = FALSE; } }
static void dropOnPlayer() { int i; long onGround; self->thinkTime--; if (self->thinkTime <= 0) { self->flags &= ~FLY; onGround = (self->flags & ON_GROUND); checkToMap(self); if (onGround == 0 && (self->flags & ON_GROUND)) { playSoundToMap("sound/common/crash", BOSS_CHANNEL, self->x, self->y, 0); shakeScreen(LIGHT, 15); self->thinkTime = 15; self->action = &dropWait; for (i=0;i<20;i++) { addSmoke(self->x + prand() % self->w, self->y + self->h - prand() % 10, "decoration/dust"); } } } }
static void headDie() { Entity *e; e = self; self = self->target; while (self != NULL) { self->die(); self->dirX = (prand() % 5) * (prand() % 2 == 0 ? -1 : 1); self->dirY = ITEM_JUMP_HEIGHT; self = self->target; } self = e; entityDieNoDrop(); self->dirX = (prand() % 5) * (prand() % 2 == 0 ? -1 : 1); self->dirY = ITEM_JUMP_HEIGHT; }
static void entityWait() { int i; checkToMap(self); if (self->flags & ON_GROUND) { if (self->active == TRUE) { self->touch = &touch; self->activate = &activate; } if (self->mental == 0) { fireTrigger(self->objectiveName); fireGlobalTrigger(self->objectiveName); fadeBossMusic(); for (i=0;i<20;i++) { addSmoke(self->x + prand() % self->w, self->y + self->h - prand() % 10, "decoration/dust"); } playSoundToMap("sound/enemy/red_grub/thud", BOSS_CHANNEL, self->x, self->y, 0); self->mental = 1; } } }
static void entityWait() { Entity *e; if (self->mental > 0) { self->thinkTime--; if (self->thinkTime <= 0) { self->thinkTime = 5; e = addExplosion(0, 0); e->x = self->x + self->w / 2 - e->w / 2; e->y = self->y + self->h / 2 - e->h / 2; e->x += prand() % e->w * (prand() % 2 == 0 ? 1 : -1); e->y += prand() % e->h * (prand() % 2 == 0 ? 1 : -1); e->damage = 0; self->mental--; } } checkToMap(self); }
void Organism::Replicate(Organism *Target) { int i; Target->age = 0; Target->alive = 1; for (i=0;i<GENELEN;i++) { Target->Genome[i]=Genome[i]; if (prand(MUTATION)) { Target->Genome[i]=rand()%(2*LETTERS); } } if (prand(GENEDUP)) { int start=rand()%GENELEN, end=rand()%GENELEN, newstart=rand()%GENELEN; int buf=0; if (start>end) { buf=end; end=start; start=buf; } for (i=newstart;(i<newstart+(end-start))&&(i<GENELEN);i++) { Genome[i]=Genome[i-newstart+start]; } } }
static void iceBlockDie() { int i; Entity *e; for (i=0;i<8;i++) { e = addTemporaryItem("common/ice_piece", self->x, self->y, RIGHT, 0, 0); e->x += self->w / 2 - e->w / 2; e->y += self->h / 2 - e->h / 2; e->dirX = (prand() % 10) * (prand() % 2 == 0 ? -1 : 1); e->dirY = ITEM_JUMP_HEIGHT + (prand() % ITEM_JUMP_HEIGHT); setEntityAnimationByID(e, i); e->thinkTime = 60 + (prand() % 60); e->touch = NULL; } playSoundToMap("sound/common/shatter", -1, player.x, player.y, 0); self->inUse = FALSE; }
static void entityWait() { int i; Entity *e; if (self->mental == 1) { for (i=0; i<4; i++) { e = addTemporaryItem("boss/azriel_grave_piece", self->x, self->y, RIGHT, 0, 0); e->x += self->w / 2 - e->w / 2; e->y += self->h / 2 - e->h / 2; e->dirX = (prand() % 10) * (prand() % 2 == 0 ? -1 : 1); e->dirY = ITEM_JUMP_HEIGHT + (prand() % ITEM_JUMP_HEIGHT); setEntityAnimationByID(e, i); e->thinkTime = 60 + (prand() % 60); } playSoundToMap("sound/common/crumble", -1, self->x, self->y, 0); self->inUse = FALSE; } checkToMap(self); }
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 die() { int i; self->action = ¨ setCustomAction(self, &invulnerableNoFlash, 240, 0, 0); setEntityAnimation(self, "STUNNED"); self->flags &= ~FLY; self->dirX = 0; self->mental = self->x < getMapStartX() + SCREEN_WIDTH / 2 ? 0 : 1; checkToMap(self); if (self->flags & ON_GROUND) { for (i=0;i<20;i++) { addSmoke(self->x + prand() % self->w, self->y + self->h - prand() % 10, "decoration/dust"); } playSoundToMap("sound/common/crash", BOSS_CHANNEL, self->x, self->y, 0); self->thinkTime = 120; self->endY = 0; self->action = &dieFinish; } }
static void prand_array (double *rate, SLindex_Type *num) /*{{{*/ { SLang_Array_Type *at = NULL; double *ai; SLindex_Type i, n; n = *num; if (n == 0) return; else if (n == 1) { SLang_push_double (prand (*rate)); return; } if (NULL == (at = SLang_create_array (SLANG_DOUBLE_TYPE, 0, NULL, &n, 1))) { isis_vmesg (INTR, I_FAILED, __FILE__, __LINE__, "creating array of random values"); return; } ai = (double *) at->data; for (i = 0; i < n; i++) { ai[i] = prand (*rate); } SLang_push_array (at, 1); }
static void castIceInit() { self->thinkTime--; if (self->thinkTime <= 0) { if (self->maxThinkTime == 1) { self->endX = 5 + prand() % 6; self->action = &castIce; } else if (self->maxThinkTime == 2) { self->endX = 3 + prand() % 4; self->action = &createIceWall; } else { self->endX = 5 + prand() % 6; self->action = &createIceBlock; } } hover(); }
static void rain() { int i; for (i=0;i<MAX_DROPS;i++) { if (droplet[i].active == TRUE) { droplet[i].y += droplet[i].dirY; if (droplet[i].y >= SCREEN_HEIGHT) { droplet[i].y = -8 - prand() % 20; droplet[i].dirX = 0; droplet[i].dirY = 8 + prand() % 8; } } else { break; } } }
static void spellMove() { int i; Entity *e; checkToMap(self); self->thinkTime--; if (self->thinkTime <= 0) { self->inUse = FALSE; } else { for (i=0;i<2;i++) { e = addBasicDecoration(self->x, self->y, "decoration/particle"); if (e != NULL) { e->x += prand() % self->w; e->y += prand() % self->h; e->thinkTime = 5 + prand() % 30; setEntityAnimationByID(e, prand() % 5); } } } }
Entity *addParticle(int x, int y) { Entity *e; e = getFreeDecoration(); if (e == NULL) { return NULL; } loadProperties("decoration/particle", e); e->thinkTime = 20 + (prand() % 30); e->x = x; e->y = y; e->action = &move; e->draw = &drawLoopingAnimationToMap; setEntityAnimationByID(e, prand() % 5); return e; }
static void entityWait() { int x, y; Entity *e; if (prand() % 60 == 0) { x = self->x + self->w / 2 + ((prand() % 6) * (prand() % 2 == 0 ? -1 : 1)); y = self->y + self->h - prand() % 10; e = addProjectile("enemy/slime_drip", self, x, y, 0, 0); e->x -= e->w / 2; e->touch = NULL; } x = self->x - 16; if (player.health > 0 && collision(x, self->y, self->w + 32, self->endY, player.x, player.y, player.w, player.h) == 1) { self->action = &bite; self->touch = &trapEntity; setEntityAnimation(self, "WALK"); self->flags &= ~FLY; self->dirY = self->speed; } }
static void shudder() { Entity *smoke; self->endX += 90; if (self->endX >= 360) { self->endX = 0; } self->x = self->startX + sin(DEG_TO_RAD(self->endX)) * 4; checkToMap(self); if (self->mental == 2) { smoke = addSmoke(0, 0, "decoration/dust"); if (smoke != NULL) { smoke->x = self->x + prand() % self->w; smoke->y = self->y + prand() % self->h; smoke->dirY = 0; } } else if (self->mental == 0) { self->x = self->startX; self->action = &entityWait; } }
static void doIntro() { int i; Entity *e; self->thinkTime--; if (self->thinkTime <= 0) { self->x = self->startX; setEntityAnimation(self, "STAND"); playSoundToMap("sound/common/gib", -1, self->x, self->y, 0); for (i=0;i<11;i++) { e = addTemporaryItem("boss/fly_boss_cocoon_piece", self->x, self->y, RIGHT, 0, 0); e->x += (self->w - e->w) / 2; e->y += (self->h - e->h) / 2; e->dirX = (prand() % 3) * (prand() % 2 == 0 ? -1 : 1); e->dirY = ITEM_JUMP_HEIGHT + (prand() % ITEM_JUMP_HEIGHT); setEntityAnimationByID(e, i); e->thinkTime = 180 + (prand() % 60); } self->draw = &drawLoopingAnimationToMap; playSoundToMap("sound/boss/fly_boss/buzz", BOSS_CHANNEL, self->x, self->y, 0); self->takeDamage = &takeDamage; self->action = &introPause; self->touch = &entityTouch; self->thinkTime = 120; self->startY = self->y; self->dirY = self->dirX = 0; self->startX = 0; facePlayer(); } else { if (self->x == self->startX || (self->thinkTime % 2 == 0)) { self->x = self->startX + (3 * (self->x < self->startX ? 1 : -1)); } } }
static void entityWait() { int i; float dirX; Entity *e; dirX = self->dirX; if (dirX != 0) { for (e=self->target;e!=NULL;e=e->target) { if (e->x > self->startX) { e->flags &= ~NO_DRAW; } else { e->flags |= NO_DRAW; } } } checkToMap(self); if (self->dirX == 0 && dirX != 0) { playSoundToMap("sound/common/crumble", -1, self->x, self->y, 0); self->mental = 1; self->touch = &pushEntity; self->x += TILE_SIZE / 2; for (e=self->target;e!=NULL;e=e->target) { e->x += TILE_SIZE / 2; e->dirX = 0; e->touch = &pushEntity; } for (i=0;i<6;i++) { e = addSmallRock(self->x, self->y, "common/small_rock"); e->x += (self->w - e->w) / 2; e->y += (self->h - e->h) / 2; e->dirX = -(prand() % 4 + 1); e->dirY = -(prand() % 3 + 3); } shakeScreen(MEDIUM, 15); } }
static void doIntro() { Entity *e; self->thinkTime--; if (self->thinkTime <= 0) { e = getFreeEntity(); if (e == NULL) { showErrorAndExit("No free slots to add a Blob Boss Part"); } loadProperties("boss/blob_boss_part", e); setEntityAnimation(e, "STAND"); e->flags |= LIMIT_TO_SCREEN; e->draw = &drawLoopingAnimationToMap; e->type = ENEMY; e->damage = 0; e->head = self; e->action = &reform; e->health = 600; e->x = self->x + self->w / 2 - e->w / 2; e->y = self->startY + self->h / 2 - e->h / 2; e->dirX = (10 + prand() % 50) * (prand() % 2 == 0 ? 1 : -1); e->dirX /= 10; e->thinkTime = 120; e->targetX = self->x + self->w / 2; self->maxThinkTime--; if (self->maxThinkTime <= 0) { self->action = &introPause; } self->thinkTime = 6; } checkToMap(self); }
static void addDust() { int i; for (i=0;i<25;i++) { addSmoke(self->x + prand() % self->w, self->y + self->h - prand() % 10, "decoration/dust"); } }
void doTeleport() { int i; float speed; Entity *e; if (abs(self->x - self->targetX) < TELEPORT_SPEED && abs(self->y - self->targetY) < TELEPORT_SPEED) { self->flags &= ~(NO_DRAW|HELPLESS|TELEPORTING); self->x = self->targetX; self->y = self->targetY; addParticleExplosion(self->x + self->w / 2, self->y + self->h / 2); self->dirY = self->dirX = 0; self->standingOn = NULL; if (!(self->flags & NO_END_TELEPORT_SOUND)) { playSoundToMap("sound/common/teleport", -1, self->x, self->y, 0); } } else { self->flags |= NO_DRAW|HELPLESS|INVULNERABLE; speed = getDistance(self->x, self->y, self->targetX, self->targetY) / 20; speed = speed < TELEPORT_SPEED ? TELEPORT_SPEED : (speed > 30 ? 30 : speed); normalize(&self->dirX, &self->dirY); self->dirX *= speed; self->dirY *= speed; self->x += self->dirX; self->y += self->dirY; for (i=0;i<5;i++) { e = addBasicDecoration(self->x, self->y, "decoration/particle"); if (e != NULL) { e->x += prand() % self->w; e->y += prand() % self->h; e->thinkTime = 5 + prand() % 30; setEntityAnimationByID(e, prand() % 5); } } } }
static void creditsSummon() { Entity *e; self->dirX = 0; hover(); self->thinkTime--; if (self->thinkTime <= 0) { switch (self->mental) { case 0: e = addBook(self->x, self->y, "enemy/green_book"); break; case 1: e = addBook(self->x, self->y, "enemy/yellow_book"); break; case 2: e = addBook(self->x, self->y, "enemy/red_book"); break; default: e = addBook(self->x, self->y, "enemy/blue_book"); self->creditsAction = &creditsMove; break; } e->x = self->x + self->w / 2; e->y = self->y + self->h / 2; e->x -= e->w / 2; e->y -= e->h / 2; e->targetY = e->y + (prand() % 16) * (prand() % 2 == 0 ? -1 : 1); e->targetX = e->x - SCREEN_WIDTH / 2 + (prand() % 16) * (prand() % 2 == 0 ? -1 : 1); e->startY = e->targetY; calculatePath(e->x, e->y, e->targetX, e->targetY, &e->dirX, &e->dirY); e->flags |= (NO_DRAW|HELPLESS|TELEPORTING|NO_END_TELEPORT_SOUND); playSoundToMap("sound/common/spell", -1, self->x, self->y, 0); e->face = RIGHT; self->mental++; self->thinkTime = 30; } }
static void finalSpellWait() { Entity *e; self->thinkTime--; if (self->thinkTime <= 0) { self->mental++; if (self->mental >= 9) { self->mental = 9; } setEntityAnimationByID(self, self->mental); self->thinkTime = 60; } if (self->head->mental == 3 || self->health != self->head->health) { self->inUse = FALSE; } else { e = addPixelDecoration(self->x, self->y); if (e != NULL) { e->x = self->x + (prand() % 32) * (prand() % 2 == 0 ? -1 : 1) + self->w / 2; e->y = self->y + (prand() % 32) * (prand() % 2 == 0 ? -1 : 1) + self->h / 2; e->startX = e->x; e->startY = e->y; e->endX = self->x + self->w / 2; e->endY = self->y + self->h / 2; e->thinkTime = 15; e->health = 0; e->maxHealth = 255; e->mental = 0; calculatePath(e->startX, e->startY, e->endX, e->endY, &e->dirX, &e->dirY); } } self->x = self->head->x + self->offsetX; self->y = self->head->y + self->offsetY; }
static void riseUp() { Entity *e, *smoke; /*facePlayer();*/ self->thinkTime--; if (self->thinkTime <= 0) { self->damage = 1; self->y -= 2; self->thinkTime = 0; self->flags &= ~NO_DRAW; self->takeDamage = &takeDamage; } alignBodyToHead(); 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; } if (self->y <= self->targetY) { self->y = self->targetY; self->targetX = self->x; self->dirX = 0; self->thinkTime = 120; self->action = &headWait; } }
static void headWait() { int x; /* Sway back and forth */ self->dirX += 0.5; if (self->dirX >= 360) { self->dirX = 0; } x = 24; self->x = self->targetX + (sin(DEG_TO_RAD(self->dirX)) * x); alignBodyToHead(); self->thinkTime--; if (self->thinkTime <= 0 && player.health > 0) { self->thinkTime = 0; x = prand() % 4; switch (x) { case 0: self->action = &biteAttackInit; break; case 1: self->action = &changeSidesInit; break; case 2: self->action = &shotAttackInit; break; default: self->action = &crushAttackInit; break; } } if (prand() % 180 == 0) { playSoundToMap("sound/boss/snake_boss/hiss", BOSS_CHANNEL, self->x, self->y, 0); } }
void drawDisintegrationLine(int x1, int y1, int x2, int y2, int colour1, int colour2, int colour3) { int speed; float dirX, dirY, x, y, xx, yy; speed = 8; calculatePath(x1, y1, x2, y2, &dirX, &dirY); dirX *= speed; dirY *= speed; x = x1; y = y1; if (fabs(dirX) > fabs(dirY)) { while (!(fabs(x2 - x) <= fabs(dirX))) { yy = (prand() % 8) * (prand() % 2 == 0 ? -1 : 1); drawColouredLine(x, y, x + dirX, y + dirY + yy, colour1, colour2, colour3); x += dirX; y += dirY + yy; drawColouredLine(x, y, x + dirX, y + dirY - yy, colour1, colour2, colour3); x += dirX; y += dirY - yy; } } else { while (!(fabs(y2 - y) <= fabs(dirY))) { xx = (prand() % 8) * (prand() % 2 == 0 ? -1 : 1); drawColouredLine(x, y, x + dirX + xx, y + dirY, colour1, colour2, colour3); x += dirX + xx; y += dirY; drawColouredLine(x, y, x + dirX - xx, y + dirY, colour1, colour2, colour3); x += dirX - xx; y += dirY; } } }
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 die() { int i; Entity *e; char name[MAX_VALUE_LENGTH]; playSoundToMap("sound/common/crumble", -1, self->x, self->y, 0); snprintf(name, sizeof(name), "%s_piece", self->name); fireTrigger(self->objectiveName); fireGlobalTrigger(self->objectiveName); for (i=0;i<9;i++) { e = addTemporaryItem(name, self->x, self->y, self->face, 0, 0); e->x += (self->w - e->w) / 2; e->y += (self->w - e->w) / 2; e->dirX = (prand() % 5) * (prand() % 2 == 0 ? -1 : 1); e->dirY = ITEM_JUMP_HEIGHT + (prand() % ITEM_JUMP_HEIGHT); setEntityAnimationByID(e, i); e->thinkTime = 60 + (prand() % 180); } self->damage = 0; if (!(self->flags & INVULNERABLE)) { self->touch = &entityTouch; self->flags &= ~FLY; self->flags |= (DO_NOT_PERSIST|NO_DRAW); self->thinkTime = 60; setCustomAction(self, &invulnerableNoFlash, 240, 0, 0); self->frameSpeed = 0; self->action = &standardDie; self->damage = 0; } }
static void sink() { self->y += 0.25; if (self->y >= self->endY) { self->inUse = FALSE; } if (prand() % 2 == 0) { addSmoke(self->x + prand() % self->w, self->endY - prand() % 10, "decoration/dust"); } }