AI Package or Something?

Post » Sat May 28, 2011 7:34 pm

I've been trying to create a new creature that upon getting to 15 or less health it will cast a spell on itself. I've tried most things I can think of... Scripting, AI package, etc, but it just will not cast that spell. I tried to change the effect of the spell to be benifical to see if it was being set to hostile, though nothing happened...
User avatar
louise fortin
 
Posts: 3327
Joined: Wed Apr 04, 2007 4:51 am

Post » Sat May 28, 2011 11:13 pm

try combat strategy, but it would really help if you told us what the script is
User avatar
Richard
 
Posts: 3371
Joined: Sat Oct 13, 2007 2:50 pm

Post » Sat May 28, 2011 7:01 pm

Just a simple script, though I didn't do anything.

scn AMexplodescript01

ref Creatureref

begin gamemode
if ( creatureref.getactorvalue health >= 15 )
creatureref.cast AMexplodeinfernal creatureref
endif
end

I also created an AI package that was cast magic on Getactorvalue Health >= 15
User avatar
ashleigh bryden
 
Posts: 3446
Joined: Thu Jun 29, 2006 5:43 am

Post » Sat May 28, 2011 11:07 pm

If you want the script to kick in when their health is 15 or less it needs to be < less than or = to 15 so:

creatureref.getactorvalue health <= 15 


What creature are you using? I read once that if your creature has no "cast" animation they can't cast spells no matter how you manipulate their script. Definitely something to rule out. :nod:
User avatar
HARDHEAD
 
Posts: 3499
Joined: Sun Aug 19, 2007 5:49 am

Post » Sat May 28, 2011 9:59 am

EDIT- Fixed
User avatar
Dewayne Quattlebaum
 
Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm

Post » Sat May 28, 2011 12:28 pm

I read once that if your creature has no "cast" animation they can't cast spells no matter how you manipulate their script. Definitely something to rule out. :nod:


This creature only has a cast self animation, would that stop it from using all magic spells? Even though mine is a self?
User avatar
Michelle Smith
 
Posts: 3417
Joined: Wed Nov 15, 2006 2:03 am

Post » Sat May 28, 2011 9:40 pm

The problem is your "creatureref" variable. Nothing sets it, so its always null, and so the cast function will always fail. Just take it out completely.
scn AMexplodescript01begin OnHit     if ( getactorvalue health <= 15 )        cast AMexplodeinfernal     endifend

This must be an object script on the creature, so all functions are implicitly referencing it. The "cast" should not need a target for an "on self" spell. Note that I changed it from "gamemode" to "onhit" otherwise you could get multiple hits in between passes of the script, and also it would constantly be checking while there's no combat going on.

However, this still won't work if your attacks on the creature do more than 15 damage (which is very likely to be the case later in the game) as on one hit, the health will be above 15 and the script won't do anything, and on the next, it will be 0 and the creature will already be dead, and unable to cast. You may want to revise that check to a percentage of max health (so that it levels with the creature), or add another mechanism for that in an "ondeath" block.
User avatar
Sarah Edmunds
 
Posts: 3461
Joined: Sat Jul 08, 2006 8:03 pm

Post » Sat May 28, 2011 8:26 pm

The problem is your "creatureref" variable. Nothing sets it, so its always null, and so the cast function will always fail. Just take it out completely.
scn AMexplodescript01begin OnHit     if ( getactorvalue health <= 15 )        cast AMexplodeinfernal     endifend

This must be an object script on the creature, so all functions are implicitly referencing it. The "cast" should not need a target for an "on self" spell. Note that I changed it from "gamemode" to "onhit" otherwise you could get multiple hits in between passes of the script, and also it would constantly be checking while there's no combat going on.

However, this still won't work if your attacks on the creature do more than 15 damage (which is very likely to be the case later in the game) as on one hit, the health will be above 15 and the script won't do anything, and on the next, it will be 0 and the creature will already be dead, and unable to cast. You may want to revise that check to a percentage of max health (so that it levels with the creature), or add another mechanism for that in an "ondeath" block.

darnet beat me to it
User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm

Post » Sat May 28, 2011 4:33 pm

You may want to revise that check to a percentage of max health (so that it levels with the creature)

And how would I create a percent? (Ima newb with this stuff, and most:D)
User avatar
john palmer
 
Posts: 3410
Joined: Fri Jun 22, 2007 8:07 pm


Return to IV - Oblivion