I've had partial progress with a simple mod I'm building, but so far only by adding to existing source code. In order to make it a proper mod, I'm trying to use the PlayerActivate.RegisterCustomActivation method to inject the code.
The problem I'm running into is that PlayerActivate.RegisterCustomActivation requires that the referenced function must be static and I need to reference the activated object (specifically, getting to the loot data is there is any). I figure there is probably a way to use the RaycastHit object passed to the function to get the object instance, but not certain how to do so. Any suggestions? Thanks!
Object activation question
- pango
- Posts: 3359
- Joined: Wed Jul 18, 2018 6:14 pm
- Location: France
- Contact:
Re: Object activation question
Use PlayerActivate.LootCheck(), or some similar code?
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
-
- Posts: 11
- Joined: Wed Aug 11, 2021 9:34 pm
Re: Object activation question
Well specifically, I want to modify properties of the in-world container object based on the contents of the container.
If I can use PlayerActivate.RegisterCustomActivation then I would want something like this:
Code: Select all
public static void ActivateContainer(RaycastHit hit)
{
GameObject go;
go = hit.GetReferenceToInWorldContainerObject();
UpdateContainer(go);
}
- Ralzar
- Posts: 2211
- Joined: Mon Oct 07, 2019 4:11 pm
- Location: Norway
Re: Object activation question
Try registering to PlayerActivate.OnLootSpawned.
Like this:
https://github.com/Ralzar81/ThiefOverha ... aul.cs#L67
Like this:
https://github.com/Ralzar81/ThiefOverha ... aul.cs#L67
-
- Posts: 11
- Joined: Wed Aug 11, 2021 9:34 pm
Re: Object activation question
Ah. great example! If the object parameter passed is what I hope it is, this should work fine. Thanks!Ralzar wrote: ↑Tue Sep 14, 2021 6:41 pm Try registering to PlayerActivate.OnLootSpawned.
Like this:
https://github.com/Ralzar81/ThiefOverha ... aul.cs#L67
-
- Posts: 11
- Joined: Wed Aug 11, 2021 9:34 pm
Re: Object activation question
I've ended up going back to using PlayerActivate.RegisterCustomActivation as it seems like OnLootSpawned isn't being called in my case.
For anyone that wants to use PlayerActivate.RegisterCustomActivation, I noticed this code in PlayerActivate:
Further experimentation showed that the RaycastHit hitInfo parameter passed to Activate gives you the activated in-game world object (hitInfo.transform = in-world object instance... BINGO!).
For anyone that wants to use PlayerActivate.RegisterCustomActivation, I noticed this code in PlayerActivate:
Code: Select all
private bool LootCheck(RaycastHit hitInfo, out DaggerfallLoot loot)
{
loot = hitInfo.transform.GetComponent<DaggerfallLoot>();
return loot != null;
}