Jump to content

Check the prepared for casting spell


Stealth21

Recommended Posts

Hello. I would like to know is there a function exists which is checking what spell is currently selected/prepared for casting by the player. And I mean not the case of the moment when I am selecting it from the spellbook (not a GetActiveMenuSelection, because the spell can be set for a quick access number keys, avoiding the process of that check), but when it is selected and we can see it's icon in the "GameMode" which hints that if you'll press the "C" button, the associated spell will be casted.

 

If where is no such function exists, then I'll try to explain the situation where I need that function.

 

I scripted the spell to empty the soulgem. The process is excatly "emptying", not a "replacing with an empty item", using such functions like GetCrossHairRef, GetCurrentSoulLevel, SetCurrentSoulLevel on a dropped in the world soulgem-with-a-soul. Script is doing it's purpose, everything fine... except the sound. I selected "Soul trap" in the "Visual Effect" of the spell's script magic effect. That means, that animation, shader/enlightment, casting sound, bolt sound, (hit sound) and area sound are "inheriting" from the "soul trap" (code STRP) magic effect. I need the animation and the enlightment from that magic effect, but I do not need the sounds of casting and of the area.

I tried to place a piece of code (not literally, an example) "SetMagicEffectCastingSound STRP null" to the spell script itself, but it works only after the spell is firstly casted, so I need it even before the spell's first cast. I do not need it changed permanently (for example, changing the STRP magic effect section in an editor) and will return the original sound after the spell's script work is done.

So, I wanted to make an 'ability spell' which holds a script which checks whenever the soulgem emptier spells are prepared for the casting by the player to change the sounds only in those moments.

 

I know that there might be a various alternative ways - not a spell but an enchanted weapon... a staff for example. There are enough equip checks to apply before 'attacking with the staff'... But in that case if I will be casting "soul trap" spells while that staff is equipped, there will be no sounds of STRP effect.

Or an amulet which gives that 'scripted ability spell' changing the sounds while it is equipped... but there is the same problem - while it is equipped, there is no STRP effect sounds when casting "soul trap" spells...

Or if a case with a GetActiveMenuSelection check, I need to know a way to deny my particular spells setting to the quick access panel.

Link to comment
Share on other sites

DrakeTheDragon, yes, that's what I was looking for! That simple function...

Looks like I just was tired yesterday... cause I was reading the OBSE function list all and over, searching the function with the "spell", "sound", "player" keyword... and was angry when only the "GetSpells" function is appearing in front of my eyes, which provides the array...

Thanks.

Link to comment
Share on other sites

scn zzSMEmptySoulGemCommonSoul

short stage
ref soulgemsearcher


Begin ScriptEffectStart
set soulgemsearcher to GetCrossHairRef
set stage to 1
End

;Begin GameMode
Begin ScriptEffectUpdate

if ( stage == 1 )
	if (( IsActivatable ) == 1 )
		if (( soulgemsearcher.IsSoulGem ) == 1 )
			if ( soulgemsearcher.GetCurrentSoulLevel == 0 )
				PlaySound SPLDestructionFail
				Message "This soulgem is empty"
				set stage to 2
				elseif ( soulgemsearcher.GetCurrentSoulLevel == 3 )
					PlaySound UIItemEnchant
					Message "You just freed the common soul from this soulgem"
					soulgemsearcher.SetCurrentSoulLevel 0
					soulgemsearcher.PlayMagicEffectVisuals DSPL
					set stage to 2
				else
					PlaySound SPLDestructionFail
					Message "There is not a common soul inside this soulgem"
					set stage to 2
				endif
		else
			PlaySound SPLDestructionFail
			Message "The spell applied not to a soulgem"
			set stage to 2
		endif
	else
		set stage to 2
		PlaySound SPLDestructionFail
	endif
elseif ( stage == 2 )
	set soulgemsearcher to SkingradWestGateMapMarker
;	set soulgemsearcher to ar_Null
	set stage to 0
endif

End

Script is doing it's purpose, everything fine

It appears that not everything is fine. The script is having such a strange behavior.

 

The spell now has three behavior stages, and it seems that the problem is in the reference:

- casting the spell to not an activatable objects do not sets a reference value to a 'soulgemsearcher' ref (but it SHOULD set the reference of ANY object)

- once casted to an activatable object, the reference value sets to a 'soulgemsearcher' ref, and the further castings to a non-activatable objects shows that that ref value do not changes! Even if it passes the 'stage 2' where it should be set to something different than 'GetCrossHairRef', like the 'SkingradWestGateMapMarker' (persisted reference in the world) or a null-valued reference.

- if to remove the activatable object after the spell was applied to it (for example, the emptied soulgem or a wrong-applied soulgem), the spell totally stops to work.

 

The spell is casted to the player. It has two "scripted" effects - the first one is a fake (none) with a target=touch, just to achieve a "casting on touch" animation (that script is not fully working in case it is target=touch, it is working only when it is applyed to the NPC/creatures), and the second one is scripted with a code above with a target=self. I just do not understand WHY the spell remembers the reference value of the 'soulgemsearcher'... it is declared inside the spell's script, shouldn't it be empty with each spell cast?!? And why I can't make it to forget about the ref value set?!? I am sure that the script passes through ( stage == 2 ), I checked that with a MessageBox.

Edited by Stealth21
Link to comment
Share on other sites

No it does not I am afraid and I tested it. You cant target weapons, armor or clutter and similar and get a getself or maybe not even GetCrossHairRef which I never tried though but keep looking as I do wonder how Telekinesis work as it manage to target and make anything glow purple, so how is it made???

 

I did tested this when I was making my display room as I wanted to use a spell at the weapons and I never got that to work. Targeting containers and living creatures works great.

 

I made 2 looting spells, one for targets and one based on the Book Looting Spell that I expanded to loot everything, even soulgems. :smile: The clutter loot spell use GetFirstRef and GetNextRef

 

Spellscripts common

A spell script has 3 parts which I guess you know

  1. Beginning
  2. Middle
  3. End

The spell must have a timer set to at least 1 second and the middle seems to loop 6 times each second as it is ran each 0.2s I guess. So I put all code I only want to run ones in the

Begin ScriptEffectFinish
End

That way the spell itself do not mess with my scripts. Often I call other scripts from the spell and you can do that in many different ways, pointing at quests and some add tokens to the player and other genius solutions but that doesn't help if you cannot get the target ref in the first place.

 

If you solve this, I will make a Blink spell similar to the ones in Skyrim, where you point anywhere and the player ports where you point. But it will never work I guess. I did prid a static object, a carpet for testing and tried to movoto it and it failed.

Edited by Pellape
Link to comment
Share on other sites

Messing with Soul gems, in an attempt to sort them, gave me headache 6 months ago. I failed to make it work.

 

We have approx 15-20 different soul gem objects and checking a stacked soul gem for its soul type is messy as you must check it and set it when you move it. Damn. I should remove them from my looting spells really. I guess all soul gems I loot with the spell, empty the souls, which I personally do not care about as I only use black soul gems anyway but I do not wish to mess with other players soul gems really so I better check it and most likely stop looting them with my spells but they can inform the player that there is a soul gem close by or in the container named Chest instead.

 

The enchanter mod I use, fill all empty soul gems with one soul for some odd reason, so when I need a stack of 100 Soul gems, I buy Grand ones, and use my Soul Gems transmuter, making them to Black and then I go to the basement in my house, spawning a bandit and get all soul gems filled. Very OP... I think it is FEA that is doing this or Multi enchanting. idk. When I got to enchanting 100 at my game comp, I thought it was a bug but it also did happen at my GFs comp after I reached 100.

Edited by Pellape
Link to comment
Share on other sites

I will add a choice to my house settings,

  • Loot soul gems and get emty
  • Loot soulgems and get grand filled with grand
  • Do not loot soul gems

Thanks for giving me this ideas to think about and comming up with a work around as if you hadn't mention Soul Gems, I would had published my rubbish scripts. :D I couldn't stop thinking about them now...

 

I just tested my loot spell in game, put a filled lesser filled soul gem inside a container, cast the spell and got an empty one. I chance my scripts right away and it is good I did not publish them yet.

Edited by Pellape
Link to comment
Share on other sites

I am so stupid and incompetent to read and understand. You did solve my soul gem problems as I now reread your scripts and I thought about this during a break.

(soulLevel:short) GetSoulLevel objectID:ref
(soulLevel:short) GetCurrentSoulLevel

When the bloody Soul Gem or any object is in a container or inside the inventory, it is the base object. When it is placed in the open, it is the reference. Pekka!!!!?? :wallbash:
I will put on this hat now. 50905320308_efe5a3ff02_o.png and wear it the rest of this evening. Damn and I just rewrote all my scripts...

I keep them as they are for now as this requires more tests and I do like the new scripts personally anyway... :wink:

 

Most functions used with references are called by Reference.function but many that checks the base object are written vice verse, function baseObject

Reference.function
function BaseObject
Edited by Pellape
Link to comment
Share on other sites

I have been brainstorming about Telekinesis - Why not add it to your spell? I mean the telekinesis spell is able to target anything so put it next to your script inside the spell object and test it and do set the script to run at least 1s and make a test. It could work but if it doesn't, it was worth a try anyway.

Link to comment
Share on other sites

Looks like I triggered your inspiration))

So, you are saying adding the telekinesis spell... Well, it do not made a trick - I tried to exclude the 'soulgemsearcher' ref and relied on the target accepting by the telekinesis effect; tried "set soulgemsearcher to GetSelf" - the spell is working only on an already placed in the world activatable objects, just like it was with a 'script effect' on touch. Also, when it is with a telekinesis effect, it becomes target=target, which becoms hard to hit such a little object like a soulgem... but when it is hitted it flies away) Still, script with a telekinesis is not working as it should.

The script written above is working (I was not care to meant, it is in 1 sec duration, and I do not see a difference yet between "GameMode" and "ScriptEffectUpdate" in that particular script), it set the reference of the soulgem/weapon/key/etc. dropped item, but, as I descripted, it's behavior is strange - the ref value do not voiding after the spell duration is over OR after the further next fresh spell castings.

And I think that I need a ref voider way. I do not know any mod which has a spell with a script effect which accepting non-living object reference value to use it as an example.

Edited by Stealth21
Link to comment
Share on other sites

  • Recently Browsing   0 members

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