void CPolterTele::tele_find_objects(xr_vector<CObject*> &objects, const Fvector &pos) { m_nearest.clear_not_free (); Level().ObjectSpace.GetNearest (m_nearest, pos, m_pmt_radius, NULL); for (u32 i=0;i<m_nearest.size();i++) { CPhysicsShellHolder *obj = smart_cast<CPhysicsShellHolder *>(m_nearest[i]); CCustomMonster *custom_monster = smart_cast<CCustomMonster *>(m_nearest[i]); if (!obj || !obj->PPhysicsShell() || !obj->PPhysicsShell()->isActive()|| custom_monster || (obj->spawn_ini() && obj->spawn_ini()->section_exist("ph_heavy")) || (obj->m_pPhysicsShell->getMass() < m_pmt_object_min_mass) || (obj->m_pPhysicsShell->getMass() > m_pmt_object_max_mass) || (obj == m_object) || m_object->CTelekinesis::is_active_object(obj) || !obj->m_pPhysicsShell->get_ApplyByGravity()) continue; Fvector center; Actor()->Center(center); if (trace_object(obj, center) || trace_object(obj, get_head_position(Actor()))) objects.push_back(obj); } }
struct key_suscription *get_suscription(int sender_id, int console) { CPOSITION it; struct key_suscription *s; it = get_head_position(&t[console].suscribers); while(it != NULL) { s = (struct key_suscription *)get_next(&it); if(s->taskid == sender_id) return s; } s = (struct key_suscription *)malloc(sizeof(struct key_suscription)); if(s == NULL) return NULL; s->susc = 0; s->taskid = sender_id; s->port = 0; add_head(&t[console].suscribers, s); return s; }
void CPseudoGigant::on_activate_control(ControlCom::EControlType type) { if (type == ControlCom::eControlThreaten) { m_sound_start_threaten.play_at_pos(this,get_head_position(this)); m_time_next_threaten = time() + Random.randI(m_threaten_delay_min,m_threaten_delay_max); } }
void CPolterTele::tele_fire_objects() { for (u32 i=0; i < m_object->CTelekinesis::get_objects_total_count();i++) { CTelekineticObject tele_object = m_object->CTelekinesis::get_object_by_index(i); //if (tele_object.get_state() != TS_Fire) { if ((tele_object.get_state() == TS_Raise) || (tele_object.get_state() == TS_Keep)) { Fvector enemy_pos; enemy_pos = get_head_position(Actor()); m_object->CTelekinesis::fire_t (tele_object.get_object(),enemy_pos, tele_object.get_object()->Position().distance_to(enemy_pos) / m_pmt_fly_velocity); return; } } }
CAlienEffector::CAlienEffector(ECamEffectorType type, CAI_Bloodsucker *obj) : inherited(type, flt_max) { dangle_target.set (angle_normalize(Random.randFs(DELTA_ANGLE_X)),angle_normalize(Random.randFs(DELTA_ANGLE_Y)),angle_normalize(Random.randFs(DELTA_ANGLE_Z))); dangle_current.set (0.f, 0.f, 0.f); monster = obj; m_prev_eye_matrix.c = get_head_position(monster); m_prev_eye_matrix.k = monster->Direction(); Fvector::generate_orthonormal_basis(m_prev_eye_matrix.k,m_prev_eye_matrix.j,m_prev_eye_matrix.i); m_inertion = 1.f; m_current_fov = MIN_FOV; }
int remove_suscription(int sender_id, int console) { CPOSITION it; struct key_suscription *s; it = get_head_position(&t[console].suscribers); while(it != NULL) { s = (struct key_suscription *)get_next(&it); if(s->taskid == sender_id) { remove_at(&t[console].suscribers, it); free(s); return 0; // success } } return 1; }
struct pipes_res * pclose(struct pipes_close *pcmd, struct pipe *p, int task) { CPOSITION it; // check pipe type if(p->type == PIPES_FILEPIPE) { fclose(p->pf); return build_response_msg(PIPESERR_OK); } if(task == p->taskid) { p->task1_closed = 1; } else if(task == p->taskid2) { p->task2_closed = 1; } // if there was a pending read, send what's left on the buffer if(p->pending) { process_pending(p); } if((p->task1_closed && p->task2_closed) || task == p->creating_task) { it = get_head_position(&p->buffer->blocks); while(it != NULL) { struct pipe_buffer_block *b = (struct pipe_buffer_block*)get_next(&it); free_block(b); } lstclear(&p->buffer->blocks); avl_remove(&pipes, p->id); free(p); } return build_response_msg(PIPESERR_OK); }
void CPolterFlame::create_flame(const CObject *target_object) { Fvector position; if (!get_valid_flame_position(target_object, position)) return; SFlameElement *element = new SFlameElement(); element->position = position; element->target_object = target_object; element->time_started = time(); element->sound.clone (m_sound, st_Effect,SOUND_TYPE_WORLD); element->sound.play_at_pos (m_object,element->position); element->particles_object = 0; element->time_last_hit = 0; Fvector target_point = get_head_position(const_cast<CObject*>(target_object)); element->target_dir.sub (target_point, element->position); element->target_dir.normalize (); m_flames.push_back (element); select_state (element, ePrepare); m_time_flame_started = time(); }
float CMeleeChecker::distance_to_enemy(const CEntityAlive *enemy) { float dist = enemy->Position().distance_to (m_object->Position()); if (dist > MAX_TRACE_ENEMY_RANGE) return dist; Fvector enemy_center; enemy->Center (enemy_center); Fvector my_head_pos = get_head_position(m_object); Fvector dir; dir.sub (enemy_center, my_head_pos); dir.normalize_safe (); collide::ray_defs r_query (my_head_pos, dir, MAX_TRACE_ENEMY_RANGE, CDB::OPT_CULL | CDB::OPT_ONLYNEAREST, collide::rqtObject); r_res.r_clear (); if (m_object->CFORM()->_RayQuery(r_query, r_res)) { if (r_res.r_begin()->O == enemy) dist = r_res.r_begin()->range; } return (dist); }
BOOL CAlienEffector::ProcessCam(SCamEffectorInfo& info) { // »нициализаци¤ Fmatrix Mdef; Mdef.identity (); Mdef.j.set (info.n); Mdef.k.set (info.d); Mdef.i.crossproduct (info.n, info.d); Mdef.c.set (info.p); // set angle if (angle_lerp(dangle_current.x, dangle_target.x, ANGLE_SPEED, Device.fTimeDelta)) { dangle_target.x = angle_normalize(Random.randFs(DELTA_ANGLE_X)); } if (angle_lerp(dangle_current.y, dangle_target.y, ANGLE_SPEED, Device.fTimeDelta)) { dangle_target.y = angle_normalize(Random.randFs(DELTA_ANGLE_Y)); } if (angle_lerp(dangle_current.z, dangle_target.z, ANGLE_SPEED, Device.fTimeDelta)) { dangle_target.z = angle_normalize(Random.randFs(DELTA_ANGLE_Z)); } // update inertion Fmatrix cur_matrix; cur_matrix.k = monster->Direction(); cur_matrix.c = get_head_position(monster); float rel_dist = m_prev_eye_matrix.c.distance_to(cur_matrix.c) / MAX_CAMERA_DIST; clamp (rel_dist, 0.f, 1.f); def_lerp(m_inertion, 1 - rel_dist, rel_dist, Device.fTimeDelta); // set pos and dir with inertion m_prev_eye_matrix.c.inertion(cur_matrix.c, m_inertion); m_prev_eye_matrix.k.inertion(cur_matrix.k, m_inertion); Fvector::generate_orthonormal_basis_normalized(m_prev_eye_matrix.k,m_prev_eye_matrix.j,m_prev_eye_matrix.i); // apply position and direction Mdef = m_prev_eye_matrix; //set fov float rel_speed = monster->m_fCurSpeed / 15.f; clamp (rel_speed,0.f,1.f); float m_target_fov = MIN_FOV + (MAX_FOV-MIN_FOV) * rel_speed; def_lerp(m_current_fov, m_target_fov, FOV_SPEED, Device.fTimeDelta); info.fFov = m_current_fov; ////////////////////////////////////////////////////////////////////////// // ”становить углы смещени¤ Fmatrix R; R.setHPB (dangle_current.x,dangle_current.y,dangle_current.z); Fmatrix mR; mR.mul (Mdef,R); info.d.set (mR.k); info.n.set (mR.j); info.p.set (mR.c); return TRUE; }