//============================================================================= // Update all game items //============================================================================= void Spacewar::update() { if(input->isKeyDown(ESC_KEY)) { exitGame(); } if(ship.getActive()) { ship.update(frameTime, shoot); if(powerupActive) { shootTime += 3*frameTime; powerupTime += frameTime; if(powerupTime >= POWERUP_DURATION) { powerupActive = false; } } else { shootTime += frameTime; } if(shoot && shootTime >= SHIP_SHOOT_DELAY) { spawnBullet(VECTOR2(ship.getX()+(shipNS::SCALE*ship.getWidth()*3)/4, ship.getY()+(shipNS::SCALE*ship.getHeight()/2)), VECTOR2(bulletNS::SPEED,0)); audio->playCue(PEW); shootTime = 0; } } if(timeSincePowerupSpawn >= POWERUP_FREQUENCY) { spawnPowerup(VECTOR2(GAME_WIDTH,(GAME_HEIGHT/4)+rand()%(GAME_HEIGHT/2)),VECTOR2(-1*powerNS::SPEED,0)); timeSincePowerupSpawn = 0; } timeSincePowerupSpawn += frameTime; for(int i=0; i<MAX_GUNS; i++) { if(guns[i].getActive()) { guns[i].update(frameTime, shoot); if(shoot) { spawnEnemyBullet(VECTOR2(guns[i].getX()+(gunNS::SCALE*guns[i].getWidth()*3)/4, guns[i].getY()+(gunNS::SCALE*guns[i].getHeight()*3)/8), VECTOR2(enemyBulletNS::SPEED,0)); audio->playCue(PEW); } } } for(int i=0; i<MAX_BULLETS; i++) { if(bullets[i].getActive()) bullets[i].update(frameTime); } for(int i=0; i<MAX_ENEMY_BULLETS; i++) { if(enemyBullets[i].getActive()) enemyBullets[i].update(frameTime); } if(power.getActive()) { power.update(frameTime); } seconds_since_start = difftime( time(0), start); //Begin Unarmed Asteroid spawning if(seconds_since_start == 10) asterGroupSize = 3; if(seconds_since_start == 20) asterGroupSize = 5; if(seconds_since_start == 30) asterGroupSize = 8; if(seconds_since_start == 40) asterGroupSize = 10; if(seconds_since_start == 60) asterGroupSize = 20; asteroidSpawnTime += frameTime; if(asteroidCounter < asterGroupSize && asteroidCounter < MAX_ASTEROIDS && asteroidSpawnTime > ASTEROID_SPAWN_DELAY) { VECTOR2 newpos = VECTOR2(GAME_WIDTH, rand() % ((GAME_HEIGHT*7)/8+asteroidNS::HEIGHT)-GAME_HEIGHT/8-asteroidNS::HEIGHT); VECTOR2 newdir = VECTOR2(GAME_WIDTH/6, rand() % GAME_HEIGHT) - newpos; D3DXVec2Normalize(&newdir,&newdir); spawnAsteroid(newpos,newdir*asteroidNS::SPEED); asteroidCounter++; asteroidSpawnTime = 0; } for(int i = 0; i < asteroidCounter; i++) { if(!asteroids[i].getActive()) asteroidCounter--; } for(int i=0; i<MAX_ASTEROIDS; i++) { if(asteroids[i].getActive()) asteroids[i].update(frameTime); if(i%2) asteroids[i].setRadians(asteroids[i].getRadians() + ASTEROID_ROTATION_SPEED);//if an even index of the asteroids array, then rotate clockwise else asteroids[i].setRadians(asteroids[i].getRadians() - ASTEROID_ROTATION_SPEED);//if an odd index of the asteroids array, then rotate counter clockwise } //End Unarmed Asteroid spawning }
void Killed (edict_t *targ, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point) { // if ((targ->client) && (targ->health < -999)) // targ->health = -999; if (!(targ->svflags & SVF_MONSTER) || (attacker->client)) targ->enemy = attacker; if ((targ->svflags & SVF_MONSTER) && (targ->deadflag != DEAD_DEAD)) { if (targ->monsterinfo.ability & GIEX_MABILITY_STEALTH) { removeStealth(); } targ->svflags |= SVF_DEADMONSTER; // now treat as a different content type if (!(targ->monsterinfo.aiflags & AI_GOOD_GUY)) { level.killed_monsters++; if (coop->value && (level.killed_monsters == level.total_monsters)) { gi.bprintf(PRINT_HIGH, "All monsters killed, %d bonus exp awarded!\n", 1000 + 100 * level.total_monsters); giveExpToAll(1000 + 100 * level.total_monsters); } // if (coop->value && attacker->client) // attacker->client->resp.score++; // medics won't heal monsters that they kill themselves if (attacker->classid == CI_M_MEDIC) targ->owner = attacker; } } if (targ->movetype == MOVETYPE_PUSH || targ->movetype == MOVETYPE_STOP || targ->movetype == MOVETYPE_NONE) { // doors, triggers, etc targ->die (targ, inflictor, attacker, damage, point); return; } if ((targ->svflags & SVF_MONSTER) && (targ->deadflag != DEAD_DEAD)) { targ->touch = NULL; monster_death_use (targ); } if ((targ->classid != CI_CORPSESPORE) && (targ->classid != CI_GIBRAIN) && (targ->classid != CI_PIZZAGIB) && (targ->classid, CI_M_INSANE) && (targ->deadflag != DEAD_DEAD)) { // Insane should never spawn ammo or powerups // gi.dprintf("Calling ammo and powerup spawn for %s\n", targ->classname); if ((game.monsterhunt == 10) && (targ->svflags & SVF_MONSTER)) { if (targ->classid != CI_M_JORG) { // You don't get any from Jorg... int i, num_players = 0; edict_t *ent; for (i=0 ; i<maxclients->value ; i++) { ent = g_edicts + 1 + i; if (!ent->inuse) continue; if (!ent->client->pers.loggedin) continue; num_players++; } if (num_players > 0) { for (i = 0; i < num_players; i++) { spawnAmmo(targ, attacker); spawnItem(targ, attacker); spawnPowerup(targ, attacker); } } } } else { spawnAmmo(targ, attacker); spawnItem(targ, attacker); spawnPowerup(targ, attacker); } if (targ->client) { if (attacker->client) { if (targ->radius_dmg > attacker->radius_dmg) { targ->client->pers.skills.stats[GIEX_STAT_LOWER_PLAYER_DEATHS]++; attacker->client->pers.skills.stats[GIEX_STAT_HIGHER_PLAYER_KILLS]++; } else { targ->client->pers.skills.stats[GIEX_STAT_HIGHER_PLAYER_DEATHS]++; attacker->client->pers.skills.stats[GIEX_STAT_LOWER_PLAYER_KILLS]++; } } else if (attacker->svflags & SVF_MONSTER) { targ->client->pers.skills.stats[GIEX_STAT_MONSTER_DEATHS]++; } else { targ->client->pers.skills.stats[GIEX_STAT_OTHER_DEATHS]++; } } else if ((targ->svflags & SVF_MONSTER) && (attacker->client)) { if (targ->monsterinfo.skill < 8) { attacker->client->pers.skills.stats[GIEX_STAT_LOW_MONSTER_KILLS]++; } else if (targ->monsterinfo.skill < 16) { attacker->client->pers.skills.stats[GIEX_STAT_MED_MONSTER_KILLS]++; } else if (targ->monsterinfo.skill < 24) { attacker->client->pers.skills.stats[GIEX_STAT_HI_MONSTER_KILLS]++; } else { attacker->client->pers.skills.stats[GIEX_STAT_VHI_MONSTER_KILLS]++; } } } targ->die (targ, inflictor, attacker, damage, point); }