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

I making a sidequest were you are supposed to uncover the affair between Hasathil (Heinrich Oaken-Hull's wife) and Enilroth

The GetDead section doesn't work. I've tried it with both their editor ID's and RefId.

The GetStage bit doesn't work even though the stage has been set to 1 and the stage 1 journal entry appears.

Scriptname SRJanvEmQuest


Begin Gamemode


;kill the quest if any of the involved parties die

if Hasathil.Getdead == 1 || HeinrichOakenHull.Getdead == 1 || SRJemily.GetDead == 1 || Enilroth.GetDead == 1

	setstage SRJanvEmilysQuest 111

endif


;If player and the guy are both near Hasathil...

If GetStage SRJanvEmilysQuest == 1

	if HasathilRef.Getdistance Player < 512 

		if HasathilRef.GetDistance EnilrothRef < 512

			setstage SRJanvEmilysQuest 50

		endif

	endif

endif


END

:D:):P

I've spent about 2 hours fiddling with this and I'm at my wits end.

Link to comment
Share on other sites

Only two hours? :D Sorry, but I typically spend up to a week getting problem scripts to work. :)

Put in some display message boxes so you can see if they are running.

Also, you should 'only' use reference names, not the object names when checking GetDead.

And a question, perhaps the settings you have on your NPC's are causing the problem. Make sure they are persistant references, and make sure they do not have the "No Low Level Processing" check box checked.

Link to comment
Share on other sites

Ha ok, it was closer to 4 hours. :D

NPCs are all set, they have low level processing, and are all persistant refs.

I know for sure the Getstage bit isn't working because i tried it with a PrintC message right after that condition and it didn't print.

(I also had the whole getdead thing commented out at that point.)

Link to comment
Share on other sites

Sounds like a quest problem. Which I know next to nothing about.

You can find out what stage your quest is currently in by using the console.

Just type in GetStage and the form ID of your quest.

Perhaps you think its at the proper stage but its not. The console command should let you know if there is a problem somewhere else in your quest.

Link to comment
Share on other sites

  • 1 month later...

Here's what I want to do...

I'm making a time sensitive quest. I want an NPC to wait for you to come back for a certain number of hours. If you don't make it in time the quest ends.

However, that part of the quest could start at any time.

Convert it to 24 hour clock? :thumbup: Oblivion uses a 24 hour clock to start with...I'm worried about the transition from 24:59 to 1:00

I think i may have solved it myself though...here's what i got...

	If TimerSet == 0

		Set ZeroHour to Gamehour + 6

		set ZeroDay to GameDaysPassed

		If ZeroHour > 24

			set ZeroHour to ZeroHour - 24

			set ZeroDay to GameDaysPassed + 1

		endif

		Set TimerSet to 1

	endif

	If GameDaysPassed >= ZeroDay && GameHour >= ZeroHour

			;do something.

	endif

Link to comment
Share on other sites

Alright, I was wondering if anyone could give me some advice on making a script for an interior that is supposed to be acting like an exterior in a constant state of night. I want to force a certain type of custom weather to play no matter what time of day it is. I was thinking it might act somewhat like an Oblivion gate.

I tried that with just the good ol' default weather system, but there were lots of issues. I figured it'd be easier with a script. :pints:

Link to comment
Share on other sites

There are probably lots of ways to do this, and it really depends on your cell set up and how you want it to work.

Probably, a script placed on an object hidden in the void of the cell would work for what you want.

scn myWeatherScript
begin OnLoad
ForceWeather myCustomWeather 1
end[/code]

You would also need to make a new climate that is always dark and assign that climate to your cell.

Link to comment
Share on other sites

The OnActivate Block of my companion critter script stopped working, that is the messagebox doesn't come up anymore.

Begin OnActivate


	if this.getdead == 1

		activate ;makes non-essential companions lootable

		return

	elseif ( GetActionRef == player )

		;Grab virtual collar, stops any combat at least momentarily.

		setignorefriendlyhits 1

		SCAonactor

		stopcombat

		Messagebox "Choose a command.", "Follow Me.", "Stay Here.", "Go Home.", "More."

		Set menu to 1 ;flag to start looking for buttonpress

		return

	else

		activate ;this will happen if an NPC ever activates live critter

	endif


End

Link to comment
Share on other sites

Begin OnActivate

if getdead == 1
activate ;makes non-essential companions lootable
return
endif
if ( GetActionRef == player )
;Grab virtual collar, stops any combat at least momentarily.
setignorefriendlyhits 1
SCAonactor
stopcombat
Messagebox "Choose a command.", "Follow Me.", "Stay Here.", "Go Home.", "More."
Set menu to 1 ;flag to start looking for buttonpress
return
else
activate ;this will happen if an NPC ever activates live critter
endif

End
[/code]

1. Its usually NOT a good idea to mix conditions in your IF logic.

2. If the script is on the creature that you are checking if its dead, you do NOT need to 'reference' it.

Link to comment
Share on other sites

Hello. I've got some questions about scripting:

1. I wish to create some NPCs, which will be the "live background", same as civilians from Megaton in F3. I.e. you can't start conversation with them after activation, but only get a single comment, taken randomly from HELLO, GREETING and Rumors. How to make such script?

2. What is "saa" and "alpha", because I've saw that in scripts created by others and I don't understand what they actually do?

3. It's probably not a script question at all, but: what is the easiest way to prevent NPC from starting combat with anyone (such NPC should just stand in one place and keep looking on the fighting persons)?

Edited by ZuTheSkunk
Link to comment
Share on other sites

Hi ZuTheSkunk,

Actually, none of that is a 'script' in the sense of scripting the game.

1. This has to do with NPC AI Packages. But, there is a script you can place on them if you want to make them NOT be activatable by the player.

scn myNoActivateScript
begin OnActivate
end[/code]

2. SAA is SetActorAlpha. Any command you are unsure of can be looked up on the WIKI.

The Oblivion WIKI of Functions

What SAA does is set the 'alpha' or transparency of the scripted thing. I use this to 'fade out' bodies after they are dead.

3. This also has to do with NPCs. But from what I know about NPC's, you click the 'AI' button on your NPC properties and change the 'Aggression' to 5. But there are other factors that control this too, like factions. If you attack somebody in the same faction as another NPC that is present and in that faction too, it could cause the whole faction to become agressive.

Link to comment
Share on other sites

3. It's probably not a script question at all, but: what is the easiest way to prevent NPC from starting combat with anyone (such NPC should just stand in one place and keep looking on the fighting persons)?

Willie has you on the right road with the Aggression setting. I just wanted to add that you may also want to look at Responsibility.

If you set it below 30 they won't be upset by most crimes they see. They may even comment about it expressing amusement.

Link to comment
Share on other sites

  • 2 weeks later...

Ok i have a script on a creature, it has a variable in it called "movehome"

It's a flag that a quest script checks to see if it should do something

Here's the code snippet


ref critter ;this is a ref to the creature


	if critter.movehome == 1

		Troll1HomeREF.moveto Critter

		set critter.movehome to 0

	endif

Now he's the bit i don't get. The script compiler doesn't like this.

It says that the If line has an unknown variable.

The weird part is that it's just the if part.

"set critter.movehome to 0" is fine. But "if critter.movehome..." doesn't work?

What?

Link to comment
Share on other sites

So, the actual reference on your 'critter' is called 'critter' in the CS?

One thing you should try is to use another variable to store the value in critter.movehome.

set myValue to critter.movehome
if myValue == 1
Troll1HomeREF.moveto Critter[/code]

If statements can sometimes be very picky. It may not know how to resolve a value in another script inside the if condition.

Another thing is there might be an error somewhere else that is causeing this IF condition to not work.

Give it a try and see if my suggestion works.

Link to comment
Share on other sites

No the ref "Critter" is just used internally by that particular script.

This is the follow behavior and death handling quest script for my companion creatures...

I use an init script to set ref Critter and tell the quest script what ref/creature it's supposed to be monitoring.

It makes updating and making new ones easier.

So the init script says something like "set JobenCreatureXquest.critter to JobenCreatureXRef"

I was trying to make my quest script spy on the creature's script and copy down variables from it. For various reasons I didn't want the creature's script to directly set those variables.

...ahhh....

I know WHAT doesn't work but I'm not sure I understand why...

The error message is incredibly unhelpful...

If i use the creatures actual REFid, then it compiles. "if SRJtrollONE.movehome == 1"

But i can't read a variable off a non-explicit reference like "critter" that's set via script.

That is to say, this sort of thing does not fly.


ref Critter

short GenericFlag


Begin Gamemode


Set Critter to [SomeRefID]


Set GenericFlag to critter.localflag


If GenericFlag == 1

   ;do something

endif


end

The compiler would say it has no idea what localflag is and that anyway there's a missing expression in the set command.

Wow this is the first time in a few months when I've had so little idea what I was doing. XD

Link to comment
Share on other sites

I'm wondering about some math functions in scripts. What I want to do is create an Ayleid mine and refinery. Basically, what you would do is gather welkynd shards from the mine (the way you would gather gold or silver nuggets) and take them to the refinery. You would put them in a chest, press a wall switch, a spell is cast on the chest and you would have 1 blue Welkynd Stone for every 4 blue welkynd shards you put in or 1 Varla Stone for every 10 white welkynd shards you put in. If you put in 10 blue welkynd shards, you would find 2 Welkynd Stones and 2 welkynd shards in the chest after you press the wall switch. So I'd need to store four variables in the script:

ShardBCount ; for the blue shards

ShardWCount ; for the white shards

WelkyndCount ; for the welkynd stones

VarlaCount ; for the Varla Stones

I would then need a way to set WelkyndCount to ShardBCount/4 and VarlaCount to ShardWCount/10 and make sure that any excess shards remain in the chest but I don't know how to set this up in a script, or even if that type of math is supported without OBSE.

Link to comment
Share on other sites

Okay, I think I've got some more questions about scripting. Certainly this time.

1. I've created an additional script for Dawnfang/Duskfang, working alongside with default scripts and not changing them at all (my intention was to make it as compatible with other mods as it's possible). His destiny is to do two things: first, to add an updating function, which replaces the sword with better ones, if player has got enough high level. Second, to prevent game from resetting amount of kills after dropping a weapon, as long as the time of that happening is not longer than one hour. And my question is simple... is this created correctly?

scn aaaSE03TsaesciBladeScript

short Best
short DuskF
short DawnF
short ResDusk
short ResDawn
short NotDusk
short NotDawn
float timer

Begin GameMode

if ( DuskF != SE03Fin.Duskblade )
set DuskF to SE03Fin.Duskblade
endif

if ( DawnF != SE03Fin.Dawnblade )
set DuskF to SE03Fin.Dawnblade
endif

if ( ResDawn > 0 )
if ( timer < 120 && gamehour >= 6 && gamehour < 18 )
if ( Player.GetItemCount SE03Dawnfang01 == 0 ) && ( Player.GetItemCount SE03DawnFang01A == 0 ) && ( Player.GetItemCount SE03Dawnfang05 == 0 ) && ( Player.GetItemCount SE03DawnFang05A == 0 ) && ( Player.GetItemCount SE03Dawnfang10 == 0 ) && ( Player.GetItemCount SE03DawnFang10A == 0 ) && ( Player.GetItemCount SE03Dawnfang15 == 0 )
if ( Player.GetItemCount SE03DawnFang15A == 0 ) && ( Player.GetItemCount SE03Dawnfang20 == 0 ) && ( Player.GetItemCount SE03DawnFang20A == 0 ) && ( Player.GetItemCount SE03Dawnfang25 == 0 ) && ( Player.GetItemCount SE03DawnFang25A == 0 ) && ( Player.GetItemCount SE03Dawnfang30 == 0 ) && ( Player.GetItemCount SE03DawnFang30A == 0 )
set timer to ( timer + getSecondsPassed )
else
set SESwordDawnfangKills to ResDawn
set ResDawn to 0
endif
endif
elseif ( timer >= 120 && gamehour >= 6 && gamehour < 18 )
set ResDawn to 0
set NotDawn to 1
elseif ( gamehour >= 18 || gamehour < 6 )
set ResDawn to 0
set NotDawn to 1
endif
endif

if ( ResDusk > 0 )
if ( timer < 120 && gamehour >= 18 || gamehour < 6 )
if ( Player.GetItemCount SE03Duskfang01 == 0 ) && ( Player.GetItemCount SE03DuskFang01A == 0 ) && ( Player.GetItemCount SE03Duskfang05 == 0 ) && ( Player.GetItemCount SE03DuskFang05A == 0 ) && ( Player.GetItemCount SE03Duskfang10 == 0 ) && ( Player.GetItemCount SE03DuskFang10A == 0 ) && ( Player.GetItemCount SE03Duskfang15 == 0 )
if ( Player.GetItemCount SE03DuskFang15A == 0 ) && ( Player.GetItemCount SE03Duskfang20 == 0 ) && ( Player.GetItemCount SE03DuskFang20A == 0 ) && ( Player.GetItemCount SE03Duskfang25 == 0 ) && ( Player.GetItemCount SE03DuskFang25A == 0 ) && ( Player.GetItemCount SE03Duskfang30 == 0 ) && ( Player.GetItemCount SE03DuskFang30A == 0 )
set timer to ( timer + getSecondsPassed )
else
set SESwordDuskfangKills to ResDusk
set ResDusk to 0
endif
endif
elseif ( timer >= 120 && gamehour >= 18 || gamehour < 6 )
set ResDusk to 0
set NotDusk to 1
elseif ( gamehour >= 6 && gamehour < 18 )
set ResDusk to 0
set NotDusk to 1
endif
endif

if ( NotDawn == 1 )
if ( Player.GetItemCount SE03Dawnfang01 == 1 ) || ( Player.GetItemCount SE03DawnFang01A == 1 ) || ( Player.GetItemCount SE03Dawnfang05 == 1 ) || ( Player.GetItemCount SE03DawnFang05A == 1 ) || ( Player.GetItemCount SE03Dawnfang10 == 1 ) || ( Player.GetItemCount SE03DawnFang10A == 1 ) || ( Player.GetItemCount SE03Dawnfang15 == 1 )
if ( Player.GetItemCount SE03DawnFang15A == 1 ) || ( Player.GetItemCount SE03Dawnfang20 == 1 ) || ( Player.GetItemCount SE03DawnFang20A == 1 ) || ( Player.GetItemCount SE03Dawnfang25 == 1 ) || ( Player.GetItemCount SE03DawnFang25A == 1 ) || ( Player.GetItemCount SE03Dawnfang30 == 1 ) || ( Player.GetItemCount SE03DawnFang30A == 1 )
set NotDawn to 0
endif
endif
endif

if ( NotDusk == 1 )
if ( Player.GetItemCount SE03Duskfang01 == 1 ) || ( Player.GetItemCount SE03DuskFang01A == 1 ) || ( Player.GetItemCount SE03Duskfang05 == 1 ) || ( Player.GetItemCount SE03DuskFang05A == 1 ) || ( Player.GetItemCount SE03Duskfang10 == 1 ) || ( Player.GetItemCount SE03DuskFang10A == 1 ) || ( Player.GetItemCount SE03Duskfang15 == 1 )
if ( Player.GetItemCount SE03DuskFang15A == 1 ) || ( Player.GetItemCount SE03Duskfang20 == 1 ) || ( Player.GetItemCount SE03DuskFang20A == 1 ) || ( Player.GetItemCount SE03Duskfang25 == 1 ) || ( Player.GetItemCount SE03DuskFang25A == 1 ) || ( Player.GetItemCount SE03Duskfang30 == 1 ) || ( Player.GetItemCount SE03DuskFang30A == 1 )
set NotDusk to 0
endif
endif
endif

if ( Best == 0 )

if ( DawnF == 1 )
if ( Player.GetItemCount SE03Dawnfang01 == 1 ) || ( Player.GetItemCount SE03DawnFang01A == 1 )
if ( player.getlevel >= 5 )
if ( SESwordDawnfangKills < 12 )
message " "
message " "
Player.Additem SE03DawnfangLeveled 1
message " "
message " "
Player.removeitem SE03Dawnfang01 1
Player.removeitem SE03Dawnfang01A 1
else
message " "
message " "
Player.Additem SE03DawnfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Dawnfang01 1
Player.removeitem SE03Dawnfang01A 1
endif
endif
elseif ( Player.GetItemCount SE03Dawnfang05 == 1 ) || ( Player.GetItemCount SE03DawnFang05A == 1 )
if ( player.getlevel >= 10 )
if ( SESwordDawnfangKills < 12 )
message " "
message " "
Player.Additem SE03DawnfangLeveled 1
message " "
message " "
Player.removeitem SE03Dawnfang05 1
Player.removeitem SE03Dawnfang05A 1
else
message " "
message " "
Player.Additem SE03DawnfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Dawnfang05 1
Player.removeitem SE03Dawnfang05A 1
endif
endif
elseif ( Player.GetItemCount SE03Dawnfang10 == 1 ) || ( Player.GetItemCount SE03DawnFang10A == 1 )
if ( player.getlevel >= 15 )
if ( SESwordDawnfangKills < 12 )
message " "
message " "
Player.Additem SE03DawnfangLeveled 1
message " "
message " "
Player.removeitem SE03Dawnfang10 1
Player.removeitem SE03Dawnfang10A 1
else
message " "
message " "
Player.Additem SE03DawnfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Dawnfang10 1
Player.removeitem SE03Dawnfang10A 1
endif
endif
elseif ( Player.GetItemCount SE03Dawnfang15 == 1 ) || ( Player.GetItemCount SE03DawnFang15A == 1 )
if ( player.getlevel >= 20 )
if ( SESwordDawnfangKills < 12 )
message " "
message " "
Player.Additem SE03DawnfangLeveled 1
message " "
message " "
Player.removeitem SE03Dawnfang15 1
Player.removeitem SE03Dawnfang15A 1
else
message " "
message " "
Player.Additem SE03DawnfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Dawnfang15 1
Player.removeitem SE03Dawnfang15A 1
endif
endif
elseif ( Player.GetItemCount SE03Dawnfang20 == 1 ) || ( Player.GetItemCount SE03DawnFang20A == 1 )
if ( player.getlevel >= 25 )
if ( SESwordDawnfangKills < 12 )
message " "
message " "
Player.Additem SE03DawnfangLeveled 1
message " "
message " "
Player.removeitem SE03Dawnfang20 1
Player.removeitem SE03Dawnfang20A 1
else
message " "
message " "
Player.Additem SE03DawnfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Dawnfang20 1
Player.removeitem SE03Dawnfang20A 1
endif
endif
elseif ( Player.GetItemCount SE03Dawnfang25 == 1 ) || ( Player.GetItemCount SE03DawnFang25A == 1 )
if ( player.getlevel >= 30 )
if ( SESwordDawnfangKills < 12 )
message " "
message " "
Player.Additem SE03DawnfangLeveled 1
message " "
message " "
Player.removeitem SE03Dawnfang25 1
Player.removeitem SE03Dawnfang25A 1
else
message " "
message " "
Player.Additem SE03DawnfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Dawnfang25 1
Player.removeitem SE03Dawnfang25A 1
endif
endif
elseif ( Player.GetItemCount SE03Dawnfang30 == 1 ) || ( Player.GetItemCount SE03DawnFang30A == 1 )
set Best to 1
elseif ( Player.GetItemCount SE03Dawnfang01 == 0 ) && ( Player.GetItemCount SE03DawnFang01A == 0 ) && ( Player.GetItemCount SE03Dawnfang05 == 0 ) && ( Player.GetItemCount SE03DawnFang05A == 0 ) && ( Player.GetItemCount SE03Dawnfang10 == 0 ) && ( Player.GetItemCount SE03DawnFang10A == 0 ) && ( Player.GetItemCount SE03Dawnfang15 == 0 )
if ( Player.GetItemCount SE03DawnFang15A == 0 ) && ( Player.GetItemCount SE03Dawnfang20 == 0 ) && ( Player.GetItemCount SE03DawnFang20A == 0 ) && ( Player.GetItemCount SE03Dawnfang25 == 0 ) && ( Player.GetItemCount SE03DawnFang25A == 0 ) && ( Player.GetItemCount SE03Dawnfang30 == 0 ) && ( Player.GetItemCount SE03DawnFang30A == 0 )
if ( SESwordDawnfangKills > 0 && NotDawn == 0 )
set ResDawn to SESwordDawnfangKills
endif
endif
endif
endif

if ( DuskF == 1 )
if ( Player.GetItemCount SE03Duskfang01 == 1 ) || ( Player.GetItemCount SE03DuskFang01A == 1 )
if ( player.getlevel >= 5 )
if ( SESwordDuskfangKills < 12 )
message " "
message " "
Player.Additem SE03DuskfangLeveled 1
message " "
message " "
Player.removeitem SE03Duskfang01 1
Player.removeitem SE03Duskfang01A 1
else
message " "
message " "
Player.Additem SE03DuskfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Duskfang01 1
Player.removeitem SE03Duskfang01A 1
endif
endif
elseif ( Player.GetItemCount SE03Duskfang05 == 1 ) || ( Player.GetItemCount SE03DuskFang05A == 1 )
if ( player.getlevel >= 10 )
if ( SESwordDuskfangKills < 12 )
message " "
message " "
Player.Additem SE03DuskfangLeveled 1
message " "
message " "
Player.removeitem SE03Duskfang05 1
Player.removeitem SE03Duskfang05A 1
else
message " "
message " "
Player.Additem SE03DuskfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Duskfang05 1
Player.removeitem SE03Duskfang05A 1
endif
endif
elseif ( Player.GetItemCount SE03Duskfang10 == 1 ) || ( Player.GetItemCount SE03DuskFang10A == 1 )
if ( player.getlevel >= 15 )
if ( SESwordDuskfangKills < 12 )
message " "
message " "
Player.Additem SE03DuskfangLeveled 1
message " "
message " "
Player.removeitem SE03Duskfang10 1
Player.removeitem SE03Duskfang10A 1
else
message " "
message " "
Player.Additem SE03DuskfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Duskfang10 1
Player.removeitem SE03Duskfang10A 1
endif
endif
elseif ( Player.GetItemCount SE03Duskfang15 == 1 ) || ( Player.GetItemCount SE03DuskFang15A == 1 )
if ( player.getlevel >= 20 )
if ( SESwordDuskfangKills < 12 )
message " "
message " "
Player.Additem SE03DuskfangLeveled 1
message " "
message " "
Player.removeitem SE03Duskfang15 1
Player.removeitem SE03Duskfang15A 1
else
message " "
message " "
Player.Additem SE03DuskfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Duskfang15 1
Player.removeitem SE03Duskfang15A 1
endif
endif
elseif ( Player.GetItemCount SE03Duskfang20 == 1 ) || ( Player.GetItemCount SE03DuskFang20A == 1 )
if ( player.getlevel >= 25 )
if ( SESwordDuskfangKills < 12 )
message " "
message " "
Player.Additem SE03DuskfangLeveled 1
message " "
message " "
Player.removeitem SE03Duskfang20 1
Player.removeitem SE03Duskfang20A 1
else
message " "
message " "
Player.Additem SE03DuskfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Duskfang20 1
Player.removeitem SE03Duskfang20A 1
endif
endif
elseif ( Player.GetItemCount SE03Duskfang25 == 1 ) || ( Player.GetItemCount SE03DuskFang25A == 1 )
if ( player.getlevel >= 30 )
if ( SESwordDuskfangKills < 12 )
message " "
message " "
Player.Additem SE03DuskfangLeveled 1
message " "
message " "
Player.removeitem SE03Duskfang25 1
Player.removeitem SE03Duskfang25A 1
else
message " "
message " "
Player.Additem SE03DuskfangLeveledPowered 1
message " "
message " "
Player.removeitem SE03Duskfang25 1
Player.removeitem SE03Duskfang25A 1
endif
endif
elseif ( Player.GetItemCount SE03Duskfang30 == 1 ) || ( Player.GetItemCount SE03DuskFang30A == 1 )
set Best to 1
elseif ( Player.GetItemCount SE03Duskfang01 == 0 ) && ( Player.GetItemCount SE03DuskFang01A == 0 ) && ( Player.GetItemCount SE03Duskfang05 == 0 ) && ( Player.GetItemCount SE03DuskFang05A == 0 ) && ( Player.GetItemCount SE03Duskfang10 == 0 ) && ( Player.GetItemCount SE03DuskFang10A == 0 ) && ( Player.GetItemCount SE03Duskfang15 == 0 )
if ( Player.GetItemCount SE03DuskFang15A == 0 ) && ( Player.GetItemCount SE03Duskfang20 == 0 ) && ( Player.GetItemCount SE03DuskFang20A == 0 ) && ( Player.GetItemCount SE03Duskfang25 == 0 ) && ( Player.GetItemCount SE03DuskFang25A == 0 ) && ( Player.GetItemCount SE03Duskfang30 == 0 ) && ( Player.GetItemCount SE03DuskFang30A == 0 )
if ( SESwordDuskfangKills > 0 && NotDusk == 0 )
set ResDusk to SESwordDuskfangKills
endif
endif
endif
endif

endif

End[/codebox]

2. In my Summon Merchant Spell mod, I've copied a summoning script from Haskill and edited it to fit my idea. Everything works correctly, except one thing: sometimes, the Merchant begins to disappear before she's able to talk to player. What causes it and how can I fix it? I mean, she should start conversation with player as long as he stands at a distance of up to 3 meters.

[codebox]scn ZUMerchantScript

; Most of this script has been taken from Haskill's summoning script. Those parts are marked as TAKEN, those mine parts
; will be marked as MINE.

short leaveVAR
float timer
short doOnce
float fadetimer
float MerchantAlpha
short resetAlpha
short summoned
float summontimer
short summonblocker


begin OnLoad

setghost 1

end


Begin OnActivate
if ( ZUgreetVAR == 0 )
Activate
endif
End

Begin GameMode

; This section makes it appear as if Merchant has activated a door and faded out. - TAKEN
if ( leaveVAR == 2 ) && ( ZUFadeOnce == 0 )
Set MerchantAlpha to .9
Set FadeTimer to 4
SetActorAlpha MerchantAlpha
set ZUFadeOnce to 1
endif

if ( ZUFadeOnce == 1 )
if ( FadeTimer > 0 )
Set FadeTimer to ( FadeTimer - GetSecondsPassed )
Set MerchantAlpha to ( MerchantAlpha - .01 )
SetActorAlpha MerchantAlpha
elseif ( FadeTimer <= 0 )
Set MerchantAlpha to 0
Set ZUFadeOnce to 2
Set FadeTimer to 0
MoveTo ZUMerchantReturnMarker
endif
endif

; This chunk fades her out after summon. - TAKEN
if ( ZUFadeOnce == 4 )
Set MerchantAlpha to 0.9
Set FadeTimer to 4
SetActorAlpha MerchantAlpha
set ZUFadeOnce to 5
endif

if ( ZUFadeOnce == 5 )
if ( FadeTimer > 0 )
Set FadeTimer to ( FadeTimer - GetSecondsPassed )
Set MerchantAlpha to ( MerchantAlpha - .01 )
SetActorAlpha MerchantAlpha
elseif ( FadeTimer <= 0 )
Set MerchantAlpha to 0
Set ZUFadeOnce to 2
Set FadeTimer to 0
MoveTo ZUMerchantReturnMarker
set resetAlpha to 1
set summoned to 0
set summontimer to 0
set summonblocker to 0
endif
endif

if ( resetAlpha == 1 )
setActorAlpha 1
set resetAlpha to 0
endif

if ( summoned == 1 )
set summontimer to ( summontimer + GetSecondsPassed )
if ( summontimer >= 5 )
if ( summonblocker == 0 )
; Send Merchant back where she came from. - TAKEN
ZUMerchantREF.pme STRP
ZUMerchantREF.removescriptpackage
ZUMerchantREF.stoplook
set ZUFadeOnce to 4
set ZUgreetVAR to 0
set summonblocker to 1
endif
endif
endif

; This part prevents Merchant from unequipping her default items, or at least it should do that. - MINE
if ( ZUMerchantREF.getitemcount ZUMerchantClothingBoots < 1 )
ZUMerchantREF.additem ZUMerchantClothingBoots 1
endif

if ( ZUMerchantREF.getequipped ZUMerchantClothingBoots == 0 )
ZUMerchantREF.equipitem ZUMerchantClothingBoots 1
endif

if ( ZUMerchantREF.getitemcount ZUMerchantClothingRobe < 1 )
ZUMerchantREF.additem ZUMerchantClothingRobe 1
endif

if ( ZUMerchantREF.getequipped ZUMerchantClothingRobe == 0 )
ZUMerchantREF.equipitem ZUMerchantClothingRobe 1
endif

if ( ZUMerchantREF.getitemcount ZUMerchantClothingGauntlets < 1 )
ZUMerchantREF.additem ZUMerchantClothingGauntlets 1
endif

if ( ZUMerchantREF.getequipped ZUMerchantClothingGauntlets == 0 )
ZUMerchantREF.equipitem ZUMerchantClothingGauntlets 1
endif

if ( ZUMerchantREF.getitemcount ZUMerchantClothingHood < 1 )
ZUMerchantREF.additem ZUMerchantClothingHood 1
endif

if ( ZUMerchantREF.getequipped ZUMerchantClothingHood == 0 )
ZUMerchantREF.equipitem ZUMerchantClothingHood 1
endif

if ( ZUMerchantREF.getitemcount ZUMerchantStaff < 1 )
ZUMerchantREF.additem ZUMerchantStaff 1
endif

if ( ZUMerchantREF.getequipped ZUMerchantStaff == 0 )
ZUMerchantREF.equipitem ZUMerchantStaff 1
endif

if ( ZUMerchantREF.getequipped Torch02 == 1 )
ZUMerchantREF.unequipitem Torch02
endif

End

scn ZUMerchantSummonQuestScript

short resetVAR
short AddTopics
short AddTopicsTwo

Begin GameMode

if ( resetVAR == 1 )
Set ZUMerchantREF.MerchantAlpha to 0
Set ZUFadeOnce to 2
Set ZUMerchantREF.FadeTimer to 0
ZUMerchantREF.MoveTo ZUMerchantReturnMarker
set ZUMerchantREF.resetAlpha to 1
set ZUMerchantREF.summoned to 0
set ZUMerchantREF.summontimer to 0
set ZUMerchantREF.summonblocker to 0
set resetVAR to 0
endif

; This part disallows player to have Merchant's staff, if he'll get it somehow.
if ( player.getitemcount ZUMerchantStaff > 0 )
player.removeitem ZUMerchantStaff 1
message "You shouldn't have this staff."
endif

if ( AddTopics == 0 )
addtopic ZUMerchantBookTopic
addtopic ZUMerchantBookBuy
addtopic ZUMerchantBookCancel
set AddTopics to 1
endif

if ( AddTopicsTwo == 0 )
addtopic ZUMerchantBuyStolen
set AddTopicsTwo to 1
endif

End[/codebox]

[codebox]scn ZUMerchantSummonSpellSCRIPT

float timer
short returnEffect ; set to 1 when played
float x
float y
float angle

begin ScriptEffectStart
if ( ZUMerchantREF.summoned == 0 )
set ZUMerchantREF.summoned to 1
; Move Merchant to player.
ZUMerchantSummonMarker.moveto player ; Get orientation of player.
; When we have math functions, we can do this:
set angle to player.getangle z

; TEMP: for now, just move on axis based on angle.
if angle <= 45 && angle >= -45
set y to 150
elseif angle >= 45 && angle <= 135
set x to 150
elseif angle >= 135 && angle <= 225
set y to -150
else
set x to -150
endif

ZUMerchantREF.moveto player x y 0
ZUMerchantREF.look player
ZUMerchantREF.pme STRP
; Merchant force-greet player.
ZUMerchantREF.addscriptpackage ZUMerchantSummonForcegreet
; Set variable on Merchant to prevent player from talking to her before she forcegreets.
set ZUgreetVAR to 1
set ZUFadeOnce to 3
else
Message "Merchant has been summoned too recently."
endif

end

begin ScriptEffectUpdate
set timer to timer + ScriptEffectElapsedSeconds
if returnEffect == 0 && timer > 4.5
ZUMerchantREF.pme STRP
set returnEffect to 1
endif
end

begin ScriptEffectFinish
if ( ZUMerchantREF.GetInSameCell Player == 0 ) && ( ZUMerchantREF.summoned == 1 )
set ZUMerchantSummonQuest.resetVAR to 1
endif
end

3. And still about this mod above, I have another problem. I wish to force Merchant to reset her equipment from time to time, so all this garbage sold to her will disappear after, lets say, one week. I've tried to do this by script way before, but somehow, the "removeallitems" function causes game to freeze. I've tried to use simple "Respawn" option for this NPC, but it has no effect so far. Adding Merchant's own vendor chest don't works, since she teleportates herself to player, far away from chest (or maybe it actually works, but I haven't made it correctly?). So, how can I add such thing?

Edited by DarkRider
Link to comment
Share on other sites

@Joben - You are correct, you CANNOT use a reference in the IF condition that way. When you save the script, it is 'compiled' then. Since the reference does not exist yet, it cannot find the reference to get the value from that references script.

@The Vyper - That is simple math. Just give the chest a Reference ID name and your good to go.

Then, on the wall switch, you have the script that does the work.

short myShardBCount
short myShardWCount
short myNum
short myVal

begin OnActivate
set myShardBCount to myChestREF.GetItemCount ShardBlue
set myShardWCount to myChestREF.GetItemCount ShardWhite

set myNum to myShardBCount / 4
if myNum > 0
set myVal to myNum * 4
myChestREF.RemoveItem ShardBlue myVal
myChestREF.AddItem WelkyndStone myNum
endif

set myNum to myShardWCount / 10
if myNum > 0
set myVal to myNum * 10
myChestREF.RemoveItem ShardWhite myVal
myChestREF.AddItem VarlaStone myNum
endif
end[/code]

@ZuTheSkunk - 1. That is a huge script, and just reading it one cannot know if it will work or not. Its best to try it and see what happens. Once you find a bug, then steps can be taken to figure out what the problem is.

I am also confused by your statement about wanting to make it 'compatible' with other mods if you are also 'adding' new versions of the weapon based on level. That alone would cause problems I would think.

2. You only have 5 seconds defined in the script before the merchant vanishes. If you don't talk in that time, then the merchant goes away.

3. Did you put a reference ID name on the merchant chest, and remove the items using the reference name?

I find it best to remove the items manually, using a switch in the same cell the chest is in.

If thats not possible, you might try moving the chest to the merchant, but below the ground. Then try to remove all items from it.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...