void EntTriggerPush::Touch(Entity &other) { // Player *player; float height, time, dist; std::stringstream sstr; if(!target) return; Vector3f v = target->GetOrigin() - other.GetOrigin(); height = v[1]; time = (float)sqrt(height / (G_GRAVITY * 0.5)); v[1] = 0; dist = v.length(); v.normalize(); v *= dist / time; v[1] = time * G_GRAVITY; sstr << "push" << " " << v[0] << " " << v[1] << " " << v[2]; if(other.GetClassName() == "player") { // logstream() << "TOUCH: " << other.GetOrigin()[0] << " " << other.GetOrigin()[1] << " " << other.GetOrigin()[2] << "\n"; EE.ThrowEvent_i(&other, sstr.str(), 0); //play sound EE.C_ExecCommand("s_play basehaste/sound/world/jumppad.wav"); } }
void LaserBeam::OnCollision(ICollidable *other) { Entity *entity = (Entity*)other; Damage_t damage; damage.damage = entity->GetHealth(); if (entity->IsPlayer()) { damage.damage = 1; } damage.direction = Vector2D(-1, 0); damage.inflictor = GetOwner(); if (GetOwner() != nullptr) { damage.statsInflictorName = GetOwner()->GetEntityClassName(); damage.statsInflictorClass = GetOwner()->GetEntityResourceClass(); } damage.statsWeaponName = GetEntityClassName(); damage.statsWeaponClass = GetEntityResourceClass(); entity->TakeDamage(damage); Vector2D laserCenter = GetOrigin(); laserCenter.x = entity->GetOrigin().x; GetGameContext()->GetParticleRoot()->CreateParticles("laser_cannon_hit", laserCenter, Vector2D(-1, 0)); }
void Client::Maintain (const Entity &ent) { if (ent.IsPlayer ()) { m_ent = ent; m_safeOrigin = ent.GetOrigin (); m_flags |= ent.IsAlive () ? CLIENT_VALID | CLIENT_ALIVE : CLIENT_VALID; } else { m_safeOrigin = nullvec; m_flags = ~(CLIENT_VALID | CLIENT_ALIVE); } }
void LaserBeam::OnSimulate(float frametime) { BaseClass::OnSimulate(frametime); float laserLength = Camera::GetInstance()->GetWorldMaxs().x - Camera::GetInstance()->GetWorldMins().x; float gameTime = GetGameContext()->GetGameTime(); SetSize(Vector2D(laserLength, LASER_MAX_SIZE_Y)); Entity *owner = GetOwner(); if (owner == nullptr || timer < gameTime) { Remove(); } else { Vector2D center = owner->GetOrigin(); center.x -= laserLength * 0.5f; center += offset; if (!spawned) { Teleport(center); spawned = true; } else { SetOrigin(center); } } if (flashTimer < gameTime) { flashSize = fixedSize; fixedSize = qlerp(qfrand(), LASER_MIN_SIZE_Y, LASER_MAX_SIZE_Y); flashTimer = gameTime + LASER_FLASH_DURATION; } }