Jump to content

Borderlands style interactions


SpartanISW108

Recommended Posts

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

I'll just go ahead and post my whole script, since the mod is free for anyone to edit/reuse as the see fit.

 

Mine tracks weapon health on drop, only picks up armor, food, book, weapon types, and only drops weapons when tapping the E key (I had issues with drop detection and picking up new items with something already equipped).

scn GAGMainSCRIPT

int iKeyTrap
int iType
int iEquipType
int bHelp
int bHeld
int bEquipMode
int bDropMode
ref rGrabbed
ref rItem
ref rBase
float fTimer
float fTemp

BEGIN GameMode
	
	; Display an instruction message the first time the mod is run
	if (bHelp == 0)
		set bHelp to 1
		showTutorialMenu GAGHelpMsg
	endif
	
	; Equip the grabbed item
	if (bEquipMode == 2)
		if (IsPlayerActionActive 5)
			if (IsFormValid rGrabbed)
				set iType to GetType rBase
				if (iType == 24)		; Armor
				elseif (iType == 25)	; Book
				elseif (iType == 26)	; Clothing
				elseif (iType == 40)	; Weapon
				elseif (iType == 47)	; Food
				else
					set bEquipMode to 0
					Return
				endif
				rGrabbed.Activate Player 1
				set bEquipMode to 3
				PlaySound GAGEquipSound
				Return
			endif
		endif
		PlaySound GAGMissSound
		set bEquipMode to 0
		Return
	elseif (bEquipMode == 3)
		player.EquipItem rBase
		set rItem to 0
		set rBase to 0
		set bEquipMode to 0
		Return
	endif
	
	; Drop the equipped item
	if (bDropMode == 2)
		set fTemp to Player.GetEquippedCurrentHealth 5
		Player.UnequipItem rItem
		set bDropMode to 3
		PlaySound GAGEquipSound
		Return
	elseif (bDropMode == 3)
		Player.RemoveItem rItem 1
		set bDropMode to 4
		Return
	elseif (bDropMode == 4)
		set fTemp to fTemp / GetHealth rItem
		set rItem to Player.PlaceAtMeHealthPercent rItem fTemp 1 100 0
		set rItem to 0
		set bDropMode to 0
	endif

	if (fTimer > 0)
		set fTimer to fTimer - GetSecondsPassed
	elseif (iKeyTrap > bHeld)
		if (bEquipMode)
			set bHeld to 1
			set bEquipMode to 2
		elseif (bDropMode)
			set bHeld to 1
			set bDropMode to 2
		endif
	endif
	
	if (iKeyTrap != IsControlPressed 27)		; Grab
		set iKeyTrap to IsControlPressed 27
		if (iKeyTrap)
			if (IsPlayerActionActive 5)
				printc "Grab active, grabbing"
				set rGrabbed to GetPlayerGrabbedRef
				if (IsFormValid rGrabbed)
					set rBase to rGrabbed.GetBaseObject
					set fTimer to GAGEquipTimerDelay
					set bHeld to 0
					set bEquipMode to 1
					Return
				endif
			elseif (IsControlPressed 5)		; Activate
				printc "Grab active, dropping"
				set rItem to Player.GetEquippedObject 5
				if (IsFormValid rItem) && (Player.IsWeaponOut == 1)
					set fTimer to GAGDropTimerDelay
					set bHeld to 0
					set bDropMode to 2
					Return
				endif
			endif
			set iKeyTrap to 0
			Return
		endif
	endif
END

The only "issue" as I'm sure this is the one the OP was referring to previously, is that the pickup+equip key is just holding grab, with no modifier. Adding a modifier would be pretty simple, but as there is a premium on keys/controls that are easy to reach, I felt it was fine to use a single key on an adjustable timer (set global vale to adjust).

 

Line 98 is what determines the extra key to drop something, and the two checks on line 101 only allow dropping if the weapon is in hand, no dropping holstered weapons.

Link to comment
Share on other sites

So if I were to take this script and modify it slightly to my tastes, it would work where holding grab+ tapping interact (E) would pick up and auto equip the weapon, regardless of what I have currently equipped? And that it wouldn't break when I use the grab command on something that isn't able to be auto-equipped? And I'd be able to change the drop currently equipped weapon key to "X"?

And also compatible with FOSE as opposed to NVSE (Some commands aren't in FOSE but are in NVSE)?

Link to comment
Share on other sites

To make it do what you want, change line 88 to be

if (IsPlayerActionActive 5) && (IsControlPressed 5)

and then to change the drop you'll need to make it be

IsKeyPressed 45

Look up scancodes here, for isKeyPressed.

It looks like it doesn't use any non-FOSE functions, so it should port back just fine. Actually, the mod has no master files, and so it can be moved around with no issues. I could just make a version that has a button selection, but that's a lot of extra code I didn't feel like writing. Feel free to modify and edit it however you want. You can release it if you like, just point back to my version too please :)

Link to comment
Share on other sites

Where would iskeypressed 45 go?

I tried making sense of this script but due to me lacking any form of proficiency in scripting I can't make complete sense of this script.

To me it seems split into 3 with the drop function being in the middle but I can't seem to see where the drop part starts

Link to comment
Share on other sites

I was not fully clear. Line 88 is the grab function, and line 98 is the drop. Put the IsKeyPressed bit in the IF statement for line 98, and the other part in line 88. Remove what is at 98 now, so:

elseif isKeyPressed 45
Link to comment
Share on other sites

Grab+E doesn't work to auto equip the weapon doing the changes you made. And drop becomes grab+X, I wish for it to be just X but I can't seem to see another variable controlling the drop function.

If you could just get the Grab+E part to work I can just put in my bit of drop script, as they both seem to do exactly the same in terms of weapon clipping through ground at times.

Really sorry I'm coming across as an idiot here :/

Link to comment
Share on other sites

 

 

set rItem to Player.PlaceAtMeHealthPercent rItem fTemp 1 100 0

Try upping the z-axis position so that the weapon has some time to fall before hitting the ground. That should help with ground collision detection. I used 0,0,140 to drop the Configuration Duck on the player's head in LCWE-FO3 and never had it fall through the ground.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...