@@ -1086,98 +1086,98 @@ public static void OnShooting(PlayerShootingWeaponEventArgs ev)
10861086
10871087 LogManager . Debug ( $ "{ customItem . CustomItem . Name } - Pickup spawned (ItemShot) - { pickup . Serial } ") ;
10881088 }
1089+ }
1090+ }
10891091
1090- if ( customItem . HasModule ( CustomFlags . InfiniteAmmo ) )
1092+ if ( customItem . HasModule ( CustomFlags . InfiniteAmmo ) )
1093+ {
1094+ IWeaponData data = customItem . CustomItem . CustomData as IWeaponData ;
1095+ customItem . MagazineModule . ServerModifyAmmo ( data . MaxMagazineAmmo ) ;
1096+ LogManager . Silent ( $ "InfiniteAmmo flag was triggered: magazine refilled to { data . MaxMagazineAmmo } ") ;
1097+ }
1098+ if ( customItem . HasModule ( CustomFlags . CustomSound ) )
1099+ {
1100+ LogManager . Debug ( $ "Attempting to play audio at { ev . Player . Position } triggered by { ev . Player . Nickname } using { customItem . CustomItem . Name } .") ;
1101+ AudioApi . PlayAudio ( customItem , ev . Player . Position ) ;
1102+ }
1103+ if ( customItem . HasModule ( CustomFlags . DieOnUse ) )
1104+ {
1105+ foreach ( DieOnUseSettings dieOnUseSettings in customItem . CustomItem . FlagSettings . DieOnUseSettings )
1106+ {
1107+ if ( dieOnUseSettings . Vaporize ?? false )
10911108 {
1092- IWeaponData data = customItem . CustomItem . CustomData as IWeaponData ;
1093- customItem . MagazineModule . ServerModifyAmmo ( data . MaxMagazineAmmo ) ;
1094- LogManager . Silent ( $ "InfiniteAmmo flag was triggered: magazine refilled to { data . MaxMagazineAmmo } ") ;
1109+ LogManager . Debug ( $ "DieOnUse triggered: { ev . Player . Nickname } vaporized by { customItem . CustomItem . Name } with DieOnUse CustomFlag") ;
1110+ ev . Player . Vaporize ( ) ;
10951111 }
1096- if ( customItem . HasModule ( CustomFlags . CustomSound ) )
1112+
1113+ if ( dieOnUseSettings . DeathMessage != null )
10971114 {
1098- LogManager . Debug ( $ "Attempting to play audio at { ev . Player . Position } triggered by { ev . Player . Nickname } using { customItem . CustomItem . Name } . ") ;
1099- AudioApi . PlayAudio ( customItem , ev . Player . Position ) ;
1115+ LogManager . Debug ( $ "DieOnUse triggered: { ev . Player . Nickname } killed by { customItem . CustomItem . Name } with DieOnUse CustomFlag ") ;
1116+ ev . Player . Kill ( $ " { dieOnUseSettings . DeathMessage . Replace ( "%name%" , customItem . CustomItem . Name ) } " ) ;
11001117 }
1101- if ( customItem . HasModule ( CustomFlags . DieOnUse ) )
1118+ else
11021119 {
1103- foreach ( DieOnUseSettings dieOnUseSettings in customItem . CustomItem . FlagSettings . DieOnUseSettings )
1104- {
1105- if ( dieOnUseSettings . Vaporize ?? false )
1106- {
1107- LogManager . Debug ( $ "DieOnUse triggered: { ev . Player . Nickname } vaporized by { customItem . CustomItem . Name } with DieOnUse CustomFlag") ;
1108- ev . Player . Vaporize ( ) ;
1109- }
1110-
1111- if ( dieOnUseSettings . DeathMessage != null )
1112- {
1113- LogManager . Debug ( $ "DieOnUse triggered: { ev . Player . Nickname } killed by { customItem . CustomItem . Name } with DieOnUse CustomFlag") ;
1114- ev . Player . Kill ( $ "{ dieOnUseSettings . DeathMessage . Replace ( "%name%" , customItem . CustomItem . Name ) } ") ;
1115- }
1116- else
1117- {
1118- LogManager . Debug ( $ "DieOnUse triggered: { ev . Player . Nickname } killed by { customItem . CustomItem . Name } with DieOnUse CustomFlag") ;
1119- ev . Player . Kill ( $ "Killed by { customItem . CustomItem . Name } ") ;
1120- }
1121- }
1120+ LogManager . Debug ( $ "DieOnUse triggered: { ev . Player . Nickname } killed by { customItem . CustomItem . Name } with DieOnUse CustomFlag") ;
1121+ ev . Player . Kill ( $ "Killed by { customItem . CustomItem . Name } ") ;
11221122 }
1123- if ( customItem . HasModule ( CustomFlags . DistruptorTracer ) )
1124- {
1125- if ( ! InventoryItemLoader . TryGetItem ( ItemType . ParticleDisruptor , out ParticleDisruptor disruptor ) )
1126- return ;
1127- if ( ! disruptor . TryGetModule ( out ImpactEffectsModule impactmodule ) )
1128- return ;
1129- if ( ! disruptor . TryGetModule ( out DisruptorHitregModule hitregmodule ) )
1130- return ;
1123+ }
1124+ }
1125+ if ( customItem . HasModule ( CustomFlags . DistruptorTracer ) )
1126+ {
1127+ if ( ! InventoryItemLoader . TryGetItem ( ItemType . ParticleDisruptor , out ParticleDisruptor disruptor ) )
1128+ return ;
1129+ if ( ! disruptor . TryGetModule ( out ImpactEffectsModule impactmodule ) )
1130+ return ;
1131+ if ( ! disruptor . TryGetModule ( out DisruptorHitregModule hitregmodule ) )
1132+ return ;
11311133
1132- Vector3 position1 = ev . Player . Camera . position ;
1133- if ( BarrelTipExtension . TryFindWorldmodelBarrelTip ( ev . FirearmItem . Serial , out var tip1 ) )
1134- position = tip1 . WorldspacePosition ;
1134+ Vector3 position1 = ev . Player . Camera . position ;
1135+ if ( BarrelTipExtension . TryFindWorldmodelBarrelTip ( ev . FirearmItem . Serial , out var tip1 ) )
1136+ position1 = tip1 . WorldspacePosition ;
11351137
1136- position . y -= 0.6f ;
1137- float maxDistance = customItem . HitscanHitregModule . DamageFalloffDistance + customItem . HitscanHitregModule . FullDamageDistance ;
1138+ position1 . y -= 0.6f ;
1139+ float maxDistance = customItem . HitscanHitregModule . DamageFalloffDistance + customItem . HitscanHitregModule . FullDamageDistance ;
11381140
1139- Ray baseRay = new ( ev . Player . Camera . position + ev . Player . Camera . forward , ev . Player . Camera . forward ) ;
1141+ Ray baseRay = new ( ev . Player . Camera . position + ev . Player . Camera . forward , ev . Player . Camera . forward ) ;
11401142
1141- if ( ev . FirearmItem . ActionModule is AutomaticActionModule autoModule )
1142- {
1143- int amount = Mathf . Min ( autoModule . AmmoStored , autoModule . ChamberSize ) ;
1144- for ( int i = 0 ; i <= amount ; i ++ )
1145- {
1146- Ray ray = customItem . HitscanHitregModule . RandomizeRay ( baseRay , customItem . HitscanHitregModule . CurrentInaccuracy ) ;
1143+ if ( ev . FirearmItem . ActionModule is AutomaticActionModule autoModule )
1144+ {
1145+ int amount = Mathf . Min ( autoModule . AmmoStored , autoModule . ChamberSize ) ;
1146+ for ( int i = 0 ; i <= amount ; i ++ )
1147+ {
1148+ Ray ray = customItem . HitscanHitregModule . RandomizeRay ( baseRay , customItem . HitscanHitregModule . CurrentInaccuracy ) ;
11471149
1148- if ( Physics . Raycast ( ray , out RaycastHit hitInfo , maxDistance , HitscanHitregModuleBase . HitregMask ) )
1149- {
1150- hitregmodule . _templateShotData = new ( disruptor , FiringState . FiringSingle ) ;
1151- impactmodule . ServerSendTracer ( hitInfo , position1 , null , impactmodule . BaseSettings . TracerPrefab ) ;
1152- }
1153- else
1154- {
1155- Vector3 endPoint = ray . origin + ( ray . direction * maxDistance ) ;
1156- hitInfo . point = endPoint ;
1157- hitregmodule . _templateShotData = new ( disruptor , FiringState . FiringSingle ) ;
1158- impactmodule . ServerSendTracer ( hitInfo , position1 , null , impactmodule . BaseSettings . TracerPrefab ) ;
1159- }
1160- }
1150+ if ( Physics . Raycast ( ray , out RaycastHit hitInfo , maxDistance , HitscanHitregModuleBase . HitregMask ) )
1151+ {
1152+ hitregmodule . _templateShotData = new ( disruptor , FiringState . FiringSingle ) ;
1153+ impactmodule . ServerSendTracer ( hitInfo , position1 , null , impactmodule . BaseSettings . TracerPrefab ) ;
11611154 }
1162- else if ( ev . FirearmItem . ActionModule is PumpActionModule pumpModule )
1155+ else
11631156 {
1164- for ( int i = 0 ; i <= pumpModule . _baseShotsPerTriggerPull ; i ++ )
1165- {
1166- Ray ray = customItem . HitscanHitregModule . RandomizeRay ( baseRay , customItem . HitscanHitregModule . CurrentInaccuracy ) ;
1157+ Vector3 endPoint = ray . origin + ( ray . direction * maxDistance ) ;
1158+ hitInfo . point = endPoint ;
1159+ hitregmodule . _templateShotData = new ( disruptor , FiringState . FiringSingle ) ;
1160+ impactmodule . ServerSendTracer ( hitInfo , position1 , null , impactmodule . BaseSettings . TracerPrefab ) ;
1161+ }
1162+ }
1163+ }
1164+ else if ( ev . FirearmItem . ActionModule is PumpActionModule pumpModule )
1165+ {
1166+ for ( int i = 0 ; i <= pumpModule . _baseShotsPerTriggerPull ; i ++ )
1167+ {
1168+ Ray ray = customItem . HitscanHitregModule . RandomizeRay ( baseRay , customItem . HitscanHitregModule . CurrentInaccuracy ) ;
11671169
1168- if ( Physics . Raycast ( ray , out RaycastHit hitInfo , maxDistance , HitscanHitregModuleBase . HitregMask ) )
1169- {
1170- hitregmodule . _templateShotData = new ( disruptor , FiringState . FiringSingle ) ;
1171- impactmodule . ServerSendTracer ( hitInfo , position1 , null , impactmodule . BaseSettings . TracerPrefab ) ;
1172- }
1173- else
1174- {
1175- Vector3 endPoint = ray . origin + ( ray . direction * maxDistance ) ;
1176- hitInfo . point = endPoint ;
1177- hitregmodule . _templateShotData = new ( disruptor , FiringState . FiringSingle ) ;
1178- impactmodule . ServerSendTracer ( hitInfo , position1 , null , impactmodule . BaseSettings . TracerPrefab ) ;
1179- }
1180- }
1170+ if ( Physics . Raycast ( ray , out RaycastHit hitInfo , maxDistance , HitscanHitregModuleBase . HitregMask ) )
1171+ {
1172+ hitregmodule . _templateShotData = new ( disruptor , FiringState . FiringSingle ) ;
1173+ impactmodule . ServerSendTracer ( hitInfo , position1 , null , impactmodule . BaseSettings . TracerPrefab ) ;
1174+ }
1175+ else
1176+ {
1177+ Vector3 endPoint = ray . origin + ( ray . direction * maxDistance ) ;
1178+ hitInfo . point = endPoint ;
1179+ hitregmodule . _templateShotData = new ( disruptor , FiringState . FiringSingle ) ;
1180+ impactmodule . ServerSendTracer ( hitInfo , position1 , null , impactmodule . BaseSettings . TracerPrefab ) ;
11811181 }
11821182 }
11831183 }
0 commit comments