Ingrediant cast a spell on player once eaten

Post » Sat May 28, 2011 7:49 am

Hello! I would like a to an ingrediant cast a custom spell on the player once eaten. Is this possible and if so, would someone please be so kind as to enlighten me? Thank you for your time!
User avatar
Big mike
 
Posts: 3423
Joined: Fri Sep 21, 2007 6:38 pm

Post » Fri May 27, 2011 9:50 pm

I don't know scripting (I am asking somethign similar in another post on this forum) but I can reassure you it is possible.
User avatar
Nina Mccormick
 
Posts: 3507
Joined: Mon Sep 18, 2006 5:38 pm

Post » Sat May 28, 2011 1:29 am

I don't know scripting (I am asking somethign similar in another post on this forum) but I can reassure you it is possible.



Do you have an answer to that post because I would really like to know how to accomplish this? From what I understand, a spell needs to be cast from a reference (http://cs.elderscrolls.com/constwiki/index.php/Talk:Cast) and cannot be cast from a script effect in the ingredients effect. I am really not sure how to go about this, because in my mind the reference would have to be near the players location to cast?

Does anyone have experience/knowledge about this, please? Peace!
User avatar
[Bounty][Ben]
 
Posts: 3352
Joined: Mon Jul 30, 2007 2:11 pm

Post » Fri May 27, 2011 7:20 pm

Add a scripted effect to the ingredient and attach what script you want. If you're wanting the eating of the ingredient to cause some sort of visual effect, like lightning striking the player from above, you would need to use a persistent, named, activator which is moved above player to act as the source of this visual effect. For magic effect scripts, the thing which is the target of that effect (in this case, the one who ate it) is what the script is being run on, and thus can be acquired with a getself function. Meaning that the mentioned lightning effect script would look something like

scn aoihdaoihref targetshort zposbegin scripteffectstartset target to getself.moveto targetset zpos to target.getpos zset zpos to zpos + 256.cast  targetend


Replacing the . with an invisible activator, and replacing with a spell containing an empty script effect (no script attached) with the desired visual. If you need the script to handle effects that you want present from consumption (which aren't from some other spell effect on the consumed object) you would need to add these to the script above within a scripteffectupdate block.
User avatar
MISS KEEP UR
 
Posts: 3384
Joined: Sat Aug 26, 2006 6:26 am

Post » Fri May 27, 2011 9:37 pm

It seems to me that this is less complicated than the effects of eating the heart from the Mehrunes Razor DLC. Not only does that have a direct effect but it adds a disease or two (Porphyric Hemophilia, Cannibal's Prion) as well as increasing Infamy.
User avatar
Dylan Markese
 
Posts: 3513
Joined: Sat Dec 01, 2007 11:58 am

Post » Sat May 28, 2011 1:34 am

It seems to me that this is less complicated than the effects of eating the heart from the Mehrunes Razor DLC. Not only does that have a direct effect but it adds a disease or two (Porphyric Hemophilia, Cannibal's Prion) as well as increasing Infamy.

Well, the thing is that the OP doesn't really mention what exactly he's wanting to do, so we're really just guessing. However, the effect you mention is really just a scripted effect on the ingredient that applies those things directly and possibly triggers a quest update (didn't play DLC). For that, it's very simple scripting with only 1 effect.
User avatar
Chris Ellis
 
Posts: 3447
Joined: Thu Jul 26, 2007 10:00 am

Post » Sat May 28, 2011 8:44 am

Add a scripted effect to the ingredient and attach what script you want. If you're wanting the eating of the ingredient to cause some sort of visual effect, like lightning striking the player from above, you would need to use a persistent, named, activator which is moved above player to act as the source of this visual effect. For magic effect scripts, the thing which is the target of that effect (in this case, the one who ate it) is what the script is being run on, and thus can be acquired with a getself function. Meaning that the mentioned lightning effect script would look something like

scn aoihdaoihref targetshort zposbegin scripteffectstartset target to getself.moveto targetset zpos to target.getpos zset zpos to zpos + 256.cast  targetend


Replacing the . with an invisible activator, and replacing with a spell containing an empty script effect (no script attached) with the desired visual. If you need the script to handle effects that you want present from consumption (which aren't from some other spell effect on the consumed object) you would need to add these to the script above within a scripteffectupdate block.



Thank you for your reply. I could not compile the script however, as it gave me an error with the "moveto" line not being valid. By you do mean the activator's reference id as it appears in the render window? I should note that the custom spells are not hostile and are usually composite ( Ex:cure disease, fortify health, resist fire). I am also not sure what you mean by invisible activator? Thank you.
User avatar
Marina Leigh
 
Posts: 3339
Joined: Wed Jun 21, 2006 7:59 pm

Post » Fri May 27, 2011 7:41 pm

Thank you for your reply. I could not compile the script however, as it gave me an error with the "moveto" line not being valid. By you do mean the activator's reference id as it appears in the render window? I should note that the custom spells are not hostile and are usually composite ( Ex:cure disease, fortify health, resist fire). I am also not sure what you mean by invisible activator? Thank you.

No, that's not how that works. Place the activator somewhere in the game world (anywhere is fine, but a custom cell is generally best). Then double click on it in the Render Window. A new window will open with information about the placed activator. There is an empty field at the top labeled "Reference Editor ID". This is where you name the activator for the script. Give it a unique name (like IngredientCasterRef or something). Now check the "Persistent Reference" box towards the bottom left corner of the window and click "Okay". Replace in your script with IngredientCasterRef (or whatever you named it) and the script will compile.
User avatar
Peter P Canning
 
Posts: 3531
Joined: Tue May 22, 2007 2:44 am

Post » Fri May 27, 2011 9:19 pm

I managed to get it to work!! I changed the script to this:

scn 17737WinterSporeSCRIPTref targetbegin scripteffectstartset target to getselfsource17737.moveto target   0,  0,  256source17737.cast 17737WinterSporeAb targetend


Currently it works perfectly! I consume the ingredient and it gives me the effect of the spell like a potion, minus the potion sounds, which is what I was really after all along. I am curious if anyone sees any problems with using this script? Thank you for your assistance-Peace!
User avatar
Angel Torres
 
Posts: 3553
Joined: Thu Oct 25, 2007 7:08 am

Post » Sat May 28, 2011 6:52 am

scn 17737WinterSporeSCRIPTref targetbegin scripteffectstartset target to getselfsource17737.moveto target   0,  0,  256source17737.cast 17737WinterSporeAb targetend

I am curious if anyone sees any problems with using this script? Thank you for your assistance-Peace!

While it might not cause an error in this case, you should NEVER start any form or reference name with numbers. You should ALWAYS use atleast 2-3 letters to start anything you define in the CS. The reason is because in several cases, the CS doesn't recognize that you're using a editor name, and thinks you're using a hexadecimal Form ID. You won't get an error with this, but it can break your scripts. You should also try to name your scripts and references as something descriptive enough so that in 2 years when you come back to fix the mod, you can have some hope of figuring out what the hell does what.
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Sat May 28, 2011 9:13 am

While it might not cause an error in this case, you should NEVER start any form or reference name with numbers. You should ALWAYS use atleast 2-3 letters to start anything you define in the CS. The reason is because in several cases, the CS doesn't recognize that you're using a editor name, and thinks you're using a hexadecimal Form ID. You won't get an error with this, but it can break your scripts. You should also try to name your scripts and references as something descriptive enough so that in 2 years when you come back to fix the mod, you can have some hope of figuring out what the hell does what.



Yeah, that's what I was affraid of. It was nice for ease of use in the CS, but seeing as how it was conflicting with the earlier script I can see this being a problem. The bad thing is, there are hundreads of references in my mod which use this prefix. Thanks for your input-Peace!
User avatar
Spooky Angel
 
Posts: 3500
Joined: Thu Aug 10, 2006 5:41 pm


Return to IV - Oblivion