How can I give an ingredient late effects?

Post » Mon May 02, 2011 3:35 am

My character was born without the lactase enzyme, one of the curses of The Serpent. So I want to make things like cheese, eggs, yogurt and milk have effects to where when you "consume" them, they damage your luck and health a tiny bit after an hour, and that it gives you a brief message saying your stomach feels uncomfortable or something like that. I tried to do it like this:

Begin Milkif ( OnActivate == 1 )	MessageBox "Your stomach feels uncomfortable."endifEnd Milk


But that doesn't allow me to pick up the item if it's in the game world. And plus, that message box appears right away. I'll just make a new script any ways and give it a new name, like lactose_intolerance or something catchy.
So what I want is, to pick up an ingredient, when and if it's consumed, a game-hour passes and I get a message box and shortly after that, my luck is damaged and my health is damaged.

Oh, and what's the difference between Drain and Damage? I don't notice anything in game.
User avatar
Amiee Kent
 
Posts: 3447
Joined: Thu Jun 15, 2006 2:25 pm

Post » Mon May 02, 2011 2:42 am

Look at the script for the disease that gives Vampirism, Porphyric Hemophilia. That has a delayed effect of 72 game hours. That might help you.
User avatar
Markie Mark
 
Posts: 3420
Joined: Tue Dec 04, 2007 7:24 am

Post » Sun May 01, 2011 8:35 pm

You need to use the object to start a global script. You do not want to use OnActivate, you need to use OnPCEquip, and you need to use PCSkipEquip for consumables or the script won't run at all after you eat the ingredient. What you do is, start a global script OnPCEquip, and use the global script to remove 1 of the ingredient that you ate and make the eating sound (because you need to simulate eating it rather than allow your character to actually eat it). Make sure you add a do-once condition to the removal, since you need to continue running the script to produce the effects. You can then use the global script to start adding the effects as time passes.
User avatar
Adriana Lenzo
 
Posts: 3446
Joined: Tue Apr 03, 2007 1:32 am

Post » Sun May 01, 2011 5:02 pm

@CCNA The Vampire_Aundae script is too complicated for me to figure out and mimic.


@Stuporstar I don't know how to start a global script or how to begin doing what you're talking about. How would I set this script up? Could you lay it out for me? I could tweak the timers in it and what not. Thanks.
User avatar
butterfly
 
Posts: 3467
Joined: Wed Aug 16, 2006 8:20 pm

Post » Sun May 01, 2011 3:32 pm

I know globals can seem pretty intimidating at first, but they're quite handy and useful in a lot of applications.

First you want to do something like this with the ingredient:
Begin YouringredientscriptShort OnPCEquipShort PCSkipEquipSet PCSkipEquip to 1 ;makes sure you don't actually eat the ingredient, because otherwise the script will stopIf ( OnPCEquip == 1 ) ;when you try to equip (eat) it, do this	Set OnPCEquip to 0	Set PCSkipEquip to 0	StartScript "Yourglobalscript"EndifEnd


So you've now started the global script by equipping the ingredient. Now you need to write the global script (don't try to save the first script before making the global script or it won't compile because it can't find the global script you're trying to start).

Begin YourglobalscriptShort doOnceif ( doOnce == 0 )	Playsound "eating" ; I forget the actual name of the sound file, put the correct one here	player->removeitem "your_ingredient" 1	set doOnce to 1endif;do all your other timing stuff;once it's all doneStopScript Yourglobalscript ;comment this part out the first time you try to save, because it can't find the script until you save it. Then uncomment this line and save again.End


That's all you need to do.
User avatar
Mrs shelly Sugarplum
 
Posts: 3440
Joined: Thu Jun 15, 2006 2:16 am

Post » Sun May 01, 2011 11:54 pm

I did save the first script but I didn't attach it to anything yet.
The sound is "eating", so you were right. Do you have to type .wav after it?

I'm thinking the best way to get the affects would be to add a spell to the players inventory. Like, player picks up item, decides to eat it a while later and then after an hour, the spell is added to their inventory. Should it be a curse instead? I'm not sure how spells and curses work. And I don't really know what the difference is between drain and damage as they both appear to do the same thing.

http://img532.imageshack.us/img532/586/testzk.jpg

When I add this spell using the console, it just adds it to my inventory. When I make it a curse, it continually lowers my health and luck arithmetically. minus 5 minus 5 minus 5...... until I'm dead. I don't want to make it a disease because then people will respond with "Please, I don't wish to catch whatever you have." How can I set this up so that when I eat X-ingredient, it'll put a spell/curse/whatever that will lower my health and luck by 5 points for an hour or so, but ONLY by 5 points. Like, say my luck is 50, after eating milk or drinking cheese, and after an hour's time of digestion, that is, my Luck will be 45 for the next hour. Not 45 then 40 then 35 then 30 then 25 then 20 then 15 then 10 then 5 then 0.... Is achieving this harder than what it seems?
Oh, and I can't forget about the message box that appears when this will happen too.
User avatar
Peetay
 
Posts: 3303
Joined: Sun Jul 22, 2007 10:33 am

Post » Mon May 02, 2011 12:56 am

You don't type .wav, you just reference the ID you get in the list in the sound menu.

Damage spells lower the max stat whereas drain spells lower the current stat. You want to use drain, not damage. Also, set the duration, but set the magnitude to 0 in the actual spell, and script the drain health effect instead. You can use GetHealthRatio to determine the percent that you want to drop the health, and stop the script from dropping health below that percentage. So:

If ( GetHealthRatio >= 0.95 ) ;95% health     ModHealth -1     Return ;make sure there's nothing else you want to do below this returnEndif


This will remove 1 health point per frame until it drops the player's health to 95%, and then it will stop.
User avatar
Charlie Sarson
 
Posts: 3445
Joined: Thu May 17, 2007 12:38 pm

Post » Mon May 02, 2011 2:28 am

Will that script have to be added into the Global script? I can't add a script to a spell. And all the dairy ingredients (cheese/yogurt/milk/butter) can only hold one script, and they'll all be using the same script. Hmm, I just realized that I have two scripts so far. Can you combine all three of these scripts into one?
User avatar
LittleMiss
 
Posts: 3412
Joined: Wed Nov 29, 2006 6:22 am

Post » Mon May 02, 2011 3:58 am

Not really. That would be added to the global script. You could use the global script to monitor the spell effect on the player, and when it wears off, stop the script. You only need two scripts, one on the ingredient to start the global script, and then the global script to do everything else.
User avatar
Gemma Flanagan
 
Posts: 3432
Joined: Sun Aug 13, 2006 6:34 pm

Post » Sun May 01, 2011 8:34 pm

I don't know how global scripts work. Do you attach them to anything, like an activator? Or do you just create it and the computer checks it because it exists in the game data?
User avatar
ezra
 
Posts: 3510
Joined: Sun Aug 12, 2007 6:40 pm

Post » Sun May 01, 2011 8:26 pm

No, you can target them by using "object_ID"->StartScript "Yourglobalscript" or target it to an npc in dialogue, but otherwise they are free-floating. You start them with the StartScript command, and stop them with the StopScript command. You don't attach them to an object at all, or else it becomes a local script and it works differently. What you want to use is a non-targeted script, so just use the StartScript command in your ingredient script (attached to the ingredient) like I posted above, and make it stop itself later.
User avatar
Baylea Isaacs
 
Posts: 3436
Joined: Mon Dec 25, 2006 11:58 am

Post » Sun May 01, 2011 6:43 pm

I tried to set up that global script but it says "eating" isn't found. But you can clearly see that "eating" is in the Sound folder, subfolder Fx. So what gives?

http://img517.imageshack.us/img517/504/86667597.jpg
User avatar
dav
 
Posts: 3338
Joined: Mon Jul 30, 2007 3:46 pm

Post » Sun May 01, 2011 2:52 pm

It could be I got the name wrong. It may be "eating" in the .wav file, but it might have been given a different ID in the CS. Go to sounds in the file menu of the CS and look for the sound there and what they call it.

(unfortunately, half the time I post here I'm at work and can't look this stuff up)
User avatar
Your Mum
 
Posts: 3434
Joined: Sun Jun 25, 2006 6:23 pm

Post » Sun May 01, 2011 4:43 pm

Ah, I found it. It was the swallow sound, not the eating sound.

Looking at this jpeg, is this one global script just pertaining to one item? Because there are twelve ingredients that are dairy related. And this is just using NOM v2.14. When v2.2 comes out, I'll just change the IDs in the script. But my question is, do I need to put all 12 of these items to be removed in the script? And the point of removing them from the player is that when the player eats them, they are gone from the inventory, right?

http://img22.imageshack.us/img22/3121/11735011.jpg


    NOM_food_cheese
    NOM_food_cheese2
    NOM_food_cheese3
    NOM_food_cheese_pie
    NOM_food_egg2
    NOM_food_egg_boil
    NOM_food_omelette
    NOM_food_omelette_crab
    1_milk_cow
    1_milk_goat
    food_kwama_egg_01
    food_kwama_egg_02



Oh, and should _Ingredient_Global_Script be in quotes? I'm thinking it should be StopScript "_Ingredient_Global_Script" since the local script has the startscript command in quotes. You didn't put it in quotes so I was wondering about that. I put quotes in this one below.




Begin _Ingredient_Global_ScriptShort doOnceif ( doOnce == 0 )	Playsound "swallow"	player->removeitem "NOM_food_cheese" 1	player->removeitem "NOM_food_cheese2" 1	player->removeitem "NOM_food_cheese3" 1	player->removeitem "NOM_food_cheese_pie" 1	player->removeitem "NOM_food_egg2" 1	player->removeitem "NOM_food_egg_boil" 1	player->removeitem "NOM_food_omelette" 1	player->removeitem "NOM_food_omelette_crab" 1	player->removeitem "1_milk_cow" 1	player->removeitem "1_milk_goat" 1	player->removeitem "food_kwama_egg_01" 1	player->removeitem "food_kwama_egg_02" 1	set doOnce to 1endif;do all your other timing stuff;once it's all doneStopScript "_Ingredient_Global_Script"End


Would that work for all the items all the time, not mattering which one I picked up, whether I consumed all of them at once or one each day or whatever?

Oh, and there's a section called Globals in the CS. Do I need to do anything with that? It's under the Gameplay tab.
User avatar
Jessie Butterfield
 
Posts: 3453
Joined: Wed Jun 21, 2006 5:59 pm

Post » Sun May 01, 2011 11:45 pm

The globals section is for global variables. There is one problem with your script though. It will remove one of each of all the ingredients in the list (even if the player doesn't have them, creating a negative encumberance bug). You need to flag which ingredient type was eaten. The most stable way to do this is using a single global variable. Go to that globals tab and select new, then type in a unique name for the global variable and hit save. It will default to a short variable at zero, which is what you want.

Now, you need to set the global variable to a number in the local script for each ingredient. So you need to make a different local script for each ingredient. Set the global variable by using "set yourglobalvariable to #" and set it to a different number in each script. Then you have to remember what number equals which ingredient eaten, and if that number matches, remove that ingredient.

If ( yourglobalvariable == 1 )     RemoveItem "firstingredienttypeID" 1endif


and continue down the line for each ingredient. Then, at the bottom of the doOnce check, just before you set doOnce to 1, set the global variable back to 0.

Also, you don't need to put the script name in quotes, but it doesn't hurt either.
User avatar
Ruben Bernal
 
Posts: 3364
Joined: Sun Nov 18, 2007 5:58 pm

Post » Mon May 02, 2011 3:06 am

I get what you're saying about making a different number for each one, but why are we doing this remove global script stuff any ways? I mean, the ingredient already disappears from my inventory when I eat it.
User avatar
Queen of Spades
 
Posts: 3383
Joined: Fri Dec 08, 2006 12:06 pm

Post » Mon May 02, 2011 2:15 am

Ah does it? I had the problem with potions being consumed before my script finished, so I had to do the manual removing. If it's not necessary, then don't worry about it.
User avatar
Portions
 
Posts: 3499
Joined: Thu Jun 14, 2007 1:47 am

Post » Mon May 02, 2011 5:01 am

Man, I'm finally getting back at this after being away for a couple weeks.

Stuporstar, is this what you mean? Or will I have to make 10 different local scripts and attach each one to each ingredient?

Left side is the local script and the right side is the global script. My global variable is named "Lactose_Global_Variable"

http://img8.imageshack.us/img8/8030/35685901.jpg
User avatar
Chelsea Head
 
Posts: 3433
Joined: Thu Mar 08, 2007 6:38 am

Post » Sun May 01, 2011 6:12 pm

Did you try it without using skip equip? If you can get the global script to start and have the player eat the ingredient normally, that would be the best. That would mean you don't have to remove the ingredient manually.
User avatar
Eve Booker
 
Posts: 3300
Joined: Thu Jul 20, 2006 7:53 pm

Post » Sun May 01, 2011 6:18 pm

Well as of right now, the ingredients don't have the lactose intolerance effects. So I can eat them normally, just like any other food, and they are removed. You know, just like in vanilla Morrowind when you eat something, it disappears. I'm pretty lost right now on what I'm doing. I don't know how to set up timers and the draining of the health. It's like, I have all these pieces of scripting to put into one script but I don't know in what order or how it should be done. This is gonna take me so long to figure out because this scripting is really complicated.



http://img218.imageshack.us/img218/4223/77041026.jpg

The GetHealthRatio is causing a problem and won't let me save.

So why do I need that Global script again? And does it do that the local script doesn't do?
User avatar
Makenna Nomad
 
Posts: 3391
Joined: Tue Aug 29, 2006 10:05 pm

Post » Mon May 02, 2011 4:47 am

You need the global script mainly to track the effects that happen after the ingredient is eaten. If you don't have one, the ingredient will just be gone and nothing will happen.
User avatar
Sammygirl500
 
Posts: 3511
Joined: Wed Jun 14, 2006 4:46 pm

Post » Mon May 02, 2011 12:07 am

I'm still lost. Where do I go from here? http://img694.imageshack.us/img694/5170/70335573.jpg

My local script is:

Begin _Ingredient_ScriptShort OnPCEquipShort PCSkipEquipSet PCSkipEquip to 1 ;makes sure you don't actually eat the ingredient, because otherwise the script will stopIf ( OnPCEquip == 1 ) ;when you try to equip (eat) it, do this	Set OnPCEquip to 0	Set PCSkipEquip to 0	StartScript "_Ingredient_Script"EndifEnd





and my global script is:

Begin _Ingredient_Global_ScriptShort doOnceif ( doOnce == 0 )	Playsound "swallow"	player->removeitem "NOM_food_cheese" 1	set doOnce to 1endif;do all your other timing stuff;once it's all doneStopScript _Ingredient_Global_ScriptEnd



Do I want to keep that player->remove item stuff and just repeat that down the line for all the items?
How do I write the timing script part? I want the effects to start 1 hour after consuming.
User avatar
Alexis Estrada
 
Posts: 3507
Joined: Tue Aug 29, 2006 6:22 pm

Post » Sun May 01, 2011 8:29 pm

Ok, the first thing I want you to do is just a test, because we want to know for sure if the removal stuff is necessary. I want you to comment out all the skip equip stuff like this:

Begin _Ingredient_ScriptShort OnPCEquip;Short PCSkipEquip;Set PCSkipEquip to 1 ;makes sure you don't actually eat the ingredient, because otherwise the script will stopIf ( OnPCEquip == 1 ) ;when you try to equip (eat) it, do this	Set OnPCEquip to 0	;Set PCSkipEquip to 0	StartScript "_Ingredient_Script"EndifEnd


This should make the player eat the ingredient. Then I want you to comment out the stopscript in the global:

Begin _Ingredient_Global_ScriptShort doOnceif ( doOnce == 0 )	Playsound "swallow"	player->removeitem "NOM_food_cheese" 1	set doOnce to 1endif;do all your other timing stuff;once it's all done;StopScript _Ingredient_Global_ScriptEnd


Now eat the ingredient in the game and open the console. Check if the global script is running. If you ate the ingredient and the script is still running, then you don't need to do any removal via script. I just want to test this and know for sure before you add a lot of stuff you don't need to.
User avatar
Stephanie Kemp
 
Posts: 3329
Joined: Sun Jun 25, 2006 12:39 am

Post » Mon May 02, 2011 1:39 am

I'm not really sure how to check to see if the script is running in the console. I just typed startscript "_ingredient_script" and below that I typed startscript "_ingredient_global_script" and it made that swallowing sound. When I typed it again and again, it didn't make that sound. But I picked up the cheese item in my inventory and then ate it and it made the sound and all that. So it seems fine to me. How else do I check to see if a script is running?
User avatar
Laura Wilson
 
Posts: 3445
Joined: Thu Oct 05, 2006 3:57 pm

Post » Sun May 01, 2011 10:27 pm

You don't want to type startscript in the console for either script. Load the game again, and just eat the ingredient. Then open the console and type sv. This will list all the global scripts currently running. Do this after commenting out the sections that I posted above. If "_ingredient_global_script" is not there after eating the ingredient, then it's not working.
User avatar
Rachel Hall
 
Posts: 3396
Joined: Thu Jun 22, 2006 3:41 pm

Next

Return to III - Morrowind