Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @wrapMethod(TargetTrackingExtension)
- public final static func OnHit(ownerPuppet: wref<ScriptedPuppet>, evt: ref<gameHitEvent>) -> Void {
- let instigator: wref<GameObject>;
- let vehicle: ref<VehicleObject>;
- let controlledObject: wref<GameObject>;
- let isControlled: Bool = false;
- let traceCost: Float;
- if !IsDefined(evt.attackData) {
- return;
- };
- instigator = evt.attackData.GetInstigator();
- if IsDefined(instigator) && instigator.IsPlayer() {
- if instigator.GetTakeOverControlSystem().IsDeviceControlled() {
- isControlled = true;
- traceCost = 1.5;
- controlledObject = instigator.GetTakeOverControlSystem().GetControlledObject();
- };
- vehicle = evt.attackData.GetSource() as VehicleObject;
- if IsDefined(vehicle) && (vehicle.IsVehicleRemoteControlled() || vehicle.IsVehicleAccelerateQuickhackActive()) {
- isControlled = true;
- traceCost = 6.0;
- controlledObject = vehicle as GameObject;
- };
- };
- if !isControlled {
- wrappedMethod(ownerPuppet, evt);
- return;
- }
- let id: TweakDBID;
- let targetTracker: wref<TargetTrackingExtension>;
- let player: ref<PlayerPuppet>;
- if !IsDefined(ownerPuppet) || !IsDefined(evt) {
- return;
- };
- instigator = evt.attackData.GetInstigator();
- if !IsDefined(instigator) {
- return;
- };
- if ownerPuppet.GetEntityID() == instigator.GetEntityID() {
- return;
- };
- if ScriptedPuppet.IsPlayerCompanion(instigator) {
- return;
- };
- if !ownerPuppet.IsActive() {
- return;
- };
- if Equals(GameObject.GetAttitudeTowards(ownerPuppet, instigator), EAIAttitude.AIA_Friendly) {
- return;
- };
- if !ownerPuppet.IsAggressive() {
- return;
- };
- if evt.attackData.HasFlag(hitFlag.WasKillingBlow) {
- return;
- };
- if evt.attackData.HasFlag(hitFlag.QuickHack) {
- return;
- };
- if evt.attackData.HasFlag(hitFlag.DealNoDamage) {
- return;
- };
- NPCStatesComponent.AlertPuppet(ownerPuppet);
- if IsDefined(evt.attackData.GetSource() as Device) && !IsDefined(evt.attackData.GetWeapon()) {
- return;
- };
- if !TargetTrackingExtension.Get(ownerPuppet, targetTracker) {
- return;
- };
- if SenseComponent.ShouldIgnoreIfPlayerCompanion(ownerPuppet, instigator) {
- return;
- };
- if AIActionHelper.TryChangingAttitudeToHostile(ownerPuppet, instigator) {
- id = targetTracker.GetCurrentPreset();
- TDBID.Append(id, t".droppingCooldownPerHit");
- NPCPuppet.RevealPlayerPositionIfNeeded(ownerPuppet, instigator.GetEntityID());
- player = instigator as PlayerPuppet;
- if player.IsBeingRevealed() && GameInstance.GetStatsSystem(GetGameInstance()).GetStatValue(Cast<StatsObjectID>(player.GetEntityID()), gamedataStatType.IgnoreAwarenessCostWhenOverclocked) != 1.00 {
- GameInstance.GetStatPoolsSystem(GetGameInstance()).RequestChangingStatPoolValue(Cast<StatsObjectID>(player.GetEntityID()), gamedataStatPoolType.QuickHackUpload, traceCost, player, true, true);
- };
- instigator = controlledObject;
- GameObject.ChangeAttitudeToHostile(ownerPuppet, instigator);
- targetTracker.AddDroppingCooldown(instigator, TweakDBInterface.GetFloat(id, 0.00));
- targetTracker.AddThreat(instigator, true, instigator.GetWorldPosition(), 1.00, -1.00, false);
- if instigator.IsSensor() {
- instigator.QueueEvent(new TurnOnVisibilitySenseComponent());
- };
- };
- }
- @wrapMethod(NPCPuppet)
- protected cb func OnRagdollImpactEvent(evt: ref<RagdollImpactEvent>) -> Bool {
- let otherVehicleObject: ref<VehicleObject>;
- if evt.triggeredSimulation {
- otherVehicleObject = evt.otherEntity as VehicleObject;
- if !IsDefined(otherVehicleObject) || !(otherVehicleObject.IsVehicleRemoteControlled() || otherVehicleObject.IsVehicleAccelerateQuickhackActive()) {
- return wrappedMethod(evt);
- };
- };
- let attackInstigator: ref<GameObject>;
- let currentPosition: Vector4;
- let damageEvent: ref<StartRagdollDamageEvent>;
- let i: Int32;
- let impactData: RagdollImpactPointData;
- let isDead: Bool;
- let isDefeated: Bool;
- let isHighFall: Bool;
- let isHitByPlayerVehicle: Bool;
- let isImpactedThrownNPC: Bool;
- let isThrownNPC: Bool;
- let otherNPCPuppet: ref<NPCPuppet>;
- let player: ref<PlayerPuppet>;
- let terminalVelocityReached: Bool;
- let vehicleHitEvent: ref<gameVehicleHitEvent>;
- vehicleHitEvent = new gameVehicleHitEvent();
- vehicleHitEvent.vehicleVelocity = otherVehicleObject.GetLinearVelocity();
- vehicleHitEvent.preyVelocity = this.GetVelocity();
- vehicleHitEvent.target = this;
- vehicleHitEvent.hitPosition = WorldPosition.ToVector4(evt.impactPoints[0].worldPosition);
- vehicleHitEvent.hitDirection = evt.impactPoints[0].worldNormal;
- vehicleHitEvent.attackData = new AttackData();
- attackInstigator = VehicleComponent.GetDriver(this.GetGame(), otherVehicleObject, otherVehicleObject.GetEntityID());
- if otherVehicleObject.IsVehicleAccelerateQuickhackActive() {
- attackInstigator = GameInstance.GetPlayerSystem(this.GetGame()).GetLocalPlayerControlledGameObject();
- };
- vehicleHitEvent.attackData.SetInstigator(attackInstigator);
- vehicleHitEvent.attackData.SetSource(otherVehicleObject);
- this.QueueEvent(vehicleHitEvent);
- isDead = this.IsDead() || StatusEffectSystem.ObjectHasStatusEffect(this, t"BaseStatusEffect.ForceKill");
- isDefeated = ScriptedPuppet.IsDefeated(this);
- isHitByPlayerVehicle = VehicleComponent.IsMountedToVehicle(this.GetGame(), GameInstance.GetPlayerSystem(this.GetGame()).GetLocalPlayerControlledGameObject());
- isThrownNPC = StatusEffectSystem.ObjectHasStatusEffect(this, t"BaseStatusEffect.ThrownNPC");
- isImpactedThrownNPC = StatusEffectSystem.ObjectHasStatusEffect(this, t"BaseStatusEffect.ImpactedThrownNPC");
- player = GameInstance.GetPlayerSystem(this.GetGame()).GetLocalPlayerControlledGameObject() as PlayerPuppet;
- otherNPCPuppet = evt.otherEntity as NPCPuppet;
- currentPosition = this.GetWorldPosition();
- i = 0;
- while i < ArraySize(evt.impactPoints) {
- impactData = evt.impactPoints[i];
- if isThrownNPC {
- if IsDefined(otherNPCPuppet) && ScriptedPuppet.IsAlive(otherNPCPuppet) && !ArrayContains(this.m_ragdollImpactedNPCs, otherNPCPuppet) {
- ArrayPush(this.m_ragdollImpactedNPCs, otherNPCPuppet);
- } else {
- this.SpawnRagdollSplatter(impactData, true);
- };
- if impactData.forceMagnitude > this.m_ragdollDamageData.maxForceMagnitude {
- this.SetRagdollDamageData(impactData, currentPosition);
- };
- } else {
- terminalVelocityReached = impactData.velocityChange >= TweakDBInterface.GetFloat(t"AIGeneralSettings.ragdollImpactKillVelocityThreshold", 11.00);
- isHighFall = impactData.velocityChange >= TweakDBInterface.GetFloat(t"AIGeneralSettings.ragdollHighFallVelocityThreshold", 8.00) && AbsF(this.m_ragdollInitialPosition.Z - currentPosition.Z) >= TweakDBInterface.GetFloat(t"AIGeneralSettings.ragdollHighFallHeightThreshold", 6.00);
- if IsDefined(otherNPCPuppet) && !otherNPCPuppet.IsRagdolling() && !ArrayContains(this.m_ragdollImpactedNPCs, otherNPCPuppet) {
- if Vector4.Length(this.GetVelocity()) <= TweakDBInterface.GetFloat(t"AIGeneralSettings.ragdollTripNPCInstigatorVelThreshold", 0.20) {
- if !GameObject.IsCooldownActive(GameInstance.GetPlayerSystem(this.GetGame()).GetLocalPlayerControlledGameObject(), n"RagdollTripGlobalCooldown") && ScriptedPuppet.CanTripOverRagdolls(otherNPCPuppet) && this.ShouldTripVictim(otherNPCPuppet) {
- otherNPCPuppet.QueueEvent(CreateForceRagdollEvent(n"Tripped over a ragdoll"));
- GameObject.StartCooldown(GameInstance.GetPlayerSystem(this.GetGame()).GetLocalPlayerControlledGameObject(), n"RagdollTripGlobalCooldown", TweakDBInterface.GetFloat(t"AIGeneralSettings.ragdollTripGlobalCooldownDuration", 0.00));
- };
- } else {
- if !(isImpactedThrownNPC && Equals(GameObject.GetAttitudeTowards(player, otherNPCPuppet), EAIAttitude.AIA_Friendly)) && impactData.velocityChange >= TweakDBInterface.GetFloat(t"AIGeneralSettings.ragdollAnotherNPCVelocityThreshold", 1.00) && Equals(otherNPCPuppet.GetNPCType(), gamedataNPCType.Human) && ScriptedPuppet.CanRagdoll(otherNPCPuppet) {
- otherNPCPuppet.QueueEvent(CreateForceRagdollEvent(n"Hit by a ragdolling NPC"));
- } else {
- this.SpawnRagdollBumpAttack(WorldPosition.ToVector4(impactData.worldPosition) + Vector4.Normalize(impactData.worldNormal) * 0.05);
- };
- };
- ArrayPush(this.m_ragdollImpactedNPCs, otherNPCPuppet);
- };
- if this.CanReceiveDamageFromRagdollImpacts(isDead, isDefeated, terminalVelocityReached, isHighFall) {
- if impactData.velocityChange >= TweakDBInterface.GetFloat(t"AIGeneralSettings.ragdollDamageMinimumVelocity", 2.00) {
- if this.m_ragdollDamageData.maxVelocityChange == 0.00 {
- damageEvent = new StartRagdollDamageEvent();
- GameInstance.GetDelaySystem(this.GetGame()).DelayEvent(this, damageEvent, 0.30);
- };
- if impactData.velocityChange > this.m_ragdollDamageData.maxVelocityChange {
- this.SetRagdollDamageData(impactData, currentPosition);
- };
- };
- } else {
- if isHitByPlayerVehicle && (isDefeated || isDead) {
- this.SpawnRagdollSplatter(impactData, isDead);
- };
- };
- if !this.m_ragdollFloorSplashSpawned && (terminalVelocityReached || isHighFall) {
- this.SpawnRagdollFloorSplash(impactData);
- };
- };
- i += 1;
- };
- if isThrownNPC {
- this.OnThrownNPCRagdollImpact();
- };
- if StatusEffectSystem.ObjectHasStatusEffectWithTag(this, n"OnePunchedMark") {
- GameObjectEffectHelper.StartEffectEvent(this, n"blood_nose_punch_strong");
- this.SpawnRagdollSplatter(impactData, isDead);
- };
- }
- @wrapMethod(ReactionManagerComponent)
- private final func ShouldStimBeProcessed(stimEvent: ref<StimuliEvent>, delayed: Bool) -> Bool {
- if Equals(stimEvent.GetStimType(), gamedataStimType.Bullet) && stimEvent.sourceObject.GetTakeOverControlSystem().IsDeviceControlled() {
- this.LogFailure("player controlled device shot bullet");
- return false;
- };
- return wrappedMethod(stimEvent, delayed);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement