MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / SpawnBodyPart

Method SpawnBodyPart

PanzerChasm/server/monster.cpp:886–925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

884}
885
886void Monster::SpawnBodyPart( Map& map, const unsigned char part_id )
887{
888 /* Select position for parts spawn.
889 * Each part must be spawned at specific point of monster body.
890 *
891 * This code is experimental. I don`t know, how original game does this.
892 * All constatns are exeprimental.
893 */
894
895 const float c_relative_hands_level= 0.65f;
896 const float c_hands_radius= 0.2f;
897
898 const m_Vec2 z_minmax= GetZMinMax();
899 m_Vec3 pos= pos_;
900
901 switch( part_id )
902 {
903 case BodyPartSubmodelId:: LeftHand:
904 pos.x+= c_hands_radius * std::cos( angle_ + Constants::half_pi );
905 pos.y+= c_hands_radius * std::sin( angle_ + Constants::half_pi );
906 pos.z+= z_minmax.x * c_relative_hands_level + z_minmax.y * ( 1.0f - c_relative_hands_level );
907 break;
908
909 case BodyPartSubmodelId::RightHand:
910 pos.x+= c_hands_radius * std::cos( angle_ - Constants::half_pi );
911 pos.y+= c_hands_radius * std::sin( angle_ - Constants::half_pi );
912 pos.z+= z_minmax.x * c_relative_hands_level + z_minmax.y * ( 1.0f - c_relative_hands_level );
913 break;
914
915 case BodyPartSubmodelId::Head:
916 pos.z+= z_minmax.y;
917 break;
918
919 default:
920 PC_ASSERT(false);
921 break;
922 };
923
924 map.SpawnMonsterBodyPart( monster_id_, part_id, pos, angle_ );
925}
926
927} // namespace PanzerChasm

Callers

nothing calls this directly

Calls 1

SpawnMonsterBodyPartMethod · 0.80

Tested by

no test coverage detected