missile_ptr world::add_missile(const plane_ptr &p, net_missile_ptr ptr) { if (!p) return missile_ptr(); const bool add_to_world = !(ptr && !ptr->source); auto m = p->special_weapon_selected ? add_missile(p->special.id.c_str(), p->render->get_special_model(), add_to_world) : add_missile(p->missile.id.c_str(), p->render->get_missile_model(), add_to_world); if (!m) return missile_ptr(); if (m_network) m->net = ptr ? ptr : m_network->add_missile(p->net, p->special_weapon_selected); return m; }
void run_a_missile(location from,location fire_to,short miss_type,short path,short sound_num,short x_adj,short y_adj,short len) { // if ((cartoon_happening == true) && (anim_step < 140)) // return; start_missile_anim(); add_missile(fire_to,miss_type,path, x_adj, y_adj); do_missile_anim(len,from, sound_num); end_missile_anim(); }
missile_ptr world::add_missile(const char *name) { model m; m.load((std::string("w_") + name).c_str(), m_location.get_params()); return add_missile(m); }
void world::update(int dt) { m_net_data_updated = false; if (m_network) { m_network->update(); network_interface::msg_add_plane mp; while (m_network->get_add_plane_msg(mp)) add_plane(mp.preset.c_str(), mp.player_name.c_str(), mp.color, false, m_network->add_plane(mp)); network_interface::msg_add_missile mm; while (m_network->get_add_missile_msg(mm)) { auto net = m_network->get_plane(mm.plane_id); if (!net) continue; for (auto &p: m_planes) { if(p->net != net) continue; p->special_weapon_selected = mm.special; add_missile(p, m_network->add_missile(mm)); break; } } network_interface::msg_game_data md; while (m_network->get_game_data_msg(md)) { auto net = m_network->get_plane(md.plane_id); if (!net) continue; for (auto &p: m_planes) { if(p->net != net) continue; p->net_game_data = md.data; break; } m_net_data_updated = true; } std::string str; while(m_network->get_general_msg(str)) { std::istringstream is(str); std::string cmd; is >> cmd; if (cmd == "explosion") { vec3 pos; float r; read(is, pos), is >> r; spawn_explosion(pos, r, false); } if (is_host()) { if (cmd == "plane_take_damage") { unsigned int plane_id; int damage; is >> plane_id, is >> damage; auto net = m_network->get_plane(plane_id); if (!net) continue; for (auto &p: m_planes) { if(p->net != net) continue; p->take_damage(damage, *this, false); break; } } } else { if (cmd == "respawn")