public static void OnCharacterKilled( ICharacter attackerCharacter, ICharacter targetCharacter, IProtoSkill protoSkill) { if (attackerCharacter is null || targetCharacter is null) { return; } Api.Logger.Info("Killed " + targetCharacter, attackerCharacter); Api.SafeInvoke( () => CharacterKilled?.Invoke(attackerCharacter, targetCharacter)); if (attackerCharacter.IsNpc || !targetCharacter.IsNpc) { return; } var playerCharacterSkills = attackerCharacter.SharedGetSkills(); // give hunting skill experience for mob kill var huntXP = SkillHunting.ExperienceForKill; huntXP *= ((IProtoCharacterMob)targetCharacter.ProtoGameObject).MobKillExperienceMultiplier; if (huntXP > 0) { playerCharacterSkills.ServerAddSkillExperience <SkillHunting>(huntXP); } if (protoSkill is ProtoSkillWeapons protoSkillWeapon) { // give weapon experience for kill protoSkillWeapon.ServerOnKill(playerCharacterSkills, killedCharacter: targetCharacter); } if (!WorldObjectClaimSystem.SharedIsEnabled) { return; } // try claim the corpse for the attacker player using var tempListCorpses = Api.Shared.GetTempList <IStaticWorldObject>(); Api.GetProtoEntity <ObjectCorpse>() .GetAllGameObjects(tempListCorpses.AsList()); foreach (var worldObjectCorpse in tempListCorpses.AsList()) { if (targetCharacter.Id == ObjectCorpse.GetPublicState(worldObjectCorpse).DeadCharacterId) { WorldObjectClaimSystem.ServerTryClaim(worldObjectCorpse, attackerCharacter, WorldObjectClaimDuration.CreatureCorpse); return; } } }
private static void ReplaceMobWithCorpse(ICharacter deadCharacter) { var position = deadCharacter.Position; var rotationAngleRad = deadCharacter.GetPublicState <ICharacterPublicState>().AppliedInput.RotationAngleRad; var isLeftOrientation = ClientCharacterAnimationHelper.IsLeftHalfOfCircle( angleDeg: rotationAngleRad * MathConstants.RadToDeg); var isFlippedHorizontally = !isLeftOrientation; var tilePosition = position.ToVector2Ushort(); Api.Server.World.DestroyObject(deadCharacter); var objectCorpse = Api.Server.World.CreateStaticWorldObject <ObjectCorpse>(tilePosition); ObjectCorpse.ServerSetupCorpse(objectCorpse, (IProtoCharacterMob)deadCharacter.ProtoCharacter, (Vector2F)(position - tilePosition.ToVector2D()), isFlippedHorizontally: isFlippedHorizontally); }
public virtual void ServerOnDeath(ICharacter character) { this.ServerSendDeathSoundEvent(character); ServerWorld.DestroyObject(character); var position = character.Position; var tilePosition = position.ToVector2Ushort(); var rotationAngleRad = character.GetPublicState <ICharacterPublicState>().AppliedInput.RotationAngleRad; var isLeftOrientation = ClientCharacterAnimationHelper.IsLeftHalfOfCircle( angleDeg: rotationAngleRad * MathConstants.RadToDeg); var isFlippedHorizontally = !isLeftOrientation; var objectCorpse = ServerWorld.CreateStaticWorldObject <ObjectCorpse>(tilePosition); ObjectCorpse.ServerSetupCorpse(objectCorpse, (IProtoCharacterMob)character.ProtoCharacter, (Vector2F)(position - tilePosition.ToVector2D()), isFlippedHorizontally: isFlippedHorizontally); }
public ObjectCorpseViewModel([NotNull] ObjectCorpse corpse) : base(corpse) { }