Open Foretack opened 1 year ago
I tried to implement this myself, but this is as far as I got:
[ConCommand(commandName = "interact_range", flags = ConVarFlags.ExecuteOnServer)]
public static void CCInteractRange(ConCommandArgs args)
{
IL.RoR2.InteractionDriver.FindBestInteractableObject += (ilc) =>
{
var cursor = new ILCursor(ilc);
bool found = cursor.TryGotoNext(
x => x.MatchLdarg(0),
x => x.MatchCallOrCallvirt<InteractionDriver>("get_interactor"),
x => x.MatchLdfld<Interactor>("maxInteractionDistance"),
x => x.MatchStloc(3)
);
if (found)
{
cursor.Emit(OpCodes.Ldarg, 0);
cursor.Emit(OpCodes.Ldloc, 3);
// EmitDelegate ?
cursor.Emit(OpCodes.Stloc, 3);
}
};
}
Describe your new command
The command should allow the user to modify the range of which they can interact with chests, shrines, printers etc...
Use cases
A lot of bodies used with spawn_as practically do not have an interaction range. For example, if you spawn_as Mithrix, the only thing you can interact with is tri-shops, and you have to be standing inside them too. Mithrix' body is too large for the player to be able to interact with anything. Many other bodies suffer from this, like Clay Dunestrider, Stone Titan, Xi Construct, drones and pretty much any body that is not the size of a playable character. This command would solve the issue for all these bodies, for any user that wishes to play as them.