DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ RegisterTransportHit()

void Entity::RegisterTransportHit ( Transport transport)
inlineprotected

См. определение в файле 3_Game/DayZ/Entities/EntityAI.c строка 4134

4135 {
4137 {
4140 Car car;
4141 Boat boat;
4142 Motorbike motorbike;
4143 float damage;
4144 vector impulse;
4145
4146 // a different attempt to solve hits from "standing" car to the players
4147 if (Car.CastTo(car, transport))
4148 {
4149 float carSpeed = car.GetSpeedometerAbsolute();
4150 if (carSpeed > 2.0)
4151 {
4152 damage = m_TransportHitVelocity.Length();
4153 ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
4154 }
4155 else
4157
4158 // compute impulse and apply only if the body dies
4159 if (IsDamageDestroyed() && carSpeed > 3.0)
4160 {
4161 impulse = 40 * m_TransportHitVelocity;
4162 impulse[1] = 40 * 1.5;
4163 dBodyApplyImpulse(this, impulse);
4164 }
4165 }
4166 else if (Motorbike.CastTo(motorbike, transport))
4167 {
4168 float motorbikeSpeed = motorbike.GetSpeedometerAbsolute();
4169 if (motorbikeSpeed > 2.0)
4170 {
4171 damage = m_TransportHitVelocity.Length();
4172 ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
4173 }
4174 else
4176
4177 // compute impulse and apply only if the body dies
4178 if (IsDamageDestroyed() && motorbikeSpeed > 3.0)
4179 {
4180 impulse = 5.0 * m_TransportHitVelocity;
4181 impulse[1] = 5.0;
4182 dBodyApplyImpulse(this, impulse);
4183 }
4184 }
4185 else if (Boat.CastTo(boat, transport))
4186 {
4187 Human player = Human.Cast(this);
4188 if (player && player.PhysicsGetLinkedEntity() == boat) // standing on boat
4189 {
4191 return;
4192 }
4193
4194 if (m_TransportHitVelocity.Normalize() > 5) // 5 m/s
4195 {
4196 damage = m_TransportHitVelocity.Length() * 0.5;
4197 ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
4198 }
4199 else
4201 }
4202 else //old solution just in case if somebody use it
4203 {
4204 // avoid damage because of small movements
4205 if (m_TransportHitVelocity.Length() > 0.1)
4206 {
4207 damage = m_TransportHitVelocity.Length();
4208 ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
4209 }
4210 else
4211 {
4213 }
4214
4215 // compute impulse and apply only if the body dies
4216 if (IsDamageDestroyed() && m_TransportHitVelocity.Length() > 0.3)
4217 {
4218 impulse = 40 * m_TransportHitVelocity;
4219 impulse[1] = 40 * 1.5;
4220 dBodyApplyImpulse(this, impulse);
4221 }
4222 }
4223 }
4224 }
bool IsDamageDestroyed(ActionTarget target)
Определения ActionBase.c:1275
bool m_TransportHitRegistered
vector m_TransportHitVelocity
proto native IEntity PhysicsGetLinkedEntity()
entity we are linked to (not valid when IEntity.GetParent() returns some entity)
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin)

Перекрестные ссылки dBodyApplyImpulse(), GetVelocity(), IsDamageDestroyed(), m_TransportHitRegistered, m_TransportHitVelocity и Human::PhysicsGetLinkedEntity().