Jump to content

Medabev

Members
  • Posts

    35
  • Joined

  • Last visited

Nexus Mods Profile

About Medabev

Medabev's Achievements

Contributor

Contributor (5/14)

  • First Post
  • Collaborator Rare
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. I'm 100% there's a better way of writing this script as you proved and I'm all for it. I'm still learning as I go, I just copple together what I know and try and make something work. I have some other scripts I've been experimenting on for learning purposes, but this particular script I really wanted to work. Now that I have a working script, I'm definitely going to try and improve on it.
  2. @dylbill Ah! That's actually kind of hilarious It's amazing how one tiny part of a script can mess up the whole thing. I'm just glad you were able to assist, I didn't think it was such a simple fix. LOL. :laugh:
  3. @dylbill I can't believe that's all it took to fix this script. I've spend a good two hours rewriting testing this thing yesterday before I gave up and decided to ask for help. I thought It was a problem with OnUpdate but never think it was the OnCombatStateChanged. This is one of my favorite scripts I've made, and I'm grateful that you helped me fix this thing up. I just tested it, and the battle is pretty chaotic, which is what I wanted plus the Loop as ended. I'm still learning about the creation kit after all this time, and the good thing, thanks to tinkering with the script I got a better understanding on how states work. It's going to be fun going back to my other scripts and cleaning those up to. Thanks again for your assistance! :laugh:
  4. Hello Everyone. I've Been working hard on a project of mine, I'd like to get ready before AE arrives. In my Mod I have Boss NPC's that need to be defeated(something like a WoW Raid boss) . I've patched together a Script that somewhat works but I've reach a snag and it needs to be in better hands. I feel like I'm doing something wrong or missing something. The Script fires off, well but it won't stop looping. I've tried killing the script when I leave the cell or unload and it still keeps going. My goal is to keep having Enemies spawning, supporting the boss and if the boss is defeated, explosions everywhere. I'd like to add more effects but I can't think of anything else. But my main priority is to get it working first. Here is the Script: Thank you for any assistance :thumbsup: Scriptname MMO_BossMobs_SCRIPT extends Actor Actor Property PlayerRef Auto ObjectReference property Xmarker1 auto ObjectReference property Xmarker2 auto ObjectReference property Xmarker3 auto ObjectReference property Xmarker4 auto ObjectReference property Xmarker5 auto ObjectReference property Xmarker6 auto ObjectReference property Xmarker7 auto ObjectReference property Xmarker8 auto ObjectReference property Xmarker9 auto ObjectReference property Xmarker10 auto ActorBase Property BossMobs Auto ObjectReference MobNPC1 ObjectReference MobNPC2 ObjectReference MobNPC3 ObjectReference MobNPC4 ObjectReference MobNPC5 ObjectReference MobNPC6 ObjectReference MobNPC7 ObjectReference MobNPC8 ObjectReference MobNPC9 ObjectReference MobNPC10 Explosion Property ExplosionIllusionMassiveLight01 Auto {Big Explosion for Pillar} Explosion Property ExplosionIllusionLight Auto {Big Explosion when Ambush Ends} Explosion Property iExplo3 Auto {Explosion when Battle is Over} ;=========================================================================== Event OnCombatStateChanged(Actor akTarget, int aeCombatState) If aeCombatState == 1 Actor player = Game.GetPlayer() If akTarget == player Registerforsingleupdate(10.0) Endif Endif EndEvent Event OnUpdate() If Self.IsDead() UnregisterforUpdate() else Endif GoToState("Busy") self.PlaceAtme(ExplosionIllusionMassiveLight01) MobNPC1 = Xmarker1.PlaceAtme(BossMobs) Xmarker1.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) MobNPC2 = Xmarker2.PlaceAtme(BossMobs) Xmarker2.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) MobNPC3 = Xmarker3.PlaceAtme(BossMobs) Xmarker3.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) MobNPC4 = Xmarker4.PlaceAtme(BossMobs) Xmarker4.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) MobNPC5 = Xmarker5.PlaceAtme(BossMobs) Xmarker5.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) MobNPC6 = Xmarker6.PlaceAtme(BossMobs) Xmarker6.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) MobNPC7 = Xmarker7.PlaceAtme(BossMobs) Xmarker7.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) MobNPC8 = Xmarker8.PlaceAtme(BossMobs) Xmarker8.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) MobNPC9 = Xmarker9.PlaceAtme(BossMobs) Xmarker9.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) MobNPC10 = Xmarker10.PlaceAtme(BossMobs) Xmarker10.PlaceAtme(ExplosionIllusionLight) utility.wait(2.0) RegisterForSingleUpdate(30.0) GoToState("") EndEvent ;=========================== State Busy Event OnUpdate() EndEvent EndState ;=========================== Event OnDeath(Actor akKiller) Xmarker1.PlaceAtme(iExplo3) utility.wait(2.0) Xmarker2.PlaceAtme(iExplo3) utility.wait(2.0) Xmarker3.PlaceAtme(iExplo3) utility.wait(2.0) Xmarker4.PlaceAtme(iExplo3) utility.wait(2.0) Xmarker5.PlaceAtme(iExplo3) utility.wait(2.0) Xmarker6.PlaceAtme(iExplo3) utility.wait(2.0) Xmarker7.PlaceAtme(iExplo3) utility.wait(2.0) Xmarker8.PlaceAtme(iExplo3) utility.wait(2.0) Xmarker9.PlaceAtme(iExplo3) utility.wait(2.0) Xmarker10.PlaceAtme(iExplo3) utility.wait(3.0) self.PlaceAtme(ExplosionIllusionMassiveLight01) EndEvent
  5. Heya guys. Well thanks for your guys help. While I did learn some things about arrays and such I'll most likely tackle that when I have more time to study up on it. I'm at least happy the Magical Script is working, however My other script I'm surprised is not working. Something was bothering me and I had to do some experiments, seems like that the disable/enable script doesn't want to work regardless if its one object or not. More specifically at certain times it just won't work, (ex: 7pm - 5am) but it will work at 6am-12pm for some reason. My main goal was to just have a shrine will only give blessings at night (preferably at different set gametimes So I can reuse the script) I tried using the script here https://www.creationkit.com/index.php?title=Talk:Complete_Example_Scripts at "Enable/Disable Object on schedule" . Doesn't seem to want to work for me now. So I'll have to figure out another way of doing this, and I'll most likely make another topic on arrays when I have better Grasp on arrays to polish up my timed Ambush script. in the meantime, I've redone the script into something more simpler in terms (hopefully) I'll start experimenting with the vanilla script (slightly modified) and try to figure out how to go about this. and hope that it actually does what its suppose to this time haha.
  6. Well good news and Bad news and what I'm currently doing: Good news, I believe I have a better grasp on arrays and I can see how they would be extremely useful when handling multiple objects. I believe I manage to declare an array and I even have access to the UI window. Now I can see how it easy it would be just to add items into that list and let the script do the rest. Bad news, trying to modify the above script has been rather confusing using this new knowledge: Basically getting these compiled errors Enable is not a function or does not exist Disable is not a function or does not exist So I'm assuming that its not as easy as I thought it would off the bat and I'm most likely screwing up my functions somehow. I do know that I gotta let the script know how many objects I want it to handle, but then I'm not sure because I could just select whatever through the UI property window. But I'll keep at it; at least it feels like I'm making progress to making this thing work
  7. One of my older scripts are being real difficult with me right now. It was working fine before but then It won't work now, if it has the same time like the script above., for instance putting it with the same time (ex: 19.0 - 5.) will cause the script to do absolutely nothing. Setting it to (6. -24.) however and it works fine. It's weird and frustrating. Just posting this here just incase , I don't think this script has anything to do with it but it's extremely weird it won't work if it has the same time. Anyway the original script I had just hid certain objects at certain times, It should be a relatively simple script and I assumed it wouldn't give me problems. I found this script awhile ago on the wiki and I really liked it. I don't know why it decided not to work if I set the script above to have the same time as this one. My Magical ambush script still works great this entire time at least, so it leads me to believe maybe theres a conflict or something?
  8. When you think you've done what you can on your own, and the compiler still complains, you're welcome to drop your updated script in here (perhaps inside a 'spoiler', this can be chosen with the Special BBCode button in the upper left corner.) Then I'll have a look and tell what you're missing. Wow thanks alot, I really appreciate it! I've been on a positive high cause of that script I got caught up clean up my other ones! Right now I'm attempting to polish another one of my scripts; cause you know its funny, when I first started doing this it was extremely daunting and frustrating. But spending some time learning how this stuff works is extremely satisfying and rewarding. After I'm done with my project, I would love to release documents and scripting knowledge I learned to help anyone else who may need it. But yeah I feel like I'm making some progress with the script, I think I'll spend a day or so with trail and error and If I don't get it I'll contact you or just post on this thread if its still around!
  9. Heya again wormple! Wow I can't believe that was the case when it comes to the explosions, one time I tried it I suspected that but thought it was far too simple to actually be the cause; guessed I overthinked it haha. It's a simple thing, I'll just make sure I position the triggerbox properly along the terrain. I cleaned it up alittle bit and I just LOVE the fact now I can adjust the Chance now, It's so much more fun. I'm just little aggravated that all I had to do was had a int property; again me over thinking stuff again. I updated the OP with the iChance function as its much superior to what I had originally. As far as the property array, I've added a new property,rewrote OnTriggerEnter section (along with the other parts of the script) but it's not compiling and it insists that its a function. I have no doubt I'm doing something wrong but I'll keep at it. I just hope whoever may want to use the script can read it , if they plan on making changes for their own needs in the meantime.
  10. Heya Wormple. Ah, you know I didn't even think about making the script shorter while working on it if I intended to share it. I'll have to go back and try cleaning up with the property array then cause I do agree its a lot right now. The Delete() was originally used when I attempted to use placeatme (and a failed attempt to randomize actors) but then I realize it was probably better to keep it there to clean up corpses. But your right, it doesn't need that cause it doesn't use placeatme so I'll go and tweak that too - Right now I have a problem with ash piles and Ghostly remains being everywhere but I realize thats probably something else dealing with vanilla and with the script. Thanks a lot! I'll try and post a more cleaner version of the script if I manage to get it to complile haha. EDIT: Got rid of Delete() and it still works! so I'm happy about that. I'll update the OP if I manage to get the Array working Else If AABRREF1.Disable() AABRREF1= NONE If AABRREF2.Disable() AABRREF2= NONE If AABRREF3.Disable() AABRREF3= NONE AABRREF3.Disable() If AABRREF4.Disable() AABRREF4= NONE If AABRREF5.Disable() AABRREF5= NONE AABRREF5.Disable() If AABRREF6.Disable() AABRREF6= NONE If AABRREF7.Disable() AABRREF7= NONE If AABRREF8.Disable() AABRREF8= NONE EndIf EndIf endif endif endif endif endif endif endif endif endif endif endif endif EndFunction
  11. Hello everyone! Hope all is well. :laugh: Been working on my Worldspace project on and off for awhile and I'm int the midst of polishing. However one thing I wanted for a long long time was Night time spawns. Even though There's a system like this already in vanilla - I have no idea how to use the Story Manager(find it too confusing) and I find Night time spawns in Vanilla to be alittle too "slowpace" for my liking. I couldn't find exactly what I was looking for to get an idea what I wanted or how to get this thing working. I've learned about Events and functions and what not, but I'm still "new" at this. Well after many hours and months of trial, error and frustration, I finally did it. I created this Trigger so that when the player enters, there's a chance (Currently set at 50% Chance out of 100) they are jumped by 8 enemies, (Along with an explosion and player Stagger) not only that but there's a setting to make sure that this trigger activates and deactivates based off the ingame time. I've read about "player.placeatme" how it can cause savebloat though its not really an issue if the placed references are deleted when no longer needed. I've tried to do this but I was unsuccessful. so I modified another script that does something similar and instead have NPC's in a separate Cell and will always move to the player if its the appropriate chance. I've been testing it out in-game and it works really good. I still can't believe it compiled to be honest. Here it is: Scriptname NTS_MagicAmbushScript extends ObjectReference {Thank you David Brashers for Public Domain Script) {Magic Ambush Script, Used to spawn Random ambushes depending on time of day, needs a seperate cell to hook up NPCs} ;*************************************************** Actor Property PlayerRef Auto Actor Property AABRREF1 Auto Actor Property AABRREF2 Auto Actor Property AABRREF3 Auto Actor Property AABRREF4 Auto Actor Property AABRREF5 Auto Actor Property AABRREF6 Auto Actor Property AABRREF7 Auto Actor Property AABRREF8 Auto GlobalVariable Property GameHour auto {You need to autofill this property from the CK} Int Property iChance auto {Set Chance for Ambush to happen} float Property EnableTime = 6.0 auto {Enable me at about 6am by default} float Property DisableTime = 24.0 auto {Disable me at about midnight by default} bool Property DeleteMe = TRUE auto {Delete me after disabling me} Explosion Property ExplosionIllusionLight01 Auto {Explosion when Ambush Appears} Explosion Property ExplosionIllusionMassiveLight01 Auto {Big Explosion when Ambush Appears} ;*************************************************** Event OnInit() {A bit of idiot proofing...} ; make sure sensible values have been set If EnableTime < 0.0 || EnableTime > 24.0 EnableTime = 6.0 ; failsafe default EndIf ; make sure sensible values have been set If DisableTime < 0.0 || DisableTime > 24.0 DisableTime = 24.0 ; failsafe default EndIf EndEvent ;*************************************************** Event OnLoad() CheckTime() ; check the time and spawn/disable me as required ; Debug.Notification("[TimedSpawnControl] OnLoad Completed.") EndEvent ;*************************************************** Event OnUpdateGameTime() CheckTime() ; check the time and spawn/disable me at calculated intervals EndEvent ;*************************************************** Event OnTriggerEnter(ObjectReference akActionRef) if(akActionRef == Game.GetPlayer()) If IsActiveTime() Int iRandom = Utility.RandomInt(1,100) If (iRandom <= iChance) self.placeAtMe(ExplosionIllusionLight01) utility.wait(0.75) self.placeAtMe( ExplosionIllusionMassiveLight01) self.KnockAreaEffect(1, 900) AABRREF1.Resurrect() AABRREF1.Disable() AABRREF1.Enable() AABRREF1.SetAV ("Aggression", 2) AABRREF1.MoveTo(PlayerREF) AABRREF2.Resurrect() AABRREF2.Disable() AABRREF2.Enable() AABRREF2.SetAV ("Aggression", 2) AABRREF2.MoveTo(PlayerREF) AABRREF3.Resurrect() AABRREF3.Disable() AABRREF3.Enable() AABRREF3.SetAV ("Aggression", 2) AABRREF3.MoveTo(PlayerREF) AABRREF4.Resurrect() AABRREF4.Disable() AABRREF4.Enable() AABRREF4.SetAV ("Aggression", 2) AABRREF4.MoveTo(PlayerREF) AABRREF5.Resurrect() AABRREF5.Disable() AABRREF5.Enable() AABRREF5.SetAV ("Aggression", 2) AABRREF5.MoveTo(PlayerREF) AABRREF6.Resurrect() AABRREF6.Disable() AABRREF6.Enable() AABRREF6.SetAV ("Aggression", 2) AABRREF6.MoveTo(PlayerREF) AABRREF7.Resurrect() AABRREF7.Disable() AABRREF7.Enable() AABRREF7.SetAV ("Aggression", 2) AABRREF7.MoveTo(PlayerREF) AABRREF8.Resurrect() AABRREF8.Disable() AABRREF8.Enable() AABRREF8.SetAV ("Aggression", 2) AABRREF8.MoveTo(PlayerREF) endif endif endif EndEvent ;*************************************************** Function CheckTime() {Decide whether to spawn the actor or disable and delete it} ; Debug.notification("[TimedSpawnControl] CheckTime was called.") If IsActiveTime() If !PlayerRef ; Debug.Notification("[TimedSpawnControl] Spawning an actor...") AABRREF1.Resurrect() AABRREF1.SetAV ("Aggression", 2) AABRREF1.MoveTo(PlayerREF) AABRREF2.Resurrect() AABRREF2.SetAV ("Aggression", 2) AABRREF2.MoveTo(PlayerREF) AABRREF3.Resurrect() AABRREF3.SetAV ("Aggression", 2) AABRREF3.MoveTo(PlayerREF) AABRREF4.Resurrect() AABRREF4.SetAV ("Aggression", 2) AABRREF4.MoveTo(PlayerREF) AABRREF5.Resurrect() AABRREF5.SetAV ("Aggression", 2) AABRREF5.MoveTo(PlayerREF) AABRREF6.Resurrect() AABRREF6.SetAV ("Aggression", 2) AABRREF6.MoveTo(PlayerREF) AABRREF7.Resurrect() AABRREF7.SetAV ("Aggression", 2) AABRREF7.MoveTo(PlayerREF) AABRREF8.Resurrect() AABRREF8.SetAV ("Aggression", 2) AABRREF8.MoveTo(PlayerREF) If AABRREF1.IsDisabled() If AABRREF2.IsDisabled() If AABRREF3.IsDisabled() If AABRREF4.IsDisabled() If AABRREF5.IsDisabled() If AABRREF6.IsDisabled() If AABRREF7.IsDisabled() If AABRREF8.IsDisabled() ; Debug.Notification("[TimedSpawnControl] Actor was disabled. Enabling.") AABRREF1.Enable() AABRREF2.Enable() AABRREF3.Enable() AABRREF4.Enable() AABRREF5.Enable() AABRREF6.Enable() AABRREF7.Enable() AABRREF8.Enable() Else ; Debug.Notification("[TimedSpawnControl] Actor exists, enabling it...") AABRREF1.Enable() AABRREF2.Enable() AABRREF3.Enable() AABRREF4.Enable() AABRREF5.Enable() AABRREF6.Enable() AABRREF7.Enable() AABRREF8.Enable() EndIf EndIf Else EndIf EndIf Else If AABRREF1.Disable() AABRREF1= NONE If AABRREF2.Disable() AABRREF2= NONE If AABRREF3.Disable() AABRREF3= NONE AABRREF3.Disable() If AABRREF4.Disable() AABRREF4= NONE If AABRREF5.Disable() AABRREF5= NONE AABRREF5.Disable() If AABRREF6.Disable() AABRREF6= NONE If AABRREF7.Disable() AABRREF7= NONE If AABRREF8.Disable() AABRREF8= NONE EndIf EndIf endif endif endif endif endif endif endif endif endif endif endif endif EndFunction ;*************************************************** bool Function IsActiveTime() {Returns TRUE if current time is within the active time range} bool bTimeRange = false float fGHour = GameHour.GetValue() If (DisableTime >= EnableTime) bTimeRange = (fGHour >= EnableTime) && (fGHour < DisableTime) Else bTimeRange = (fGHour >= EnableTime) || (fGHour < DisableTime) EndIf ; Debug.Notification("[TimedSpawnControl] IsActiveTime returned: " + bTimeRange) Return bTimeRange EndFunction ;*************************************************** float Function GetInterval() {Calculate the time interval for the next update call} float int1 float int2 float newinterval float fGHour = GameHour.GetValue() ; Debug.Notification("[TimedSpawnControl] GetInterval called") If EnableTime >= fGHour Int1 = EnableTime - fGHour Else Int1 = EnableTime - fGHour +24 EndIf If DisableTime >= fGHour Int2 = DisableTime - fGHour Else Int2 = DisableTime - fGHour +24 EndIf If Int1 <= Int2 ; choose the smallest time interval newinterval = Int1 Else newinterval = int2 EndIf If newinterval < 0.167 newinterval = 0.167 ; set the minimum update interval to about 10 game minutes EndIf ; Debug.Notification("[TimedSpawnControl] The next update will be in " + newinterval + " hours.") Return newinterval EndFunction ;*************************************************** Anyway I'm pretty happy with the script all things considering and I wanted to share it just in case someone out there needed something similar. If there's any glaring issues with the script, let me know! I'm still testing it but I feel its pretty good right now to share. Thank you all for reading and I hope you all have a great week and enjoy the script for those looking for a "niche" Script such as this :tongue: EDIT: Cleaned up abit thanks to wormple12! Many thanks friend. PS: If you're reading this, Thank you to ReDragon2013, Steve40 for your assistance making this Frankenstein of a script. Your input helped me make this thing and learn quite abit about scripting allowing me to go back and modify and improve other aspects of my project.
  12. Hello! Been working on a mod for a while and I'm actually getting ready to wrap it up, but I want to clean it up. I manage to get a radiant quest working , A simple fetch quest - something to do to pass time and it worked! then my unique NPC stopped giving me dialogue after my second mission completion. I know the alias works because it's been a different location every time I tried it again, but it ALWAYS stops after I finish the second mission. I tried even putting reset() at the final Quest Stage like (and the quest Main Script) Game.GetPlayer().removeItem(Alias_ItemOne.GetReference(), 1) Game.GetPlayer().removeItem(Alias_itemTwo.GetReference(), 1) X_Gather.reset() X_Gather.stop() X_Gather.start() And got the same exact results. I'm actually at a lost what to do, because I know it works but It just simple refuses to reset. To make matters worse another one of my Quests resets just fine, using .stop() / .start() Functions. Does anyone have any ideas what I should do? Thank you for your time EDIT: I manage to get it to work! It works flawlessly now. For anyone who might have this issue, the way I solved it was by setting the stage back to 0 at the final stage. Game.GetPlayer().removeItem(Alias_ItemOne.GetReference(), 1) Game.GetPlayer().removeItem(Alias_itemTwo.GetReference(), 1) X_Gather.stop() X_Gather.setstage(0) X_Gather.start() And it works! the Quest repeats now, with dialogue and all.
  13. No, it's my mistake. I should've been more clearer, Honestly your script has helped alot about the "states". This is so much scripting I hope at least if someone in the future is in need of a script like this they find this thread. Been thinking about at least making a Winrar or something of all the scripts I've dug up from the past so they are easier to find. I"m going to keep messing around with this script though, been experimenting and been having various results.
  14. Ok wow, that is a REALLY well formatted script. Thanks a lot! The script compiled successfully! I'm going to test it and hope it works out. I definitely messed something up in my last attempt so I hope this time it finally works. Looking forward playing around with this, this is actually really exciting, minus the parts when the script is being difficult. But yeah I better understand whats going on now. I think this will help for sure EDIT: Bad news, doesn't seem to be restarting and mobs aren't deleted anymore, good news though is that the portal is completely invisible now, it actually caught me by surprise when I got into range. Will be playing around with this some more, feel we are getting really close to the desire results.
  15. Ah, thanks a lot DungeonDweller! The script you posted compiled perfectly. (Something I'm not use to seeing for myself) and yes, you are spot on, I want the trigger to run again after a certain amount of time has passed. This particular line, "Spot for your desired code", I've tried putting the entire code in that segment and got errors, been fiddling around with it and realize that was wrong and tried configuring the "Waiting" part. Basically this "works", but I wanted to run this by you to make sure I wrote this right. Feels like I messed something up though but I'll be running some more test, since I know OnUpdateGametime doesn't take into account for waiting or sleeping. Once again thanks a lot for your help! Will post back results :laugh: Scriptname TEST_AnomalySpawner extends ObjectReference {Handles the destruction stages and enemy spawning of the magic anomaly spawner object} Float property fHours auto { The number of hours to pass before this trigger resets. } ActorBase Property EncMagicAnomaly Auto {enemy to spawn} Explosion Property ExplosionIllusionLight01 Auto {explosion to play whne it opens} Explosion Property ExplosionIllusionMassiveLight01 Auto {explosion to play whne it opens} ; Enemy holders Actor myEncMagicAnomaly01 Actor myEncMagicAnomaly02 Actor myEncMagicAnomaly03 ; Blend values (how open it the portal 0-1) float fToggleBlendStart = 0.3 float fToggleBlendOpen = 0.9 float fToggleBlendFull = 1.0 float fToggleBlendGone = 0.0 ; Temporary blend value holder float myCurrentBlend ;Is player in trigger and the portal is not open int playerInTrigger ; Enemy count int numberOfEnemiesAlive ; Distances with 3000 unit trigger to test fade portal open float maxTestRange = 1500.0 Float minTestRange = 550.0 ; holder for player actor myPlayer ; gates for making the drath of each enemy affect script only once int Gate1 int Gate2 int Gate3 STATE FirstState Event OnTriggerEnter(ObjectReference akTriggerRef) if akTriggerRef == Game.GetPlayer() ; put script in its waiting phase. Code after GoToState will still run. GoToState("SecondState") ;-----spot for your desired code {Feels like I did something wrong here} RegisterForSingleUpdateGameTime(fHours) endif EndEvent ENDSTATE auto state waiting ; Set initial blend ab=mount for portal and get player locally Event onLoad() self.SetAnimationVariableFloat("fToggleBlend", fToggleBlendStart) myPlayer = game.getPlayer() EndEvent ;waits for player to enter trigger once he does it tests for distance and triggers the portal to open if he gets close enough Event OnTriggerEnter(ObjectReference akActionRef) playerInTrigger = 1 self.SetAnimationVariableFloat("fDampRate", 0.3) while playerInTrigger == 1 ;&& playerLeftTrigger float myDistance = myPlayer.getDistance(self) ; debug.trace("myDistance = " + myDistance) if myDistance <= minTestRange ;player is close enoght to automatically open the portal goToState("opened") playerInTrigger = 0 elseIf myDistance <= maxTestRange Float animationValue = CalculateAnimationValue(myDistance, minTestRange,maxTestRange, fToggleBlendStart, fToggleBlendFull) ; debug.trace("animationValue = " + animationValue) self.SetAnimationVariableFloat("fToggleBlend", animationValue) utility.wait(0.05) endif endWhile EndEvent ;stop testing if player leaves trigger without opening portal Event OnTriggerLeave(ObjectReference akActionRef) playerInTrigger = 0 EndEvent endState state opened ;The portal is opened playe some explosions and spawn 3 enemies Event onBeginState() ; debug.trace("opened") int doOnce = 0 if doOnce == 0 self.placeAtMe(ExplosionIllusionLight01) utility.wait(0.75) self.placeAtMe(ExplosionIllusionMassiveLight01) self.KnockAreaEffect(1, 900) self.SetAnimationVariableFloat("fToggleBlend", fToggleBlendFull) utility.wait(0.5) myEncMagicAnomaly01 = self.placeActorAtMe(EncMagicAnomaly) myEncMagicAnomaly01.setScale(utility.randomFloat(0.7, 1.25)) utility.wait(1.5) myEncMagicAnomaly02 = self.placeActorAtMe(EncMagicAnomaly) myEncMagicAnomaly02.setScale(utility.randomFloat(0.7, 1.25)) utility.wait(0.5) myEncMagicAnomaly03 = self.placeActorAtMe(EncMagicAnomaly) myEncMagicAnomaly03.setScale(utility.randomFloat(0.7, 1.25)) numberOfEnemiesAlive = 3 doOnce = 1 endIf utility.wait(3.5) self.SetAnimationVariableFloat("fDampRate", 0.03) self.SetAnimationVariableFloat("fToggleBlend", fToggleBlendOpen) ; debug.trace("isDead " + myEncMagicAnomaly01.IsDead()) ;While ther are some enemies alive test each one to see if they are dead evey half second. If they are run the fade out function. while numberOfEnemiesAlive > 0 utility.wait(0.5) if Gate1 == 0 if myEncMagicAnomaly01.IsDead() == true anomalyDied() Gate1 = Gate1 + 1 endIf endIf if Gate2 == 0 if myEncMagicAnomaly02.IsDead() == true anomalyDied() Gate2 = Gate2 + 1 endIf endIf if Gate3 == 0 if myEncMagicAnomaly03.IsDead() == true anomalyDied() Gate3 = Gate3 + 1 endIf endIf endwhile EndEvent endState STATE SecondState Event OnUpdateGameTime() ; put it back in its main state GoToState("FirstState") EndEvent ENDSTATE ; function to test the distance from the player to the portal and ramp up the art accordingly Float Function CalculateAnimationValue(float PlayerDistance, float NearDistance, float FarDistance, float AnimationMin, float AnimationMax) Float percent = 1-((PlayerDistance - NearDistance)/(FarDistance - NearDistance)) Float returnValue = (percent * (AnimationMax - AnimationMin)) + AnimationMin Return returnValue EndFunction ; Function to fade out the art each time an enemy dies finally disabling the art after the last enemy Function anomalyDied() ; debug.trace("running anomaly died") ; debug.trace("01 is dead = " + myEncMagicAnomaly01.IsDead()) ; debug.trace("02 is dead = " + myEncMagicAnomaly02.IsDead()) ; debug.trace("03 is dead = " + myEncMagicAnomaly03.IsDead()) myCurrentBlend = self.GetAnimationVariableFloat("fToggleBlend") ; debug.trace("myCurrentBlend = "+ myCurrentBlend) self.SetAnimationVariableFloat("fToggleBlend", myCurrentBlend - (fToggleBlendOpen / 3)) numberOfEnemiesAlive = numberOfEnemiesAlive - 1 if numberOfEnemiesAlive == 0 utility.wait(0.5) self.disable(true) endif EndFunction
×
×
  • Create New...