34 magnum.SyncCylinderRotation();
55 const string ATT_SLOT_CYLINDER =
"RevolverCylinder";
56 const string ATT_SLOT_EJECTOR =
"RevolverEjector";
75 m_LastMuzzleloaded = 0;
131 m_fsm.AddTransition(
new WeaponTransition( C, __L__, Chamber, null,
new WeaponGuardAnyChamberFiredOut(
this)));
147 m_fsm.AddTransition(
new WeaponTransition( C, __T__, Trigger_normal, null,
new GuardAnd (
new WeaponGuardCurrentChamberFull(
this),
new GuardNot(
new WeaponGuardCurrentChamberFiredOut(
this))) ));
159 SelectionBulletHide();
167 for (
int i = 0; i < GetMuzzleCount(); i++)
169 if ( CanChamberFromMag(i, mag) )
171 if (IsChamberEmpty(i))
185 if ( !FindAttachmentBySlotName(ATT_SLOT_EJECTOR) )
187 GetInventory().CreateAttachment(
"Magnum_Ejector");
190 if ( !FindAttachmentBySlotName(ATT_SLOT_CYLINDER) )
192 GetInventory().CreateAttachment(
"Magnum_Cylinder");
195 ForceSyncSelectionState();
196 SyncCylinderRotation();
217 ErrorEx(
string.Format(
"Invalid muzzle index: %1", muzzleIndex));
224 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
225 Magnum_Ejector ejector = Magnum_Ejector.Cast(GetAttachmentByType(Magnum_Ejector));
226 if (cylinder && ejector)
228 float anim_phase = cylinder.GetAnimationPhase(
"Rotate_Cylinder");
233 cylinder.ResetAnimationPhase(
"Rotate_Cylinder", rot );
234 ejector.ResetAnimationPhase(
"Rotate_Ejector", rot );
242 cylinder.SetAnimationPhase(
"Rotate_Cylinder", rot );
243 ejector.SetAnimationPhase(
"Rotate_Ejector", rot );
250 SetCylinderRotationAnimationPhase(GetCylinderRotation(GetCurrentMuzzle()), reset);
255 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
260 SetAttachmentsHealth();
268 for (
int i = 0; i < GetInventory().AttachmentCount(); i++)
270 entity = GetInventory().GetAttachmentFromIndex(i);
273 attachment.SetHealth01(
"",
"Health",GetHealth01());
280 super.OnFire(muzzle_index);
281 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
284 string bullet_nose =
"bullet_nose";
285 if (muzzle_index > 0)
286 bullet_nose =
string.
Format(
"bullet_nose_" + (muzzle_index + 1));
287 cylinder.HideSelection(bullet_nose);
298 for (
int i = 0; i < GetMuzzleCount(); i++)
308 super.ShowBullet(muzzleIndex);
310 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
313 string bullet =
"bullet";
315 bullet =
string.
Format(
"bullet_" + (muzzleIndex + 1));
317 cylinder.ShowSelection(bullet);
321 string bullet_nose =
"bullet_nose";
323 bullet_nose =
string.
Format(
"bullet_nose_" + (muzzleIndex + 1));
324 cylinder.ShowSelection(bullet_nose);
331 super.HideBullet(muzzleIndex);
333 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
336 string bullet =
"bullet";
338 bullet =
string.
Format(
"bullet_" + (muzzleIndex + 1));
340 cylinder.HideSelection(bullet);
342 string bullet_nose =
"bullet_nose";
344 bullet_nose =
string.
Format(
"bullet_nose_" + (muzzleIndex + 1));
345 cylinder.HideSelection(bullet_nose);
352 super.OnDebugSpawn();
357 entity.SpawnEntityOnGroundPos(
"Ammo_357", entity.GetPosition());
366 super.GetDebugActions(outputList);
378 const float animPhaseOffset = 0.167;
380 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
381 Magnum_Ejector ejector = Magnum_Ejector.Cast(GetAttachmentByType(Magnum_Ejector));
385 float animPhase = cylinder.GetAnimationPhase(
"Rotate_Cylinder");
386 if (animPhase + animPhaseOffset > 1.0)
389 cylinder.ResetAnimationPhase(
"Rotate_Cylinder", animPhase);
390 ejector.ResetAnimationPhase(
"Rotate_Ejector", animPhase);
393 cylinder.SetAnimationPhase(
"Rotate_Cylinder", animPhase);
394 ejector.ResetAnimationPhase(
"Rotate_Ejector", animPhase);
399 return super.OnAction(action_id, player, ctx);
405class Magnum_Ejector
extends DummyItem {};
Param4< int, int, string, int > TSelectableActionInfoWithColor
void AddAction(typename actionName)
void RemoveAction(typename actionName)
FirearmActionLoadBullet FirearmActionBase FirearmActionLoadBulletQuick()
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
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
@ DEFAULT
default weapon state
const float MAGNUM_ROTATION_POSITION_M1
const float MAGNUM_ROTATION_POSITION_5
const float MAGNUM_ROTATION_POSITION_0
class SSPFireout extends WeaponStableState OnEntry
enum FSMTransition WeaponTransition
bool IsSingleState()
Special one for when the weapon only has one singular state (like Magnum)
bool IsChamberFiredOut(int idx)
bool IsChamberFull(int idx)
pair ( action, actionType )
Super root of all classes in Enforce script.
static bool IsWeaponLogEnable()
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Serialization general interface. Serializer API works with:
override void OnDebugSpawn()
void SetCylinderRotationAnimationPhase(float rot, bool reset=false)
override bool IsShowingChamberedBullet()
void SyncCylinderRotation(bool reset=true)
static float GetCylinderRotation(int muzzleIndex)
override void AssembleGun()
override void InitStateMachine()
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
void SetAttachmentsHealth()
override bool CanChamberBullet(int muzzleIndex, Magazine mag)
override void ShowBullet(int muzzleIndex)
override RecoilBase SpawnRecoilObject()
override void HideBullet(int muzzleIndex)
override bool CanEjectBullet()
override void OnFire(int muzzle_index)
override void SetActions()
charging of weapon without ammo to be chambered
signalize mechanism manipulation
weapon finite state machine
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
override int GetCurrentStateID()
override void OnExit(WeaponEventBase e)
override bool HasBullet()
override bool HasMagazine()
represent weapon state base
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float AbsFloat(float f)
Returns absolute value.
const int SAT_DEBUG_ACTION
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
WeaponActionChamberingTypes