Jump to content

geck scripting problem


macgun1

Recommended Posts

Posted

hi guys

 

I have been looking around for an auto looting mod for new vegas and have had trouble finding one with all the features I wanted.

 

I was hoping to find one that came up with a message in the corner telling you what you picked up otherwise I find myself constantly checking if its working or not and also not knowing what I have picked up is a pain.
I also wanted it to automatically pick plants.

 

I could not find anything with those features for new vegas. I did find auto loot enhanced (https://www.nexusmod...egas/mods/42631) but again it does not have the feature I want. So I figured if it does not have it then I will add it (the creator of the mod has stated in the comments of his mod that he is ok with anyone trying to improve it).

 

I would like to state though that I have never created a mod or edited one before beyond changing textures in a mod, never touched coding so this is a first for me though I do know a little about coding.

 

anyway the problem I have bumped into is that the auto harvest mod is now not collecting from npc bodies and I cannot figure out why. it collects items dropped on the floor and I managed to successfully get it to collect plants (turns out the code was in there but only one plant was added) and I also added messageex commands than it works fine.

 

I have noticed that it will not collect items when im standing next to the bodies so it seems to be stuck trying to collect from the bodies. there is also a code that will tell you with messageex if there is a gun nearby without picking it up

 

here is a section of the code for bodies. im pretty sure its actually a problem with all containers but bodies were the ones I was testing with and im presume if I can fix this code I can fix the others.

Ref NPCR             ;npc body
Ref InvPos           ;Inventory position in the body
Ref Invcount         ;number of unique items in body
Ref Lootr            ;current selected item
Ref Lootname         ;Ref I added to store the in game name of the current item selected
Ref Lootcount        ;Ref I added to store the amount of current item selected
short XChem          ;variables to indicate item is various items if >= 0 pick up item
short XAlchC
short XDrink
short XAlch
short XFood
short XHunger
short XMag
short XAlchM
short XThirst
short XVeno
short XEW
short XExpl
short XGun
short XAmmoM
short XBook
short XEPlace
short XEThrow
short XCMNY
short XMsc
short XMscEW
short XMscExpl
short XMscGun
short XMscC
short XMscQ
set NPCR to GetFirstRef 42 1 0              ;targets npc body
	Label 42                            ;loop 42 start
	if IsFormValid NPCR                 ;validity check
		if (Player.GetDistance NPCR < 201) && (NPCR.GetDisabled == 0) &&  (NPCR.GetDead == 1)            ;if player under a certain distance and body not disabled and body dead then:
			if ALEnhGKey          ;toggle option in mcm?
				NPCR.RemoveAllTypedItems player 1 1 46
			endif
			if ALEnhGNote
				NPCR.RemoveAllTypedItems player 1 1 49
			endif
			if ALEnhGIMOD
				NPCR.RemoveAllTypedItems player 1 1 103
			endif                 ;removes items and gives to player?
			set InvPos to 0        ;initial inventory position
			Label 210                ;loop 210 start
			set InvCount to NPCR.GetNumItems     ;sets inv count to inv size
			if InvPos < InvCoun        ;if selected item position less than inv size then
				set LootR to NPCR.GetInventoryObject InvPos    ;sets current selected item as the item of the current position
				Set Lootname to LootR.getbaseobject         ;I added to get item name
				Set Lootcount to Lootr.getrefcount          ;I added to get item amount
				if ALEnhGChem             ;global variable to indicate mcm menu checkbox is ticked? (pick up chems)?
					set XChem to ListGetFormIndex ALEnhLChem LootR  ;checks if loot is in the chems list else returns -1
				else
					set XChem to -1     ;if the chems checkbox is unticked automatically sets not to pick up
				endif                         ;below is a repeat of the previous but for different lists and items
				if ALEnhGAlchC
					set XAlchC to ListGetFormIndex ALEnhLAlchC LootR
				else
					set XAlchC to -1
				endif
				if ALEnhGDrink
					set XDrink to ListGetFormIndex ALEnhLDrink LootR
				else
					set XDrink to -1
				endif
				set XAlch to ListGetFormIndex ALEnhLAlch LootR
				if ALEnhGFood
					set XFood to ListGetFormIndex ALEnhLFood LootR
				else
					set XFood to -1
				endif
				set XMag to ListGetFormIndex ALEnhLMag LootR
				if ALEnhGAlchM
					set XAlchM to ListGetFormIndex ALEnhLAlchM LootR
				else
					set XAlchM to -1
				endif
				if ALEnhGVenom
					set XVeno to ListGetFormIndex ALEnhLVenom LootR
				else
					set XVeno to -1
				endif
				if ALEnhGEW
					set XEW to ListGetFormIndex ALEnhLEW LootR
					set XMscEW to ListGetFormIndex ALEnhLMiscEW LootR
				else
					set XEW to -1
					set XMscEW to -1
				endif
				if ALEnhGExpl
					set XExpl to ListGetFormIndex ALEnhLExpl LootR
					set XMscExpl to ListGetFormIndex ALEnhLMiscExpl LootR
					set XEPlace to ListGetFormIndex ALEnhLExplPlace LootR
					set XEThrow to ListGetFormIndex ALEnhLExplThrow LootR
				else
					set XExpl to -1
					set XMscExpl to -1
					set XEPlace to -1
					set XEThrow to -1
				endif
				if ALEnhGGun
					set XGun to ListGetFormIndex ALEnhLGun LootR
					set XMscGun to ListGetFormIndex ALEnhLMiscGun LootR
				else
					set XGun to -1
					set XMscGun to -1
				endif
				if ALEnhGAmmoM
					set XAmmoM to ListGetFormIndex ALEnhLAmmoM LootR
				else
					set XAmmoM to -1
				endif
				set XBook to ListGetFormIndex ALEnhLBook LootR
				set XCMNY to ListGetFormIndex ALEnhLCMNY LootR
				set XMsc to ListGetFormIndex ALEnhLMisc LootR
				if ALEnhGMiscC
					set XMscC to ListGetFormIndex ALEnhLMiscC LootR
				else
					set XMscC to -1
				endif
				if ALEnhGMiscQ
					set XMscQ to ListGetFormIndex ALEnhLMiscQ LootR
				else
					set XMscQ to -1
				endif
				if ALEnhGCons
					set XHunger to ListGetFormIndex ALEnhLHunger LootR
					set XThirst to ListGetFormIndex ALEnhLThirst LootR
				else
					set XHunger to -1
					set XThirst to -1
				endif
				if ALEnhGPros
					if (GetType LootR == 40) && (GetWeight LootR != 0) 
						if (ListGetFormIndex ALEnhLExplPlace LootR < 0) && (ListGetFormIndex ALEnhLExplThrow LootR < 0) && (GetValue LootR / GetWeight LootR >= ALEnhGRatio)     ;this works fine, checks weapon weight and rather than pick it up it notifies that there is a weapon
							MessageEx "Weapon available."
						endif
					endif
				endif
				if (XChem >= 0) || (XAlchC >= 0) || (XDrink >= 0) || (XAlch >= 0) || (XFood >= 0) || (XMag >= 0) || (XAlchM >= 0) || (XVeno >= 0) || (XEW >= 0) || (XExpl >= 0) || (XGun >= 0) || (XAmmoM >= 0) || (XBook >= 0) || (XCMNY >= 0) || (XMsc >= 0) || (XMscEW >= 0) || (XMscExpl >= 0) || (XMscGun >= 0) || (XMscC >= 0) || (XMscQ >= 0) || (XEPlace >= 0) || (XEThrow >= 0) ;if the current item scored greater than -1 then
					NPCR.RemoveItem LootR 1  ; removes item from body
					Player.AddItem LootR 1 1   ;adds item to player
					Messageex "you took %.0f %n's" Lootcount Lootname  ;I added this to indicate when picking things up
				elseif (XHunger >= 0) && (Player.IsHardcore == 1) && (Player.GetAV Hunger >= ALEnhGHunger) && (Player.HasMagicEffect RestoreStarvationLevel == 0)   ;checks if player is in hardcore and feeds them if hunger is above certain amount
					NPCR.RemoveItem LootR 1        ;repeat of above
					Player.AddItem LootR 1 1
					Player.CastImmediateOnSelf LootR       ;consumes item instead
					messageex "you consumed %n" Lootname    ;message i added to indicat consumption
					Player.RemoveItem LootR 1 1           ;removes item from player inventory
				elseif (XThirst >= 0) && (Player.IsHardcore == 1) && (Player.GetAV Dehydration >= ALEnhGThirst) && (Player.HasMagicEffect RestoreDehydrationLevel == 0)
					NPCR.RemoveItem LootR 1              ;repeat of above for thirst
					Player.AddItem LootR 1 1
					Player.CastImmediateOnSelf LootR
					messageex "you consumed %n" Lootname
					Player.RemoveItem LootR 1 1
				else
					set InvPos to InvPos + 1       ;adds one to counter (possibility of missing items as item count will change? though code repeats so may not matter)
				endif
				Goto 210  ;end loop
			endif
		endif
		set NPCR to Pencil01    ;out of date fix to problem according to wiki its been patched. see no need to change it as it should have no effect
		set NPCR to GetNextRef    ; go to next body
		Goto 42 ;loop code again
	endif

	

I added all the comments on the code as there were none before, it was very difficult to figure out exactly what everything meant. any help would be appreciated, if needed I can upload the script in so people can troubleshoot it themselves.

Posted

here's a typo:

 

if InvPos < InvCoun        

 

it lacks a T at the end

Posted
1 hour ago, A.J. said:

here's a typo:

 


if InvPos < InvCoun        

 

it lacks a T at the end

thanks for pointing it out, thankfully with errors like that the programs refuses to let you save it and says what line the error is on so i managed to find it.

 

I have actually managed to figure out alot of it and I have changed alot since I posted this, but I still need to test it out in game. If it works I might see if I can contact the original auther and see if he wants to upload it. I doubt it though as he has not been online in a while.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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