Scythe42 Posted April 14, 2017 Share Posted April 14, 2017 (edited) I thought I try to ask here as search efforts lead nowhere so far: I have some script that randomly spawns NPCs at various locations. I want these NPCs to do some kind of cast at an object. Just a custom spell at an xmarker or another reference as a target. The object's FormID might be different at each location, but I am able to pass is as a parameter to whatever Papyrus functions are involved / or the coordinates where the object is. How do I script this? The NPC is there but I did not really find info how to continue from here to make the NPC do stuff. Only examples I found are examples of pre-scripted stuff at specific locations as a quest with a fragment for individual locations. And that is not what i am looking for as everything is setup dynamically. So I cannot really provide fixed locations. Can anyone point me in the right direction here how to proceed? Edited April 14, 2017 by Scythe42 Link to comment Share on other sites More sharing options...
Tarshana Posted April 15, 2017 Share Posted April 15, 2017 Maybe a trigger box? Also packages; I have my Market population do stuff at various times during the day; sit, eat, drink or browse the stores using idle markers. Link to comment Share on other sites More sharing options...
Scythe42 Posted April 15, 2017 Author Share Posted April 15, 2017 (edited) Packages and Idle Markers will not work in my scenario as it is fully setup dynamically depending on the presence of the NPC itself and a potential target. Script is attached to the NPCs to set them up and start what they are supposed to be doing. I just having problem to get SetLookAt() and DoCombatSpellApply() to work properly with my NPCs and my custom spell. NPC will just idle or not firing the spell at all and sitting with it equipped there. The thing is I do not seem to have full control over what the NPC does. In my tries so far the NPC just idles with the spell equipped often or doesn't even equip it. Ah well, guess I dig more into it this evening. Just thought someone might have done this before and has a working example. Edited April 15, 2017 by Scythe42 Link to comment Share on other sites More sharing options...
Deleted3897072User Posted April 15, 2017 Share Posted April 15, 2017 Would it work if, when you spawn the NPC you ForceRef it into a quest alias that has a script attached to it? And the alias script does the casting? Point being that you can use the same quest alias over and over again (as long as you don't need more than one at a time anywhere). Link to comment Share on other sites More sharing options...
Borgut1337 Posted April 15, 2017 Share Posted April 15, 2017 The creation kit wiki page on the Cast function recommends using an AI package with the UseMagic procedure if you want a character to really visibly cast something. If that doesn't work for you, a completely scripted workaround that may work would be to simultaneously use the Cast function to cast the spell, and the SendAnimationEvent function to make the character play a spellcasting animation. May be difficult to time them correctly though. Might be possible to start playing animation first, and find a good timing for the Cast function using OnAnimationEvent to detect when a certain point in the animation is reached. Link to comment Share on other sites More sharing options...
Tarshana Posted April 16, 2017 Share Posted April 16, 2017 Packages and Idle Markers will not work in my scenario as it is fully setup dynamically depending on the presence of the NPC itself and a potential target. Script is attached to the NPCs to set them up and start what they are supposed to be doing. I just having problem to get SetLookAt() and DoCombatSpellApply() to work properly with my NPCs and my custom spell. NPC will just idle or not firing the spell at all and sitting with it equipped there. The thing is I do not seem to have full control over what the NPC does. In my tries so far the NPC just idles with the spell equipped often or doesn't even equip it. Ah well, guess I dig more into it this evening. Just thought someone might have done this before and has a working example. Well that sounds like a lot of fun...and way above my pay grade. Anyone who can code anything in my game gets +5 cookies from me; I read papyrus as well as I read Sanskrit. I wish I had more help to offer..so I will make more virtual cookies for you instead. Link to comment Share on other sites More sharing options...
Recommended Posts