Have a quick question? Need a quick answer?
If you have not had any luck with the http://www.creationkit.com/Main_Page, post away and hopefully someone will have the answer(s) you seek.
Previous threads:
Have a quick question? Need a quick answer?
If you have not had any luck with the http://www.creationkit.com/Main_Page, post away and hopefully someone will have the answer(s) you seek.
Previous threads:
got a strange issue i'm currently pretty clueless with:
a bunch of npc's get spawned by aliases.
each of these aliases has a script that's, a.o., supposed to increment a counter on the belonging quest's script (simply like QuestSCRIPT.Counter += 1) when it has it's ref, which i start checking OnInit or, if no ref's yet found then, by subsequent single update registrations until filled.
i definitely can tell the according script block runs, since other stuff set in it gets properly set (and quest's still running and all my aliases filled of course)
but: my counter int only reaches 60-80% of the actual ref count (varying from try to try on a pretty random base).
why is this so?
only hypothesis i got is, most of the refs are spawned in custom int cells that hadn't been loaded at the time (=some odd persistence issue), but i figure if the alias holds a ref should mean it has actually spawned the refs regardlessly of this, or not? (and also, if it actually didn't count any refs in such cells, total count would come out far lower even)
..it can't be like my quest script gets some kind of hickup because ~20 instances try to increment the same variable at pretty much the same time, or can it? (which would surprise me, since i think they should simply stack up and get processed one after the other?)
any hints anybody?
This sounds like a classic threading problem. This very problem is discussed at the bottom of http://www.creationkit.com/Threading_Notes_%28Papyrus%29#Another_example of the http://www.creationkit.com/Threading_Notes_(Papyrus) page on the CK Wiki:
Because all of your references are spawned at the same time, multiple references might all get the value from the remotes script at the same time, and then set the value later. Example of how this could possibly work out with 4 references:
Ref1 gets value of 0 from QuestSCRIPT.CounterRef1 adds 1 to 0, and then sets QuestSCRIPT.Counter to 1Ref2 gets value of 1 from QuestSCRIPT.CounterRef3 gets value of 1 from QuestSCRIPT.CounterRef2 adds 1 to 1, and then sets QuestSCRIPT.Counter to 2Ref3 adds 1 to 1, and then sets QuestSCRIPT.Counter to 2Ref4 gets value of 2 from QuestSCRIPT.CounterRef4 adds 1 to 2, and then sets QuestSCRIPT.Counter to 3
The solution is to make a function in QuestSCRIPT that does the adding instead. Then each reference can call that function instead of directly manipulating the property.
Re:last thread...
@S70,
So part of that worked, thanks I've still got a couple of characters behaving weirdly, but it's better than it was
Slightly new problem... In the intro, we have the PC in a cart going down the road; I've got a scene the same in my Mod, complete with two carts and the PC being in the second one. The first cart goes perfectly, but the second one gets half-way there and suddenly starts freaking out like it has hit something or the havoc has gone chaotic... At one point it was driving along sideways, and the horse keeps turning (but ultimately going towards the destination fine...) Any idea what might 1) cause that sudden spasm, and 2) why it would only affect one cart, and not the other? Both carts use identical Forms for the horse and the Cart; the only differences are the PC and the other NPCs in each, which have their own base forms...
boy, who'd have thought they'd have exactly my issue covered in the wiki )
tough read that page anyway, but rather enlightening
very well, read above article before this part of your post and concluded pretty much that from what i got from it, good to see that confirmed before even asking
thx a lot, this'll save me a lot of time testing stupid new versions of the same problem i'd have scripted otherwise
that was the thing with the navmesh testing, right? came to habitually use this for every navmesh i do myself, tedious as it may seem at first, it's an enormous time saver
I'm not sure how to make this happen. I have a spell setting the actor to EnableAI(False) and I don't want the PC to be able to get more than 1 free hit in so I thought making an OnHit event might be able to re-enable the AI. Here's the script with the least amount of errors in it:
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \ bool abBashAttack, bool abHitBlocked) Actor Reference = akTarget auto ;Error: no viable alternative at input 'akTarget' akTarget.EnableAI(true)EndEvent
This compiles but it doesn't enable the actors AI.
Actor kTargetEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \ bool abBashAttack, bool abHitBlocked) kTarget.EnableAI(true)EndEvent
Forgot to tell the script that akTarget = kTarget.
Another Question: I'd like to have the shout animation for a lesser power, how do I go about doing that? MT_BreathExhaleShort is the animation event. In other words, how do I force the PC into an animation event and pop them out of it after the animation is finished or when I want?
What is that script on, an ActiveMagicEffect?
With your first script, Auto is used for properties, which are defined outside functions/events. akTarget also isn't defined. With your second script, kTarget also isn't defined. In your script, it appears to be empty or set to None.
Scriptname _test_testscript extends ActiveMagicEffectActor kTargetEvent OnEffectStart(Actor akTarget, Actor akCaster) akTarget.EnableAI(false) ;akTarget is a parameter in the OnEffectStart event kTarget = akTarget ;akTarget is only defined in the event, so we use the kTarget variable (defined outside) to point to the spell targetendEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashHit, bool abHitBlocked) GoToState("DoneState") ;prevent this from firing numerous times kTarget.EnableAI() ;alternatively "GetTargetActor().EnableAI()" as GetTargetActor() is an ActiveMagicEffect function to get the spell target endEventState DoneState Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashHit, bool abHitBlocked) ;do nothing endEventendState
I think I edited my post 30s before you posted. Is your way safer? Mine was pretty simple, I just forgot to tell the script that akTarget = kTarget but I'm assuming that you didn't just use the state thing for added fun.
Yea, there was actually a recent thread on this: http://www.gamesas.com/topic/1519192-onhit-onupdate-events-script-heavy/
Basically the state makes it so that the event will only trigger once, while all later OnHit events will get thrown out