34 magnum.SyncCylinderRotation();
53 int m_LastMuzzleloaded;
55 const string ATT_SLOT_CYLINDER =
"RevolverCylinder";
56 const string ATT_SLOT_EJECTOR =
"RevolverEjector";
75 m_LastMuzzleloaded = 0;
88 override void InitStateMachine ()
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();
165 override bool CanChamberBullet(
int muzzleIndex, Magazine mag)
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();
199 static float GetCylinderRotation(
int muzzleIndex)
217 ErrorEx(
string.Format(
"Invalid muzzle index: %1", muzzleIndex));
222 void SetCylinderRotationAnimationPhase(
float rot,
bool reset =
false)
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");
229 if (
Math.AbsFloat(anim_phase - rot) > 0.1 )
233 cylinder.ResetAnimationPhase(
"Rotate_Cylinder", rot );
234 ejector.ResetAnimationPhase(
"Rotate_Ejector", rot );
242 cylinder.SetAnimationPhase(
"Rotate_Cylinder", rot );
243 ejector.SetAnimationPhase(
"Rotate_Ejector", rot );
248 void SyncCylinderRotation(
bool reset =
true)
250 SetCylinderRotationAnimationPhase(GetCylinderRotation(GetCurrentMuzzle()), reset);
255 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
260 SetAttachmentsHealth();
264 void SetAttachmentsHealth()
268 for (
int i = 0; i < GetInventory().AttachmentCount(); i++)
270 entity = GetInventory().GetAttachmentFromIndex(i);
271 if (
Class.CastTo(attachment,entity) )
273 attachment.SetHealth01(
"",
"Health",GetHealth01());
278 override void OnFire(
int muzzle_index)
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);
291 override bool IsShowingChamberedBullet()
296 override bool CanEjectBullet()
298 for (
int i = 0; i < GetMuzzleCount(); i++)
306 override void ShowBullet(
int muzzleIndex)
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);
329 override void HideBullet(
int muzzleIndex)
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();
355 if (
Class.CastTo(entity,
this) )
357 entity.SpawnEntityOnGroundPos(
"Ammo_357", entity.GetPosition());
364 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
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);
405 class Magnum_Ejector
extends DummyItem {};