Upload from upload_mods.ps1
This commit is contained in:
164
Harmony/Harmony_AIDirector.cs
Normal file
164
Harmony/Harmony_AIDirector.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
namespace Harmony.AIDirectorPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(AIDirector))]
|
||||
[HarmonyPatch("NotifyNoise")]
|
||||
public class NotifyNoisePatch
|
||||
{
|
||||
public static bool Prefix(AIDirector __instance, Entity instigator, Vector3 position, string clipName, float volumeScale)
|
||||
{
|
||||
AIDirectorData.Noise noise;
|
||||
if (!AIDirectorData.FindNoise(clipName, out noise) || instigator is EntityEnemy)
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise 1");
|
||||
return false;
|
||||
}
|
||||
AIDirectorPlayerState directorPlayerState = (AIDirectorPlayerState)null;
|
||||
if ((bool)instigator)
|
||||
{
|
||||
if (instigator.IsIgnoredByAI())
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise 2");
|
||||
return false;
|
||||
}
|
||||
__instance.playerManagementComponent.trackedPlayers.dict.TryGetValue(instigator.entityId, out directorPlayerState);
|
||||
}
|
||||
if (instigator is EntityItem entityItem && ItemClass.GetForId(entityItem.itemStack.itemValue.type).ThrowableDecoy.Value)
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise 3");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise clipName: " + clipName);
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise noise.heatMapStrength: " + noise.heatMapStrength);
|
||||
|
||||
if (directorPlayerState != null)
|
||||
{
|
||||
if (directorPlayerState.Player.IsCrouching)
|
||||
volumeScale *= noise.muffledWhenCrouched;
|
||||
float volume = noise.volume * volumeScale;
|
||||
if (directorPlayerState.Player.Stealth.NotifyNoise(volume, noise.duration))
|
||||
instigator.world.CheckSleeperVolumeNoise(position);
|
||||
}
|
||||
if ((double)noise.heatMapStrength <= 0.0)
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise 4");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool canProceed = true;
|
||||
|
||||
if (instigator is EntityAliveV2)
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise IS FROM NPC");
|
||||
canProceed = false;
|
||||
}
|
||||
|
||||
/*if (instigator is EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer)instigator;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
string heldItem = player.inventory.holdingItem.GetItemName();
|
||||
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise IS FROM PLAYER, held item: " + heldItem);
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise IS FROM PLAYER, tags: " + player.inventory.holdingItem.ItemTags);
|
||||
|
||||
if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("ranged")) && !player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("ammo")))
|
||||
{
|
||||
ItemClass itemClass = ItemClass.GetItem(heldItem, false).ItemClass;
|
||||
|
||||
ItemActionRanged myAction = (ItemActionRanged)itemClass.Actions[0];
|
||||
ItemActionData _actionData = player.inventory.holdingItemData.actionData[0];
|
||||
ItemActionRanged.ItemActionDataRanged itemActionDataRanged = (ItemActionRanged.ItemActionDataRanged)_actionData;
|
||||
|
||||
float myDelay = 60f / EffectManager.GetValue(PassiveEffects.RoundsPerMinute, itemActionDataRanged.invData.itemValue, 60f / itemActionDataRanged.OriginalDelay, player);
|
||||
int roundsPerMinute = (int)(60 / myDelay);
|
||||
|
||||
float divisor = RebirthUtilities.CalculateHeatMapDivisor(roundsPerMinute);
|
||||
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise roundsPerMinute: " + roundsPerMinute);
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise divisor: " + divisor);
|
||||
|
||||
if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponLongRangeRifles")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 1))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponShotguns")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 2))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponAssaultRifles")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 3))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponMachineGuns")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 4))
|
||||
{
|
||||
if (heldItem != "MachineGun01_FR")
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponRevolvers")) ||
|
||||
player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("WeaponTier3DeployableTurrets")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 5))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponSubmachineGuns")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 6))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponPistols")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 7))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponHeavyHandguns")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 8))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponTacticalRifles")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 9))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise AFTER noise.heatMapStrength: " + noise.heatMapStrength);
|
||||
|
||||
if (canProceed)
|
||||
{
|
||||
__instance.NotifyActivity(EnumAIDirectorChunkEvent.Sound, World.worldToBlockPos(position), noise.heatMapStrength * volumeScale, 240f);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user