Ex0rdium Posted March 7, 2015 Share Posted March 7, 2015 Just seeing if anyone knows how to run a script for something after a group of specific enemies have been killed. I know how to run an Ondeath script on one enemy.I just need something to run after I kill like 4 or 5.Any help would be appreciated. Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted March 7, 2015 Share Posted March 7, 2015 If that group of specific enemies are each using a quest alias reference, then you can attach 1 alias script with OnDeath() event to each alias in their quest. Link to comment Share on other sites More sharing options...
Ex0rdium Posted March 7, 2015 Author Share Posted March 7, 2015 Dang. Was hoping involving a quest wouldnt be necessary. Im a little way off from having to implement quests with my mod Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted March 7, 2015 Share Posted March 7, 2015 Adding for example say your 5 enemy npcs to a blank quest is really quite easy.You don't have to set up quest stages, objectives, dialogues or anything like that if you don't need it. I know the Quest window looks daunting with all it's options and tabs, but you only need to focus on what you need to use.Before long it becomes 2nd nature to say "I'll add a quest for this" with different things you add in the game. Other ways you could do it without a quest would be attach your ondeath script to each enemy and each time one of those enemies dies add a count to a Global variable or even another property in a script.When the count hit's 5 then do your required action. Link to comment Share on other sites More sharing options...
Ex0rdium Posted March 7, 2015 Author Share Posted March 7, 2015 Would you be able to give me an example of how to write a global variable? Basically what Im wanting to do is simply enable an object that is disabled when they all die. Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted March 8, 2015 Share Posted March 8, 2015 (edited) Add a global variable in CK select in the Object Window -> Miscellaneous -> Global -> Right click the right hand side of the object window and select New from the context menu.In the Global window that pops up enter a name in the ID field for your new global variable. example name: KilledEnemiesClick OK and you now have your global variable ready to use in your Actor Script. In your Actor Script add a property for the newly created global variable.Along with that maybe add a property for your ObjectReference you want to enable when they are all dead.I gave the name for an Object as SecretChest.Attach the script to each enemy actor in CK.After you attach the script to an actor, do a properties on the script and set the Properties to point to your global variable and your SecretChest that you want to enable.(Do this for each actor, the script below is based on 5 actors) ScriptName EnemyActorScript Extends Actor GlobalVariable Property KilledEnemies Auto ObjectReference Property SecretChest Auto Event OnDeath(Actor akKiller) KilledEnemies.Mod(1) If KilledEnemies.GetValueInt() >= 5 SecretChest.Enable() EndIf EndEventI haven't tested this, but it does compile error free.In theory it should work, but in practice there might be timing issues depending on how quick the actors are killed and OnDeath() of one actor may not be registered as another dies at the same time (mutithreaded scripts sometimes don't sync as expected in some situations) Edited March 8, 2015 by sLoPpYdOtBiGhOlE Link to comment Share on other sites More sharing options...
Ex0rdium Posted March 8, 2015 Author Share Posted March 8, 2015 Thanks alot! I will give it a try! Link to comment Share on other sites More sharing options...
Ex0rdium Posted March 8, 2015 Author Share Posted March 8, 2015 It worked perfectly! Thanks again. Just to confirm, I would have to make a new global variable for each different time i want to do this, correct? Link to comment Share on other sites More sharing options...
Recommended Posts