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

Hitting an object with a specific item in hand.


_echo
 Share

Recommended Posts

I made this script to help me detect when the player hit an object with a specific item. I will be using it for my custom resource gathering for a project of mine. Its not perfect nor pretty, but it works, so I thought I would share it.

Scriptname MyMiningSCRIPT extends ObjectReference  


;==========

;Properties

;==========


WEAPON Property MyPickaxeProp  Auto  

;Needs to be set in the Properties window.


;==========

;Functions

;==========


Function MessageBox(string asMessageBoxText) native global

;Used for the debug message boxes.


Bool Function IsEquipped(Form akItem) native

;A yes or no variable to detect if a specific item is equipped.


Int Function RandomInt(int aiMin = 0, int aiMax = 100) native global

;The random number minimum and maximum.


;==========

;Events

;==========


Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \

  bool abBashAttack, bool abHitBlocked) 

;Not sure if all this is necessary, so i kept it just in case.


Int Random = Utility.RandomInt() ;Assigning the random number to the variable "Random".


	If (Game.GetPlayer().IsEquipped(MyPickaxeProp)) ;Checking the equipped status of the given item.

		If Random >= 50

			Debug.MessageBox("The value is 50 or higher.")

		Elseif Random < 50

			Debug.MessageBox("The value is 49 or lower.")

		EndIf

	EndIf


EndEvent

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