34 magnum.SyncCylinderRotation();
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();
164 if ( CanChamberFromMag(muzzleIndex, mag) )
166 if (IsChamberEmpty(muzzleIndex))
181 GetInventory().CreateAttachment(
"Magnum_Ejector");
186 GetInventory().CreateAttachment(
"Magnum_Cylinder");
189 ForceSyncSelectionState();
211 ErrorEx(
string.Format(
"Invalid muzzle index: %1", muzzleIndex));
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");
227 cylinder.ResetAnimationPhase(
"Rotate_Cylinder", rot );
228 ejector.ResetAnimationPhase(
"Rotate_Ejector", rot );
236 cylinder.SetAnimationPhase(
"Rotate_Cylinder", rot );
237 ejector.SetAnimationPhase(
"Rotate_Ejector", rot );
249 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
262 for (
int i = 0; i < GetInventory().AttachmentCount(); i++)
264 entity = GetInventory().GetAttachmentFromIndex(i);
267 attachment.SetHealth01(
"",
"Health",GetHealth01());
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);
292 for (
int i = 0; i < GetMuzzleCount(); i++)
302 super.ShowBullet(muzzleIndex);
304 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
307 string bullet =
"bullet";
309 bullet =
string.
Format(
"bullet_" + (muzzleIndex + 1));
311 cylinder.ShowSelection(bullet);
315 string bullet_nose =
"bullet_nose";
317 bullet_nose =
string.
Format(
"bullet_nose_" + (muzzleIndex + 1));
318 cylinder.ShowSelection(bullet_nose);
325 super.HideBullet(muzzleIndex);
327 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
330 string bullet =
"bullet";
332 bullet =
string.
Format(
"bullet_" + (muzzleIndex + 1));
334 cylinder.HideSelection(bullet);
336 string bullet_nose =
"bullet_nose";
338 bullet_nose =
string.
Format(
"bullet_nose_" + (muzzleIndex + 1));
339 cylinder.HideSelection(bullet_nose);
346 super.OnDebugSpawn();
351 entity.SpawnEntityOnGroundPos(
"Ammo_357", entity.GetPosition());
360 super.GetDebugActions(outputList);
372 const float animPhaseOffset = 0.167;
374 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
375 Magnum_Ejector ejector = Magnum_Ejector.Cast(GetAttachmentByType(Magnum_Ejector));
379 float animPhase = cylinder.GetAnimationPhase(
"Rotate_Cylinder");
380 if (animPhase + animPhaseOffset > 1.0)
383 cylinder.ResetAnimationPhase(
"Rotate_Cylinder", animPhase);
384 ejector.ResetAnimationPhase(
"Rotate_Ejector", animPhase);
387 cylinder.SetAnimationPhase(
"Rotate_Cylinder", animPhase);
388 ejector.ResetAnimationPhase(
"Rotate_Ejector", animPhase);
393 return super.OnAction(action_id, player, ctx);
399class Magnum_Ejector
extends DummyItem {};
Param4< int, int, string, int > TSelectableActionInfoWithColor
void AddAction(typename actionName)
@ UNKNOWN
24 - Any other error. Can be returned from any call.
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
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)
override void InitStateMachine()
const string ATT_SLOT_EJECTOR
override void HideBullet(int muzzleIndex)
override RecoilBase SpawnRecoilObject()
override bool IsShowingChamberedBullet()
override void ShowBullet(int muzzleIndex)
override void AssembleGun()
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
override void SetActions()
void SyncCylinderRotation(bool reset=true)
override bool CanEjectBullet()
static float GetCylinderRotation(int muzzleIndex)
override bool CanChamberBullet(int muzzleIndex, Magazine mag)
override void OnFire(int muzzle_index)
const string ATT_SLOT_CYLINDER
override void OnDebugSpawn()
void SetCylinderRotationAnimationPhase(float rot, bool reset=false)
void SetAttachmentsHealth()
charging of weapon without ammo to be chambered
signalize mechanism manipulation
weapon finite state machine
override void OnExit(WeaponEventBase e)
override void OnEntry(WeaponEventBase e)
override bool HasBullet()
override int GetCurrentStateID()
override bool HasMagazine()
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
represent weapon state base
Serializer ParamsReadContext
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