Jump to content

Need Help With Summon Spell Scripting


Manjarowolf

Recommended Posts

I know this might sound a bit much, but could anyone help me out with the scripted effect for a spell I'm making?

 

The spell requires a target that is a dead body and the range is targeted. I want to make it so that when the spell is

cast on the target, a message at the top says "replacing soul...", waits about 20 seconds, and then summons a

Dremora in its place. I'm not sure if I can make the corpse actually swap rather than just summon the Dremora but

I just wondering how i'll make this work.

 

Would anyone know how I write that out in the a new script? I'm not very advanced with scripting and I'm still learning,

So would someone be able to post how it's suppose to look in the Edit Scripts window?

 

What parameters would I need to set and would the summon be limited in duration or could it be made permanent until death?

 

Please help me out here guys.

Thanks

Link to comment
Share on other sites

Might look really good with a simultaneous fading in and out of Dremora and corpse. But I digress...

 

This wouldn't really act like a standard summon spell. After the message pooped up and the timer ran out you would then have to either place an invisible friendly at the desired location (out-of-the-box summon spells are self-targeting only) have them cast the spell, and then make it follow you rather than the actual summoner. (I have no idea if 0 or negative duration would yield a permanent summons or not) but to keep it around you'd probably need the invisible summoner tagging along too

 

OR you would need to mimic the desired spell effects and simply place a creature at the target corpse. it would need its own script to disable it on death (complete with magical "poof" effect.) and a duration timer, if so desired. Then have it follow you. If it is to be permanent, then you'd probably want to include some behavior control. (I'm actually in the midst of making a mod that would serve just that purpose, but as my mod is far from complete, I'd recommend using Minionz for simplicity)

 

As for actual code, you need to decide exactly how you want it to work. Obviously you need to set a reference for the target corpse. Send the message, set up and run the timer, create, place and get the reference for the summoned dremora (probably all while disabled or otherwise unseen), trigger spell effects shaders, (do the fades if desired), set an initial ai, and the rest depends on how you decide you want it to behave in life and death,

 

Does it have a duration or is it permanent until death? Does it always have one specific level? is its level permanently established upon summoning? Does it level up with you? If so how far ahead or behind? Because while this may not be part of the summon spell, itself, it will need to be part of the dremora when it gets summoned.

 

Nothing you've asked about so far is very hard, to do. The question is really is "What exactly do you want?"

Link to comment
Share on other sites

Thanks for the information. I hadn't really thought too far into the extensive parts of it, just how I would actually get it written in the script so it would work. I just want the spell to activate at the targeted corpse(if possible), and have an invisible timer start up as if the summoning takes time; sort of like a stalled or delayed spell. Once the the timer hits 15 seconds, the spells effect activates and then summons the Dremora and replace(or better yet it would likely delete or remove) the dead body. Now that I think about it, that fade would be nice, but I'm not particularly inclined to have it implemented.

 

I know that the remove functions are limited and a body needs to be disabled first so I'd have to get that in somehow.

But if I'd need a placeholder friendly invisible unit and the other stuff, how would I go about that in the script? Or what would you suggest I type that would bring me the closes to that?

Link to comment
Share on other sites

Before we continue, I need to say something. I didn't get back with you yesterday because my lung hurts and I'm having trouble breathing, Additionally, because of this, I'm kind of light-headed and I'm not thinking as well as normal. My primary concern is trying to get funding for medical help. If I've got something worse than pneumonia, I may end up dropping the ball on you without further warning.

 

So... If someone else would like to step in, Manjarowolf might appreciate that.

 

The invisible friendly is just one way to do it, and not the best way, I'm honestly not sure why I even mentioned it. I'd seriously recommend the second method. To add a limited duration in that method, it would simply be a matter of attaching a script with a timed "spell expiration" routine to the summoned dremora.

 

I'm honestly not that familiar with Oblivion, yet, but my experience with Morrowind is that removing an object within a script that is attached to said object crashes the game. I don't know for sure, but I'd assume the same happens in Oblivion. Spells "attach" themselves to the target for the spells duration, but am unsure as yet as to how. I don't know if removing something with a spell cast at it would cause a crash or not, but as it turns out this is a moot point, because as you're dealing with corpses, your spell really doesn't need to do it.

 

Non-permanent corpses, e.g. most of the things you kill, will eventually be automatically removed by game. Permanent (quest Item) corpses wouldn't normally be removed anyway so you're not loosing anything there. although it might be a bad idea to disable a quest item corpse in case some quest is actually going to need it to be there. So basically, you won't actually need to remove the corpse, just disable it so it won't be in your way.

 

As for removing the summoned dremora, I just discovered a discussion on the issue you mentioned before. I'll need to look into this a bit and get back with you later. Unfortunately, the workaround suggested uses dummy NPCs which would be of pre-established levels and equipment. This issue inhibiting the complete removal of actors is just one of the many annoying differences I'm discovering between scripting for Morrowind and Scripting for Oblivion.

 

Targeting a corpse is not a problem, you just need to run an IsActor check, followed by a GetDead, I would also suggest a test againt GetIsGhost because your spell is set up to simulate "possessing" a physical body which is someting that a ghost isn't supposed to have. Additionally you could test for GetIsCreature to impose a limit of NPC or creature, GetIsPlayableRace or GetIsRace could prevent using races you don't want but I don't see any reason that a dremora shouldn't be able to be summoned into either a Dremora or a Golden Saint corpse.

 

Unfortunately, because of the game engine's design, getting particular about creatures is more difficult. There are only a few "type" categories, Creature, Daedra, Giant, Horse, Humanoid and Undead. and the stock CS has no provision to check this. You'd need to use OBSE's GetCreatureType to test for these limits and even that gets limited because, in-game, Mehrunes Dagon is the only "Giant", and the "Humanoid" type which nominally could have been used to distinguish the bipedal humanoid appearing creatures is not used except in two cases, the corpse of Nath Dyer, and a TestCreatureSpriggan template that was never actually utilized. Because of this there is no way to directly test for a distinction between a mountain lion and a goblin. The "biped" flag under "Movement" was never even used, only "Walk", "Swim" and "Fly".

 

Functionally this limits the "Type"s to Creature, Daedra, Horse, and Undead, which, as mentioned before, can only be tested for this using OBSE. and a few zombies, such as the first one encountered in the tutorial are actually "Type"d as "Creature"s, which doesn't help matters either. In concept, I would see no reason that a "possessing" dremora shouldn't be able to inhabit any bipedal form, but if you feel that it would just be too weird seeing a wolf corpse morph into a dremora, unless you disallow all creatures, there really only one effective way that I know of to really be "racially" selective and that would be to use OBSE's GetCreatureSoundBase and there may even be some exceptions when using that.

 

Because the spell is designed to replace the corpse, you need to ensure that any corpse can only be under the effects of a single casting. Unfortunately, as this check would be in the script it wouldn't prevent multiple castings, it would just keep additional castings from having any effect. Also as described, there would be no visual means of determining whether the spell found a valid target or if a particular corpse is currently undergoing the transformation. Additionally, I realize that you want the actual summons to take a while, but it would look odd if the effect shaders on the corpse began after 20 seconds without an immediate apparent cause. I would suggest playing an effect shader on the corpse upon casting, with a condition to keep playing it until the corpse is disabled. The same shader, without an extending loop, could then be applied to the dremora just before it gets enabled. Visually showing that the spell is in progress, and connect the appearance of the dremora with the removal of the corpse.

 

With the SetActorAlpha function, fading would be fairly easy to set up. Just a timed loop which raises or lowers the alpha settings by a set amount that gives the desired fade effect.

 

Well, I need to take a break for now, but next time I'm on, I'll have some sample code worked out for you to evaluate, and I'll also look further into this issue of removing dynamically generated NPCs because what I've read so far can't be completely correct, otherwise your game would get bogged down because all of the dead, disabled, but still referenced, leveled-list generated random encounters' corpses hidden in the background would still need to be scanned to ensure that they didn't need to be rendered. Extended play would become impossible.

 

At the very worst I'd think that you could still set up a work around that would force a call for a leveled list encounter from a list containing only the one creature you want.

Edited by KenJackson
Link to comment
Share on other sites

O.K. Between frequent snoozes, I wrote up some sample code for you.
Because of the need to ensure that there can only be one instance of the spell affecting any single corpse, combined with the fact that any spell script that would check to see if a target is under the effects of that spell would always see itself and return 1, I needed to split this into an "Ability" that performs the actual spell processing and a castable "Spell" that does nothing but verify that the target is valid, makes sure it does not have the "Ability" and apply the ability when and if the target passes all tests.

First the "Spell":

scn CustomSummonSpellScript

;This script determines if the target is a valid target or not. If the target is ;valid,;it then applies the actual spell in the form of an ability.

begin ScriptEffectStart
	if IsActor ==1
		if GetDead ==1
			if GetIsGhost == 0

;				if IsQuestItem ==0	; this would prevent using a corpse that may be needed for a quest, 												; IsQuestItem reequires OBSE
					; This is where you'd insert additional checks that would limit acceptible targets

					if IsSpellTarget CustomSummonAbility == 0
						AddSpell CustomSummonAbility
					endif
;				endif
			endif
		endif
	endifend

 

scn CustomSummonAbilityScript

float timer
short IsHere		;Just as Moses had to keep telling the rabbits "Only two." you need to tell the spell "Only one."
float FadeIn
float FadeOut
ref rDremoraRef	;this will need to be assigned to the dremora

begin ScriptEffectStart
	PlayMagicShaderVisuals effectEnchantIllusion	;Try differnt shaders see which one you like. I set this line here
							;because this is where I think it would look best - see below

	Set FadeOut to 1
end


begin ScriptEffectUpdate
	set timer to timer + ScriptEffectElapsedSeconds
	if timer > 20
		if IsHere == 0	;Is he there yet?

;			PlayMagicShaderVisuals effectEnchantIllusion	;This is where the shader would go if you'd rather delay starting them, as well, which is as you described

			;rDremoraRef  place Dremora	;this is where you'll actually place the dremora
							;but I'm still investigating the best method

			set IsHere to 1			;He's HERE!!!!
			rDremoraRef.SetActorAlpha 0	;but he's invisible
			rDremoraRef.enable		;and now he'll be able to interact with the world
			rDremoraRef.PlayMagicShaderVisuals effectEnchantIllusion

		else
			Set FadeIn to Fadein + .03	;adjust the .03 for the fade rate you desire bigger = faster
			Set FadeOut to FadeOut +.03	;just remember that the duration on the magic ability needs to last
							;long enough for the fade to complete
			rDremoraRef.saa	FadeIn		;saa is just another way of calling SetActorAlpha
			saa FadeOut
		endif
	endif
end


begin ScriptEffectFinish
	rDremoraRef.RemoveScriptPackage
	rDremoraRef.AddScriptPackage MyAI	;MyAI will be the ID of the (likely custom) 'follow' package
	StopMagicShaderVisuals effectEnchantIllusion
	rDremoraRef.StopMagicShaderVisuals effectEnchantIllusion
end



The ScriptEffectStart section only runs on the first frame of the spell, so all of the initialization procedures go there, eliminating the standard "DoOnce" condition.
The ScriptEffectUpdate part runs each frame and contains the timer for the delayed effects. I haven't included the code for "creating" the Dremora yet, because I haven't figured out the best way to do it to avoid the issue of past summons' bodies piling up.
The ScriptEffectFinish section only runs after the spell has run it's course. As such unlike most abilities, this ability needs to have a specific duration, otherwise the Dremora will just stand there with the effect shader still running. You'll need to experiment with the Fade speeds and the ability's duration to get the balance you like, and you can also adjust the timer.

To experiment with this you could just add the line:
set rDremoraRef to PlaceAtMe <my Dremora>
at the point where it says ;rDremoraRef place Dremora, replacing <my Dremora> with the ID of a custom Dremora that Isn't out to kill you.
The Dremora will need two AI packages. The first a Wander package with a radius of 0 and no idle animations, that will be his default so that he stands still while the spell is in progress. The second being the Follow package which will replace the first as the spell terminates.

I'm just hoping that a corpse can run an ability. if not, don't toss the code. It will just need to be executed some other way.

Edited by KenJackson
Link to comment
Share on other sites

I officially hate the editor. It messed up the code in the above post when I realized I'd forgotten to mention something.

Repairing the code, other errors occurred. so instead of trying to re-edit to repair those errors, I'm just going to make this Errata post.

 

The last line in the spell code is supposed to be two, an "endif" and an "end".

 

Between the two windows, there should be some comment about the "Spell" needing to be where magicka costs and such things that effect the player should be done. Not in the spell Scipt, mind you, but in the spell listing itself. Also the "Spell"s Duration can be rather short, Then I indicate that the second box contains the code for the "Ability" that will be applied to the corpse.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...