Jump to content

[LE] Need some help scripting a menu with three options


Recommended Posts

- If by "hitbox" you mean the mesh's Collision.

It depends on the type of the mesh's collision, some can be adjusted in NifSkope and some other needs to be edited in a 3D program like 3D Studio Max.

But none of them can be edited/adjusted in CK.


- If by "hitbox" you mean the "Virtual Box" that surrounds all objects and it's use to define the models range in the XYZ 3d space.

Then, no.


- If by "I've scaled the .nif and now the box is huge" you mean scaling the nif in NifSkope.

The answer is related to the above.

Link to comment
Share on other sites

 

- If by "hitbox" you mean the mesh's Collision.
It depends on the type of the mesh's collision, some can be adjusted in NifSkope and some other needs to be edited in a 3D program like 3D Studio Max.
But none of them can be edited/adjusted in CK.
- If by "hitbox" you mean the "Virtual Box" that surrounds all objects and it's use to define the models range in the XYZ 3d space.
Then, no.
- If by "I've scaled the .nif and now the box is huge" you mean scaling the nif in NifSkope.
The answer is related to the above.

 

Sad then, since I think it's the second option. In the ck, it's the gizmo that determines the thing that you mentioned. I've investigated a bit while I was writing the previous post, and it seems to be a bug inside of the engine of Skyrim, unfixable, which is a shame.

 

Either way, thanks for all of your help with this. I've never been an expert with ck and my mods are rather simple, that there's no need to use scripting most of the times.

 

Cheers!

Edited by xGoReTHeRoNx
Link to comment
Share on other sites

It's not a bug, this "Virtual Box" that you see in CK around the objects is what the CK uses to "Snap to Grid" and "Snap to Angle", it's what holds the data that CK needs so that you can place / move objects around in the 3d space and link objects together.


CK dosen't actualy see the 3d models as you comprehend them (as your eyes / brain see them), but only their XYZ data needed for the occupation/population in the 3d space.


* CK only sees "Dots", otherwise known as "Vertex".



Everybody started with simple things at some point in their modding journey, scripting it's just one more step in the evolution of your modding skills.


And as you probably already know everything in games is based on 'Codes', so learning coding it's a must if you want to break the "Amateur Barrier" and jump/leap forwards/evolve to a higher modding status.

* Once you start learning coding, a vast whole new world will unfold in front of you...


Have a nice weekend.

Edited by maxarturo
Link to comment
Share on other sites

Hi Nexus community!

 

I've been out of modding a lot of time by now, and I need some help scripting a menu, simple in terms of purpose, but complicated when I have to write the script of it.

My knowledge about Papyrus and programming in general is zero and normally I avoid as much as possible the scripting thing.

 

But in this case, I see myself forced to use it, since there's no other way to do it properly.

 

I have an idea that is a custom placeable shrine that gives you some blessings all at a time. I want that shrine to be able to be dropped and picked up whenever I want.

 

The thing that came to my mind was through a menu that, when you activate it, it'll show 3 options: Receive the custom blessing, pick up the shrine, or cancel.

 

I've been using a mod that I know of, that does the thing I want partially. It's called Your Market Stall, but its programming seems a bit complicated.

 

I've managed to drop the shrine from my inventory, and stays put the way I want, and when I click on it, the menu shows correctly, and it gives me the blessing, but it fails when has to pick up the shrine or simply, cancelling the action.

 

This is the code I've got. I'm learning from imitation, and it is far from being finish, so don't be hursh please.

Scriptname ArtisanShrineScript extends ObjectReference  

MiscObject Property ArtisanShrine Auto
Spell Property ArtisanSpellFortAlchemy Auto
Spell Property ArtisanSpellFortEnchanting Auto
Spell Property ArtisanSpellFortSmithing Auto
Message Property ArtisanShrineMenu Auto
Message Property ArtisanShrineAddBlessMsg  Auto  
Message Property ArtisanShrineRemoveBlessMsg  Auto
Message Property ArtisanShrineRemoveFailMsg Auto
Bool Property isPlaced = false Auto Hidden 

Event onLoad()
	if (is3DLoaded())
		blockActivation(true)
	endIf
endEvent

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
		if (akOldContainer == Game.getPlayer())
			ObjectReference shrine = placeAtMe(ArtisanShrine, 1, false, true)
			shrine.setPosition(shrine.getPositionX(), shrine.getPositionY(), akOldContainer.getPositionZ())
			shrine.setAngle(180, 180, akOldContainer.getAngleZ())
			float px = shrine.getPositionX()
			float py = shrine.getPositionY()
			float pz = shrine.getPositionZ()
			float pA = shrine.getAngleZ()
			float distance = 50
			distance = 60
			shrine.enable()
			disable()
			delete()
		else
			disable()
			setPosition(getPositionX(), getPositionY(), akOldContainer.getPositionZ())
			setAngle(180, 180, akOldContainer.getAngleZ())
			enable()
		endIf
endEvent

int Button
Event OnActivate(objectReference akActionRef)
	If akActionRef == Game.GetPlayer()
		Button = ArtisanShrineMenu.show()
			if Button == 0
				ArtisanSpellFortAlchemy.Cast(akActionRef, akActionRef)
				ArtisanSpellFortEnchanting.Cast(akActionRef, akActionRef)
				ArtisanSpellFortSmithing.Cast(akActionRef, akActionRef)
				if akActionRef == Game.GetPlayer()
				ArtisanShrineRemoveBlessMsg.Show()
				ArtisanShrineAddBlessMsg.Show()

			elseif Button == 1

Event OnActivate(ObjectReference akActivator)
	if(isPlaced == FALSE) 
		if akActivator.getItemCount(ArtisanShrine) >= 1
			isPlaced = TRUE
			self.getLinkedRef().enable()
			(akActivator as actor).removeItem(ArtisanShrine, 1)
		else
			ArtisanShrineRemoveFailMsg.show()
		endif
	else
		isPlaced = FALSE  
		self.getLinkedRef().disable()
		(akActivator as actor).addItem(ArtisanShrine, 1)
	endif
endEvent

As you can see it's a complete mess, but I know that someone with programming knowledge could help me. I've been with this several days with no luck at all.

Any help would greatly appreciated.

Not a complete mess.

 

Scripts on objectreferences don't need to have their positions called via GetPosition, and instead you can use x y or z. Yeah, the letters. Also the virtual box is called the bounding box.

Edited by AnishaDawn
Link to comment
Share on other sites

Yeah.... "Bounding Box"...!!!!!, i was stuck for 2 days trying to remember the actual name, but i just couldn't remember...!!!, well i guess one brain can only do so much...

Link to comment
Share on other sites

Well, I've been playing with the mod ingame for a while, and although it works as I wanted, isn't that perfect, haha.

 

The thing is, that your codes (Maxarturo and the other guy/girl, I can't remember the name now), are working perfect.

 

But there's a problem, because sometimes the shrine sinks into the ground (like if there's no collision), and disappears before me.

 

Is there any way to fix that, in a way that if you are looking at some point, the shrine would stay over the place you put it? Let's say a workbench for example, or maybe a table.

 

PS: Thanks for the info about CK, it's an impressive tool but tricky like no other, even more if you haven't enough knowledge about programming.

As I mentioned earlier, my mods are simple. Like retextures, or maybe modified armors, but that's it, hehe.

Link to comment
Share on other sites

"sometimes the shrine sinks into the ground (like if there's no collision)"

The only way that something like this could happen is if the "Shrine Activator" has Havok behavior, which it shouldn't !!, only the "Misc Shrine" should have 'Havok' although it's not necessary, because it gets imidiately disabled after droping it from the inventory.


I can't see any other reason why this could happen, especially since the scripts i posted are just small parts of some of mine in-game working scripts, and by now they have been tested literally thousands of times, since more than a month now i've been only playing the game using all my mod's stuff.

But in the other hand, you are the only one sitting in front of your PC, so there is no way i can know what you have actually done and what you've done wrong.


*** Don't ever use a 'Save File' that has seen the script to test it.

Don't ever use a 'Save File' that has seen your script, and then modify the script > save > and test. All modifications on scripts need a 'Save File' that has never seen the script to test it.


Before "baking" the script into your playing 'Save File', you need to test it using "COC" and 'Save Files' that you will then delete. This is a repeating process.

Link to comment
Share on other sites

Hello again Maxarturo!

 

First, I have no doubt about your scripts or the ones of the other guy. I know that is a thing from my part, and thus, I've been investigating and testing some more. As a note, I've done all my testing working directly with coc qasmoke and coc whiterun, without loading any of my saves.

 

I think that the thing that occurs with the shrine itself, it is caused by the .nif. See, I used the blacksmithing anvil as a base, which, it's static by nature, and not designed to be carriable or droppable.

 

But I realized that if you jump onto the furniture (a table for example), the shrine will stay stable in front of you, but if you do it when you're on the floor, the shrine will be at the floor, ignoring the table. So, I guess there's no way to fix that since it takes as reference the Z and X axis where you are at the moment you put the shrine.

 

I don't know I've explained correctly, but I hope it will be understandable.

 

I suppose that the solution to put the shrine on a surface, is to be (the player) on the same suface as well.

 

Your scripts definitely work so there's no problem with that, maybe it's me that I didn't explained myself well in the first place.

 

Here are some pictures of it in qasmoke.

 

Screen-Shot3.png
Screen-Shot4.png
Screen-Shot5.png
Screen-Shot6.png
I suppose that the shrine it's a bit to the left because it's a scalated object, but I'm not sure. It should be in the center, right?
Edited by xGoReTHeRoNx
Link to comment
Share on other sites

Your issue is cause by the fact that the whole setup doesn't care or detects if there is an object or void in front of the player, the script only cares about the player's position (The Player's BSFadeNode), so that it can place the "Shrine's BSFadeNode" where the script calls.

The functions:

GetPosition

SetPosition

GetAngle

SetAngle

MoveTo

Cannot detect obstacles or the void, if the player is facing a wall or a big rock, and so on....


If this is for a public mod, then you need to inform the downloaders how to use the 'Shrine', like what not to do ( standing in front of a wall ).


* There is a way to resolve this, but things start to become a little more complicated.


Your shrine in my opinion is way to small, and i think you need to at least give it some height, you need to take in account the fact that a player could use it outdoors and where it will spawn there may be a rock or a pile of straw or whatever.


Your 'Shrine it's not in the center because the whole mesh it's not aligned with the meshe's "BSFadeNode", the game engine only sees the "BSFadeNode" and not the actual model.


The "BSFadeNode" is the reference that gives the origin position of the mesh, for example:

- Actor's have theirs in the center of their 2 legs in the ground position.

- Misc Sphere objects have theirs in the center of the object, so that the "Havok" can work and roll correctly.


I hope it helps, and have a nice week.

Link to comment
Share on other sites

I forgot to add in all my previous posts that, i used a 'Value of 200' to move the shrine in front of the player, i just put this value from the top of my head, which it may need to be adjusted so that the shrine spawns in front / right near the player's feet.


** I think in one of my scripts / set ups which does something similar, i've added a value of 75 to spawn the object half a meter (in human metrics) in front of the player's feet.

But i'll have to check it because i don't really remember...


I think a good number would be 100 or 75, but you need to test it so that it fits to your liking.



shrine.MoveTo(Game.GetPlayer(), 100.0 * Math.sin(az), 100.0 * Math.cos(az), 0.0, false)



Minimizing the 'Spawn Distance' will also help a lot to avoid spawning the shrine inside or beneath any other objects if the shrine's spawn location is obscured by another mesh.


I hope it helps.

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...