25 ProjectileType m_ProjectileType;
27 void AmmoData(
string init_type )
32 m_CartridgeType =
g_Game.ConfigGetInt(
"CfgMagazines " + init_type +
" iconCartridge" );
33 m_ProjectileType =
g_Game.ConfigGetInt(
"CfgMagazines " + init_type +
" iconType" );
41 ref array<string> m_CompatiableAmmo;
42 ref array<float> m_ChanceToJam;
43 protected float m_ManipulationDamage;
47 m_ChanceToJam =
new array<float>;
48 InitReliability(m_ChanceToJam);
49 m_ManipulationDamage = ConfigGetFloat(
"manipulationDamage");
50 m_CompatiableAmmo =
new array<string>;
51 ConfigGetTextArray(
"ammoItems", m_CompatiableAmmo);
52 if ( !
g_Game.IsDedicatedServer() )
57 string classname = ClassName();
58 if ( !m_AmmoData.Contains(classname) )
60 ref AmmoData new_data =
new AmmoData( classname );
61 if ( new_data.m_IsValid )
62 m_AmmoData.Insert( classname,
new AmmoData( classname ) );
68 proto native
int GetAmmoCount();
70 proto native
void ServerSetAmmoCount(
int ammoCount);
71 proto native
void LocalSetAmmoCount(
int ammoCount);
79 proto
bool LocalAcquireCartridge(out
float dmg, out
string cartTypeName);
80 proto
bool ServerAcquireCartridge(out
float dmg, out
string cartTypeName);
87 proto native
bool LocalStoreCartridge(
float ammoDamage,
string cartTypeName);
88 proto native
bool ServerStoreCartridge(
float ammoDamage,
string cartTypeName);
97 proto
bool GetCartridgeAtIndex(
int cartIndex, out
float dmg, out
string cartTypeName);
106 proto
bool SetCartridgeAtIndex(
int cartIndex, out
float dmg, out
string cartTypeName);
114 proto
bool SetCartridgeDamageAtIndex(
int cartIndex,
float dmg);
117 static AmmoData GetAmmoData(
string classname )
121 if ( !m_AmmoData.Contains(classname) )
123 ref AmmoData new_data =
new AmmoData( classname );
124 if ( new_data.m_IsValid )
125 m_AmmoData.Insert( classname,
new AmmoData( classname ) );
130 return m_AmmoData.Get( classname );
134 protected void UpdateAnimation();
136 bool IsCompatiableAmmo(
ItemBase ammo )
138 if ( m_CompatiableAmmo && ammo )
139 return ( m_CompatiableAmmo.Find( ammo.GetType() ) > -1 );
144 bool CanAddCartridges(
int count)
146 int spc_avail = GetAmmoMax() - GetAmmoCount();
147 return count <= spc_avail;
151 void ServerAddAmmoCount(
int ammoCount)
153 ServerSetAmmoCount(GetAmmoCount() + ammoCount);
155 void LocalAddAmmoCount(
int ammoCount)
157 LocalSetAmmoCount(GetAmmoCount() + ammoCount);
162 return ItemBaseType.Cast(GetEntityType()).m_Count;
165 void ServerSetAmmoMax()
167 ServerSetAmmoCount( GetAmmoMax() );
169 void LocalSetAmmoMax()
171 LocalSetAmmoCount( GetAmmoMax() );
174 override bool IsMagazine()
180 bool LocalAcquireCartridgeEx(out
float ammoDamage, out
string cartTypeName)
182 bool changeAmmoCount = LocalAcquireCartridge(ammoDamage, cartTypeName);
184 return changeAmmoCount;
188 bool ServerAcquireCartridgeEx(out
float ammoDamage, out
string cartTypeName)
190 bool changeAmmoCount = ServerAcquireCartridge(ammoDamage, cartTypeName);
192 return changeAmmoCount;
196 bool ServerStoreCartridgeEx(
float ammoDamage,
string cartTypeName)
197 {
bool changeAmmoCount = ServerStoreCartridge(ammoDamage, cartTypeName);
199 return changeAmmoCount;
206 return ( GetAmmoCount() > 1 );
211 bool InitReliability(out array<float> reliability_array)
213 if (
g_Game.ConfigIsExisting(
"cfgMagazines " +
GetType() +
" Reliability ChanceToJam"))
215 g_Game.ConfigGetFloatArray(
"cfgMagazines " +
GetType() +
" Reliability ChanceToJam",reliability_array);
221 float GetChanceToJam()
223 int level = GetHealthLevel();
225 if (level >= 0 && level < m_ChanceToJam.Count())
226 return m_ChanceToJam[level];
239 MiscGameplayFunctions.TransferItemProperties(dst.GetItem(), new_pile);
241 new_pile.ServerSetAmmoCount(0);
242 int quantity = GetAmmoCount();
244 for (
int i = 0; i < Math.Floor( quantity * 0.5 ); ++i)
247 string cartrige_name;
248 ServerAcquireCartridge(damage, cartrige_name);
249 new_pile.ServerStoreCartridge(damage, cartrige_name);
251 new_pile.SetSynchDirty();
256 override void SplitItem(PlayerBase player)
262 Magazine new_pile = Magazine.Cast( player.CreateCopyOfItemInInventoryOrGround(
this ) );
265 new_pile.ServerSetAmmoCount(0);
266 int quantity = this.GetAmmoCount();
268 for (
int i = 0; i < Math.Floor( quantity / 2 ); i++)
271 string cartrige_name;
272 ServerAcquireCartridge(damage, cartrige_name);
273 new_pile.ServerStoreCartridge(damage, cartrige_name);
275 new_pile.SetSynchDirty();
280 void ApplyManipulationDamage()
282 AddHealth(
"",
"Health",-m_ManipulationDamage);
287 if ( GetAmmoCount() == GetAmmoMax() )
300 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
302 WeightDebugData data = WeightDebug.GetWeightDebug(
this);
303 data.
SetCalcDetails(
"TMAG: ("+GetAmmoCount()+
"(Ammo count) * " + ConfigGetFloat(
"weightPerQuantityUnit")+
"(weightPerQuantityUnit)) + " + GetConfigWeightModifiedDebugText());
306 return GetConfigWeightModified() + (GetAmmoCount() * ConfigGetFloat(
"weightPerQuantityUnit"));
311 Magazine other_magazine = Magazine.Cast(other_item);
312 int free_space = GetAmmoMax() - GetAmmoCount();
314 return free_space >= other_magazine.GetAmmoCount();
322 if ( other_item.GetType() !=
GetType() )
325 Magazine other_magazine;
326 if ( Class.CastTo(other_magazine, other_item) )
329 int this_free_space = GetAmmoMax() - GetAmmoCount();
330 int numberOfTransferredBullets = 0;
331 int currentAmount = GetAmmoCount();
333 for (
int i = 0; i < this_free_space && other_magazine.GetAmmoCount() > 0 ; i++)
336 string cartrige_name;
337 other_magazine.ServerAcquireCartridge(damage, cartrige_name);
338 if (ServerStoreCartridge(damage, cartrige_name))
339 ++numberOfTransferredBullets;
344 float resultingHealth = (currentAmount * GetHealth() + numberOfTransferredBullets * other_magazine.GetHealth()) / GetAmmoCount();
345 SetHealth(
"",
"", resultingHealth);
348 other_magazine.SetSynchDirty();
355 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
358 Weapon_Base wpn = Weapon_Base.Cast(parent);
361 return player.GetWeaponManager().CanDetachMagazine(wpn,
this);
364 return super.CanDetachAttachment(parent);
369 super.OnInventoryEnter(player);
371 PlayerBase p = PlayerBase.Cast(player);
372 p.GetWeaponManager().OnMagazineInventoryEnter(
this);
377 super.OnInventoryExit(player);
379 PlayerBase p = PlayerBase.Cast(player);
380 p.GetWeaponManager().OnMagazineInventoryExit(
this);
385 super.OnWasAttached(parent, slot_id);
387 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
388 Weapon_Base wpn = Weapon_Base.Cast(parent);
391 player.GetWeaponManager().OnMagazineAttach(
this);
397 super.OnWasDetached(parent, slot_id);
399 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
400 Weapon_Base wpn = Weapon_Base.Cast(parent);
404 player.GetWeaponManager().OnMagazineDetach(
this);
411 float damage = 1 - GetHealthLevelValue(newLevel) + 0.001;
413 int cartridgeCount = GetAmmoCount();
414 for (
int i = 0; i < cartridgeCount; ++i)
415 SetCartridgeDamageAtIndex(i, damage);
418 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
420 if (GetAmmoCount() > 0)
427 super.GetDebugActions(outputList);
434 if (action_id ==
EActions.PRINT_BULLETS)
437 Class.CastTo(magazine,
this);
438 for (
int i = 0; i < magazine.GetAmmoCount(); i++)
442 magazine.GetCartridgeAtIndex(i, damage, className);
443 Debug.Log(
string.Format(
"Bullet: %1, Damage %2", className, damage));
448 return super.OnAction(action_id, player, ctx);
451 override bool CanBeFSwaped()
453 Weapon_Base wpn = Weapon_Base.Cast(GetHierarchyParent());
463class MagazineStorage : Magazine
Param4< int, int, string, int > TSelectableActionInfoWithColor
eBleedingSourceType GetType()
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
override bool CanDetachAttachment(EntityAI parent)
void AddAction(typename actionName)
const int ECE_IN_INVENTORY
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
class GP5GasMask extends MaskBase ItemBase
void OnCombine(ItemBase other_item)
override bool CanBeSplit()
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
void CombineItems(ItemBase other_item, bool use_stack_max=true)
void OnInventoryEnter(Man player)
Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter.
float GetWeightSpecialized(bool forceRecalc=false)
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
override void OnWasAttached(EntityAI parent, int slot_id)
void SplitItem(PlayerBase player)
void OnInventoryExit(Man player)
Event called on item when it is removed from the player(Man) inventory, passes the old owner as a par...
enum CartridgeType Tracer
override void OnWasDetached(EntityAI parent, int slot_id)
overrides the base behavior - intentional
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
void SetCalcDetails(string details)
Keffiyeh_LightBlue SetActions
Serializer ParamsReadContext
const int SAT_DEBUG_ACTION