Closed Jimmy-Baby closed 2 years ago
It's a prediction issue. You can test this by setting cl_predict 0. They might still get created on the server, just not sent to clients. If that's the case, a solution would be a matter of hooking a Temp ent and changing the clients.
setting cl_predict to 0 fixed all of the gore effects straight away! thanks for the reply. :)
unfortunately, for any clients of the server, all movement inputs are delayed by however much latency they have to the server. which makes sense of course, considering the console commands name.
I will look into your suggestion. thanks again 👍🏻
I also noticed you can't only see the fx from your own damage. When others shoot, it shows correctly.
Ah! Good observation; I didn't even think to check if this was the case. I assumed it was the same for all damage dealt, with all clients spawned in.
I hate to ask, I am used to figuring these things out on my own, but I am quite unfamiliar with sourcepawn, and sourcemod especially. I literally only started looking into SP two days ago. Luckily it's very very similar to C, which I've been using for a few years now.
What do you mean when you say 'hooking a temp ent and changing the clients'? Are you saying I should try to create an sdkhook whenever an entity is created, check if it is an FX entity by filtering by classname, and then somehow making sure they are replicated on the client that dealt the damage? (As it seems all other clients see the FX already).
Feel free to give an as simple an answer as you wish, you've done some great work on the mod already :)
Its been a while since I have done work on the mod and anything Source Engine related so apologies in advance if the information or potential solutions that I provide are incorrect.
To give some insight on SourceMod and SourcePawn, SourcePawn is actually very C-like with some C++ functionality such as MethodMaps mimicing structs and classes. SourceMod provides signature scans, vtable indexes and hardcoded offsets through the gamedata folder/files. You can dereference/read/write pointer objects using LoadFromAddress and StoreToAddress. You will be commonly running your logic in SourcePawn through hooks already provided by SDKHooks or the other default hooks. If you wish to hook functions that you have offsets for inside your custom gamedata, you'll need to use a custom extension called DHooks. You'll be able to hook virtual functions and detour functions with this extension.
As for potential solutions, you could hook the NPC's SDKHook_OnTakeDamage using the SourcePawn function SDKHook and check who the attacker is. If the attacker is a player using a hitscan weapon, you could try running a traceray that runs from the player's eye angles and getting the position of the result. From there, you can emit a particle effect (I do not remember how to but I'll leave this as a exercise for you) on that position.
I hope this was informative. If you need any more information or run into any problems, feel free to ask! We always need more contributors to complete the full vision the mod.
Thanks for the response, ampreeT.
I have done hooking stuff before in C++ in the kernel and in games and stuff. It all seems relatively the same.
Below there's a screenshot of my OnTakeDamage hook I have been testing with. As it stands it crashes the server when enabled, but only when the hook is hit. Also, I know the hook is working properly. It is the code within the hook function causing the crash.
I have a feeling the issue lies in the fact that I'm maybe using entity references/indexes incorrectly? I can't see what else is wrong. I am precaching the hm_sound.wav which I have packaged into a custom .vpk with this directory structure:
jsound.vpk ->sound -->hm_sound.wav
Once I get everything working I'll add some menu options in the pre-existing sourcecoop menu for this and make a pull rq. :)
P.S I am not adding code directly because I am on phone ;) P.P.S I haven't had a good look at the console output when it crashes as I don't have Black Mesa Dedicated Server installed yet; my friend has been hosting. :)
Try looking at the debug/crash logs if you are able to get any. SourceMod will catch any SourcePawn errors thrown and will print them out into the console. From what I can see, you will need to close the handle that you received from TR_TraceRayEx(...). You also might need to precache the sound using PrecacheSound if it isn't being executed somewhere else. Try also passing BloodParticle.GetEntIndex() as the first parameter of TeleportEntity(...) as our CBaseEntity methodmap is custom (It may be passing this as a invalid pointer address). You can alternatively use it as BloodParticle.Teleport(...) as our methodmap wraps most member functions.
I am not sure if this has been updated or if it will be implemented at some point, but I do have a method as well hooking in to:
AddTempEntHook("WeaponBullets", ReCreateImpact);
Although you also need to hook OnTakeDamage for melee weapons, it might be better to do it all through OnTakeDamage, but this tempent hook gives exact bullet shoot from origin, and angles that it is heading in.
For the particle effect, you should use the property of the target: m_bloodColor
to set the type of blood to emit, this also ensures that tanks and npc_plantlight
don't emit blood at all as they have blood color -1.
It hasn't been fixed yet. I'd recommend going the path of least resistance - there are too many effects to recreate manually. Have you tried hooking EffectDispatch tempent? Also Black mesa has an extra tempent "BlackMesa Shot".
I haven't tested EffectDispatch yet, the other tempents for BloodSpray don't seem to work. The TempEnt for "BlackMesa Shot" also never fires for players, Only "WeaponBullets" seems to be used (at least in co-op, not sure about multiplayer).
Check pull request :D Did my best effort.
@Balimbanana I think it's just best to use premade particles, no? Also, did you manage to get melee effects working?
ALSO, do tanks have synthetic blood
EDIT: Never-mind, I switched hooks over to NpcOnTakeDamage, which also allowed me to fix melee effects.
Hi,
Apologies if this has already been explained, but, why are there no blood/gore fx on NPC's when they are hit by bullets/crowbar/etc when playing with sourcecoop?
I have started writing a plugin to try to accomodate for this lacking feature, though, I am having issues with it so far.
Thanks.