static void bomber_update(struct foe_bomber *f) { jarhead_update(&f->jarhead); if (f->jarhead.state == JARHEAD_ALIVE) { if (f->jarhead.state == JARHEAD_ALIVE && f->refire_count > BOMBER_TICS_BEFORE_REFIRE && irand(20) == 0) { add_bomb(&f->common.pos); f->refire_count = 0; } else { f->refire_count++; } } }
// Move the player void PLAYER::move() { #ifndef EDITOR int who = (this == &p1) ? 1 : 2; int who2 = who-1; // Used for array indices // Reduce the icon alpha if(p_icon_alpha[who2]) { p_icon_alpha[who2] -= 0.005f; if(p_icon_alpha[who2] < 0.0f) p_icon_alpha[who2] = 0.0f; } // If we're dead, reduce the death counter and respawn if(!alive) { death_counter--; if(death_counter == 0) { // Respawn to a block int ox, oy; get_respawn_position((int)get_real_x(), (int)get_real_y(), ox, oy); int odir = dir; //clear(); alive = true; x = ox; y = oy; dir = odir; nextdir = dir; tx = x; ty = y; walking = false; jumping = false; dying = false; offset = 0.0f; create_teleport_effect(x, y); show_icon(who2); // Play the appear sound play_sound(SND_APPEAR, false); } return; } // Advance the dying animation if we're actually dying if(dying) { die_anim -= 0.03f; // Create the blue "burning down" effect float px = get_real_x(); float py = get_real_y(); for(int f=0; f < RAND(2,10); f++) { float rnd = RANDF(-0.3f, 0.3f); VECT pos(px, 2*size - 0.05f - (2.5f*size*(1-die_anim)), py); pos.x += rnd; pos.z -= rnd; if(pos.y < 0.0f) pos.y = 0.0f; VECT dir = 0.0f; float c1[4] = { 0.1f, 0.7f, 1, 1 }; float c2[4] = { 0.1f, 0.7f, 1, 0 }; add_particle(pos, dir, RAND(20,35), 0.1f, 0.4f, c1, c2, part_star); } if(die_anim < 0.0f) { die_anim = 0.0f; alive = false; // Explode the player bombs if(num_bombs > 0) { list<BOMB>::iterator b; for(b = bomblist.begin(); b != bomblist.end(); ++b) if((*b).owner == who && (*b).time > 1) (*b).time = 1; // Makes the bomb explode on the next cycle } } return; } // Jumping stuff if(jumping) { jump_pos += jump_speed; if(jump_pos >= 1.0f) { jump_pos = 1.0f; // We're now on the target tile x = jump_tx; y = jump_ty; tx = x; ty = y; offset = 0.0f; jumping = false; } // Create some particles if we're teleporting if(in_teleport && jumping) { VECT pos(get_real_x(), 0.25f, get_real_y()); pos += jump_dir * jump_pos * jump_dist; pos.y += jump_height * SIN(180.0f * jump_pos); VECT dir; for(int f=0; f<5; f++) { VECT ppos = pos + VECT(RANDF(-0.5f,0.5f),RANDF(-0.5f,0.5f),RANDF(-0.5f,0.5f)); dir.x = dir.y = dir.z = 0.0f; float c1[4] = { 0.3, 0.7f, 1, 1 }; float c2[4] = { 0, 0, 1, 0 }; add_particle(ppos, dir, RAND(10,30), 0.1f, 0.3f, c1, c2, part_teleport); } } // This is a dirty hack. Read the comments from the beginning of this file. if(map[jump_tx][jump_ty][1] && jump_pos > 0.9f) { players_on_block_x[who2] = jump_tx; players_on_block_y[who2] = jump_ty; } return; } // This is a dirty hack. Read the comments from the beginning of this file. if(map[x][y][1]) { players_on_block_x[who2] = x; players_on_block_y[who2] = y; //return; } else { players_on_block_x[who2] = -1; } // Don't move if we're using the napalm or the teleport power if(using_special_power && (which_special_power == RED_POWER_NAPALM)) return; if(using_special_power == who && (which_special_power == BLUE_POWER_TELEPORT)) return; // Don't move if the level is finished if(level_pause) return; // Advance the animation anim += 0.20f; if((int)anim > 3) anim = 0.0f; // Advance the turning animation if(turning) { turning_counter++; if(turning_counter == 5) { dir = nextdir; nextdir = dir + 1; if(nextdir > DIR_W) nextdir = DIR_N; } else if(turning_counter == 10) { dir = nextdir; turning = false; } } if(!walking && ((config.moving_style[who2] == MOV_RELATIVE && !key[config.key_up[who2]]) || (config.moving_style[who2] == MOV_ABSOLUTE && !key[config.key_up[who2]] && !key[config.key_down[who2]] && !key[config.key_left[who2]] && !key[config.key_right[who2]]))) anim = 0.0f; // Check if we're on a block bool on_block = false; if(map_solid(x,y)) on_block = true; // Don't move if we're using the flower power (absolute) if(on_block && config.moving_style[who2] == MOV_ABSOLUTE && (p1.num_flower_bombs > 0 || p2.num_flower_bombs > 0)) return; // Check for turning input if(key[config.key_left[who2]]) { if(config.moving_style[who2] == MOV_RELATIVE) { // Relative moving if(!turn_key_down[0] && !turning) { // Turn left nextdir = dir - 1; if(nextdir < DIR_N) nextdir = DIR_W; if(!walking) dir = nextdir; turn_key_down[0] = true; } } else if(config.moving_style[who2] == MOV_ABSOLUTE && !walking) { // Absolute moving dir = DIR_W; walking = true; offset = 0.0f; tx = x - 1; ty = y; // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } } else turn_key_down[0] = false; if(key[config.key_right[who2]]) { if(config.moving_style[who2] == MOV_RELATIVE) { // Relative moving if(!turn_key_down[1] && !turning) { // Turn right nextdir = dir + 1; if(nextdir > DIR_W) nextdir = DIR_N; if(!walking) dir = nextdir; turn_key_down[1] = true; } } else if(config.moving_style[who2] == MOV_ABSOLUTE && !walking) { // Absolute moving dir = DIR_E; walking = true; offset = 0.0f; tx = x + 1; ty = y; // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } } else turn_key_down[1] = false; // Check for 180 degree turning if(key[config.key_down[who2]]) { if(config.moving_style[who2] == MOV_RELATIVE) { // Relative moving if(!turn_key_down[2] && !turning && !walking && !key[config.key_up[who2]]) { nextdir = dir + 1; if(nextdir > DIR_W) nextdir = DIR_N; turning = true; turning_counter = 0; turn_key_down[2] = true; } } else if(config.moving_style[who2] == MOV_ABSOLUTE && !walking) { // Absolute moving dir = DIR_S; walking = true; offset = 0.0f; tx = x; ty = y + 1; // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } } else turn_key_down[2] = false; // Don't move if we're using the flower power (relative) if(on_block && config.moving_style[who2] == MOV_RELATIVE && (p1.num_flower_bombs > 0 || p2.num_flower_bombs > 0)) return; // Check for walking input if(key[config.key_up[who2]] && !walking && !turning) { if(config.moving_style[who2] == MOV_RELATIVE) { // Relative moving walking = true; offset = 0.0f; dir = nextdir; switch(dir) { default: case DIR_N: tx = x; ty = y - 1; break; case DIR_E: tx = x + 1; ty = y; break; case DIR_S: tx = x; ty = y + 1; break; case DIR_W: tx = x - 1; ty = y; break; } // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } else { // Absolute moving dir = DIR_N; walking = true; offset = 0.0f; tx = x; ty = y - 1; // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } } // Move towards the target tile if(offset < 1.0f && (tx != x || ty != y)) { offset += 0.1f; // If we're reached the target tile, move again if(offset >= 1.0f) { x = tx; y = ty; offset = 0.0f; walking = false; in_teleport = 0; } } // Reload the weapons if(reload > 0) reload--; // Dropping bombs if(key[config.key_shoot[who2]] && reload == 0 && num_bombs < 3 && !on_block && !icon_menu.wait) { reload = 30; // Plant the bomb add_bomb(x, y, BTYP_NORMAL, who); num_bombs++; // Play the sound play_sound(SND_BOMB, false); } // Invoke the special powers if(key[config.key_special[who2]]) { open_icon_menu(who, on_block); show_icon(0); show_icon(1); } #endif }