Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

General Script Questions #1


WillieSea
 Share

Recommended Posts

@StarX - You have two (2) soul gems.

One is the 'empty' version that you check for on creature death.

The other is the 'full' version that contains the specific creatures soul.

I don't see what the problem here would be, you can have as many of each soulgem type as you want and it would not mess anything up.

Hah, you're right! Guess I shouldn't do to much thinking when I'm tired and it's almost 3 AM on a normal workday. :D

Thanks mate! Hope you don't mind if I bother you with a few more questions in the future, as I'm not the most gifted scripter out there! :rofl:

Link to comment
Share on other sites

I'm only going to care which items are which after I know how many are in the container. I'm really just aiming to make it simple and only allow one item in the container at a time, for my sanity's sake. I could find a way to check each item one at a time, decide if they are game for the script, and then do the next part of the script...

But as ambitious as I am, I think it'd be best to limit it to one item per run of the script at first, so thus I'll need to know how to check if there is more then one item in the container.

Link to comment
Share on other sites

I'm only going to care which items are which after I know how many are in the container. I'm really just aiming to make it simple and only allow one item in the container at a time, for my sanity's sake. I could find a way to check each item one at a time, decide if they are game for the script, and then do the next part of the script...

But as ambitious as I am, I think it'd be best to limit it to one item per run of the script at first, so thus I'll need to know how to check if there is more then one item in the container.

Getnumitems is what you are looking for. Bear in mind, that it will only tell you how many unique items are in there, a stack of arrows counts as one. You would have to jump thru some further hoops to see if it was one arrow, or a thousand. Getitemcount would tell you how many are in the stack. So basically, what you would want to do is:

set somevariable to containerid.getnumitems

assuming there was only one:

set somerefrence to containerid.getinventoryobject 0

set itemcount to containerid.getitemcount somereference

and itemcount would be the number of somerefernce items in the container.

That help?

Link to comment
Share on other sites

<snippity-snippum-snippers>

EDIT:

Totally side question, but is there a function that does either of the following?

Returns the FormID of the key to target door/container

or

Returns if the door/container was unlocked via key or via lockpick/spell

Thanks!

Edited by Running4Cover
Link to comment
Share on other sites

Your questions probably should be in the Dialog thread instead since I cannot create dialog to save myself from a wet paper bag. Really! :evil:

So, I can't help with setting up conditioned dialog.

I also think dialog only runs once per time the player hits the dialog. A quest script could be used to continually check something, like a timer.

As for the side questions, there is no way to do either of them with vanilla scripts.

But what you could do is script the locked door that when activated the first time, it checks to see if the player has the key in their inventory. You could then set a variable yes or no. And check if the door is unlocked. A combination of the two might perform the way you want it to.

Link to comment
Share on other sites

Ah, yes, I totally forgot there was a dialogue section, I apologize (I'll copy the post there).

Concerning the locked door/container bit, my goal was actually to make a script that ran on every locked door and container in the game when you tried to open them with either a spell or a lockpick. I have been trying to learn the workings of Oblivion script so that I can expand a few aspects of thieving, is this case specifically I was trying to add a more complicated style of lock to them game. My goal was to do something like this;

Using a pick lock (or magic) to open a chest, there will be a random chance that the object will have a better lock (chance based somewhat on the lock's difficulty), in which case it will remain locked and the player will have to use a prybar (new item) to open it. To directly copy from a thread on the BGSForums:

...run a script whenever the player successfully unlocks (via lockpick or magic, not key) there is an X% chance that it will have a deadbolt, in which case the only way to open it will be with a prybar tool. The prybar can only open deadbolts, and can result in the following possibilities based on Luck and Security; opens lock, doesn't open lock and you drop the prybar, the lock doesn't open and you injure yourself, or the lock doesn't open and the prybar breaks (small chance of the last three). No matter which happens there will be a noise that alerts NPC's within a very short distance that you opened a lock, and you will of course be in trouble if that lock was to a restricted area or someone elses chest. Players with high enough strength and hand to hand don't need a prybar to do what I just described.

Anyway, thank you for your reply, and I'll move my post to the Dialogue thread now :whistle:

CC

Link to comment
Share on other sites

I'm coming with my new question. :yes: I wish to create scripted spell effect that creates a rain of specific item, for about 10 seconds in 5-10 meters around the target. Copies of this item must keep falling for those 10 seconds, instead of falling at once. What is the easiest way to perform such a thing?

EDIT: Ah, one more question. I assume that the Command spell wouldn't work if being cast not from actor. I've read that the Cast function will not work on the player, if the spell is marked as On Target. So, is there some way to simulate the Command spell by script?

Link to comment
Share on other sites

Well, you could use 'MoveTo' to place an existing 'dead, persistant reference, disabled rat' at the target location. Then move its Z position UP where you want the spawned objects to appear.

Then you could use 'PlaceAtMe' to place the falling objects at the dead rats position.

You could use a timer to delay dropping the objects around, perhaps every 0.2 seconds. You could also vary the X and Y position of the dead rat to allow the objects to fall in different trajectories.

http://cs.elderscrolls.com/constwiki/index.php/MoveTo

http://cs.elderscrolls.com/constwiki/index.php/PlaceAtMe

Link to comment
Share on other sites

Okay, I've tried to do so, but it seems I've made something wrong. Can you help me?

scn ZUSE30RandomEffectCheeseRainSCRIPT

ref target
float timer
short Random1
short Random2
short Random3
short Random4
short Random5

Begin ScriptEffectStart

set target to getself
RainMarker1.moveto target 0 0 4000
RainMarker2.moveto target 100 100 4000
RainMarker3.moveto target -100 100 4000
RainMarker4.moveto target 100 -100 4000
RainMarker5.moveto target -100 -100 4000
DAClavicusDogStatueREF.say SE30RainCheeseVoice 1 SE14VoiceofSheogorath 1
playsound SE30RainVoiceCheese
playsound SE30RainThunder
set timer to 0.1

End

Begin ScriptEffectUpdate

if ( timer > 0 && timer < 10 )

set timer to ( timer + 0.1 )

set Random1 to GetRandomPercent
if ( Random1 >= 0 && Random1 < 50 )
RainMarker1.placeatme CheeseWedge 0 0 0
elseif ( Random1 >= 50 )
RainMarker1.placeatme CheeseWheel 0 0 0
endif

set Random2 to GetRandomPercent
if ( Random2 >= 0 && Random2 < 50 )
RainMarker2.placeatme CheeseWedge 0 0 0
elseif ( Random2 >= 50 )
RainMarker2.placeatme CheeseWheel 0 0 0
endif

set Random3 to GetRandomPercent
if ( Random3 >= 0 && Random3 < 50 )
RainMarker3.placeatme CheeseWedge 0 0 0
elseif ( Random3 >= 50 )
RainMarker3.placeatme CheeseWheel 0 0 0
endif

set Random4 to GetRandomPercent
if ( Random4 >= 0 && Random4 < 50 )
RainMarker4.placeatme CheeseWedge 0 0 0
elseif ( Random4 >= 50 )
RainMarker4.placeatme CheeseWheel 0 0 0
endif

set Random5 to GetRandomPercent
if ( Random5 >= 0 && Random5 < 50 )
RainMarker5.placeatme CheeseWedge 0 0 0
elseif ( Random5 >= 50 )
RainMarker5.placeatme CheeseWheel 0 0 0
endif

return

endif

End

Begin ScriptEffectFinish

set timer to 0

End[/codebox]

Link to comment
Share on other sites

Other than possibly getting half a bajillion pieces of cheese, what is it that is not right?

1. I am not sure what your timer is supposed to be doing. It does not look like it accomplishes anything. And make sure your 'duration' on the spell is at least a couple of seconds. With this it will drop cheese for the duration of the spell.

Begin ScriptEffectUpdate

if timer >= 0
set timer to timer - ScriptEffectElapsedSeconds
else
set timer to 0.1

set Random1 to GetRandomPercent
if Random1 < 50
RainMarker1.placeatme CheeseWedge 0 0 0
else
RainMarker1.placeatme CheeseWheel 0 0 0
endif

set Random2 to GetRandomPercent
if Random2 < 50
RainMarker2.placeatme CheeseWedge 0 0 0
else
RainMarker2.placeatme CheeseWheel 0 0 0
endif

set Random3 to GetRandomPercent
if Random3 < 50
RainMarker3.placeatme CheeseWedge 0 0 0
else
RainMarker3.placeatme CheeseWheel 0 0 0
endif

set Random4 to GetRandomPercent
if Random4 < 50
RainMarker4.placeatme CheeseWedge 0 0 0
else
RainMarker4.placeatme CheeseWheel 0 0 0
endif

set Random5 to GetRandomPercent
if Random5 < 50
RainMarker5.placeatme CheeseWedge 0 0 0
else
RainMarker5.placeatme CheeseWheel 0 0 0
endif

return

endif

End[/code]

3. Also, I changed your IF conditions for the 'random' numbers. Take a look at them.

4. There is no need to have the ScriptEffectFinish. The timer will not contain a value when the spell ends so there is no need to set it.

Link to comment
Share on other sites

Are you sure that the objects "RainMarker1-5" are being placed in the world at the correct location? You can uncheck the 'initially disabled' box to see if they are moving to the target location correctly.

Also, the spell needs a target, such as an NPC or creature.

It may also be that you don't have the script attached to the spell correctly. Or that you are using a 'dirty' save game.

Link to comment
Share on other sites

Well, the Markers are set in the testing cell and teleports properly to the sky, the spell is used on the NPC, is properly linked with Script Effect and I've even checked the old save game without even entering the Shivering Isles. Everything works except the mayor thing - raining cheese. It seems that the only reason of why it doesn't work is just the game's caprice.

Eh, well. It's not essential for my mod, so I'll give up with this. Thank you anyway for your help.

Link to comment
Share on other sites

I am currently having problems with a Quest script that detects the current month and current time.

What I did is that the script checks the months and declares which season the game is in.

For the time of day, it checks the hour and declares if it's morning, day or night.

What doesn't work is that my debug messages telling the time of day and the current season appear once only... in one Oblivion session. If I reload my game, the messages don't show anymore. Or if I reload another savegame, they don't show either.

Weird indeed!

Here's the script:

SCN OblivifallEMSeason&TimeOfDayScript


Short CurrentMonth

Short CurrentTime


short SeasonWinter

Short SeasonSpring

short SeasonSummer

short SeasonFall


short Day

short Night

short Morning


Begin GameMode


set CurrentMonth to GameMonth



if  Night == 0 && (GetCurrentTime >= 19) && (GetCurrentTime < 5)

	MessageBox "It's NightTime!"

	set Night to 1

	set Morning to 0

	set Day to 0

Endif


If Morning == 0 && (GetCurrentTime >= 6) && (GetCurrentTime < 10)

	MessageBox "It's Morning Time!"

	set Morning to 1

	set Day to 0

	set Night to 0

Endif


If Day == 0 && (GetCurrentTime >= 11) && (GetCurrentTime < 18)

	MessageBox "It's DayTime!"

	set Day to 1

	set Night to 0

	set Morning to 0

endif



if SeasonWinter == 0 && CurrentMonth == 0 || CurrentMonth == 1 || CurrentMonth == 11

	MessageBox "It's Winter!"

	set SeasonWinter to 1

	set SeasonSpring to 0

	set SeasonSummer to 0

	set SeasonFall to 0

endif


If SeasonSpring == 0 && CurrentMonth == 2 || CurrentMonth == 3 || CurrentMonth == 4

	MessageBox "It's Spring!"

	set SeasonWinter to 0

	set SeasonSpring to 1

	set SeasonSummer to 0

	set SeasonFall to 0


endif


If SeasonSummer == 0 && CurrentMonth == 5 || CurrentMonth == 6 || CurrentMonth == 7

	MessageBox "It's Summer!"

	set SeasonWinter to 0

	set SeasonSpring to 0

	set SeasonSummer to 1

	set SeasonFall to 0

Endif


If SeasonFall == 0 && CurrentMonth == 8 || CurrentMonth == 9  || CurrentMonth == 10

	MessageBox "It's Fall!"

	set SeasonWinter to 0

	set SeasonSpring to 0

	set SeasonSummer to 0

	set SeasonFall to 1

endif




end

Link to comment
Share on other sites

need help creating a simple script that will only make 3 NPCs appear when this quest starts, similar to the way holvstein only appears on gnoll mountain when you receive the dark brotherhood quest to kill him

basically i have a camp with 2 bandits and a horse and i only want them to appear there when this quest begins. i tried reverse programming the holvstein quest but it didn't work. so far i've tried setting persistent references and only enabling it on the quest stage but this didn't work, was also considering placing them all in a dummy cell and only moving them to the camp when the quest stage is started with MoveTo but i couldn't figure that out either

help?

Link to comment
Share on other sites

i never tried initially disabling them. so something like this?

on the NPCs

---------

snc MISHredmanebandit1

Begin GameMode

mishredmane1ref.disable

End

---------

snc MISHredmanebandit2

Begin GameMode

mishredmane2ref.disable

End

---------

snc MISHgreycourser

Begin GameMode

mishgreycourserref.disable

End

---------

on quest stage 10 - result script

---------

mishredmane1ref.enable

mishredmane2ref.enable

mishgreycourser.enable

Link to comment
Share on other sites

You're welcome. :jellytime:

Now I've got my own, rather simple question... is there any function that allows me to check the user of the specified item? I have some weapon with enchantment, that should check who uses this weapon - player or someone else. I've searched on the CSWiki, but haven't found anything like that.

Link to comment
Share on other sites

i need to be able to check if a certain horse is in the same cell as an NPC for that NPC to offer a certain topic. would this work?

on the horse


scn scriptname


Begin GameMode


   if NPC1ref.GetInSameCell horseref

      AddTopic NPC1topic


   elseif NPC2ref.GetInSameCell horseref

      AddTopic NPC2topic


   elseif NPC3ref.GetInSameCell horseref

      AddTopic NPC3topic


endif


End

Edited by Mishaxhi
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...