Maybe someone can tell me...script... - by 37637598
cyrano on 27/8/2004 at 21:10
You really seemed to be married to some of your ideas. I understand and respect that; I can be the same way. However, I recommend that you actually compile your script and test it. Perhaps then you will be able to understand some of the obstacles that I have detailed. Even scripts that have no errors don’t always run as expected, and still require tweaking. I think that having a number of objects representing different quantities of stored water (Mkb_water001, Mkb_water002, etc.) unnecessarily complicates matters. If this was my project (and my initials were MKB), I would approach it this way:
A well, with a local script attached.
Start _Mkb_WellScript
; short Mkb_UnitsOWater ; global variable, stores amount of water player is carrying
if ( OnActivate == 1 ) ; when you activate well by pressing space bar…
.....if ( GetItemCount “Mkb_bota_bag” > 0 ) ; check to see you have water storage
..........if ( UnitsOWater < 4 ) ; if it is not full…
...............set UnitsOWater to 4 ; fill bota bag
..........endif
.....endif
endif
End _Mkb_WellScript
A Bota bag, (or whatever you want to use for water storage).
I recommend that you take an clothing item like a ring or amulet (not pants or you will end up naked every time you take a drink—not an unexpected outcome if you are drinking something other than water, but that is a different mod). Give it a new ID and name (Mkb_bota_bag and Bota bag, respectively), save it as a NEW object!!!!, and replace the .NIF and .tga with that of your Boda bag.
This is now an equipable item, that will allow you to simulate the drinking of water. When it is equipped, the game engine will treat it as if it was a ring (or amulet). It will occupy a ring slot and displace one of your rings if you are fully equipped. The script will force un-equip the Boda bag/ring (that will prevent the script from executing more than one cycle—more than one swig of water), but you will have to re-equip other rings yourself. I would not attached the main script to this item. To work most effectively, your main script needs to be global. However, you could incorporate the main script with the one attached to the Boda bag if you wish. Here is the script attached to the Boda bag:
Begin _Mkb_BotaBag
; short Mkb_UnitsOWater ; global variable
; short Mkb_Thirsty ; global variable
; short Mkb_TakeAPiss ; global variable
; short Mkb_DehydrationState ; global variable
short OnPCEquip ; local variable to detect if Bota bag is used
short button
if ( OnPCEquip == 1 ) ; when you drag it onto you character from inventory…
.....MessageBox, “Have a drink?”, “Yes”, “No”
.....set button to GetButtonPressed
.....if ( button == -1 ) ; if no button is pressed yet…
..........return
.....elseif ( button == 1 ) ; player chooses not to drink
..........player->AddItem, “common_ring_01”, 1 ; this force un-equips the Boga bag
..........player->AddItem, “common_ring_02”, 1
..........player->Equip “common_ring_01” ; this could be a problem, it seems to require Tribunal.
..........player->Equip “common_ring_021”
..........player->RemoveItem “common_ring_01”, 1
..........player->RemoveItem “common_ring_02”, 1
..........return
.....else ; player takes a drink
..........if (Mkb_UnitsOWater > 0 ) ; if there is water in the Bota bag…
...............set Mkb_UnitsOWater to ( Mkb_UnitsOWater – 1 ) ; …consume one unit
...............set Mkb_Thirsty to ( Mkb_Thirsty – 1 ) ; decrease thirst level…
...............if ( Mkb_Thirsty < 0 ) ; …but not below zero
....................set Mkb_Thirsty to 0
...............endif
...............set Mkb_DehydrationState to ( Mkb_DehydrationState – 0.25 )
...............if ( Mkb_DehydrationState < 0 )
....................set Mkb_DehydrationState to 0
...............endif
...............set Mkb_HoursElaped to (Mkb_HoursElapsed – 4 )
...............if ( Mkb_HoursElapsed < 0 )
....................set Mkb_HoursElapsed to 0
...............endif
...............set Mkb_TakeAPiss to ( Mkb_TakeAPiss + 1 )
...............if ( UnitsOWater == 3 )
....................MessageBox, “Bota bag is three-quarters full”, “ok”
...............elseif ( UnitsOWater == 2 )
....................MessageBox, “Bota bag is half full”, “ok”
...............elseif ( UnitsOWater == 1 )
....................MessageBox, “Bota bag is one-quarter full”, “ok”
...............elseif ( UnitsOWater == 0 )
....................MessageBox, “Bota bag is empty”, “ok”
...............endif
...............player->AddItem, “common_ring_01”, 1
...............player->AddItem, “common_ring_02”, 1
...............player->Equip “common_ring_01”
...............player->Equip “common_ring_021”
...............player->RemoveItem “common_ring_01”, 1
...............player->RemoveItem “common_ring_02”, 1
...............return
..........elseif ( Mkb_UnitsOWater == 0 )
...............MessageBox, “*Damn, I’m out of water*”, “ok”
...............player->AddItem, “common_ring_01”, 1
...............player->AddItem, “common_ring_02”, 1
...............player->Equip “common_ring_01”
...............player->Equip “common_ring_021”
...............player->RemoveItem “common_ring_01”, 1
...............player->RemoveItem “common_ring_02”, 1
...............return
..........endif
.....endif
endif
End _Mkb_BotaBag
Main Global Script
Begin _Mkb_DehydrationEffects
; short Mkb_UnitsOWater ; global variable, stores amount of water player is carrying
; float Mkb_PreviousHour ; global variable, stores last time script executed
; short Mkb_PreviousDay ; gobal variable, stores last day script executed
; short Mkb_HoursElapsed ; global variable, stores hours passed without a drink
; short Mkb_Thirsty ; global variable, stores state of thirst
; short Mkb_TakeAPiss ; global variable, stores state of bladder
; short Mkb_DehydrationState ; global variable, stores state of dehydration (serious!)
short doOnce ; local variable
short state ; local variable
if ( doOnce == 0 ) ; set initial conditions
.....set Mkb_PreviousHour to GameHour ; GameHour is a global variable
.....set Mkb_PreviousDay to DaysPassed ; DaysPassed is a Tribunal global variable. If you do not have Tribunal
.....and/or you do not what Tribunal dependency,use Day instead, but it may require a workaround.
.....set Mkb_HoursElapsed to 0
.....set Mkb_Thirsty to 0
.....set Mkb_TakeAPiss to 0
.....set Mkb_DehydrationState to 0
.....set doOnce to 1 ; only executes once
endif
if ( Mkb_PreviousDay == DaysElasped ) ; same day
.....if ( GameHour - Mkb_PreviousHour < 1 ) ; do not execute global continuously, only
.....; once for each hour that passes (saves wear and tear on FPS)
..........return
.....else
..........set state to 1
.....endif
else
.....set Mkb_PreviousHour to (Mkb_PreviousHour – 24 )
.....set Mkb_PreviousDay to (Mkb_PreviousDay + 1 )
.....return
endif
if ( state == 1 )
.....if ( GameHour – Mkb_PreviousHour < 1 )
..........set state to 2
.....else
..........set HoursElasped to ( HoursElapsed + 1 )
..........set Mkb_PreviousHour to ( Mkb_PreviousHour + 1 )
..........return
.....endif
elseif ( state == 2 ) ; establishes level of thirst
.....if (Mkb_HoursElapsed >= 4 )
..........set Mkb_Thirsty to ( Mkb_Thirsty + 1 )
..........set Mkb_HoursElapsed to ( Mkb_HoursElapsed – 4 )
..........if ( Mkb_Thirsty >= 3 )
...............MessageBox, “I can’t recall the last time I was so thirsty”, “ok”
..........elseif ( Mkb_Thirsty == 2 )
...............MessageBox, “I am very thirsty!”, “ok”
..........elseif ( Mkb_Thirsty == 1 )
...............MessageBox, “I’m feeling thirsty”, “ok”
..........endif
..........return
.....else
..........set state to 3
.....endif
elseif ( state == 3 ) ; established level of dehydration
.....if ( Mkb_Thirsty >= 4 )
..........set Mkb_DehydrationState to ( Mkb_DehydrationState + 1 )
..........set Mkb_Thirsty to ( Mkb_Thirsty – 4 )
..........return
.....else
..........set state to 4
.....endif
elseif ( state == 4 ) ; consequences of not staying hydrated
.....if ( Mkb_DehydrationState >= 5 ) ; terminally dehydrated
..........player->setHealth, 0 ; dead
..........return
.....elseif ( Mkb_DehydrationState >= 3.5 ) ; severely dehydrated
..........player->AddSpell, Mkb_Dehydration_04
..........player->RemoveSpell, Mkb_Dehydration_03
..........player->RemoveSpell, Mkb_Dehydration_02
..........player->RemoveSpell, Mkb_Dehydration_01
..........MessageBox “You are so dehydrated can barely function”, “ok…not really”
..........set state to 0
..........return
.....elseif ( Mkb_DehydrationState >= 2.5 ) ; seriously dehydrated
..........player->AddSpell, Mkb_Dehydration_03
..........player->RemoveSpell, Mkb_Dehydration_04
..........player->RemoveSpell, Mkb_Dehydration_02
..........player->RemoveSpell, Mkb_Dehydration_01
..........MessageBox “You are experiencing hallucinations from dehydration”, “ok…cool”
..........set state to 0
..........return
.....elseif ( Mkb_DehydrationState >= 1.5 ) ; somewhat dehydrated
..........player->AddSpell, Mkb_Dehydration_02
..........player->RemoveSpell, Mkb_Dehydration_04
..........player->RemoveSpell, Mkb_Dehydration_03
..........player->RemoveSpell, Mkb_Dehydration_01
..........MessageBox “You are weary from dehydration”, “ok…sorta”
..........set state to 0
..........return
.....elseif ( Mkb_DehydrationState >= 0.5 ) ; slightly dehydrated
..........player->AddSpell, Mkb_Dehydration_01
..........player->RemoveSpell, Mkb_Dehydration_04
..........player->RemoveSpell, Mkb_Dehydration_03
..........player->RemoveSpell, Mkb_Dehydration_02
..........MessageBox “Dehydration is taxing your fatigue”, “ok”
..........set state to 0
..........return
.....endif
endif
End _Mkb_DehydrationEffects
Drinking water will mollify these effects, but it will only take effect when this script runs again (at lease one hour). I included just space-holding spell effects, you already know what you want to do there. From what I hear, your spells may have to be made as abilities and diseases in order to continually affect the player. You have already worked out how to handle the expelling of fluids; your script for that can access and modify the Mkb_TakeAPiss global variable. This script runs when menus are open, which means that during wait, sleep and fast travel, dehydration effects will still take place. Again, drinking water before travel and then again immediately after travel, will head off the bad effects. This could be changed for sleeping (using the check GetPCSleep), but I don’t know if it could be done with the other cases. It is not unrealistic, so I am comfortable leaving it as it is for now. [ I just re-read your post and this is how you would prefer to handle sleep. :) ]The main script will execute once each hour when the player is not sleeping or fast traveling, so the exotic checks (entire days of time passing), will rarely be executed, but they are there just in case.
These scripts are untested, there could be bugs, but I am confident they are solvable. If you decide to go this route, let me know if it doesn’t compile or run properly, and I will help you solve the problem. If you go with a global script, you know that it has to be triggered. That can be done at the console, but I am certain that you can come up with a method of starting the script in the normal flow of play. If you want the main script to be local, we can discuss that further. You don’t have to wait around for your graphics to be incorporated. You can attach the script to anything that is equipable (e.g. ring) if you want to test the code.
37637598 on 28/9/2004 at 22:58
Thank you cyrano for the reply. I've entered the script into the editor. there were some errors (Due to difference in font, and various other reasons), but i'm at work right now so i don't remember what they were. i just mainly wanted to thank you for the help, and to let you know that i still exist. i haven't replied for so long because my internet is down! You're right... I am married to my ideas, but with any marriage, I beleive that it should be open to change :ebil: :ebil: . The main reason is, I HATE MORROWIND!!!!!!!! I am planning to make it 1000 times better! Thats why I have so much ambition! I have had my 2+ years worth of playing, and loving the game, but when that game gets old, IT GETS OLD!!! When i'm finished with it, I'm gonna say, HAHA!!! to bethesda. I truley beleive so far, it's already 100 times better! I'll put up a game-play video of the plugin, soon...
Does anyone know the sampling frequency used by bethesda for the mp3 format voice files??? I'm trying to make new dialogue, but can't figure out the right freq! when I try it with the files I've already made, the npc's dont even say anything. HELPmuchNEEDED!
thank you again everybody... 37637598-out.
37637598 on 2/10/2004 at 00:12
The problem was the whole 'MenuMode' bug. I fixed it... I think...
short Drinking
short AskQuestion
if ( OnPCEquip == 1 )
set Drinking to 10
endif
if ( Drinking == 10 )
if ( MenuMode == 0 )
Set AskQuestion to 1
Set Drinking to 0
endif
endif
if ( AskQuestion == 1 )
Set Button to GetButtonPressed
Messagebox, "Do you want to drink it?" "yes" "no"
if ( Button == 1 )
Set THIRSTY to 0 and do all the other shit!!!
this is just the basic idea... not the actual script. :thumb:
37637598 on 8/10/2004 at 03:37
There are still errors. when I test the script (in game), it does a message box constantley!
&************************************
Begin _Mkb_BotaBag
short state
short ask
short OnPCEquip ; local variable to detect if Bota bag is used
short button
if ( OnPCEquip == 1 ) ; when you drag it onto you character from inventory
set state to 10
endif
if ( state == 10 )
if ( MenuMode == 0 )
Set ask to 1
set state to 0
endif
endif
if ( ask == 1 )
MessageBox, "Have a drink?", "Yes", "No"
set button to GetButtonPressed
set ask to 0
endif
if ( button == 1 ) ; if no button is pressed yet
return
elseif ( button == 0 ) ; player chooses to drink
if ( Mkb_UnitsOWater > 0 ) ; if there is water in the Bota bag
set Mkb_UnitsOWater to ( Mkb_UnitsOWater - 1 ) ; consume one unit
set Mkb_Thirsty to 0
player->AddItem, "common_ring_01", 1 ; this force un-equips the Boga bag
player->AddItem, "common_ring_02", 1
player->Equip "common_ring_01" ; this could be a problem, it seems to require Tribunal.
player->Equip "common_ring_02"
player->RemoveItem "common_ring_01", 1
player->RemoveItem "common_ring_02", 1
set Mkb_DehydrationState to ( Mkb_DehydrationState - 0.25 )
if ( Mkb_DehydrationState < 0 )
set Mkb_DehydrationState to 0
endif
set Mkb_HoursElapsed to ( Mkb_HoursElapsed - 4 )
if ( Mkb_HoursElapsed < 0 )
set Mkb_HoursElapsed to 0
endif
set Mkb_TakeAPiss to ( Mkb_TakeAPiss + 1 )
elseif ( Mkb_UnitsOWater >= 3 )
MessageBox, "Bota bag is three-quarters full", "ok"
return
elseif ( Mkb_UnitsOWater == 2 )
MessageBox, "Bota bag is half full", "ok"
return
elseif ( Mkb_UnitsOWater == 1 )
MessageBox, "Bota bag is one-quarter full", "ok"
return
elseif ( Mkb_UnitsOWater == 0 )
MessageBox, "*Damn, I’m out of water*", "ok"
player->AddItem, "common_ring_01", 1
player->AddItem, "common_ring_02", 1
player->Equip "common_ring_01"
player->Equip "common_ring_02"
player->RemoveItem "common_ring_01", 1
player->RemoveItem "common_ring_02", 1
return
set Mkb_UnitsOWater to -1
endif
endif
end
***********************************
it keeps messaging, "*Damn, I’m out of water*", "ok"
i'll work on it some more...
If you can think of a way to prevent this messagebox from constantley going, please tell me. :thumb:
Striker on 8/10/2004 at 09:27
You "Return" before you set the variable to -1.
cyrano on 8/10/2004 at 18:37
Quote Posted by 37637598
There are still errors. when I test the script (in game), it does a message box constantley!
***********************************
if ( button == 1 ) ; if no button is pressed yet
return
***********************************
it keeps messaging, "*Damn, I'm out of water*", "ok"
i'll work on it some more...
If you can think of a way to prevent this messagebox from constantley going, please tell me. :thumb:
This line of code may be the problem. It should read: " if ( button == -1) ". I suspect what happened is the script wasn't told to wait for input (the mouse click on a button), and the "else" condition is being satisfied every frame that the script runs, so it keeps pasting the message box. Make that line fix and try it. It is possible there are other bugs, but I don't have time at this moment to examine it. Post if problems remain.
37637598 on 21/10/2004 at 00:17
i got it all fixed and workin.//
now i'm working on a Lute Playing Script. i hope you're not getting annoyed by me postin so-much about scripting... I'll PM you the lute script, (don't want to reveil to everyone my work until release date...) if you don't mind. it works, but I need some of your advice about song making on the lute. hope you can help, or someone else... either way. Thanks for all past help Cyrano :thumb:
cyrano on 22/10/2004 at 01:01
Certainly, send me a PM. It is probably better to communicate that way (or E-mail) since it is not likely anyone else in interested in this. Sound is not my forte, but I will be happy to look at what you have. By the way, congratulations on getting the script to work.
37637598 on 23/10/2004 at 03:01
Thanks! I'll PM you the site where you can download the sound files, and script.