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...

Ownership Enabling...


Cerest
 Share

Recommended Posts

I'm trying to make a script that allows a noninvasive way of enabling markers/objects at inns and abroad... I thought I knew what I was doing... but I apparently dont @_@

 

In game, I allow an object whose ownership changes during the course of the game (an inn bed, or say, the bed in the archmages quarters) to be "xGSxEnablingObject" and I allow the object I want to activate to be "xGSxObjectToBeEnabled"... However, when ownership changes, it doesn't fire @_@ and the chest/activator that I want to enable in the room of an inn doesn't appear. The chest/activator doesn't have an enable parent as I understand that disables the enable() function and is initially disabled... so... what is wrong?

 

Also, I read that RegisterForUpdate(1) is an unsafe command to use... and that RegisterForSingleUpdate() is better in most circumstances, is this one of them? If so, how would I implement it in this case?

 

Thank you for the help!

 

EDIT: After some fiddling, it seems to work properly,

 

 

PS: It may be good to just copy and paste this into Notepad++, as I narrated this script and wrapping is disabled and there is incorrect syntax highlighting.

Scriptname xGSxOwnershipEnableScript extends ObjectReference 

;The purpose of this script is to allow us to enable objects based on the ownership of another object. This is especially useful for inns as the ownership of the rental bed changes, and thus, we can tag objects to be enabled whenever we rent a room. We also see use this for times when a player suddently gains control of a home/area/guild. Keep in mind that we can use a bed (the enabling object whose ownership we now have) to enable a marker rather than then link the script to each individual object and the bed, and then you can link items to that marker. You don't have to use a bed, you can use anything you like, it just so happens that beds typically have a high level of ownership changes. This is preferred since we don't have to edit any vanilla scripts or dialogues, which can be bug prone at times. Keep in mind this is a very general script, it can be used for ANYTHING.

;Set Objects and tell the game what we are referencing to.
ObjectReference Property xGSxEnablingObject Auto 
;The xGSxEnablingObject is the object whose ownership changes, say a rental bed in an inn
ObjectReference Property xGSxObjectToBeEnabled Auto 
;The xGSxObjectToBeEnabled is the object who is enabled due to the fact the player owns xGSxEnablingObject. If you wanted a luggage to travel with you at inns, this is where you would attach the lugguge.

bool xGSxOwnershipScriptOn 
;This boolean variable tells us if the script is on. This is also here so that I don't have to use the RegisterforUpdate commands which can cause save game bloat.

Event OnCellAttach()
	xGSxOwnershipScriptOn = true ;Essentially turns the script on when I enter the cell, this way, I don't have to use Registerforupdate.
	RegisterForSingleUpdate(1) ;Activate the script iniatially
EndEvent

Event OnCellDetach()
	xGSxOwnershipScriptOn = false ;Disables the script when I leave the cell, this way, I don't have to use Registerforupdate.
EndEvent

Event OnUpdate() ;Initially started by entering the cell on Event OnCellAttach
	If (xGSxOwnershipScriptOn == true) ;This asks if the script is on. 
		if (xGSxEnablingObject.isDisabled() == 0) ;Is the enabling object enabled? Most of the time, this is true. But I added this option here in case the enabling object itself gets disabled. This is useful for instances where "great" chaos can occur (like in the DB questline) and items need to disappear. Be vary of this function. 
			if (xGSxEnablingObject.GetActorOwner() == Game.GetPlayer().GetActorBase()) ;This is asking, is the "bed" owned by the player?
				if (xGSxObjectToBeEnabled.isDisabled() == 1) ;If the "bed" is owned by the player, is the object to be enabled off?
					xGSxObjectToBeEnabled.enable() ;If the object to be enabled is off, then turn it on.
				endif
			else
				if (xGSxObjectToBeEnabled.isDisabled() == 0) ;If the bed is not owned by the player, is the object to be enabled on?
					xGSxObjectToBeEnabled.disable() ;Turn the object off.
				endif		
			endif
		endif
		RegisterForSingleUpdate(1) ;Ensures that script continues.
	EndIf
EndEvent

 

 

DId I unregister it correctly? Would it be better to use a while loop? Also is there an AND function in the If command? Like

 

If (x>3 AND y<2)
	wear pants
else
	wear hat
endif
Edited by Cerest
Link to comment
Share on other sites

  • 3 weeks later...

Thank you! I found the page in the CK wiki describing those as well, rather hard to find >_>

 

Another small question.

 

What is wrong with this syntax?

 

Event OnUpdate()
	int PlayerAR = Game.GetPlayer().GetBaseAV("Alteration")
	int PlayerBL = player.GetBaseAV("Block")
EndEvent

Neither of these compile :/

Link to comment
Share on other sites

What are the errors?

 

Your second line:

 

int PlayerBL = player.GetBaseAV("Block")

 

'player' is invalid. It must be 'Game.GetPlayer()'

 

 

If the error says it cannot convert, or something like that, the reason may be because those values are returned as 'float' variable types, and need to be converted to integers.

 

int PlayerAR = Game.GetPlayer().GetBaseAV("Alteration") as int

Link to comment
Share on other sites

That was the issue... gosh, I'm just trying to follow the guides over at the Creation Kit wiki, there is no mention of a "as int" part in the guide for "GetBaseActorValue," (I linked it above in case you want to see it)... thank you! It compiles! :D

 

Any speaking of how much I love the Creation Kit wiki... I'm now having trouble even declaring an array >_>

 

The guide here, uses this command,

 int[] Array1 = new int[5]

Which I thought meant, "make a array of integers named Array1 and have it have 5 elements in it"

 

But apparently not since it doesn't compile! D:

 

It says "no viable alternative at input 'new'" in the Papyrus status.

Link to comment
Share on other sites

I find the 'array's in papyrus confusing myself.

 

It depends on where you put that command in your script. If its outside of 'Event' code, that should work based on what the wiki says.

I would probably separate them instead, with the declaration outside the Event code, and the assignment inside event code.

 

Int[] Array1

Event OnInit()

   Array1 = New Int[10]

EndEvent

Link to comment
Share on other sites

It simply doesn't work outside of event code :(

 

But what you gave me, however, does work, as do all the other Event stuff.

 

Thank you! You are a big help :D

 

Again, NOT in the wiki -_-

Edited by Cerest
Link to comment
Share on other sites

Two more questions:

 

35786-1-1367964363.jpg

 

How exactly can you truncate strings? I'm trying to get rid of the extra 0s there... and I'm not doing so hot.

 

PlayerSTAREL[0] = Math.Floor(CerK / 30)
CerLvlGloStr.SetValue(PlayerSTAREL[0]) ;Strength
CerDispStats[0] = CerLvlGloStr.GetValue() as string ;Strength
AddTextOption("Strength", CerDispStats[0])

The Global value (CerLvlGloStr) is set as a "short" global value, whatever that means... but the rest are integers... so I don't know how the extra 000000000s got there @_@

 

-------------------------------------

 

Secondly, do you know what script handles the "You leveled up! Choose an Attribute" message on the skills menu? I'm trying to just disable the message but still allow the standard level up stuff the occur (like perks and such) but not allow the attributes to be configured. I'm hoping that a script handles that and not a .swf file or something that is hardcoded into the game :S.

Edited by Cerest
Link to comment
Share on other sites

1. I will guess that this is a global:

CerLvlGloStr.GetValue()

 

Globals are all floats, which come with lots of zeros after the decimal.

 

You could move the global float variable into an integer variable, then use that in your 'as string' command.

 

2. I would say that is not a script but a game engine function.

Link to comment
Share on other sites

Quest items are marked as quest object on the properties of the object in the Object List. There is a check box for it.

 

In a cursory look at the functions, I did not see a command to detect if an object is a quest object.

There may be a command for it though, I just didn't see it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...