Jump to content

Help with NPC Looting Bodies Script


Recommended Posts

Well, bad news. I was wrong about the packages working the first time and stopping working, they work as usual, i just thought the npc near the bodies were looting them from the distance, but the problem is even more weird, it's the first looter who never changes. Remains the same and "loots" the bodies from whenever distance the body is, even when dead :/

 

As shown in this video:

 

My question would be if there is a way to re-fill the Looter using the quest system? maybe declaring the looter in the same quest alias as the body? because that part works flawlessly, the new bodies are recognized and filled, old ones and new ones created. Also @LarannKiar where should i put that code? sorry i'm still lost and trying to catch up with your method.

Link to comment
Share on other sites

  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

Well, it didn't work. Mmm, i'm clueless now, will wait for some help while i keep testing.

 

EDIT:

Well crap, i'm dumb. Forgot to untick the "allow dead" and "allow destroyed" .

 

hallelujah.jpg

 

@LarannKiar my dude, thank you so much again for all the help. I have a mentor now. Will have some fun tweaking and getting fancy with this, first will be adding 2 maybe 3 additional looters and bodies to rush things a bit and make several actors interact with bodies at the same time (sound bad but you get me), i plan to add special behaviors on animals and even add a misc item that you can put on favorites so you can order dogmeat to search for bodies without looting them.

Edited by cenarius451
Link to comment
Share on other sites

Glad it works now.

 

Of course I don't want to tell you how to write your own mod but I'd give you some advice.. because my initial version was a bit rushed.. So I'd change some things.

 

- replacing the script variables (like LootedBody_01_Actor) with reference aliases. Filling up the aliases from the quest script; start the game timer (with the OnInit() event) in the ref alias scripts and not in the quest script ..

 

- use the OnCombatStateChanged event: if the actor enters into a combat, the loot package should stop.

 

- also adding IsInCombat == 0 conditions to ref aliases.. (if they're in combat, they would loot nearby bodies.. a mod shouldn't interfere with this vanilla behavior)

 

- IsChild == 0 (just to be sure...)

 

- also you can add the GetInFaction -- WorkshopNPCFaction == 0 (so your settlers won't wander into the wastes to loot bodies).

Link to comment
Share on other sites

@LarannKiar - You should do this mod, you are clearly better than me, i just know how to cut and paste code and try to make it work, besides i just gave the idea for this, i bet this mod would be far better if someone with more knowledge about what can and can't be done with the CK handles it, i mean the trick with the alias quest? seriously i would have never solved that issue. Still i'm happy with your mod as is and will tweak it the best i can. The only concern i have is about the number of bodies and how the game will handle them but worst case i will destroy the bodies the moment the npcs loot them, will look ugly but hey better than a bloated save.

Edited by cenarius451
Link to comment
Share on other sites

@LarannKiar - You should do this mod, you are clearly better than me, i just know how to cut and paste code and try to make it work, besides i just gave the idea for this, i bet this mod would be far better if someone with more knowledge about what can and can't be done with the CK handles it, i mean the trick with the alias quest? seriously i would have never solved that issue. Still i'm happy with your mod as is and will tweak it the best i can. The only concern i have is about the number of bodies and how the game will handle them but worst case i will destroy the bodies the moment the npcs loot them, will look ugly but hey better than a bloated save.

 

You shouldn't give up. :smile:

 

The more time you spend creating mods, the more experienced you'll be.

 

I've made an updated version, here. Of course it's not a problem if you don't understand everything at first.. I always upload the source codes of my scripts, now there are also a lot of notes in them..

 

Anyway I won't steal your idea so you can do whatever you like with it.. :smile:

Edited by LarannKiar
Link to comment
Share on other sites

Well i'm not planning to learn coding. When i said i wanted to learn i meant about the CK and its capabilities, and your coding is just beyond me.

 

Also you sure you sent the right file? this seems to add containers and looters. I also didn't want to mess with containers in your first mod, Quest items are a concern and it's already risky to make npcs loot bodies that might have quest items on them, even when i know they are not deleted just moved onto other npcs but what if let's say Carla loots a quest item? the marker will probably show on her but you would never retrieve it unless it's for sale (would be hilarious and hope it could happend sometimes)? or what about any other npcs you can't kill and loot? risky already.

 

And seriously, steal my idea and make an immersive mod with it. I have a request though,it would be nice if you make a change to your script to allow more looters and bodies, because i tried but i won't be able to make it as the script you made was made with only one looting in mind, or if there is a way to reduce the timer to lets say 5 seconds unless there is a looting happening? in which case the timer would stop?, so if the process "take turns" when looting at least this would allow it to be faster. Right now for example a looter finds a body but there are also two other bodies nearby, the looter loots the first one and then runs away to its original possition, then goes back and loots the second one, and so on, sometimes it even picks a different npc so the looting looks like it's made by turns even when the first looter is closer to the bodies, it doesn't look cute (though still a minor complain, i'm really happy how it works as it is anyway). A way to improve this would be to once a looter is chosen after a body is located, make the looter loot the first body, and then the 5 second timer would give the looter enough time to process a second looting, and a third and a fourth if there are bodies around the looter. Then if there is no bodies left, restart the alias quest so it could pick other looters as well, though idk how to make it because the alias quest now at least in my edit also contains the looter which is what makes possible to pick different looters as your original mod kept the looter even when he died as shown in the third testing video i made. I really hope you do more stuff and release this mod in the future.

 

In the meantime here is my edit and the mod i'm playing with: https://drive.google.com/file/d/1Gq0O21iYt54his332aRcJqhFQrs-_OqM/view?usp=sharing

It works 100%, npcs loot around players (exceptions would be insects, as there are too many to process, like radroaches).

Link to comment
Share on other sites

 

Also you sure you sent the right file? this seems to add containers and looters. I also didn't want to mess with containers in your first mod, Quest items are a concern and it's already risky to make npcs loot bodies that might have quest items on them, even when i know they are not deleted just moved onto other npcs but what if let's say Carla loots a quest item? the marker will probably show on her but you would never retrieve it unless it's for sale (would be hilarious and hope it could happend sometimes)? or what about any other npcs you can't kill and loot? risky already.

 

 

Quest items won't be removed. Only items with the specified keywords will be removed from the dead bodies. It's in the quest script:

	if (CurrentLooter.GetReference() as Actor).GetCombatState() == 0
		int iWaponCount = CurrentlyLooted.GetReference().GetItemCount(ObjectTypeWeapon)
		int iArmorCount = CurrentlyLooted.GetReference().GetItemCount(ObjectTypeArmor)
		int iStimpakCount = CurrentlyLooted.GetReference().GetItemCount(ObjectTypeWeapon)
		int iBottlecapCount = CurrentlyLooted.GetReference().GetItemCount(Bottlecaps)
		int iAmmoCount = CurrentlyLooted.GetReference().GetItemCount(ObjectTypeAmmo)
		if iWaponCount > 0
			(CurrentlyLooted.GetReference() as Actor).RemoveItem(ObjectTypeWeapon, iWaponCount, abSilent = true, akOtherContainer = CurrentLooter.GetReference())
		endif
		if iArmorCount == 1
			(CurrentlyLooted.GetReference() as Actor).RemoveItem(ObjectTypeArmor, abSilent = true, akOtherContainer = CurrentLooter.GetReference())
		elseif iArmorCount > 1 && iArmorCount < 4
			int iRandomInt = Utility.RandomInt(1, 2)
			(CurrentlyLooted.GetReference() as Actor).RemoveItem(ObjectTypeArmor, iRandomInt, abSilent = true, akOtherContainer = CurrentLooter.GetReference())
		elseif iArmorCount >= 4
			int iRandomInt = Utility.RandomInt(2, 4)
			(CurrentlyLooted.GetReference() as Actor).RemoveItem(ObjectTypeArmor, iRandomInt, abSilent = true, akOtherContainer = CurrentLooter.GetReference())
		endif 
		if iStimpakCount > 0
			(CurrentlyLooted.GetReference() as Actor).RemoveItem(ObjectTypeStimpak, iStimpakCount, abSilent = true, akOtherContainer = CurrentLooter.GetReference())
		endif
		if iBottlecapCount > 0
			(CurrentlyLooted.GetReference() as Actor).RemoveItem(Bottlecaps, iBottlecapCount, abSilent = true, akOtherContainer = CurrentLooter.GetReference())
		endif
		if iAmmoCount > 0
			(CurrentlyLooted.GetReference() as Actor).RemoveItem(ObjectTypeAmmo, iAmmoCount, abSilent = true, akOtherContainer = CurrentLooter.GetReference())
		endif
	endif

if there is a way to reduce the timer to lets say 5 seconds unless there is a looting happening? in which case the timer would stop?

 

The loot timer is defined by a Global Variable: NDB_G_Start_Helper_Timer_Time. It's set to 10. StartTimer() uses real-time which means it's 10 seconds. It's not Constant so you can change this global: if you change it to 3600, you'll see only one looting NPC in one "real" hour.

 

But changing the StartTimer() (real-time rimer) to StartTimerGameTime() (game-time timer) is also an option.

 

 

a looter finds a body but there are also two other bodies nearby, the looter loots the first one and then runs away to its original possition, then goes back and loots the second one, and so on, sometimes it even picks a different npc so the looting looks like it's made by turns even when the first looter is closer to the bodies, it doesn't look cute (though still a minor complain, i'm really happy how it works as it is anyway). A way to improve this would be to once a looter is chosen after a body is located, make the looter loot the first body, and then the 5 second timer would give the looter enough time to process a second looting, and a third and a fourth if there are bodies around the looter. Then if there is no bodies left, restart the alias quest so it could pick other looters as well, though idk how to make it because the alias quest now at least in my edit also contains the looter which is what makes possible to pick different looters as your original mod kept the looter even when he died as shown in the third testing video i made. I really hope you do more stuff and release this mod in the future.

 

 

In the updated version, the same looter and corpse won't be used by the looter quest for at least 2 game-hours.

 

That's why the RecentlyLooted_01 - 10 and the RecentLooter_01 - 10 aliases are: each alias has a keyword (NDB_RecentlyLooted_Keyword and NDB_RecentLooter_Keyword). After looting, these aliases get filled with the references of the looted body and the looter. The looter quest will not pick NPCs with these keywords.

 

You don't have to worry about save bloat either. The new version only uses one script variable (the furniture: LootFurniture) which is set to be disabled and deleted immediatelly after the looter quest stops. Also, keywords won't be added to actors by scripts. NPCs only have temporary keywords (by being quest aliases). Quest aliases will be cleared by this game timer:

Function InitializeMe()
	StartTimerGameTime(NDB_G_RecentLooter_Timer_Initial_Time.GetValue(), RecentLooter_TimerID)
EndFunction


Event OnTimerGameTime(int aiTimerID)
	if Self.GetReference().Is3DLoaded() == 1
		StartTimerGameTime(NDB_G_RecentLooter_Timer_Time.GetValue(), RecentLooter_TimerID)
	else
		RecentLooters.RemoveRef(Self.GetReference())
		Self.Clear()
	endif
EndEvent


Event OnDeath(Actor akKiller)
	RecentLooters.RemoveRef(Self.GetReference())
	Self.Clear()
EndEvent
Edited by LarannKiar
Link to comment
Share on other sites

Well i'm back to modding. I tested your updated version, and it's cute and all but i don't like it because the furniture animation is nice but makes things too slow, that and looters seem happy to loot only ammo because they ignore armor and weapons, weirdly enough. I took a look at your script and they should take the rest. I don't know why they don't. Also they still loot in turns but even slower. I even have the time to follow them, and loot the bodies they find while they do the crouching and search animation, which is sad, and on top of it they aren't selected until 2 ingame hours according to your description above? that makes it so i see the three looters at drumlin dinner do nothing after they loot their bodies, while there are several bodies remaining to be looted.

 

That's why i prefer to keep working on the older mod, with some tweaks it can be improved. I'll give the fight with the script and see if i can make the timer shorter and quicker without interrupting a looting process, so i don't have to wait much for a looter to be chosen because for me that's the main problem, i can accept them being chosen in turns at random but looters are chosen too slowly.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...