Casting a Spell

Post » Sun Feb 07, 2010 6:59 pm

I'm trying to make an activator cast a shock spell on a creature. This works for the most part, but in some cells (i.e. "Vivec, Arena Pit", where I thought I'd go to test it out), and sometimes just after the creature dies, it bugs out a bit, resulting in some permanent shock effects that don't go away.

I think the problem is, the spell is being cast, but for some reason it loses its target and becomes "stuck". I don't understand why this is happening, as it works fine most of the time (but NEVER in the arena).

This script is attached to an activator - the activator should cast the spell, and then disappear.

Begin dd_cast_shock_dravenfloat zPosfloat timerif ( menumode == 1 )	returnendifif ( GetDisabled == 1 )	if ( timer >= 3 )		setdelete 1	else		set timer to ( timer + GetSecondsPassed )	endifelse	set zPos to ( GetPos, z + 64 )	setPos, z, zPos	; Lift out of the ground	Cast, "dd_shock_strike", "dagoth draven"	DisableendifEnd


Like I said, most of the time it works fine, but sometimes I just end up with a random "shock ball" just hovering there.

Any help would be much appreciated.
User avatar
Philip Rua
 
Posts: 3348
Joined: Sun May 06, 2007 11:53 am

Post » Sun Feb 07, 2010 4:11 pm

I don't know if it applies in this case, but I believe that spells cast by activators have to be "touch" range to be dependable. If your target is out of touch range and the spell is a ranged spell, that might be the cause of the hovering shock ball. I have no idea why the Arena cell should be different though...
User avatar
OJY
 
Posts: 3462
Joined: Wed May 30, 2007 3:11 pm

Post » Sun Feb 07, 2010 12:11 pm

I don't know if it applies in this case, but I believe that spells cast by activators have to be "touch" range to be dependable. If your target is out of touch range and the spell is a ranged spell, that might be the cause of the hovering shock ball. I have no idea why the Arena cell should be different though...


Thanks for the reply.

At least for now, I've changed it so that it targets the player instead of the creature. It's not quite the effect I was going for, but it works. It's still on target though, so apparently activators can cast "on target" spells at least some of the time.

As I said in the thread description, I think this function could really do with some research and better documentation. MWSFD says nothing about the "scale parameters are bad" error message (which I eventually found out was to do with using an invisible activator to cast the spell), and now this :(
User avatar
Wayne W
 
Posts: 3482
Joined: Sun Jun 17, 2007 5:49 am

Post » Sun Feb 07, 2010 12:44 pm

Just steal or butcher parts from the Dwemer Mines (things that shoot spells at the player) from THAT Tribunal mission. If your not familiar i can post the script up here for you. I keep it in my library. Fairly useful script for all sorts of things.
User avatar
Jade MacSpade
 
Posts: 3432
Joined: Thu Jul 20, 2006 9:53 pm

Post » Sun Feb 07, 2010 3:11 pm

I think the problem may not related to the specific function; you are maybe trying to target a not unique reference to an object
the creature should be unique and placed in game in TESCS, not by script.
Copy the "dagoth draven" original creature giving it a new unique ID (for instance dnDagothDraven), place it in Vivec, Arena Pit inside TESCS render window
disable/enable dnDagothDraven as needed from script, and try
Cast, "dd_shock_strike", "dnDagothDraven"
Also, try giving more time before the setdelete 1, it should be used only after you are sure any child sound/effect animation of the object are done.
User avatar
Rinceoir
 
Posts: 3407
Joined: Thu Jun 29, 2006 1:54 am

Post » Sun Feb 07, 2010 8:38 am

Just steal or butcher parts from the Dwemer Mines (things that shoot spells at the player) from THAT Tribunal mission. If your not familiar i can post the script up here for you. I keep it in my library. Fairly useful script for all sorts of things.

I might have a look at that later then, for interest's sake. I'll probably leave the script in question as it is now though, it actually works pretty well.

I think the problem may not related to the specific function; you are maybe trying to target a not unique reference to an object
the creature should be unique and placed in game in TESCS, not by script.
Copy the "dagoth draven" original creature giving it a new unique ID (for instance dnDagothDraven), place it in Vivec, Arena Pit inside TESCS render window
disable/enable dnDagothDraven as needed from script, and try
Cast, "dd_shock_strike", "dnDagothDraven"
Also, try giving more time before the setdelete 1, it should be used only after you are sure any child sound/effect animation of the object are done.

Hmm... strange that it still worked some of the time. I figured it didn't matter too much about a unique reference because of this (from MWSFD):
Cast will prefer a reference in the current cell if there is one available, so there's no need to move a reference from a storage cell: you can just place a new one.

And also this:
If the spell's target is not in the current cell, the NPC will cast anyway (this doesn't cause any errors, but it does look a little odd - particularly targeted spells). They will also cast 'through' objects, other NPCs, walls… anything that's in the way.

Although I suppose in that case it might be talking specifically about NPCs.

EDIT: Oh and I changed the timer before "setdelete" to 10.
User avatar
Alexx Peace
 
Posts: 3432
Joined: Thu Jul 20, 2006 5:55 pm

Post » Sun Feb 07, 2010 11:45 pm

Well for the Cast function I couldn't figure out how to make it work properly...

So what I did was:

"aa shaddow_Tii Guar"-> Cast, "Hearth Health", "aa shaddow_Tii Guar"
"aa shaddow_Tii Guar"-> ModHealth 20 ;Then I added the effects in manually.

Casting the spell didn't actually do anything but I did it just for the visual effect. I understand this might not apply to your situation but it is mainly for the better documentation of the Cast effect.
User avatar
Lillian Cawfield
 
Posts: 3387
Joined: Thu Nov 30, 2006 6:22 pm

Post » Sun Feb 07, 2010 4:22 pm

Well for the Cast function I couldn't figure out how to make it work properly...

So what I did was:

"aa shaddow_Tii Guar"-> Cast, "Hearth Health", "aa shaddow_Tii Guar"
"aa shaddow_Tii Guar"-> ModHealth 20 ;Then I added the effects in manually.

Casting the spell didn't actually do anything but I did it just for the visual effect. I understand this might not apply to your situation but it is mainly for the better documentation of the Cast effect.


Out of curiosity, was the spell "On Self"? Because as far as I can tell, that ought to work :s
User avatar
Allison C
 
Posts: 3369
Joined: Mon Dec 18, 2006 11:02 am

Post » Sun Feb 07, 2010 5:09 pm

Yes but when the actor simply cast the spell it didn't work. The only way I could get it to work was to manually add the effects to the actor. I am only using Cast for visual effects now.
User avatar
Neliel Kudoh
 
Posts: 3348
Joined: Thu Oct 26, 2006 2:39 am

Post » Sun Feb 07, 2010 3:09 pm

I accidentally found your answer while looking for something unrelated but similar ( see the NPC Alarm thread). Psycholex was on the right track. Apparently Bethesda was aware of issues with activators casting ranged spells.

The "projectile mine" uses a script that tracks the PCs xyz positions, and balances against the PC sneak skill. If the mine is triggered, the script uses a "placeAtPC type of function to put an activator within touch range of the PC, which then delivers the spell and resulting damage to the PC by using touch range. One thing I found interesting was an apparent function that I've never encountered... It reads:

if ( detonate == 1 )	ExplodeSpell "proj_trap_spell"	set triggered to 1	disableendif


It then uses a timer to setdelete to 1 after 4 seconds. I presume that if ranged spells cast by activators were dependable, they wouldn't have gone to such lengths, eh?
User avatar
Jonathan Egan
 
Posts: 3432
Joined: Fri Jun 22, 2007 3:27 pm

Post » Mon Feb 08, 2010 12:28 am

The "projectile mine" uses a script that tracks the PCs xyz positions, and balances against the PC sneak skill. If the mine is triggered, the script uses a "placeAtPC type of function to put an activator within touch range of the PC, which then delivers the spell and resulting damage to the PC by using touch range.

I believe that, for activators, "touch range" is essentially unlimited; if an activator casts a spell on the player "On Touch", the player will instantly be hit it. I used this same technique in my "Deadly Dagoths" mod so that the player would be hit by a spell without the creatures having to go through the casting animation.

One thing I found interesting was an apparent function that I've never encountered... It reads:

if ( detonate == 1 )	ExplodeSpell "proj_trap_spell"	set triggered to 1	disableendif


It then uses a timer to setdelete to 1 after 4 seconds. I presume that if ranged spells cast by activators were dependable, they wouldn't have gone to such lengths, eh?

Using a timer to delete the activator after having it cast a spell is standard, but I've never really looked into "ExplodeSpell"... perhaps that could be of use to me. I think the reason Bethesda probably did all this was because you can't have an activator cast an area-effect spell on itself (which is probably why they came up with ExplodeSpell). Then they used another activator to cast an "OnTouch" spell on the Player if he is within the blast radius, to simulate the effects of being hit by the explosion.

Thanks for the information.

It seems to me that the issue probably is to do with unique references, as having as activator cast a ranged spell on the player seems to work fine for me.
User avatar
Bloomer
 
Posts: 3435
Joined: Sun May 27, 2007 9:23 pm


Return to III - Morrowind

cron