34 magnum.SyncCylinderRotation();
53 int m_LastMuzzleloaded;
55 const string ATT_SLOT_CYLINDER =
"RevolverCylinder";
56 const string ATT_SLOT_EJECTOR =
"RevolverEjector";
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);
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);
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 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);
323 override void HideBullet(
int muzzleIndex)
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();
349 if (
Class.CastTo(entity,
this) )
351 entity.SpawnEntityOnGroundPos(
"Ammo_357", entity.GetPosition());
358 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
364 super.GetDebugActions(outputList);
373 const float animPhaseOffset = 0.167;
375 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
376 Magnum_Ejector ejector = Magnum_Ejector.Cast(GetAttachmentByType(Magnum_Ejector));
380 float animPhase = cylinder.GetAnimationPhase(
"Rotate_Cylinder");
381 if (animPhase + animPhaseOffset > 1.0)
384 cylinder.ResetAnimationPhase(
"Rotate_Cylinder", animPhase);
385 ejector.ResetAnimationPhase(
"Rotate_Ejector", animPhase);
388 cylinder.SetAnimationPhase(
"Rotate_Cylinder", animPhase);
389 ejector.ResetAnimationPhase(
"Rotate_Ejector", animPhase);
394 return super.OnAction(action_id, player, ctx);
400class Magnum_Ejector
extends DummyItem {};
Param4< int, int, string, int > TSelectableActionInfoWithColor
void AddAction(typename actionName)
override void AssembleGun()
pair ( action, actionType )
Super root of all classes in Enforce script.
Serialization general interface. Serializer API works with:
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)
represent weapon state base
override bool HasBullet()
override bool HasMagazine()
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
void OnFire(Entity flare)
proto native CGame GetGame()
const int SAT_DEBUG_ACTION
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
override int GetCurrentStateID()
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
@ DEFAULT
default weapon state
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
enum FSMTransition WeaponTransition
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit
bool IsSingleState()
Special one for when the weapon only has one singular state (like Magnum)
bool IsChamberFiredOut(int idx)
bool IsChamberFull(int idx)