static void Postfix(Agent shooterAgent, EquipmentIndex weaponIndex, Vec3 position, Vec3 velocity, Mat3 orientation, bool hasRigidBody, bool isPrimaryWeaponShot, int forcedMissileIndex, Mission __instance) { MissionWeapon missionWeapon = shooterAgent.Equipment[weaponIndex]; WeaponStatsData[] wsd = missionWeapon.GetWeaponStatsData(); if ((wsd[0].WeaponClass == (int)WeaponClass.Bow) || (wsd[0].WeaponClass == (int)WeaponClass.Crossbow)) { PropertyInfo property2 = typeof(WeaponComponentData).GetProperty("MissileSpeed"); property2.DeclaringType.GetProperty("MissileSpeed"); property2.SetValue(shooterAgent.Equipment[weaponIndex].CurrentUsageItem, _oldMissileSpeed, BindingFlags.NonPublic | BindingFlags.SetProperty, null, null, null); } }
static bool Prefix(Agent shooterAgent, EquipmentIndex weaponIndex, Vec3 position, ref Vec3 velocity, Mat3 orientation, bool hasRigidBody, bool isPrimaryWeaponShot, int forcedMissileIndex, Mission __instance) { MissionWeapon missionWeapon = shooterAgent.Equipment[weaponIndex]; WeaponStatsData[] wsd = missionWeapon.GetWeaponStatsData(); if ((wsd[0].WeaponClass == (int)WeaponClass.Bow) || (wsd[0].WeaponClass == (int)WeaponClass.Crossbow)) { if (missionWeapon.ItemModifier != null) { FieldInfo field = typeof(ItemModifier).GetField("_missileSpeed", BindingFlags.NonPublic | BindingFlags.Instance); field.DeclaringType.GetField("_missileSpeed"); int missileSpeedModifier = (int)field.GetValue(missionWeapon.ItemModifier); _oldMissileSpeed = missionWeapon.GetModifiedMissileSpeedForUsage(0) - missileSpeedModifier; } else { _oldMissileSpeed = missionWeapon.GetModifiedMissileSpeedForUsage(0); } float ammoWeight = missionWeapon.AmmoWeapon.GetWeight(); int calculatedMissileSpeed = Utilities.calculateMissileSpeed(ammoWeight, missionWeapon, missionWeapon.GetModifiedMissileSpeedForUsage(0)); Vec3 shooterAgentVelocity = new Vec3(shooterAgent.Velocity, -1); Vec3 myVelocity = new Vec3(velocity, -1); myVelocity.Normalize(); float shooterAgentSpeed = Vec3.DotProduct(shooterAgentVelocity, myVelocity); Vec3 modifierVec = shooterAgentVelocity + myVelocity; velocity.x = myVelocity.x * (calculatedMissileSpeed + shooterAgentSpeed); velocity.y = myVelocity.y * (calculatedMissileSpeed + shooterAgentSpeed); velocity.z = myVelocity.z * (calculatedMissileSpeed + shooterAgentSpeed); PropertyInfo property2 = typeof(WeaponComponentData).GetProperty("MissileSpeed"); property2.DeclaringType.GetProperty("MissileSpeed"); property2.SetValue(shooterAgent.Equipment[weaponIndex].CurrentUsageItem, calculatedMissileSpeed, BindingFlags.NonPublic | BindingFlags.SetProperty, null, null, null); } return(true); }
private void SetFireSwordEnable(bool enable) { if (Agent.Main == null) { return; } if (enable) { EquipmentIndex index = Agent.Main.GetWieldedItemIndex(Agent.HandIndex.MainHand); if (index == EquipmentIndex.None) { return; } GameEntity wieldedWeaponEntity = Agent.Main.GetWeaponEntityFromEquipmentSlot(index); MissionWeapon wieldedWeapon = Agent.Main.WieldedWeapon; int length = wieldedWeapon.GetWeaponStatsData()[0].WeaponLength; int num = (int)Math.Round(length / 10f); Skeleton skeleton = Agent.Main.AgentVisuals.GetSkeleton(); Light light = Light.CreatePointLight(FireLordConfig.FireSwordLightRadius); light.Intensity = FireLordConfig.FireSwordLightIntensity; light.LightColor = FireLordConfig.FireSwordLightColor; switch (wieldedWeapon.CurrentUsageItem.WeaponClass) { case WeaponClass.OneHandedSword: case WeaponClass.TwoHandedSword: case WeaponClass.Mace: case WeaponClass.TwoHandedMace: for (int i = 1; i < num; i++) { MatrixFrame localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)).Elevate(i * 0.1f); ParticleSystem particle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_game_burning_agent", wieldedWeaponEntity, ref localFrame); skeleton.AddComponentToBone(Game.Current.HumanMonster.MainHandItemBoneIndex, particle); } light.Frame = light.Frame.Elevate((num - 1) * 0.1f); break; case WeaponClass.OneHandedAxe: case WeaponClass.TwoHandedAxe: case WeaponClass.OneHandedPolearm: case WeaponClass.TwoHandedPolearm: case WeaponClass.LowGripPolearm: int fireLenth = (num > 19)? 9 :(num > 15)? 6 : (num > 12)? 5 :(num > 10) ? 4 : 3; for (int i = num - 1; i > 0 && i > num - fireLenth; i--) { MatrixFrame localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)).Elevate(i * 0.1f); ParticleSystem particle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_game_burning_agent", wieldedWeaponEntity, ref localFrame); skeleton.AddComponentToBone(Game.Current.HumanMonster.MainHandItemBoneIndex, particle); } light.Frame = light.Frame.Elevate((num - 1) * 0.1f); break; default: //InformationManager.DisplayMessage(new InformationMessage("当前武器无法点燃")); return; } skeleton.AddComponentToBone(Game.Current.HumanMonster.MainHandItemBoneIndex, light); //只有通过扔掉再重新捡起这把武器,才能让粒子效果出现 DropLock = true; Agent.Main.DropItem(index); SpawnedItemEntity spawnedItemEntity = wieldedWeaponEntity.GetFirstScriptOfType <SpawnedItemEntity>(); Agent.Main.OnItemPickup(spawnedItemEntity, EquipmentIndex.None, out bool removeItem); DropLock = false; _fireSwordLight = light; _fireSwordEntity = wieldedWeaponEntity; _fireSwordEnabled = true; } else { _fireSwordEnabled = false; if (_fireSwordEntity != null) { Skeleton skeleton = Agent.Main.AgentVisuals.GetSkeleton(); if (_fireSwordLight != null && skeleton != null) { skeleton.RemoveComponent(_fireSwordLight); } _fireSwordEntity.RemoveAllParticleSystems(); } } }
private static WeaponStatsData[] GetAmmoWeaponStatsData(MissionWeapon missionWeapon) { return(missionWeapon.GetWeaponStatsData()); }