I have this code so far that allows me to have "Damage States" for lack of a better term. I have it so when the KActor takes a set amount of damage it switches meshs, and I have it so it plays a soundcue. Both of these work, but everytime I try to get a particle system to work it never works. This code allows for the mesh, soundcue to be added from inside the editor by selecting the KActor and hitting F4 and playing with its properties, I need the Particle System to be able to be implemented this way as well. Does anyone have any ideas on how to do this, or can anyone help me do this?? Thanks for any help that can be given, and let me know if you need more info.
Actor Factory for the Above Code.
Code:
// Breakable Actor class, that is referanced by DarkJourneyBreakableActorFactory class DarkJourneyBreakableActor extends KActor config(Game) native placeable; // Types of Damage that are counted var() array<class<DamageType> > DamageTypes; struct native BreakableStep { // Total amount of damage to take before activating the event var() float DamageThreshold; // KActor template to use when this object breaks var() StaticMesh BreakMesh; // The physics mode to switch to var() EPhysics Physics; // Sound to play when the object breaks or switches damage states var() SoundCue BreakSound; structdefaultproperties { DamageThreshold = 0.0 Physics = PHYS_RigidBody } }; // Sequence of events of destruction.. starts at 0 var() array<BreakableStep> BreakableSteps; // Current breakable step var int CurrentBreakableStep; native function vector GetOffsetToWorld(vector Offset); // Checks to see if the KActor has taken a valid damage type and if so changes the breakable step event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser) { if (IsValidDamageType(DamageType)) { if (CurrentBreakableStep == BreakableSteps.Length - 1) { TakeLastDamage(Damage, EventInstigator, false, CurrentBreakableStep); } else { TakeStepDamage(Damage, EventInstigator, false, CurrentBreakableStep); } } Super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser); } function TakeLastDamage(int Damage, Controller EventInstigator, bool bIsBroken, int BrokenStep) { BreakableSteps[CurrentBreakableStep].DamageThreshold -= Damage; if (BreakableSteps[CurrentBreakableStep].DamageThreshold < 0) { BreakLastApart(EventInstigator); } else if (bIsBroken) { BreakStepApart(BrokenStep); } } function TakeStepDamage(int Damage, Controller EventInstigator, bool bIsBroken, int BrokenStep) { BreakableSteps[CurrentBreakableStep].DamageThreshold -= Damage; if (BreakableSteps[CurrentBreakableStep].DamageThreshold < 0) { CurrentBreakableStep++; if (CurrentBreakableStep < BreakableSteps.Length - 1) { TakeStepDamage(-BreakableSteps[CurrentBreakableStep-1].DamageThreshold, EventInstigator, true, CurrentBreakableStep-1); } else { TakeLastDamage(-BreakableSteps[CurrentBreakableStep-1].DamageThreshold, EventInstigator, true, CurrentBreakableStep-1); } } else if (bIsBroken) { BreakStepApart(BrokenStep); } } // Searches DamageTypes[] for the specified damage type final function bool IsValidDamageType(class<DamageType> inDamageType) { local bool bValid; bValid = true; if (DamageTypes.Length > 0) { bValid = (DamageTypes.Find(inDamageType) != -1); } return bValid; } function BreakStepApart(int BrokenStep) { if (BreakableSteps[BrokenStep].BreakSound != None) { PlaySound(BreakableSteps[BrokenStep].BreakSound, true,,, CollisionComponent.Bounds.Origin); } if (BreakableSteps[BrokenStep].BreakMesh != None) { StaticMeshComponent.SetStaticMesh(BreakableSteps[BrokenStep].BreakMesh); } SetPhysics(BreakableSteps[BrokenStep].Physics); if(BreakableSteps[BrokenStep].Physics == PHYS_RigidBody) { StaticMeshComponent.WakeRigidBody(); } } function BreakLastApart(Controller EventInstigator) { local KActorSpawnable SpawnedActor; SetPhysics(PHYS_None); SetCollision(false,false); if (CollisionComponent != None) { CollisionComponent.SetBlockRigidBody(false); } SetTimer(0.1, false, 'HideAndDestroy'); TriggerEventClass(class'SeqEvent_Destroyed',EventInstigator); if (BreakableSteps[CurrentBreakableStep].BreakSound != None) { PlaySound(BreakableSteps[CurrentBreakableStep].BreakSound, true,,, CollisionComponent.Bounds.Origin); } if (BreakableSteps[CurrentBreakableStep].BreakMesh != None) { SpawnedActor = spawn(class'KActorSpawnable',,,Location, Rotation); if (SpawnedActor != none) { SpawnedActor.StaticMeshComponent.SetStaticMesh(BreakableSteps[CurrentBreakableStep].BreakMesh); SpawnedActor.SetPhysics(BreakableSteps[CurrentBreakableStep].Physics); if (BreakableSteps[CurrentBreakableStep].Physics == PHYS_RigidBody) { SpawnedActor.StaticMeshComponent.WakeRigidBody(); } } } } function HideAndDestroy() { StaticMeshComponent.SetHidden(true); Destroy(); } event Destroyed() { Super.Destroyed(); } defaultproperties { CollisionType = COLLIDE_BlockAll bNoDelete = true bProjTarget = true CurrentBreakableStep = 0 }
Code:
// Actor Factory for Custom Breakable Actor Class class DarkJourneyBreakableActorFactory extends ActorFactoryRigidBody; defaultproperties { MenuName="Add Dark Journey Breakable Actor" NewActorClass=class'DarkJourney.DarkJourneyBreakableActor' CollisionType=COLLIDE_BlockAll }
Comment