// Draw the weapon fire when firing void Weapon::DrawWeaponFire() { if (m_weapon_fire == NULL) return; Point2i hand; ActiveCharacter().GetHandPosition(hand); Point2i hole(hand + hole_delta * Point2i(ActiveCharacter().GetDirection(),1)); if (ActiveCharacter().GetDirection() == DIRECTION_RIGHT) hole = hole - Point2i(0, m_weapon_fire->GetHeight()/2); else hole = hole + Point2i(0, m_weapon_fire->GetHeight()/2); Double dst = hand.Distance(hole); Double angle = hand.ComputeAngle(hole); angle += ActiveCharacter().GetFiringAngle(); if (ActiveCharacter().GetDirection() == DIRECTION_LEFT) angle -= PI; Point2i spr_pos = hand + Point2i(static_cast<int>(dst * cos(angle)), static_cast<int>(dst * sin(angle))); m_weapon_fire->SetRotation_HotSpot(Point2i(0,0)); m_weapon_fire->SetRotation_rad(ActiveCharacter().GetFiringAngle()); m_weapon_fire->Draw(spr_pos); }
float AIIdea::RateExplosion(const Character & shooter, const Point2i& position, const ExplosiveWeaponConfig& config, const float& expected_additional_distance) { float rating = 0.0f; FOR_ALL_LIVING_CHARACTERS(team, character) { float distance = position.Distance(character->GetCenter()); distance += expected_additional_distance; if (distance < 1.0f) distance = 1.0f; Double Dist = distance; float min_damage = GetDamageFromExplosion(config, Dist); float max_damage = min_damage; if (Dist <= config.blast_range) { float force = GetForceFromExplosion(config, Dist).tofloat(); min_damage += MIN_DAMAGE_PER_FORCE_UNIT * force; max_damage += MAX_DAMAGE_PER_FORCE_UNIT * force; } bool is_friend = shooter.GetTeamIndex() == character->GetTeamIndex(); if (is_friend) { rating -= RateDamageDoneToEnemy(min_damage, max_damage, *character); } else { rating += RateDamageDoneToEnemy(min_damage, max_damage, *character); } }
const Point2i Weapon::GetGunHolePosition() const { Point2i pos; ActiveCharacter().GetHandPosition(pos); Point2i hole(pos + hole_delta * Point2i(ActiveCharacter().GetDirection(),1)); Double dst = pos.Distance(hole); Double angle = pos.ComputeAngle(hole); if (ActiveCharacter().GetDirection() == DIRECTION_RIGHT) angle += ActiveCharacter().GetFiringAngle(); else angle += ActiveCharacter().GetFiringAngle() - PI; return pos + Point2i(static_cast<int>(dst * cos(angle)), static_cast<int>(dst * sin(angle))); }