34 magnum.SyncCylinderRotation();
53 int m_LastMuzzleloaded;
55 const string ATT_SLOT_CYLINDER =
"RevolverCylinder";
56 const string ATT_SLOT_EJECTOR =
"RevolverEjector";
60 AddAction(FirearmActionLoadMultiBulletQuick);
65 override RecoilBase SpawnRecoilObject()
67 return new MagnumRecoil(
this);
72 m_LastMuzzleloaded = 0;
85 override void InitStateMachine ()
87 m_abilities.Insert(
new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED));
88 m_abilities.Insert(
new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP));
89 m_abilities.Insert(
new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE));
90 m_abilities.Insert(
new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
91 m_abilities.Insert(
new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_SPECIAL));
92 m_abilities.Insert(
new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
93 m_abilities.Insert(
new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED));
94 m_abilities.Insert(
new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED));
102 WeaponMagnumChambering Chamber =
new WeaponMagnumChambering(
this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP,WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
103 WeaponMagnumChambering Chamber_E =
new WeaponMagnumChambering(
this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED,WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
106 WeaponCharging Mech =
new WeaponCharging(
this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
108 WeaponStateBase Trigger_normal =
new WeaponFireMagnum(
this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL);
109 WeaponStateBase Trigger_dry =
new WeaponFireMagnum(
this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED);
124 m_fsm =
new WeaponFSM();
128 m_fsm.AddTransition(
new WeaponTransition( C, __L__, Chamber, null,
new WeaponGuardAnyChamberFiredOut(
this)));
144 m_fsm.AddTransition(
new WeaponTransition( C, __T__, Trigger_normal, null,
new GuardAnd (
new WeaponGuardCurrentChamberFull(
this),
new GuardNot(
new WeaponGuardCurrentChamberFiredOut(
this))) ));
156 SelectionBulletHide();
162 override bool CanChamberBullet(
int muzzleIndex, Magazine mag)
164 if ( CanChamberFromMag(muzzleIndex, mag) )
166 if (IsChamberEmpty(muzzleIndex))
179 if ( !FindAttachmentBySlotName(ATT_SLOT_EJECTOR) )
181 GetInventory().CreateAttachment(
"Magnum_Ejector");
184 if ( !FindAttachmentBySlotName(ATT_SLOT_CYLINDER) )
186 GetInventory().CreateAttachment(
"Magnum_Cylinder");
189 ForceSyncSelectionState();
190 SyncCylinderRotation();
193 static float GetCylinderRotation(
int muzzleIndex)
211 ErrorEx(
string.Format(
"Invalid muzzle index: %1", muzzleIndex));
216 void SetCylinderRotationAnimationPhase(
float rot,
bool reset =
false)
218 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
219 Magnum_Ejector ejector = Magnum_Ejector.Cast(GetAttachmentByType(Magnum_Ejector));
220 if (cylinder && ejector)
222 float anim_phase = cylinder.GetAnimationPhase(
"Rotate_Cylinder");
223 if ( Math.AbsFloat(anim_phase - rot) > 0.1 )
227 cylinder.ResetAnimationPhase(
"Rotate_Cylinder", rot );
228 ejector.ResetAnimationPhase(
"Rotate_Ejector", rot );
236 cylinder.SetAnimationPhase(
"Rotate_Cylinder", rot );
237 ejector.SetAnimationPhase(
"Rotate_Ejector", rot );
242 void SyncCylinderRotation(
bool reset =
true)
244 SetCylinderRotationAnimationPhase(GetCylinderRotation(GetCurrentMuzzle()), reset);
249 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
254 SetAttachmentsHealth();
258 void SetAttachmentsHealth()
262 for (
int i = 0; i < GetInventory().AttachmentCount(); i++)
264 entity = GetInventory().GetAttachmentFromIndex(i);
265 if ( Class.CastTo(attachment,entity) )
267 attachment.SetHealth01(
"",
"Health",GetHealth01());
272 override void OnFire(
int muzzle_index)
274 super.OnFire(muzzle_index);
275 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
278 string bullet_nose =
"bullet_nose";
279 if (muzzle_index > 0)
280 bullet_nose =
string.Format(
"bullet_nose_" + (muzzle_index + 1));
281 cylinder.HideSelection(bullet_nose);
285 override bool IsShowingChamberedBullet()
290 override bool CanEjectBullet()
292 for (
int i = 0; i < GetMuzzleCount(); i++)
300 override void ShowBullet(
int muzzleIndex)
302 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
305 string bullet =
"bullet";
307 bullet =
string.Format(
"bullet_" + (muzzleIndex + 1));
309 cylinder.ShowSelection(bullet);
313 string bullet_nose =
"bullet_nose";
315 bullet_nose =
string.Format(
"bullet_nose_" + (muzzleIndex + 1));
316 cylinder.ShowSelection(bullet_nose);
321 override void HideBullet(
int muzzleIndex)
323 super.HideBullet(muzzleIndex);
325 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
328 string bullet =
"bullet";
330 bullet =
string.Format(
"bullet_" + (muzzleIndex + 1));
332 cylinder.HideSelection(bullet);
334 string bullet_nose =
"bullet_nose";
336 bullet_nose =
string.Format(
"bullet_nose_" + (muzzleIndex + 1));
337 cylinder.HideSelection(bullet_nose);
344 super.OnDebugSpawn();
347 if ( Class.CastTo(entity,
this) )
349 entity.SpawnEntityOnGroundPos(
"Ammo_357", entity.GetPosition());
356 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
362 super.GetDebugActions(outputList);
371 const float animPhaseOffset = 0.167;
373 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
374 Magnum_Ejector ejector = Magnum_Ejector.Cast(GetAttachmentByType(Magnum_Ejector));
378 float animPhase = cylinder.GetAnimationPhase(
"Rotate_Cylinder");
379 if (animPhase + animPhaseOffset > 1.0)
382 cylinder.ResetAnimationPhase(
"Rotate_Cylinder", animPhase);
383 ejector.ResetAnimationPhase(
"Rotate_Ejector", animPhase);
386 cylinder.SetAnimationPhase(
"Rotate_Cylinder", animPhase);
387 ejector.ResetAnimationPhase(
"Rotate_Ejector", animPhase);
392 return super.OnAction(action_id, player, ctx);
398class Magnum_Ejector
extends DummyItem {};
Param4< int, int, string, int > TSelectableActionInfoWithColor
void AddAction(typename actionName)
override void AssembleGun()
@ UNKNOWN
24 - Any other error. Can be returned from any call.
signalize mechanism manipulation
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
void OnFire(Entity flare)
Serializer ParamsReadContext
class GP5GasMask extends MaskBase ItemBase
const int SAT_DEBUG_ACTION
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
enum MagnumStableStateID init
const float MAGNUM_ROTATION_POSITION_2
const float MAGNUM_ROTATION_POSITION_1
const float MAGNUM_ROTATION_POSITION_3
const float MAGNUM_ROTATION_POSITION_4
const float MAGNUM_ROTATION_POSITION_6
class Magnum extends Magnum_Base Magnum_Base
const float MAGNUM_ROTATION_POSITION_M1
const float MAGNUM_ROTATION_POSITION_5
const float MAGNUM_ROTATION_POSITION_0
class SSPFireout extends WeaponStableState OnEntry
override int GetCurrentStateID()
override bool HasBullet()
override bool HasMagazine()
enum FSMTransition WeaponTransition
enum FSMTransition WeaponEventBase
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit
bool IsSingleState()
Special one for when the weapon only has one singular state (like Magnum).
void WeaponStableState(Weapon_Base w=NULL, WeaponStateBase parent=NULL, int anim_state=-1)
bool IsChamberFiredOut(int idx)
bool IsChamberFull(int idx)