-
Notifications
You must be signed in to change notification settings - Fork 57
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
Kills not logged when player is on vehicle. #437
Comments
Following up on this. I did some testing and this was with one shot from a T3 sniper rifle to the head while I was riding on a motorcycle/bike.
and this is the code that's generating that log: [HarmonyPatch(typeof(EntityAlive), "ProcessDamageResponse")]
public class EntityPlayerProcessDamageResponse
{
private static void Prefix(EntityAlive __instance, DamageResponse _dmResponse, out bool __state)
{
__state = __instance.IsAlive();
}
// Using __state to see if the entity was alive before processing damage
private static async void Postfix(EntityAlive __instance, DamageResponse _dmResponse, bool __state)
{
Log.Out($"Fatal: {_dmResponse.Fatal} Victim: {__instance.entityType}, Killer {_dmResponse.Source.CreatorEntityId}, {_dmResponse.Source.getEntityId()}, state: {__state}");
}
} So it's trying the call 6 times but the attacker is only in it the first 4 times before the damage is recognized as "fatal". The next two after the kill shows it can't identify the killer. Now this was from one shot to the head while the victim is on a bike. I did some further testing and serialized the DamageResponse object out for one of the times the source entityId was -1 and got this: {
"Source": {
"uvHit": {
"x": 0.0,
"y": 0.0,
"magnitude": 0.0,
"sqrMagnitude": 0.0
},
"hitTransformName": "",
"hitTransformPosition": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"magnitude": 0.0,
"sqrMagnitude": 0.0
},
"BuffClass": null,
"AttackingItem": null,
"damageSource": 1,
"damageType": 11,
"bIsDamageTransfer": false,
"DismemberChance": 0.0,
"BonusDamageType": 0,
"DamageTypeTag": {
"IsEmpty": false
},
"CreatorEntityId": -1,
"ItemClass": null,
"CanStun": false,
"DamageMultiplier": 1.0
},
"Strength": 1,
"ModStrength": 0,
"MovementState": 0,
"HitDirection": 2,
"HitBodyPart": 0,
"PainHit": false,
"Fatal": true,
"Critical": false,
"Dismember": false,
"CrippleLegs": false,
"TurnIntoCrawler": false,
"Random": 0.9297966,
"ImpulseScale": 0.0,
"Stun": 0,
"StunDuration": 0.0,
"ArmorSlot": 8,
"ArmorSlotGroup": 1,
"ArmorDamage": 0
} Notice that the |
You need to check the attached entity is null. If not null then that is the player it needs to process. It sounds like damage may or may not apply to the vehicle first so my system just was not coded with that in mind. You are correct that people can die from a buff |
The server tools doesn't capture kills and give rewards when a player kills someone who's on a vehicle. I ran into this on my mod on the same server. For my mod, I hooked into
EntityAlive:ProcessDamageResponse
and theDamageResponse.Source entityId
is -1. I'm currently looking to see how I can get the killer when the player is killed on a vehicle.The text was updated successfully, but these errors were encountered: