SirCumference64 Posted July 13, 2017 Share Posted July 13, 2017 I'm working on a script for a playable Wispmother that, at different amounts of health, will either spawn wisps or shades as long as the current set of wisps or shades are dead. Problem is, I can't seem to script it so that when the actors die, the game recognizes that and registers for another update to spawn more. This is what I have so far: Scriptname OrbSpawnScript extends ActiveMagicEffect;;;;;;;;;;;;;;PropertiesActorbase Property Orb01 AutoActorbase Property Orb02 AutoActorbase Property Orb03 AutoActorbase Property Shade01 AutoActorbase Property Shade02 AutoSpell Property orbspawn autoFloat Property Shadehealth AutoInt LiveOrbsInt LiveShades;;;;;;;;;;;;;;;;VariablesActor orb1Actor orb2Actor orb3Actor shade1Actor shade2objectReference orb001objectReference orb002objectReference orb003;;;;;;;;;;;;;EventsEvent onEffectStart(Actor Target, Actor Caster)RegisterForSingleUpdate(1)EndEventEvent onUpdate() If Game.GetPlayer().getactorvaluepercentage ("health") > shadehealth && LiveOrbs<= 0 LiveOrbs = 3 orb1 = Game.GetPlayer().placeactoratme(orb01) orb2 = Game.GetPlayer().placeactoratme(orb02) orb3 = Game.GetPlayer().placeactoratme(orb03)RegisterForSingleUpdate(1) EndIf If Game.GetPlayer().getactorvaluepercentage ("health") < shadehealth orb1.kill() orb2.kill() orb3.kill() shade1 = Game.GetPlayer().placeactoratme(shade01) shade2 = Game.GetPlayer().placeactoratme(shade02) RegisterForSingleUpdate(1) endif endEventEVENT onActivate(objectReference actronaut); debug.trace("Wisp Activated") if actronaut == orb001 || orb002 || orb003 utility.wait(0.1); debug.trace("Actronaut was one of my orbs") liveOrbs -= 1 RegisterForSingleUpdate(1) EndIf EndEventEvent OnDying(Actor akKiller) orb1.kill() orb2.kill() orb3.kill() shade1.kill() shade2.kill()EndEvent The OnActivate event was pulled from the original wispmother script since it was used to track when her orbs died, but I can't seem to actually get it to work. Is there a way to perform this kind of function within an active magic effect script? Any help would definitely be appreciated, since I've kind of hit a wall here and nothing I've tried has worked. Link to comment Share on other sites More sharing options...
foamyesque Posted July 13, 2017 Share Posted July 13, 2017 You're going to need a script on the orbs themselves containing an OnDeath event (or polling, but polling sucks). You can do that a variety of ways. If these actor bases are unique to your mod and unlevelled, you can add the script directly to them. Otherwise you'll need to make use of magic effects or quest aliases. Link to comment Share on other sites More sharing options...
SirCumference64 Posted July 13, 2017 Author Share Posted July 13, 2017 Gotcha, thankfully that is the case, since I copied the orbs over from the original ones, so they have a static level and are NPCs unique to the mod. I'm assuming I'd have to reference part of the magic effect script in the new actor script I make and attach to the orbs, so I'm guessing there's a way to do that. Real talk thanks for the help, I'll do some research later this evening! Link to comment Share on other sites More sharing options...
SirCumference64 Posted July 14, 2017 Author Share Posted July 14, 2017 I'm a little stuck again (this script is the most complex one I've tried to mess with) and I can't figure out how to import the LiveOrbs and LiveShades int lines from the original script to the new one I'm putting on the actors, since I need to subtract an integer from those each time one of the creatures dies to get the count back to zero so more can spawn. I'm looking into global variables in the meantime to see if I can figure something out that way. Link to comment Share on other sites More sharing options...
foamyesque Posted July 14, 2017 Share Posted July 14, 2017 I'm a little stuck again (this script is the most complex one I've tried to mess with) and I can't figure out how to import the LiveOrbs and LiveShades int lines from the original script to the new one I'm putting on the actors, since I need to subtract an integer from those each time one of the creatures dies to get the count back to zero so more can spawn. I'm looking into global variables in the meantime to see if I can figure something out that way. Don't bother. Those states can remain tracked only in the activemagiceffect script. What you do is: 1. Spawn them with placeatme. You're already storing the object references, so cast those variables to the script name you added to the actor. This will allow you to call functions, events, and propertiess of that script from the activemagiceffect script.2. Create an ActiveMagicEffect auto property on the actor script.3. Set that property from the activemagiceffect script to 'self'. In effect, this means the orbs will now know what activemagiceffect 'owns' them.4. In the activemagiceffect script, have an event that updates the state of your orb counts and so on whenever it is called, taking an Actor as an argument. OnOrbDeath or similar.5. In the actor script, have an OnDeath event that calls that event on the saved activemagiceffect script, passing "self" in as the argument. Demo: scriptname SC64_WispmotherEffect extends ActiveMagicEffect ActorBase Property OrbBase Auto Actor[] OrbArray int iLiveOrbs = 0 ;set up the orbs Event OnEffectStart(Actor akTarget, Actor akCaster) OrbArray = new Actor[3] int i = OrbArray.Length while i > 0 i-=1 OrbArray[i] = akTarget.PlaceActorAtMe(OrbBase) (OrbArray[i] as SC64_OrbActor).OwningEffect = self endwhile iLiveOrbs = OrbArray.Length ;any other setup stuff EndEvent ;custom event Event OnOrbDeath(Actor akDeadOrb) int iIndex = OrbArray.Find(akDeadOrb) if iIndex < 0 else iLiveOrbs-=1 OrbArray[iIndex] = none ;any other stuff you need to do endif EndEvent ;clean up any remaining orbs Event OnEffectFinish(Actor akTarget, Actor akCaster) int i = OrbArray.Length while i > 0 i-=1 if OrbArray[i] != none OrbArray[i].DisableNoWait() OrbArray[i].Delete() OrbArray[i] = none endif endwhile EndEvent scriptname SC64_OrbActor extends Actor SC64_WispMotherEffect Property OwningEffect Auto Event OnDeath(Actor akKiller) if OwningEffect != none OwningEffect.OnOrbDeath(self) endif EndEvent Fair warning: I haven't checked this for compilation and it doesn't do everything you say you want your script to do, but it demos how to pass information back and forth. Also it's extensible to more than just the player if you want to go that route. Link to comment Share on other sites More sharing options...
SirCumference64 Posted July 14, 2017 Author Share Posted July 14, 2017 Oh man thank you so much for taking the time to write that out, even if it doesn't compile it gives me ideas to work with. And the other stuff isn't a big deal anyway, since spawning the shades is just dependent on health and the NPC wisp mothers tend to spawn them with extreme prejudice anyway. I can work that in no problem. Link to comment Share on other sites More sharing options...
Recommended Posts