5 float m_fMomentumToDamageScale;
7 [
Attribute(
"",
UIWidgets.Object,
"List of objects (particles, debris, etc) to spawn on destruction of the object",
category:
"Destruction FX")]
8 ref array<ref SCR_BaseSpawnable> m_aDestroySpawnObjects;
10 [
Attribute(
"0", uiwidget:
UIWidgets.ComboBox,
"Type of material for destruction sound",
"", ParamEnumArray.FromEnum(SCR_EMaterialSoundTypeBreak))]
11 SCR_EMaterialSoundTypeBreak m_eMaterialSoundType;
13 [
Attribute(
"0", uiwidget:
UIWidgets.CheckBox,
"Total destruction: If a destructible takes too much damage from a single source while this is enabled, instead of advancing to the next phase, it will be deleted from the world without any effects. Total destruction overrides \"Destroy at no health\"",
"")]
14 bool m_bTotalDestructionEnabled;
16 [
Attribute(defvalue:
"0", uiwidget:
UIWidgets.Slider,
desc:
"Amount of damage to take from a single source to trigger total destruction",
params:
"0 64000 1")]
17 float m_fTotalDestructionThreshold;
23 protected static const int MIN_DESTRUCTION_RESPONSE_INDEX = 6;
25 static const int TOTAL_DESTRUCTION_MAX_HEALTH_MULTIPLIER = 10;
32 return prefabData.GetDamageMultiplier(
type);
42 return prefabData.GetDamageReduction();
52 return prefabData.GetDamageThreshold();
64 return prefabData.GetMaxHealth();
68 override void OnDamage(
int previousState,
int newState,
float currentHealth, notnull
BaseDamageContext damageContext, ScriptBitWriter frameData)
76 if (previousState == newState)
81 destructionData.m_vHitPosition = damageContext.hitPosition;
82 destructionData.m_vHitDirection = damageContext.hitDirection.Normalized();
83 destructionData.m_vHitNormal = damageContext.hitNormal.Normalized();
84 destructionData.m_fHitDamage = damageContext.damageValue;
85 destructionData.m_eDamageType = damageContext.damageType;
86 destructionData.m_iPreviousPhase = previousState;
90 const bool totalDestruction = prefabData.m_bTotalDestructionEnabled && (damageContext.damageValue >= prefabData.m_fTotalDestructionThreshold);
91 destructionData.m_bTotalDestruction = totalDestruction;
94 if(destructionData.m_bTotalDestruction)
97 RplComponent.DeleteRplEntity(
this,
false);
101 destructionData.Save(frameData);
121 bool destroyAtNoHealth;
122 prefabData.GetPrefab().Get(
"DestroyAtNoHealth", destroyAtNoHealth);
124 bool lastPhase = prefabData.GetNumDestructionPhases() - 1 == damagePhaseIndex;
133 phys.SetResponseIndex(phase.m_ePhysicalResponseIndex);
138 if (destroyAtNoHealth && lastPhase)
155 if (prefabData.m_eMaterialSoundType > 0)
158 if (lastPhase && destroyAtNoHealth)
193 DestructionManager manager = world.GetDestructionManager();
200 vector minsOffset =
"-5 -5 -5";
201 vector maxsOffset =
"5 5 5";
203 minsOffset = minsOffset*1.5;
204 maxsOffset = maxsOffset*1.5;
208 manager.QueueDestructionHeatmapEntry(entry);
216 destructionData.Load(frameData);
219 if(destructionData.m_bTotalDestruction)
224 GoToDamagePhase(destructibleState, destructionData.m_iPreviousPhase, destructionData, JIP);
261 Physics ownerPhysics = contact.Physics1;
262 Physics otherPhysics = contact.Physics2;
264 float ownerMass = ownerPhysics.GetMass();
265 float otherMass = otherPhysics.GetMass();
266 int ownerReponseIndex = ownerPhysics.GetResponseIndex();
267 int otherResponseIndex = otherPhysics.GetResponseIndex();
270 float damage = prefabData.GetMaxHealth();
274 if (ownerReponseIndex < MIN_DESTRUCTION_RESPONSE_INDEX || otherResponseIndex -
MIN_MOMENTUM_RESPONSE_INDEX < ownerReponseIndex - MIN_DESTRUCTION_RESPONSE_INDEX)
277 damage = momentum * prefabData.m_fMomentumToDamageScale;
285 vector relVel = contact.VelocityBefore2 - contact.VelocityBefore1;
286 outMat[0] = contact.Position;
287 outMat[1] = relVel.Normalized();
288 outMat[2] = contact.Normal;
void SCR_BaseDebrisSmallEntity(IEntitySource src, IEntity parent)
override bool FilterContact(IEntity owner, IEntity other, Contact contact)
Armor doesn't take collisiondamage.
override bool HandleDamage(BaseDamageContext damageContext, IEntity owner)
SCR_CharacterBloodHitZone OnDamage
Resilience - incapacitation or death, depending on game mode settings.
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
float GetDamageThreshold()
float GetDamageReduction()
float GetDamageMultiplier(EDamageType type)
SCR_DestructibleEntityClass MIN_MOMENTUM_RESPONSE_INDEX
void SCR_DestructibleEntity(IEntitySource src, IEntity parent)
void GoToDamagePhase(int damagePhaseIndex, int previousDamagePhaseIndex, SCR_DestructionData destructionData, bool streamed)
Only call from OnStateChanged, otherwise you have HUGE desync.
SCR_EDestructionResponseIndex
override void EOnContact(IEntity owner, IEntity other, Contact contact)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
override void OnFilteredContact(IEntity owner, IEntity other, Contact contact)
enum SCR_EPhysicsResponseIndex MIN_IMPULSE_THRESHOLD
SCR_VehicleDamageManagerComponentClass GetPrefabData()
void OnStateChanged(int destructibleState, ScriptBitReader frameData, bool JIP)
proto external Physics GetPhysics()
bool GetPhaseModelAndRemap(out ResourceName modelPath, out string remap, ResourceName parentPrefabPath=ResourceName.Empty)
static void SetDamagePhaseSignal(notnull IEntity owner, int damagePhaseIndex=0)
static void SpawnDestroyObjects(notnull IEntity owner, notnull array< ref SCR_BaseSpawnable > spawnList, notnull SCR_DestructionHitInfo destructionHitInfo)
Spawns objects that are meant to be created when the object is destroyed (particles,...
static void PlaySound(notnull IEntity owner, SCR_EMaterialSoundTypeBreak materialSoundType, int numDamagePhases, int damagePhaseIndex)
static float CalculateMomentum(notnull Contact contact, float ownerMass, float otherMass)
static void UpdateResponseIndex(notnull Physics physics, float health, float maxHealth)
static void SetModel(notnull IEntity owner, ResourceName modelName)
static void RegenerateNavmeshDelayed(notnull IEntity owner)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
EDestructionHeatmapCategory