elseagoat Posted March 20, 2012 Author Share Posted March 20, 2012 (edited) Got another bug, though your suggestion fixed the last one. The spell is cool because it is more powerful when more enemies are nearby. But, when there are lots of enemies and tons of these shades spawn (one for each enemy) then sometimes a shade or two will continue to exist even when the target actor dies, leaves the radius, or the hazard despawns. Basically, it seems to continue to exist after the magic effect ends. This is a problem, because I want the shades to be invincible (the power of the spell kind of relies on that, otherwise I would have to constantly respawn the shades when they die). So when this happens, the shade that never got deleted when it should have runs rampant and kills everything in the vicinity, chasing them to the ends of the earth. I think it may have to do with Utility.wait() causing the script to pause, and potentially "missing" the event (onEffectFinish) that causes the shades to be deleted. This is just a guess. The other potential reason I could see is that I have no conditions for the magic effect that the script is tied to. Looking at the basic vanilla soul trap spell, I use a very similar script to soul trap the enemies, but have none of the conditions that that one does. So the problem may be happening when essential actors "bleedout" but do not die. I am also having trouble forcing the shades to attack a specific target and ignore other targets. Is there a function to make an actor leave combat, so that the startCombat function might work better? Here is the latest version:Scriptname soulharvestscript extends activemagiceffect ActorBase Property shade Auto Float Property distancefeet Auto Hazard Property theharvestinghazard Auto Activator Property summonportal Auto ObjectReference targetobj ObjectReference harvester ObjectReference portal1 Actor spawnedshade Actor target Float maxdistance Event OnEffectStart(Actor akTarget, Actor akCaster) if (akTarget.isDead()) ;checking to make sure target isnt dead, if it is, skip all this stuff Dispel() else target = akTarget maxdistance = ((distancefeet * 21.345) + 10) ;this simply converts the property from feet to units, and then adds 10 harvester = Game.FindClosestReferenceOfTypeFromRef(theharvestinghazard, target, maxdistance) ;this locates the hazard object reference and then stores it so it can be used later to determine distance portal1 = harvester.placeAtMe(summonPortal) ;creates our entry portal Utility.wait(1) spawnedshade = portal1.placeAtMe(shade) ;this spawns a single shade near the actor that is the target of the magic effect spawnedshade.IgnoreFriendlyHits() ;this is to make the shade ignore accidental hits from other shades and the player, to keep them from getting pissed and turning around and attacking each other spawnedshade.StartCombat(target) ;attempts to make the shade immediately target its own target Utility.wait(3) ;waits 3 seconds portal1.DisableNoWait() ;cleans up our entry portal portal1.Delete() RegisterForSingleUpdate(0.5) ;start our updates to check various things endif endEvent Event OnUpdate() If (target.isDead()) Dispel() else If (harvester == none) ;checks to see if the hazard object casting this spell still exists, if not, then the effect is dispelled Dispel() endIf If (target.getDistance(harvester) > maxdistance) ;this checks to see if the target has walked too far away from the original place the spell was cast, if so, then dispel the effect from them. Dispel() endIf If (spawnedshade.GetCombatTarget() != target) ;this is to try and make each spawned shade stick to its own target and ignore others, so it they try to attack something else it will tell them to stop spawnedshade.StartCombat(target) endIf RegisterForSingleUpdate(0.5) ;tells the script to check these three things again in half a second endIf endEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) spawnedshade.Kill(target) ;killing the shade to get a better death animation than just instantly dissapearing Utility.wait(2) spawnedshade.DisableNoWait() ;cleaning up all our stuff spawnedshade.Delete() endEvent Edited March 20, 2012 by elseagoat Link to comment Share on other sites More sharing options...
fg109 Posted March 21, 2012 Share Posted March 21, 2012 I doubt that the utility.wait is causing any problems, but I don't know what could be going wrong. How many do you mean when you say a lot of enemies? It's unlikely, but maybe you reached some kind of limit in script processing. A quick and dirty fix would be to give the shades a script: Event OnLoad() RegisterForSingleUpdate(40) EndEvent Event OnUpdate() DisableNoWait() Delete() EndEvent Of course, if that actually works, that means the problem wasn't from overloading the engine. As for the shades not attacking their own targets, it might have something to do with combat style or aggressiveness. You could try experimenting with that. The script command StopCombatAlarm would stop your shade and anyone attacking it to stop combat. Link to comment Share on other sites More sharing options...
elseagoat Posted March 21, 2012 Author Share Posted March 21, 2012 I doubt that the utility.wait is causing any problems, but I don't know what could be going wrong. How many do you mean when you say a lot of enemies? It's unlikely, but maybe you reached some kind of limit in script processing. A quick and dirty fix would be to give the shades a script: Event OnLoad() RegisterForSingleUpdate(40) EndEvent Event OnUpdate() DisableNoWait() Delete() EndEvent Of course, if that actually works, that means the problem wasn't from overloading the engine. As for the shades not attacking their own targets, it might have something to do with combat style or aggressiveness. You could try experimenting with that. The script command StopCombatAlarm would stop your shade and anyone attacking it to stop combat. Thanks for the reply. You are probably my favorite person in the world right now because of all your help. I actually fixed both problems. It was apparently an issue with the spell being cast on essential actors. I don't know why, but for some reason the shade would sometimes persist and run around after an essential actor fell to the ground, seeking a new target to attack. By going to the Soul Trap spell, finding its magic effect, and simply copy pasting the conditions there into the conditions in the hazard spell, it fixed the shades sometimes persisting and running amok. Setting the shades to Agressive, Foolhardy, Helps Nobody seemed to fix the issue where they would seemingly randomly attack targets (which may have been a result of being Very Aggressive and thus wanting to attack the first thing they saw, or because they wanted to help the player as they are in the player faction.) This seemed to also help considerably: If (spawnedshade.GetCombatTarget() != target) ;this is to try and make each spawned shade stick to its own target and ignore others, so it they try to attack something else it will tell them to stop spawnedshade.StopCombat() spawnedshade.StartCombat(target) endIf Now I am working on the IMOD as you suggested, and I almost have it working, but it seems to act funny sometimes. wrote a tiny script for the player cast part of the magic effect to spawn an invisible activator. Then, in the activator, I put a script that gets the player location and does periodic checks to determine the player distance from the activator and whether the player was within that distance or not during the previous check, so that I could trigger the fade ins and fade outs upon entering and exiting the radius. I used a while loop. It kind of worked, but it was buggy. Sometimes it would work fine, sometimes the effect would just stay on if the player left the radius, and sometimes if the player returned to the radius it wouldnt turn back on. will try with periodic event OnUpdates with registerforsingleupdate() next, hopefully that will work better. Otherwise, the spell is turning out nicely, largely due to your help. all of your suggestions and input I have either used, or it has led me to a solution that i wouldnt have otherwise thought of. I greatly appreciate it. Looks wicked cool when 5 dudes charge at you, you throw down this spell and back up, and watch this portal open and 5 shades pour out and attack the enemies. then, as they fall one by one, blue souls come from their bodies towards you and fill your soul gems, while the shades melt to the ground before vanishing after they have completed their purpose. Once I get some better effects for it (I want a different portal than the default summon one, but that looks like it involves somehow extracting models from the master file which I do not know how to do, and it would be nice to put some black smoke around the area where the shades are permitted to remain in, but I see nothing in the game files that looks like I want it to) it will be complete. Thanks to you I will have made my first mod within 3 days of downloading the CK and giving modding a shot for the first time ever. Link to comment Share on other sites More sharing options...
fg109 Posted March 21, 2012 Share Posted March 21, 2012 (edited) I helped because your spell sounded really cool. I thought of doing something similar before, but couldn't think of enough ideas for a good spell mod. I wasn't aware you needed to use scripting to control the fading in and out of the IMOD, but like I said, no experience with them. No idea what could be going wrong though without taking a look at the script. Edited March 21, 2012 by fg109 Link to comment Share on other sites More sharing options...
elseagoat Posted March 21, 2012 Author Share Posted March 21, 2012 (edited) I helped because your spell sounded really cool. I thought of doing something similar before, but couldn't think of enough ideas for a good spell mod. I wasn't aware you needed to use scripting to control the fading in and out of the IMOD, but like I said, no experience with them. No idea what could be going wrong though without taking a look at the script. Edit: well here it is! Spell is 99% complete, just one graphical glitch to iron out and some simple balancing to do! http://forums.nexusmods.com/index.php?/topic/625024-first-mod-attempt-req-feedback/ Edited March 21, 2012 by elseagoat Link to comment Share on other sites More sharing options...
Recommended Posts