This looks alright on paper...

Post » Thu Jan 10, 2013 5:39 am

I wrote this a while ago for BBD's "Hunting in Skyrim" mod. The end result is supposed to be a bottle of "Animal Attractant" that when dropped leaves a "scent pile" which then attracts local animal actors (like in red dead redemption)

After a couple of tests and revisions i just couldn't figure out why I wouldn't work and it ended up being shelved after the two of us got distracted by other things

After being reminded of it today, I thought i'de post it here to maybe get more brains on the case


Here's the setup:

FormList AnimalList (filled with all the animal actors)
GlobalVariable BaitTracker (set to 0)
MiscObject ScentBottle (following script attached to base object)
Spoiler
Scriptname RDRScentBottleScript extends ObjectReference  Activator Property scentPile  autoGlobalVariable Property baitTracker  autoEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)   If (akOldContainer == game.GetPlayer()) && !akNewContainer      If (baitTracker.GetValue() == 0)         Utility.Wait(5.0)         Self.PlaceAtMe(ScentPile)         Debug.Notification("Scent Pile deployed")         baitTracker.SetValue(1)         Self.Delete()      Else         Self.Delete()         akOldContainer.AddItem(self)         Debug.Messagebox("You can only use one bait at a time")      EndIf   EndIfEndEvent
Activator ScentPile (following script attached to base object)
Spoiler
Scriptname RDRScentPileScript extends ObjectReference  FormList Property animalList  AutoInt timer = 0Int div = 1Int Property duration = 60  AutoGlobalVariable Property baitTracker  AutoActor[] randomActorArrayActor Property playerREF  AutoEvent OnInit()	Debug.Notification("Initialised")	randomActorArray = New Actor[10]	GoToState("Start")EndEventState Start	Event OnBeginState()		RegisterForSingleUpdate(1)		Debug.Messagebox("Timer Started")		FillArray(randomActorArray)		Debug.Messagebox("Animal Array"+"\n Animal 1 = " +randomActorArray[0].GetActorBase()+"\n Animal 2 = " +randomActorArray[1].GetActorBase()+"\n Animal 3 = " +randomActorArray[2].GetActorBase()+"\n Animal 4 = " +randomActorArray[3].GetActorBase()+"\n Animal 5 = " +randomActorArray[4].GetActorBase()+"\n Animal 6 = " +randomActorArray[5].GetActorBase()+"\n Animal 7 = " +randomActorArray[6].GetActorBase()+"\n Animal 8 = " +randomActorArray[7].GetActorBase()+"\n Animal 9 = " +randomActorArray[8].GetActorBase()+"\n Animal 10 = " +randomActorArray[9].GetActorBase())	EndEvent	Event OnUpdate()		If (timer == 0)			PathNthActorArray(randomActorArray, 0)			timer += 1			RegisterForSingleUpdate(1)		ElseIf(timer < duration) && (timer > 0)			SendActorArray(randomActorArray, div)			timer += 1			RegisterForSingleUpdate(1)		ElseIf (timer >= duration)			GoToState("End")		EndIf	EndEventEndStateState End	Event OnBeginState()		Debug.Notification("Scent Bait depleted")		self.Disable()		self.Delete()		Timer = 0		baitTracker.SetValue(0)	EndEventEndStateFunction FillArray(Actor[] akActorArray, Int aiElement = 0)	aiElement = akActorArray.Length	While aiElement > 0		aiElement -= 1		akActorArray[aiElement] = (Game.FindRandomReferenceOfAnyTypeInListFromRef(animalList, playerREF, 4096.0) as Actor)	EndWhileEndFunctionFunction PathNthActorArray(Actor[] akActorArray, Int aiElement = 0)	akActorArray[aiElement].PathToReference(self, 0.7)EndFunctionFunction  SendActorArray(Actor[] akActorArray, Int i = 0)	If (timer == ((duration / 10) * i))		PathNthActorArray(akActorArray, i)		Debug.Notification("Sending Actor "+(i + 1))		div += 1	EndIfEndFunction

When I tried it out in game, the bottle switched for the scent pile "okay" (I use that term loosely because it kept spawning the activator in mid-air). But then, nothing. No animals pathing. Maybe it's because the activator was not on the ground?

Any ideas? Does anything stand out?

- Hypno
User avatar
Dewayne Quattlebaum
 
Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm

Post » Thu Jan 10, 2013 4:14 am

It stands to reason that it wouldn't work if the activator doesn't touch the ground, after all, PathToReference uses NavMesh, and NavMesh can only get things touching the ground.
Another problem will be that PathToReference is latent. What may be a better idea is to add your actors to aliases (after all, there's only a Max of 10 of them, and 10 aliases aren't too hard to build) each with a Travel package with a target of the scent pile Activator.
User avatar
Matt Fletcher
 
Posts: 3355
Joined: Mon Sep 24, 2007 3:48 am

Post » Thu Jan 10, 2013 5:44 am

PathToReference can also time-out. In my experience it can be fairly unreliable. I haven't tested it over long unobstructed distances but I'm not optimistic......
Making use of packages if possible is a much surer method. A crying shame we can't add packages to NPC's straight out of a script, they need to be an Alias, a shame indeed. :cry:

I thought I'd just pop in with that little nugget. I really need to be getting to bed...........
User avatar
He got the
 
Posts: 3399
Joined: Sat Nov 17, 2007 12:19 pm


Return to V - Skyrim