Multiple Summons for NPCs

Post » Sun Nov 18, 2012 3:45 am

Okay, for my mod it's necessary that NPCs are able to summon multiple actors at once to fight for them with a spell. It doesn't need to be unlimited, but should be a high enough number that it probably won't be reached during any battles (like 100?).

I know that I can increase the player's commanded actor limit with a perk, but this seems impossible for NPCs.

I have some ideas to get around this issue, but there are problems with them.

The first thing I thought of was: Make a different spell for NPCs that doesn't use the hard-coded summon effect, and just runs a script that places an actor at the target of the spell. Doing that seems pretty easy, but I'm confused about how to make the "summoned" actor fight only for its caster? The first thing I thought of is to add them to a faction together, but there is potential that I'll want two NPCs fighting each other like this. And having several copies of the same spell for each actor is something I really do not want to do. It would also be nice if the "summoned" actors followed the caster, but is not completely necessary.

Also, tell me the best way to spawn actors and get rid of them when they die?

Suggestions?
User avatar
Miguel
 
Posts: 3364
Joined: Sat Jul 14, 2007 9:32 am

Post » Sun Nov 18, 2012 11:51 am

In the mod I am making, I had an interesting bug in which a single summon had a clone which would not follow. Under the Magic Effect the Skill Usage multiplier seemed to dictate the number of summons that would appear. The value for the clone was 0.06, have not tried for a value smaller than this, but would imagine more clones with a smaller value. Not sure if this will get the desired effect but worth a look.
User avatar
Setal Vara
 
Posts: 3390
Joined: Thu Nov 16, 2006 1:24 pm

Post » Sun Nov 18, 2012 4:41 pm

In the mod I am making, I had an interesting bug in which a single summon had a clone which would not follow. Under the Magic Effect the Skill Usage multiplier seemed to dictate the number of summons that would appear. The value for the clone was 0.06, have not tried for a value smaller than this, but would imagine more clones with a smaller value. Not sure if this will get the desired effect but worth a look.

Thanks, I'm more interested in being able to have two different types at once. I.e. the NPC casts a spell to summon a bear, and then casts another spell to summon an atronach, and they both stay in the game and fight for him. I'll look at it though.
User avatar
Chloe Mayo
 
Posts: 3404
Joined: Wed Jun 21, 2006 11:59 pm

Post » Sun Nov 18, 2012 3:27 am

Perhaps use a cast command in papyrus and attack the script to your magic effect
User avatar
Kahli St Dennis
 
Posts: 3517
Joined: Tue Jun 13, 2006 1:57 am

Post » Sun Nov 18, 2012 3:26 am

Don't use Cast on an actor. Use a package that includes this: http://www.creationkit.com/Procedure_UseMagic

(Cast ruins actors, because there is no casting pose ... or something ... when using the Cast command)



No idea on multiple summons, never tried it, just thought I'd post about the above.
User avatar
Calum Campbell
 
Posts: 3574
Joined: Tue Jul 10, 2007 7:55 am

Post » Sun Nov 18, 2012 12:38 pm

Don't use Cast on an actor. Use a package that includes this: http://www.creationkit.com/Procedure_UseMagic

(Cast ruins actors, because there is no casting pose ... or something ... when using the Cast command)



No idea on multiple summons, never tried it, just thought I'd post about the above.

I think I was misunderstood. My idea is the following. Create spell1 with magic effect1 and give the spell to the player. Attach script to magic effect1 with cast command to cast another spell. This way when the player cast spell1 he/she automatically cast spell2 as well using one animation.
User avatar
Robert Jackson
 
Posts: 3385
Joined: Tue Nov 20, 2007 12:39 am

Post » Sun Nov 18, 2012 6:47 am

Actually, I made a new perk to increase the commanded actor limit, added it to an NPC, and it works now.

I don't know, the last time I tested perks with NPCs it didn't work. That was a few months ago though, so maybe it was stealthily fixed in an update? Or I was doing something wrong before.

http://i.imgur.com/fdfvMh.jpg
User avatar
Milagros Osorio
 
Posts: 3426
Joined: Fri Aug 25, 2006 4:33 pm

Post » Sun Nov 18, 2012 12:51 am

Okay, so now I am stuck again with two related issues:

(1) I need to get the "owner" of a summoned actor. Some examples of how I would want to use this are:
A spell that may be cast on a summoned actor to damages an actor value of its owner.
When a summoned actor dies, it restores an actor value of its owner.
While a particular summoned actor is alive, its owner gets an actor value fortified.
Etc.

Maybe there's no function to actually do this, so I thought the easiest way would be to assign the owner manually with "setactorowner" when it's cast (this does work on other actors), and then just check it later. I'm having a really difficult time actually doing that though. My first idea was to make a small scripted area effect on target location that was part of the same spell as the summoned spell, which assigns ownership of any targets to the caster, but this does not work unless it's fired at an existing actor, because no matter what I do, I can't get the effect to apply to the summoned actor of the same spell.

My next idea, I think, is much worse. It's to force every actor to cast a silent/invisible spell right after they cast a summoning spell, and have that spell set the ownership. While I think it would work for the player, it just seems like (a) a really bad solution that's prone to failure, and ( :cool: something that may not even work for NPCs, since I would need to know the target for them already, and if I knew the target at this point, I would already have access to both the NPC and summoned actor and could just set the ownership without casting the spell.

I realize that I can check whether the actor is the player's ally or not, but this doesn't help me for actors summoned by NPCs, and unlike Skyrim, I want my mod's mechanics to work the same for the player and NPCs.

---
(2) I need to apply an effect to self after casting a "target location" spell, if certain conditions are met.

Example of how I would use this:
A spell that summons an actor at the target location, and if of the caster is below , then the caster takes 10 damage to .
More defined example:
If an actor casts a spell that works on target location with less than 50 magicka, he takes 10 health damage as well. These values should be specific to each spell.

I was thinking of something similar to above, which is to add second, scripted, effect to the spell with the conditions I want, and in "oneffectstart" I can just get the caster and do whatever I want there. This sometimes works fine, but the problem is the effect only starts when other actors are already around. So if you cast something in a completely empty area, the effect can never start because there are no targets for it.

Again, I could do some really unreliable and terrible things ot make this work, such as making an invisible permanent follower to receive the effects, or forcing the actor to cast another spell on itself with the "onspellcast" event. But these are both awful ideas of course, and I would rather just forego my planned mechanics than use them.

Hopefully someone has some better ideas.
User avatar
Andy durkan
 
Posts: 3459
Joined: Fri Aug 03, 2007 3:05 pm

Post » Sun Nov 18, 2012 10:04 am

1) Could you use one of the (unused) ActorValues to store the original CASTER of thr Summon Spell (store on the summoned NPC)? The problem is that quite a few mods are using AVs, so your compatibility-count might drop a bit.

Would work and is easy though, I think??

2) Invisible Follower was what I was going to suggested. If your spell has to be targetted, then you gotta have a target ... only way to guarantee one is create an invisible one (that always follows the player around if the player has the relevant spell). Nasty. Would work.

No way of having some form of "self" spell kick off the routine? So self-spell (that does -10 damage to own health) with an OnEffectStart script to move a reference from a "blank" holding cell to the player's feet? Messy, but possibly less nasty?
User avatar
Sherry Speakman
 
Posts: 3487
Joined: Fri Oct 20, 2006 1:00 pm

Post » Sun Nov 18, 2012 5:19 am

1) Could you use one of the (unused) ActorValues to store the original CASTER of thr Summon Spell (store on the summoned NPC)? The problem is that quite a few mods are using AVs, so your compatibility-count might drop a bit.

It's a total conversion so that's not a big deal for me, but can you explain a bit more what you mean? I'm not sure how that would work.

Would work and is easy though, I think??

No way of having some form of "self" spell kick off the routine? So self-spell (that does -10 damage to own health) with an OnEffectStart script to move a reference from a "blank" holding cell to the player's feet? Messy, but possibly less nasty?

Certainly less nasty than the follower thing, but only works for summoning, not for firing a spell at another actor. I might just forget about having spells with an effect on the target and self, but I guess I will test both.
Thanks for the suggestions, will report back after testing.
User avatar
Jack Bryan
 
Posts: 3449
Joined: Wed May 16, 2007 2:31 am

Post » Sun Nov 18, 2012 9:48 am

http://www.creationkit.com/Actorvalue

(Having thought about it a bit more ... may not be any use to you, though).

I'll have a re-think, gotta be an easier way to hold a variable against an actor ... data is all there when you initialise your stuff, just need a way to remember it for when you need it
User avatar
electro_fantics
 
Posts: 3448
Joined: Fri Mar 30, 2007 11:50 pm

Post » Sun Nov 18, 2012 3:38 pm

http://www.creationkit.com/Actorvalue

(Having thought about it a bit more ... may not be any use to you, though).

I'll have a re-think, gotta be an easier way to hold a variable against an actor ... data is all there when you initialise your stuff, just need a way to remember it for when you need it

Well, I thought of a another "nasty" way to do it, but probably the most reliable out of every one suggested so far: Attach a script to the casting actor with an OnSpellCast event which sets some permanent placeholder's data to something that can be used to identify itself. Then attach a script to all summoned actors which retrieve that data a very short time after they were cast, and use setActorOwner with it. It's nasty because everyone casting spells would use the same data, but it seems unlikely that they're going to cast their spells at the exact times needed to set the incorrect actor as the owner. At least it's probably better for performance than the other methods too.

Edit: Okay, setActorOwner only takes an ActorBase, so I still need some way to store the actor reference.

Edit2: Okay, so I could possibly use GetFormID, set one the placeholder's actor values to the formid, then get the actor value and use game.getform in the summoned actor's script and set one of it's actor values to the formID for future use.

Edit3: I've tested that and it certainly works, does anyone want to now ruin my feeling of victory by telling me why I shouldn't use getform?
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm

Post » Sun Nov 18, 2012 4:32 pm

I'll post what I did in case anyone is interested.

Attached to the caster:

Scriptname AASummonOwnershipPass extends Actor  ;Add this keyword to summon spell effects;keyword property AASpellSummon auto;Ownership placeholder, it's just a random guy in an empty cell.actor property AASummonOwnershipPlaceholder autoEvent OnSpellCast(Form akSpell)	;Is the spell a summon spell? - I'll use SKSE for this later.	;if ( akSpell.getNthEffect(0).hasKeyword(AASpellSummon) )				;Pass self formID to an ownership placeholder. The formID will be stored in "Fame" I guess.		AASummonOwnershipPlaceholder.setAV("Fame", getFormID())				;debug.messagebox("Self's FormID = "+GetFormID()+" self = "+self+" placeholder = "+AASummonOwnershipPlaceholder)			;endif	Endevent

Attached to the summoned actor:
Scriptname AASummonOwnershipSet extends Actor  ;Ownership placeholder, it's just a random guy in an empty cell.actor property AASummonOwnershipPlaceholder auto;Owner of this summoned actoractor ownerint ownerFormIDEvent OnLoad()	;Get the owner's formid from the placeholder	ownerFormID = AASummonOwnershipPlaceholder.getAV("Fame") as int	;Set own ownerFormID actor value	self.setAV("Fame", ownerFormID)		;Get owner as an actor ref	owner = Game.getForm(ownerFormID) as actor		;debug.messagebox("Owner FormID = "+ownerFormID+" owner = "+owner+" placeholder = "+AASummonOwnershipPlaceholder)	Endevent

Thank you h4vent for the suggestion of using actor values. Maybe something like this is what you had in mind to start with?
User avatar
i grind hard
 
Posts: 3463
Joined: Sat Aug 18, 2007 2:58 am

Post » Sun Nov 18, 2012 4:36 pm

I'll post what I did in case anyone is interested.

Attached to the caster:

Scriptname AASummonOwnershipPass extends Actor  ;Add this keyword to summon spell effects;keyword property AASpellSummon auto;Ownership placeholder, it's just a random guy in an empty cell.actor property AASummonOwnershipPlaceholder autoEvent OnSpellCast(Form akSpell)	;Is the spell a summon spell? - I'll use SKSE for this later.	;if ( akSpell.getNthEffect(0).hasKeyword(AASpellSummon) )				;Pass self formID to an ownership placeholder. The formID will be stored in "Fame" I guess.		AASummonOwnershipPlaceholder.setAV("Fame", getFormID())				;debug.messagebox("Self's FormID = "+GetFormID()+" self = "+self+" placeholder = "+AASummonOwnershipPlaceholder)			;endif	Endevent

Attached to the summoned actor:
Scriptname AASummonOwnershipSet extends Actor  ;Ownership placeholder, it's just a random guy in an empty cell.actor property AASummonOwnershipPlaceholder auto;Owner of this summoned actoractor ownerint ownerFormIDEvent OnLoad()	;Get the owner's formid from the placeholder	ownerFormID = AASummonOwnershipPlaceholder.getAV("Fame") as int	;Set own ownerFormID actor value	self.setAV("Fame", ownerFormID)		;Get owner as an actor ref	owner = Game.getForm(ownerFormID) as actor		;debug.messagebox("Owner FormID = "+ownerFormID+" owner = "+owner+" placeholder = "+AASummonOwnershipPlaceholder)	Endevent

Thank you h4vent for the suggestion of using actor values. Maybe something like this is what you had in mind to start with?
That's almost exactly what I had in mind ... before I convinced myself that it wasn't going to work! ;)

A nice bit of coding that, mate - Looks pretty clean too and should be reliable (I think ... !) - GetForm should be OK, I wouldn't worry about that. And it is compatible with just about anything that doesn't use the AV of "Fame" (but then there's no point worrying about that ... I read a post easlier from madmole that said we can all worry too much about what other mods ours are compatible with - or not - in the end players have to make a choice which incompatible mods they want

:)
User avatar
Liii BLATES
 
Posts: 3423
Joined: Tue Aug 22, 2006 10:41 am


Return to V - Skyrim