/* * ProjectilesMove; called for every frame. * dt is number of milliseconds since last time animation timer went off. * Return True iff some projectile moved. */ Bool ProjectilesMove(int dt) { list_type l, next; if (current_room.projectiles == NULL) return False; // Have to be careful here, since deleting items from list as we go down it l = current_room.projectiles; while (l != NULL) { Projectile *p = (Projectile *) (l->data); next = l->next; if (MoveSingle(&p->motion, dt)) { current_room.projectiles = list_delete_item(current_room.projectiles, p, CompareProjectiles); SafeFree(p); } else if (p->flags & PROJ_FLAG_FOLLOWGROUND) { p->motion.z = GetPointFloor(p->motion.x, p->motion.y); } l = next; } return True; }
/* * MoveTooCloseToWall: User is moving from (old_x, old_y) to (new_x, new_y). * Return True if this moves user too close to an impassable wall. */ Bool MoveTooCloseToWall(BSPTree tree, int old_x, int old_y, int new_x, int new_y, int min_distance) { int i, last_x, last_y, x, y, z; // Divide move into a few pieces to prevent a move that jumps clear through // a wall, but where either endpoint isn't too close to a wall last_x = old_x; last_y = old_y; for (i=1; i <= STEPS_PER_MOVE; i++) { // Find height of floor at object's current location z = GetPointFloor(tree, last_x, last_y); x = old_x + (new_x - old_x) * i / STEPS_PER_MOVE; y = old_y + (new_y - old_y) * i / STEPS_PER_MOVE; if (MoveCheckBSPNode(tree, last_x, last_y, x, y, z, min_distance) == True) return True; last_x = x; last_y = y; } return False; }
/* * D3DParticleIsAlive: Decrements particle energy, checks if particle * is alive and can be displayed. Doesn't check if * particle is behind the player, because position * and velocity still need to be updated for these. */ Bool D3DParticleIsAlive(emitter *pEmitter, particle *pParticle) { if (pParticle->energy == 0) return false; if (--pParticle->energy <= 0) { pParticle->energy = 0; pEmitter->numAlive--; return false; } if (pEmitter->emitterFlags & PS_WEATHER_EFFECT) { PDIB pdibCeiling = NULL; pdibCeiling = GetPointCeilingTexture(pParticle->pos.x, pParticle->pos.y); if (pdibCeiling) { pParticle->energy = 0; pEmitter->numAlive--; return false; } } // If we don't allow this type of particle to survive inside the ground, destroy it. if ((pEmitter->emitterFlags & PS_GROUND_DESTROY) && (pParticle->pos.z < GetPointFloor(pParticle->pos.x, pParticle->pos.y))) { //debug(("destroying particle, floor: %i, pHeight: %6.1f \n", // GetPointFloor(pParticle->pos.x, pParticle->pos.y), pParticle->pos.z)); pParticle->energy = 0; pEmitter->numAlive--; return false; } return true; }