Spell Effect Scripts

Post » Fri Sep 10, 2010 12:15 am

I'm a long-term fan of Morrowind, and I've used the editor for it far longer than that of Oblivion, so the scripting for Oblivion is eating my brain. I've made a VERY simple spell that's supposed to mimic an ability of the Zerg Queen from Starcraft called "Spawn Broodlings." For those of you who don't know, the ability shoots a projectile at any organic ground unit (including a few small machines, presumably targeting their pilots) which instantly kills its target and spawns two very weak creatures called Broodlings which die a short time after they appear.

I wanted to recreate this classic ability in my first mod and give it to some of the Desert Mages that I'm creating. What I'm trying to do to keep it from being overpowered is to give the spell 2 effects: the first is a simple Damage Health 10 points on target, then the next is the Brooling's spawn ability. I'd like to script the spell to detect if it kills its target, but I"m not sure how. Here's what I'm using for the moment:

Scriptname BroodlingSpawnScriptBegin SpcripEffectStart   kill   Placeatme SpellEffectBroodling 2   endifend


And the Broodlings themselves have a very simple script that makes them disappear on death:
Scriptname BroodlingDeathScriptBegin OnDeath   Disableendifend


Frankly, the Broodlings are too weak to even bother with their timer; all I want to do is rid the spell of its OHK effect. My idea for a possible workaround is to add a "broodling egg" or some strange item like that, that detects its owners death and deletes itself, spawning a broodling at the same time. It'd give the spell a nice stacking effect if it had to be done.
User avatar
Alisia Lisha
 
Posts: 3480
Joined: Tue Dec 05, 2006 8:52 pm

Post » Fri Sep 10, 2010 8:10 am

Why not use GetActorValue Health? Set that if the health is 0 (thus is dead) create a broodling
User avatar
Lil'.KiiDD
 
Posts: 3566
Joined: Mon Nov 26, 2007 11:41 am

Post » Fri Sep 10, 2010 1:09 pm

That makes sense...I tried that but i was using "GetHealth"...still new to the scripting language. I'll try that, thanks.
User avatar
glot
 
Posts: 3297
Joined: Mon Jul 17, 2006 1:41 pm

Post » Fri Sep 10, 2010 10:35 am

I think GetActorValue gives the maximum, not the current. The OBSE function GetActorValue2 returns the current health. I think something like this will work though:
The spell has 2 effects, Damage Health 10 on target, and this script effect for 1 second on target:

scriptname BroodlingSpawnScript

ref target

begin scripteffectfinish
set target to Getself
if target.getdead == 1
placeatme spelleffectbroodling 2
endif
end

What this would do is deal 10 damage, then after 1 second, the scripteffectfinish block triggers, checks if the target is dead, and if it is dead, it spawns 2 broodlings.
User avatar
Ria dell
 
Posts: 3430
Joined: Sun Jun 25, 2006 4:03 pm

Post » Fri Sep 10, 2010 4:06 am

I think GetActorValue gives the maximum, not the current. The OBSE function GetActorValue2 returns the current health. I think something like this will work though:
The spell has 2 effects, Damage Health 10 on target, and this script effect for 1 second on target:

scriptname BroodlingSpawnScript

ref target

begin scripteffectfinish
set target to Getself
if target.getdead == 1
placeatme spelleffectbroodling 2
endif
end

What this would do is deal 10 damage, then after 1 second, the scripteffectfinish block triggers, checks if the target is dead, and if it is dead, it spawns 2 broodlings.


No, GetAV returns the current, I've tested it myself in-game. To get the maximum you'll need GetBaseAV and a check for fortify enchantment/abilities.

Also, placeatme has a few http://cs.elderscrolls.com/constwiki/index.php/PlaceAtMe, mainly save game bloating.
As a rule of thumb, it's OK to use PlaceAtMe a finite number of times (i.e., a quest script that runs once and creates 20 PlaceAtMe objects). It's not OK if your script can potentially use PlaceAtMe an infinite number of times (i.e., a Summon spell that creates a new creature with PlaceAtMe, an activator/button that creates a new sword).


Might want to try other methods, for example, creating 20 broodlings in a dummy cell like test cells, and move them accordingly to the desired place. 20 broodlings by itself might be too many, you might want to limit the number of spawnable broodlings at once because too many characters on screen is not a good idea either. Imagine using Finger of The Mountain with 30 broodlings around
User avatar
Lindsay Dunn
 
Posts: 3247
Joined: Sun Sep 10, 2006 9:34 am

Post » Fri Sep 10, 2010 5:38 am

By the way why not use getDead ?
This is more accurate than checking the actor's health because there are circumstances when the actor can die without losing all of their health (such as through Kill).

The script is running on the target of the spell so a simple if getDead would suffice - no ? Maybe a gotcha on scripts not running on dead actors (EDIT : no prob - the script will run for at least a frame which is just fine) - but maybe this only for their scripts - worth testing anyway.
Use getDead.
User avatar
Nicole Elocin
 
Posts: 3390
Joined: Sun Apr 15, 2007 9:12 am

Post » Fri Sep 10, 2010 2:12 am

Oh sorry your right GetAV is current. I was thinking of SetAV and ModAV.
User avatar
Anna S
 
Posts: 3408
Joined: Thu Apr 19, 2007 2:13 am

Post » Fri Sep 10, 2010 5:45 am

I'm still confused...so will getdead work, then? Cause it'll make this a lot easier. I was using "OnDeath target" which didn't work....I still don't understand scripting in this game. Seems like a timer will work for this.
User avatar
Elisabete Gaspar
 
Posts: 3558
Joined: Thu Aug 31, 2006 1:15 pm

Post » Fri Sep 10, 2010 3:16 am

I'm still confused...so will getdead work, then? Cause it'll make this a lot easier. I was using "OnDeath target" which didn't work....I still don't understand scripting in this game. Seems like a timer will work for this.

Test it :) It should work :
begin scripteffectfinishif getdead == 1placeatme spelleffectbroodling 2endifend

Avoid placeatme though. Follow Raestloz idea with the dummy cell - and you will need some OBSE probably to check which broodling is already movedto the target...
User avatar
Eduardo Rosas
 
Posts: 3381
Joined: Thu Oct 18, 2007 3:15 pm

Post » Fri Sep 10, 2010 6:44 am

Avoid placeatme though. Follow Raestloz idea with the dummy cell - and you will need some OBSE probably to check which broodling is already movedto the target...


Maybe 2 different broodlings? spelleffectbroodling1 and spelleffectbroodling2, and when either dies they get sent back to the dummy cell and resurrected?

EDIT: Wait wait wait...nevermind I forgot to look at the link. So place 2 broodlings where the target is, then move them to a dummy cell...Then use a global variable to detect how many broodlings are currently placed maybe? I'll go test it out.:) Thank you everyone for your help!

PS: Any other SC spells you think would be good to see in Oblivion?
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm

Post » Fri Sep 10, 2010 3:11 am

Btw now that I come to think about it I am not sure placeatme actors cause bloat - I started a thread once - I had noticed OOO's golems are summoned via placeatme - they seemed to be cleared alright
User avatar
Lori Joe
 
Posts: 3539
Joined: Tue Jun 20, 2006 6:10 am

Post » Fri Sep 10, 2010 4:31 am

I don't know if this was in SC, but it seems like a good idea -
how about a spell that you cast at a dead body, which then spawns the broodlings?
I think you can script it to detect if the spell targets a corpse. Then you may also need to disable the corpse so it can't be exploited

and sorry for digressing, but what does bloating mean?
User avatar
Matt Fletcher
 
Posts: 3355
Joined: Mon Sep 24, 2007 3:48 am

Post » Fri Sep 10, 2010 2:25 pm

and sorry for digressing, but what does bloating mean?

http://cs.elderscrolls.com/constwiki/index.php/Common_Mistakes#Savegame_Bloating
User avatar
Chris Guerin
 
Posts: 3395
Joined: Thu May 10, 2007 2:44 pm

Post » Fri Sep 10, 2010 11:30 am

Btw now that I come to think about it I am not sure placeatme actors cause bloat - I started a thread once - I had noticed OOO's golems are summoned via placeatme - they seemed to be cleared alright

Note that using PlaceAtMe as a way to spawn extra enemies is fairly safe because the reference does get cleaned up once the actor is dead and the respawn time has elapsed.

It looks like that once an actor is killed the reference is cleared by the engine itself, so I think (I think) using placeatme for several actors that you expect to be killed is alright; using placeatme for activators is not
User avatar
Kelly Osbourne Kelly
 
Posts: 3426
Joined: Sun Nov 05, 2006 6:56 pm

Post » Thu Sep 09, 2010 11:27 pm

It looks like that once an actor is killed the reference is cleared by the engine itself, so I think (I think) using placeatme for several actors that you expect to be killed is alright; using placeatme for activators is not
Yes - and http://cs.elderscrolls.com/constwiki/index.php/Talk:Common_Mistakes
User avatar
Rebecca Dosch
 
Posts: 3453
Joined: Thu Jan 18, 2007 6:39 pm


Return to IV - Oblivion