Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ID_Dedicated/null for Npc.UserId Parameter. Additional functionality: - Npc.LookAt - Npc.ShootWeapon - Npc.SetAimDownSight - Player.UnloadWeapon - Player.ToggleWeaponFlashlight #2297

Merged
merged 16 commits into from
Feb 3, 2024

Conversation

creepycats
Copy link
Contributor

@creepycats creepycats commented Nov 23, 2023

Use ID_Dedicated or null to ensure an NPC is VSR Compliant (Uses Unverified/DedicatedHost instances, which will not take up slots or show on the Player List)

Added Multiple Functions for NPC characters to Look at Points, and use a Held Firearm (Shooting, ADS, Flashlight, Reloading)

Had to remake this cause I fricked up branches 😅

Use "ID_Dedicated" to ensure an NPC is VSR Compliant

Added Multiple Functions for NPC characters to Look at Points, and use a Held Firearm
@creepycats
Copy link
Contributor Author

Cedric on his way to demolish my PR:

@NotIntense
Copy link
Contributor

Using ID_Dedicated for me, as shown in the provided screenshots, doesn't prevent the NPC from showing in the player list/appearing in player count.
image
image

@VALERA771
Copy link
Contributor

Using ID_Dedicated for me, as shown in the provided screenshots, doesn't prevent the NPC from showing in the player list/appearing in player count.

image

image

Just changing id doesn't change anything if you aren't using this PR

@creepycats
Copy link
Contributor Author

Yeah, with the PR, it should set the InstanceMode to DedicatedServer just like my previous fix functions for plugins did, which did appear to work properly.

Also this was literally one of if not the final solutions we had made when looking a few months ago to solve the issue.

@creepycats
Copy link
Contributor Author

Update: I DID miss something Lmfao, you cant set npc.ReferenceHub.authManager.UserId with the Dedicated Server like I did. You have to instead use npc.ReferenceHub.authManager.SyncedUserId. Ill commit the change real quick.

@NotIntense
Copy link
Contributor

NotIntense commented Nov 25, 2023

Using ID_Dedicated for me, as shown in the provided screenshots, doesn't prevent the NPC from showing in the player list/appearing in player count.
image
image

Just changing id doesn't change anything if you aren't using this PR

Dumbass, I was :trollface:

@creepycats
Copy link
Contributor Author

I've also added support for null alongside ID_Dedicated. This gives you the option of plain Unverified players and Dedicated Server players. Issue should be resolved.
image

@creepycats creepycats changed the title NPC Features + VSR NPC Weapon/Look Features + VSR Nov 25, 2023
Exiled.API/Features/Npc.cs Outdated Show resolved Hide resolved
Exiled.API/Features/Npc.cs Outdated Show resolved Hide resolved
Exiled.API/Features/Npc.cs Outdated Show resolved Hide resolved
Exiled.API/Features/Npc.cs Outdated Show resolved Hide resolved
Exiled.API/Features/Npc.cs Outdated Show resolved Hide resolved
Exiled.API/Features/Npc.cs Outdated Show resolved Hide resolved
@creepycats
Copy link
Contributor Author

Did my best to get it working before I had to leave. Noticed I also overrode the shooting position when hitting players. Anyways, I simplified the if returns into one function, and use an IDestructible instead of NetworkIdentity.

@creepycats
Copy link
Contributor Author

creepycats commented Nov 27, 2023

Gonna change more things and do comment stuff. Renaming functions to be more clear, etc

@creepycats
Copy link
Contributor Author

Should be all done. Might need to fix a bug or two if it comes up, but this should work.

  • Function Names are Clearer
  • They return a bool depending on if the requests are received or if the player is not able to send the request.
  • Added Documentation for the bool returns
  • I THINK I shortened the two if->return statements into one for each one
    (if (RoleManager.CurrentRole is not IFpcRole fpc || ReferenceHub.inventory._curInstance is not Firearm firearm))
  • NetworkIdentity replaced with IDestructible, using Game's own weapon logic

Fixed some formatting of Documentation and Usings

Removed the ReloadWeapon Function from NPC.cs as Player.cs has it already.
@creepycats
Copy link
Contributor Author

Fixed Documentation with past commits, and also removed the ReloadWeapon function from NPCs since Player apparently has it already. I might move everything except for the ShootWeapon function in the Weapon stuff to Player as well.

@creepycats creepycats changed the title NPC Weapon/Look Features + VSR NPC VSR Option (null/ID_Dedicated) + Player Weapon/Look Shortcut Functions Nov 28, 2023
@creepycats
Copy link
Contributor Author

creepycats commented Nov 28, 2023

Quickly moved my weapon and LookAt functions to Player.cs from NPC.cs. This is NOT tested and I will be modifying them in ~3 hours to fit the current function for Reloading. Will look for review afterwards.

@Misaka-ZeroTwo Misaka-ZeroTwo marked this pull request as draft November 28, 2023 20:04
@creepycats
Copy link
Contributor Author

creepycats commented Nov 29, 2023

Should be good to go.

  • Consistency with ReloadWeapon for others
  • Moved LookAt, ShootWeapon and SetAimDownSight back to NPC since they only seem to work properly there.
  • Rewrote LookAt since it for some reason didn't work with players or at all using the shortcut method, so I use smth else
  • Removed Lerp parameter for LookAt
  • Converted InventorySystem Firearm to be based on Exiled's Firearm
  • Fixed ReloadWeapon function previously present, where multiple Messages caused multiple reloads at once, instead of denying repeated requests after the first. (Discovered whilst testing UnloadWeapon)

All was tested privately. VSR-options for NPCs (null/ID_Dedicated) works perfectly, and all Player tied functions work on both the client and server. Any function that didnt was moved to NPC specifically for their control (AKA Looking around, Shooting, and ADSing)

@creepycats creepycats marked this pull request as ready for review November 29, 2023 00:33
At the request of Yamato, I looked to simplify the LookAt script.

Now combined a lot of stuff into just a few lines, reduced math and use of Mathf.Repeat. Works just as well as it did before.
@creepycats creepycats changed the title NPC VSR Option (null/ID_Dedicated) + Player Weapon/Look Shortcut Functions NPC VSR Option (null/ID_Dedicated), Basic Look, Shoot, ADS Functions + Player Weapon Functions Nov 29, 2023
@Misaka-ZeroTwo Misaka-ZeroTwo added this to the Exiled 8.4.4 milestone Dec 1, 2023
@creepycats creepycats changed the title NPC VSR Option (null/ID_Dedicated), Basic Look, Shoot, ADS Functions + Player Weapon Functions Unverified NPCs (null/ID_Dedicated), Basic Look, Shoot, ADS Functions + Player Weapon Functions Dec 4, 2023
Just reverted a line of the documentation, thats it
@creepycats
Copy link
Contributor Author

Made two small changes to Documentation, sorry it took so long i got eepy

@creepycats creepycats changed the title Unverified NPCs (null/ID_Dedicated), Basic Look, Shoot, ADS Functions + Player Weapon Functions Npc.UserId Parameter Allow ID_Dedicated/null, Add Npc.LookAt, Npc.ShootWeapon, Npc.SetAimDownSight, Player.UnloadWeapon, Player.ToggleWeaponFlashlight Dec 23, 2023
@NaoUnderscore NaoUnderscore changed the title Npc.UserId Parameter Allow ID_Dedicated/null, Add Npc.LookAt, Npc.ShootWeapon, Npc.SetAimDownSight, Player.UnloadWeapon, Player.ToggleWeaponFlashlight Allow ID_Dedicated/null for Npc.UserId Parameter> Jan 6, 2024
@NaoUnderscore NaoUnderscore changed the title Allow ID_Dedicated/null for Npc.UserId Parameter> Allow ID_Dedicated/null for Npc.UserId Parameter. Additional functionality: - Npc.LookAt - Npc.ShootWeapon - Npc.SetAimDownSight - Player.UnloadWeapon - Player.ToggleWeaponFlashlight Jan 6, 2024
@NaoUnderscore NaoUnderscore modified the milestones: Exiled 8.4.4, Exiled 9 Jan 6, 2024
@NaoUnderscore NaoUnderscore added the Do not merge Don't merge this PR label Jan 6, 2024
@NaoUnderscore NaoUnderscore changed the base branch from dev to apis-rework January 13, 2024 18:17
@NaoUnderscore NaoUnderscore added P1 First Priority and removed Do not merge Don't merge this PR labels Jan 29, 2024
@NaoUnderscore NaoUnderscore merged commit 91b6b4d into Exiled-Team:apis-rework Feb 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 First Priority regarding-api
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants