public override void Execute() { Debug.Assert(DropAll || DobjArtifact != null); if (DobjArtifact != null) { if (DobjArtifact.IsWornByCharacter()) { PrintWearingRemoveFirst(DobjArtifact); NextState = Globals.CreateInstance <IStartState>(); goto Cleanup; } if (!DobjArtifact.IsCarriedByCharacter()) { if (!GetCommandCalled) { if (DobjArtifact.IsCarriedByCharacter(true) && DobjArtifact.IsCarriedByContainer()) { RedirectToGetCommand <IDropCommand>(DobjArtifact); } else { NextState = Globals.CreateInstance <IStartState>(); } } else if (DobjArtifact.DisguisedMonster == null) { NextState = Globals.CreateInstance <IStartState>(); } goto Cleanup; } } ProcessLightSource(); DroppedArtifactList = DropAll ? ActorMonster.GetCarriedList() : new List <IArtifact>() { DobjArtifact }; if (DroppedArtifactList.Count <= 0) { gOut.Print("There's nothing for you to drop."); NextState = Globals.CreateInstance <IStartState>(); goto Cleanup; } foreach (var artifact in DroppedArtifactList) { ProcessArtifact(artifact); } gOut.WriteLine(); Cleanup: if (NextState == null) { NextState = Globals.CreateInstance <IMonsterStartState>(); } }
public override void Execute() { Debug.Assert(DobjArtifact != null); ProcessEvents(EventType.BeforeUseArtifact); if (GotoCleanup) { goto Cleanup; } DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false); if (DobjArtAc == null) { PrintTryDifferentCommand(DobjArtifact); goto Cleanup; } if (DobjArtAc.IsWeapon01()) { NextState = Globals.CreateInstance <IReadyCommand>(); CopyCommandData(NextState as ICommand); goto Cleanup; } if (DobjArtAc.Type == ArtifactType.DisguisedMonster) { if (!DobjArtifact.IsUnmovable() && !DobjArtifact.IsCarriedByCharacter()) { if (DobjArtifact.IsCarriedByContainer()) { PrintRemovingFirst(DobjArtifact); } else { PrintTakingFirst(DobjArtifact); } } gEngine.RevealDisguisedMonster(ActorRoom, DobjArtifact); NextState = Globals.CreateInstance <IMonsterStartState>(); goto Cleanup; } if (DobjArtAc.Type == ArtifactType.Drinkable) { NextState = Globals.CreateInstance <IDrinkCommand>(); CopyCommandData(NextState as ICommand); goto Cleanup; } if (DobjArtAc.Type == ArtifactType.Edible) { NextState = Globals.CreateInstance <IEatCommand>(); CopyCommandData(NextState as ICommand); goto Cleanup; } Debug.Assert(DobjArtAc.Type == ArtifactType.Wearable); NextState = Globals.CreateInstance <IWearCommand>(); CopyCommandData(NextState as ICommand); Cleanup: if (NextState == null) { NextState = Globals.CreateInstance <IMonsterStartState>(); } }
public override void Execute() { RetCode rc; Debug.Assert(DobjArtifact != null && IobjArtifact != null && Prep != null && Enum.IsDefined(typeof(ContainerType), Prep.ContainerType)); Debug.Assert(DobjArtifact.IsCarriedByContainer(IobjArtifact) && DobjArtifact.GetCarriedByContainerContainerType() == Prep.ContainerType); ArtTypes = new ArtifactType[] { ArtifactType.DisguisedMonster, ArtifactType.DeadBody, ArtifactType.BoundMonster, ArtifactType.Weapon, ArtifactType.MagicWeapon }; DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false); if (DobjArtAc == null) { DobjArtAc = DobjArtifact.GetCategories(0); } if (DobjArtAc != null && DobjArtAc.Type != ArtifactType.DisguisedMonster && DobjArtifact.Weight <= 900 && !DobjArtifact.IsUnmovable01() && (DobjArtAc.Type != ArtifactType.DeadBody || DobjArtAc.Field1 == 1) && DobjArtAc.Type != ArtifactType.BoundMonster) { OmitWeightCheck = DobjArtifact.IsCarriedByMonster(ActorMonster, true); DobjArtifactCount = 0; DobjArtifactWeight = DobjArtifact.Weight; if (DobjArtifact.GeneralContainer != null) { rc = DobjArtifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.In, true); Debug.Assert(gEngine.IsSuccess(rc)); rc = DobjArtifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.On, true); Debug.Assert(gEngine.IsSuccess(rc)); } ActorMonsterInventoryWeight = 0; rc = ActorMonster.GetFullInventoryWeight(ref _actorMonsterInventoryWeight, recurse: true); Debug.Assert(gEngine.IsSuccess(rc)); if (!gEngine.EnforceMonsterWeightLimits || OmitWeightCheck || (DobjArtifactWeight <= ActorMonster.GetWeightCarryableGronds() && DobjArtifactWeight + ActorMonsterInventoryWeight <= ActorMonster.GetWeightCarryableGronds() * ActorMonster.CurrGroupCount)) { DobjArtifact.SetCarriedByMonster(ActorMonster); Debug.Assert(gCharMonster != null); if (gCharMonster.IsInRoom(ActorRoom)) { if (ActorRoom.IsLit()) { MonsterName = ActorMonster.EvalPlural(ActorMonster.GetTheName(true), ActorMonster.GetArticleName(true, true, false, true, Globals.Buf01)); gOut.Print("{0} removes {1} from {2} {3}.", MonsterName, DobjArtifact.GetArticleName(), gEngine.EvalContainerType(Prep.ContainerType, "inside", "on", "under", "behind"), OmitWeightCheck ? IobjArtifact.GetArticleName(buf: Globals.Buf01) : IobjArtifact.GetTheName(buf: Globals.Buf01)); } else { MonsterName = string.Format("An unseen {0}", ActorMonster.CheckNBTLHostility() ? "offender" : "entity"); gOut.Print("{0} picks up {1}.", MonsterName, "a weapon"); } } // when a weapon is picked up all monster affinities to that weapon are broken FumbleMonsterList = gEngine.GetMonsterList(m => m.Weapon == -DobjArtifact.Uid - 1 && m != ActorMonster); foreach (var monster in FumbleMonsterList) { monster.Weapon = -1; } } } if (NextState == null) { NextState = Globals.CreateInstance <IErrorState>(x => { x.ErrorMessage = string.Format("{0}: NextState == null", Name); }); } }