public void CollectCorpse(Corpse corpse) { corpse.IsCollected = false; corpse.Center = Vector2.Zero; Player.resources += corpse.Resources; corpse.Remove(); }
protected override void Die() { var corpse = new Corpse(Center, deadTexture, 10); corpse.Initialize(); EnemyManager.Corpses.Add(corpse); base.Die(); }
private static void UpdateCorpse(UpdateValuesDto dto, Corpse obj) { UpdateObject(dto, obj); if(obj.Owner != null) { dto.Set(UpdateFields.CORPSE_FIELD_OWNER, obj.Owner.Guid); //dto.Set(UpdateFields.CORPSE_FIELD_PARTY, obj.Owner.Party); } dto.Set(UpdateFields.CORPSE_FIELD_DISPLAY_ID, obj.DisplayId); if(obj.Owner != null) { IInventory inventory = obj.Owner.Inventory; for(int i = 0; i < 19; i++) { if(null != inventory[i]) { dto.Set(UpdateFields.CORPSE_FIELD_ITEM + i, inventory[i].Entry); } } } dto.Set(UpdateFields.CORPSE_FIELD_BYTES_1, obj.Bytes1_0, (byte)obj.Race, (byte)obj.Gender, obj.Skin); dto.Set(UpdateFields.CORPSE_FIELD_BYTES_2, obj.Face, obj.HairStyle, obj.HairColor, obj.Face); dto.Set(UpdateFields.CORPSE_FIELD_GUILD, obj.GuildId); dto.Set(UpdateFields.CORPSE_FIELD_FLAGS, (uint)obj.Flags); dto.Set(UpdateFields.CORPSE_FIELD_DYNAMIC_FLAGS, (uint)obj.DynamicFlags); }
// Use this for initialization void Start() { Corpse next = new Corpse ("kosticka", gameObject.transform.position); /* jmeno v DB, pozice umrtí.*/ Loot.corpseList.Add (next); Loot.corpseList.Add (next); Loot.corpseList.Add (next); Loot.corpseList.Add (next); Loot.corpseList.Add (next); }
private Building_Grave FindBestGrave(Pawn p, Corpse corpse) { Predicate<Thing> predicate = (Thing m) => !m.IsForbidden(p) && p.CanReserve(m, 1) && ((Building_Grave)m).Accepts(corpse); if (corpse.innerPawn.ownership != null && corpse.innerPawn.ownership.AssignedGrave != null) { Building_Grave assignedGrave = corpse.innerPawn.ownership.AssignedGrave; if (predicate(assignedGrave) && corpse.Position.CanReach(assignedGrave, PathEndMode.ClosestTouch, TraverseParms.For(p, Danger.Deadly, TraverseMode.ByPawn, false))) { return assignedGrave; } } Func<Thing, float> priorityGetter = (Thing t) => (float)((IStoreSettingsParent)t).GetStoreSettings().Priority; Predicate<Thing> validator = predicate; return (Building_Grave)GenClosest.ClosestThing_Global_Reachable(corpse.Position, Find.ListerThings.ThingsInGroup(ThingRequestGroup.Grave), PathEndMode.ClosestTouch, TraverseParms.For(p, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, priorityGetter); }
void HandleLootMoney(LootMoney lootMoney) { Player player = GetPlayer(); foreach (var lootView in player.GetAELootView()) { ObjectGuid guid = lootView.Value; Loot loot = null; bool shareMoney = true; switch (guid.GetHigh()) { case HighGuid.GameObject: { GameObject go = player.GetMap().GetGameObject(guid); // do not check distance for GO if player is the owner of it (ex. fishing bobber) if (go && ((go.GetOwnerGUID() == player.GetGUID() || go.IsWithinDistInMap(player, SharedConst.InteractionDistance)))) { loot = go.loot; } break; } case HighGuid.Corpse: // remove insignia ONLY in BG { Corpse bones = ObjectAccessor.GetCorpse(player, guid); if (bones && bones.IsWithinDistInMap(player, SharedConst.InteractionDistance)) { loot = bones.loot; shareMoney = false; } break; } case HighGuid.Item: { Item item = player.GetItemByGuid(guid); if (item) { loot = item.loot; shareMoney = false; } break; } case HighGuid.Creature: case HighGuid.Vehicle: { Creature creature = player.GetMap().GetCreature(guid); bool lootAllowed = creature && creature.IsAlive() == (player.GetClass() == Class.Rogue && creature.loot.loot_type == LootType.Pickpocketing); if (lootAllowed && creature.IsWithinDistInMap(player, AELootCreatureCheck.LootDistance)) { loot = creature.loot; if (creature.IsAlive()) { shareMoney = false; } } else { player.SendLootError(lootView.Key, guid, lootAllowed ? LootError.TooFar : LootError.DidntKill); } break; } default: continue; // unlootable type } if (loot == null) { continue; } loot.NotifyMoneyRemoved(); if (shareMoney && player.GetGroup() != null) //item, pickpocket and players can be looted only single player { Group group = player.GetGroup(); List <Player> playersNear = new List <Player>(); for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next()) { Player member = refe.GetSource(); if (!member) { continue; } if (player.IsAtGroupRewardDistance(member)) { playersNear.Add(member); } } uint goldPerPlayer = (uint)(loot.gold / playersNear.Count); foreach (var pl in playersNear) { pl.ModifyMoney(goldPerPlayer); pl.UpdateCriteria(CriteriaTypes.LootMoney, goldPerPlayer); Guild guild = Global.GuildMgr.GetGuildById(pl.GetGuildId()); if (guild) { uint guildGold = MathFunctions.CalculatePct(goldPerPlayer, pl.GetTotalAuraModifier(AuraType.DepositBonusMoneyInGuildBankOnLoot)); if (guildGold != 0) { guild.HandleMemberDepositMoney(this, guildGold, true); } } LootMoneyNotify packet = new LootMoneyNotify(); packet.Money = goldPerPlayer; packet.SoleLooter = playersNear.Count <= 1 ? true : false; pl.SendPacket(packet); } } else { player.ModifyMoney(loot.gold); player.UpdateCriteria(CriteriaTypes.LootMoney, loot.gold); Guild guild = Global.GuildMgr.GetGuildById(player.GetGuildId()); if (guild) { uint guildGold = MathFunctions.CalculatePct(loot.gold, player.GetTotalAuraModifier(AuraType.DepositBonusMoneyInGuildBankOnLoot)); if (guildGold != 0) { guild.HandleMemberDepositMoney(this, guildGold, true); } } LootMoneyNotify packet = new LootMoneyNotify(); packet.Money = loot.gold; packet.SoleLooter = true; // "You loot..." SendPacket(packet); } loot.gold = 0; // Delete the money loot record from the DB if (!loot.containerID.IsEmpty()) { loot.DeleteLootMoneyFromContainerItemDB(); } // Delete container if empty if (loot.isLooted() && guid.IsItem()) { player.GetSession().DoLootRelease(guid); } } }
private static void SummonDelay_Callback(object state) { object[] states = (object[])state; Mobile caster = (Mobile)states[0]; Corpse corpse = (Corpse)states[1]; Point3D loc = (Point3D)states[2]; Map map = (Map)states[3]; CreatureGroup group = (CreatureGroup)states[4]; if (corpse.Animated) { return; } Mobile owner = corpse.Owner; if (owner == null) { return; } double necromancy = caster.Skills[SkillName.Necromancy].Value; double spiritSpeak = caster.Skills[SkillName.SpiritSpeak].Value; int casterAbility = 0; casterAbility += (int)(necromancy * 30); casterAbility += (int)(spiritSpeak * 70); casterAbility /= 10; casterAbility *= 18; if (casterAbility > owner.Fame) { casterAbility = owner.Fame; } if (casterAbility < 0) { casterAbility = 0; } Type toSummon = null; SummonEntry[] entries = group.m_Entries; #region Mondain's Legacy BaseCreature creature = caster as BaseCreature; if (creature != null) { if (creature.AIObject is NecroMageAI) { toSummon = typeof(FleshGolem); } } #endregion for (int i = 0; toSummon == null && i < entries.Length; ++i) { SummonEntry entry = entries[i]; if (casterAbility < entry.m_Requirement) { continue; } Type[] animates = entry.m_ToSummon; if (animates.Length >= 0) { toSummon = animates[Utility.Random(animates.Length)]; } } if (toSummon == null) { return; } Mobile summoned = null; try { summoned = Activator.CreateInstance(toSummon) as Mobile; } catch { } if (summoned == null) { return; } if (summoned is BaseCreature) { BaseCreature bc = (BaseCreature)summoned; // to be sure bc.Tamable = false; if (bc is BaseMount) { bc.ControlSlots = 1; } else { bc.ControlSlots = 0; } Effects.PlaySound(loc, map, bc.GetAngerSound()); BaseCreature.Summon((BaseCreature)summoned, false, caster, loc, 0x28, TimeSpan.FromDays(1.0)); } if (summoned is SkeletalDragon) { Scale((SkeletalDragon)summoned, 50); // lose 50% hp and strength } summoned.Fame = 0; summoned.Karma = -1500; summoned.MoveToWorld(loc, map); corpse.Hue = 1109; corpse.Animated = true; Register(caster, summoned); #region Mondain's Legacy /*if (creature != null) * { * if (creature.AIObject is NecroMageAI) * ((NecroMageAI)creature.AIObject).Animated = summoned; * }*/ #endregion }
public static int CorpseNotoriety(Mobile source, Corpse target) { if (AutoRestart.ServerWars || target.AccessLevel > AccessLevel.Player) { return(Notoriety.CanBeAttacked); } // Alan mod: custom teams if (source.CustomTeam) { // corpse teams are copied over from the mob List <XmlTeam> targetTeams = XmlAttach.GetTeams(target); if (targetTeams != null) { List <XmlTeam> fromTeams = XmlAttach.GetTeams(source); if (XmlTeam.SameTeam(fromTeams, targetTeams)) { if (XmlTeam.ShowGreen(fromTeams, targetTeams)) { return(Notoriety.Ally); } // otherwise just use default notoriety } // they are on the enemy team, allow harmful else { return(Notoriety.Enemy); } } } // end Alan mod Body body = (Body)target.Amount; BaseCreature cretOwner = target.Owner as BaseCreature; if (cretOwner != null) { if (cretOwner.FreelyLootable) { return(Notoriety.CanBeAttacked); } Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) { return(Notoriety.Ally); } else if (sourceGuild.IsEnemy(targetGuild)) { return(Notoriety.Enemy); } } Faction srcFaction = Faction.Find(source, true, true); Faction trgFaction = Faction.Find(target.Owner, true, true); if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && Faction.IsFactionFacet(source.Map)) { return(Notoriety.Enemy); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } int actual = Notoriety.CanBeAttacked; if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead))) { actual = Notoriety.Murderer; } if (DateTime.UtcNow >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice)) { return(actual); } Party sourceParty = Party.Get(source); List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source || (sourceParty != null && Party.Get(list[i]) == sourceParty)) { return(actual); } } return(Notoriety.Innocent); } else { if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead))) { return(Notoriety.Murderer); } if (target.Criminal && target.Map != null && ((target.Map.Rules & MapRules.HarmfulRestrictions) == 0)) { return(Notoriety.Criminal); } Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) { return(Notoriety.Ally); } else if (sourceGuild.IsEnemy(targetGuild)) { return(Notoriety.Enemy); } } Faction srcFaction = Faction.Find(source, true, true); Faction trgFaction = Faction.Find(target.Owner, true, true); if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && Faction.IsFactionFacet(source.Map)) { List <Mobile> secondList = target.Aggressors; for (int i = 0; i < secondList.Count; ++i) { if (secondList[i] == source || secondList[i] is BaseFactionGuard) { return(Notoriety.Enemy); } } } if (target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } if (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature)) { return(Notoriety.CanBeAttacked); } CustomRegion region1 = source.Region as CustomRegion; CaptureZoneRegion regionCz = source.Region as CaptureZoneRegion; if (region1 != null && region1.AlwaysGrey() || regionCz != null && regionCz.Czone.AlwaysGrey) { return(Notoriety.CanBeAttacked); } List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source) { return(Notoriety.CanBeAttacked); } } return(Notoriety.Innocent); } }
private bool ProcessTarget() { Target targ = m_Mobile.Target; if (targ == null) { return(false); } Mobile toTarget; toTarget = m_Mobile.Combatant as Mobile; //if ( toTarget != null ) //RunTo( toTarget ); if (targ is DispelSpell.InternalTarget && !(m_Mobile.AutoDispel)) { List <Mobile> targets = new List <Mobile>(); foreach (Mobile m in m_Mobile.GetMobilesInRange(12)) { if (m is BaseCreature) { if (((BaseCreature)m).IsDispellable && CanTarget(m_Mobile, m)) { targets.Add(m); } } } if (targets.Count >= 0) { int whichone = Utility.RandomMinMax(0, targets.Count); if (targets[whichone] != null) { targ.Invoke(m_Mobile, targets[whichone]); } } } else if (targ is TeleportSpell.InternalTarget || targ is Shadowjump.InternalTarget) { if (targ is Shadowjump.InternalTarget && !m_Mobile.Hidden) { return(false); } Map map = m_Mobile.Map; if (map == null) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); return(true); } int px, py; bool teleportAway = (m_Mobile.Hits < (m_Mobile.Hits / 10)); if (teleportAway) { int rx = m_Mobile.X - toTarget.X; int ry = m_Mobile.Y - toTarget.Y; double d = m_Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); } else { px = toTarget.X; py = toTarget.Y; } for (int i = 0; i < m_RandomLocations.Length; i += 2) { int x = m_RandomLocations[i], y = m_RandomLocations[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { targ.Invoke(m_Mobile, lt); return(true); } } int teleRange = targ.Range; if (teleRange < 0) { teleRange = 12; } for (int i = 0; i < 10; ++i) { Point3D randomPoint = new Point3D(m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0); LandTarget lt = new LandTarget(randomPoint, map); if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { targ.Invoke(m_Mobile, new LandTarget(randomPoint, map)); return(true); } } } else if (targ is AnimateDeadSpell.InternalTarget) { Type type = null; List <Item> itemtargets = new List <Item>(); foreach (Item itemstofind in m_Mobile.GetItemsInRange(5)) { if (itemstofind is Corpse) { itemtargets.Add(itemstofind); } } for (int i = 0; i < itemtargets.Count; ++i) { Corpse items = (Corpse)itemtargets[i]; if (items.Owner != null) { type = items.Owner.GetType(); } if (items.ItemID != 0x2006 || items.Channeled || type == typeof(PlayerMobile) || type == null || (items.Owner != null && items.Owner.Fame < 100) || ((items.Owner != null) && (items.Owner is BaseCreature) && (((BaseCreature)items.Owner).Summoned || ((BaseCreature)items.Owner).IsBonded))) { continue; } else { targ.Invoke(m_Mobile, items); break; } } if (targ != null) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } } else if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null) { if ((targ.Range == -1 || m_Mobile.InRange(toTarget, targ.Range)) && m_Mobile.CanSee(toTarget) && m_Mobile.InLOS(toTarget)) { targ.Invoke(m_Mobile, toTarget); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { targ.Invoke(m_Mobile, m_Mobile); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } return(true); }
public static void Corpse_OnCommand(CommandEventArgs e) { Mobile from = e.Mobile; if (!from.Alive) { from.SendMessage("You are dead and cannot do that!"); return; } Map map = from.Map; if (map == null) { return; } int range = 1000; // 1000 TILES AWAY int HowFarAway = 0; int TheClosest = 1000000; int IsClosest = 0; int distchk = 0; int distpck = 0; ArrayList bodies = new ArrayList(); ArrayList empty = new ArrayList(); ArrayList mice = new ArrayList(); foreach (Item body in from.GetItemsInRange(range)) { if (body is Corpse) { Corpse cadaver = (Corpse)body; int carrying = body.GetTotal(TotalType.Items); Mobile mSp = new CorpseCritter(); mSp.MoveToWorld(new Point3D(body.X, body.Y, body.Z), body.Map); if (GhostHelper.SameArea(from, mSp) == true && cadaver.Owner == from && carrying > 0) { distchk++; bodies.Add(mSp); if (GhostHelper.HowFar(from.X, from.Y, mSp.X, mSp.Y) < TheClosest) { TheClosest = GhostHelper.HowFar(from.X, from.Y, mSp.X, mSp.Y); IsClosest = distchk; } } else if (cadaver.Owner == from && carrying < 1) { empty.Add(body); mice.Add(mSp); } } } for (int h = 0; h < bodies.Count; ++h) { distpck++; if (distpck == IsClosest) { Mobile theBody = ( Mobile )bodies[h]; HowFarAway = GhostHelper.HowFar(from.X, from.Y, theBody.X, theBody.Y); from.QuestArrow = new CorpseArrow(from, theBody, HowFarAway * 2); } } for (int u = 0; u < empty.Count; ++u) { Item theEmpty = ( Item )empty[u]; theEmpty.Delete(); } for (int m = 0; m < mice.Count; ++m) { Mobile theMouse = ( Mobile )mice[m]; theMouse.Delete(); } if (distchk == 0) { from.SendMessage("You have no nearby corpse in this area!"); } }
public static void CheckVision(Pawn pawn) { // Basically a copy of the function in PawnObserver if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight) || pawn.needs.mood == null) { return; } // caravans have some different management Caravan caravan = pawn.GetCaravan(); if (caravan != null) { // inside caravan // see other foreach (Pawn potentialOther in caravan.PawnsListForReading) { Find.World.GetComponent <FriendshipMemoryGlobalTracker>().Notify_PhysicalSightOccured(pawn, potentialOther); } // see dead foreach (Thing thing in CaravanInventoryUtility.AllInventoryItems(caravan)) { Corpse potentialCorpse = thing as Corpse; if (potentialCorpse != null) { Pawn deadPawn = potentialCorpse.InnerPawn; Find.World.GetComponent <FriendshipMemoryGlobalTracker>().Notify_PhysicalSightOfCorpseOccured(pawn, deadPawn); } } return; } Map map = pawn.Map; if (map == null) { return; } MapPawns pawns = pawn.Map.mapPawns; IntVec3 selfPosition = pawn.Position; // seen alive foreach (Pawn potentialOther in pawns.AllPawnsSpawned) { if (GenSight.LineOfSight(selfPosition, potentialOther.Position, map, skipFirstCell: true)) { // can see! float distanceSq = selfPosition.DistanceToSquared(potentialOther.Position); if (distanceSq > 25) { // distance radius > 5, excluded continue; } Find.World.GetComponent <FriendshipMemoryGlobalTracker>().Notify_PhysicalSightOccured(pawn, potentialOther); } } // seen corpse for (int i = 0; (float)i < 100f; i++) { IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[i]; if (!intVec.InBounds(map) || !GenSight.LineOfSight(intVec, pawn.Position, map, skipFirstCell: true)) { continue; } List <Thing> thingList = intVec.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { Corpse potentialCorpse = thingList[j] as Corpse; if (potentialCorpse != null) { Pawn deadPawn = potentialCorpse.InnerPawn; Find.World.GetComponent <FriendshipMemoryGlobalTracker>().Notify_PhysicalSightOfCorpseOccured(pawn, deadPawn); } } } // tick the stuff Find.World.GetComponent <FriendshipMemoryGlobalTracker>().GetFriendshipMemoryTrackerForSubject(pawn)?.Notify_TickOnce(TickIntervalVision); }
public static int CorpseNotoriety(Mobile source, Corpse target) { if (target.AccessLevel > AccessLevel.VIP) { return(Notoriety.CanBeAttacked); } Body body = (Body)target.Amount; BaseCreature cretOwner = target.Owner as BaseCreature; if (cretOwner != null) { Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) { return(Notoriety.Ally); } else if (sourceGuild.IsEnemy(targetGuild)) { return(Notoriety.Enemy); } } Faction srcFaction = Faction.Find(source, true, true); Faction trgFaction = Faction.Find(target.Owner, true, true); if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet) { return(Notoriety.Enemy); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } int actual = Notoriety.CanBeAttacked; if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead))) { actual = Notoriety.Murderer; } if (DateTime.UtcNow >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice)) { return(actual); } Party sourceParty = Party.Get(source); List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source || (sourceParty != null && Party.Get(list[i]) == sourceParty)) { return(actual); } } return(Notoriety.Innocent); } else { if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead))) { return(Notoriety.Murderer); } if (target.Criminal && target.Map != null && ((target.Map.Rules & MapRules.HarmfulRestrictions) == 0)) { return(Notoriety.Criminal); } Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) { return(Notoriety.Ally); } else if (sourceGuild.IsEnemy(targetGuild)) { return(Notoriety.Enemy); } } Faction srcFaction = Faction.Find(source, true, true); Faction trgFaction = Faction.Find(target.Owner, true, true); if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet) { List <Mobile> secondList = target.Aggressors; for (int i = 0; i < secondList.Count; ++i) { if (secondList[i] == source || secondList[i] is BaseFactionGuard) { return(Notoriety.Enemy); } } } if (target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } if (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature)) { return(Notoriety.CanBeAttacked); } List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source) { return(Notoriety.CanBeAttacked); } } return(Notoriety.Innocent); } }
protected override void OnTarget(Mobile from, object target) { double skill = from.Skills[SkillName.Forensics].Value; double minSkill = 30.0; if (target is Corpse) { if (skill < minSkill) { from.SendLocalizedMessage(501003); //You notice nothing unusual. return; } if (from.CheckTargetSkill(SkillName.Forensics, target, minSkill, 55.0)) { Corpse c = (Corpse)target; if (c.m_Forensicist != null) { from.SendLocalizedMessage(1042750, c.m_Forensicist); // The forensicist ~1_NAME~ has already discovered that: } else { c.m_Forensicist = from.Name; } if (((Body)c.Amount).IsHuman) { from.SendLocalizedMessage(1042751, (c.Killer == null ? "no one" : c.Killer.Name));//This person was killed by ~1_KILLER_NAME~ } if (c.Looters.Count > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < c.Looters.Count; i++) { if (i > 0) { sb.Append(", "); } sb.Append(c.Looters[i].Name); } from.SendLocalizedMessage(1042752, sb.ToString());//This body has been distrubed by ~1_PLAYER_NAMES~ } else { from.SendLocalizedMessage(501002);//The corpse has not be desecrated. } } else { from.SendLocalizedMessage(501001);//You cannot determain anything useful. } } else if (target is Mobile) { if (skill < 36.0) { from.SendLocalizedMessage(501003);//You notice nothing unusual. } else if (from.CheckTargetSkill(SkillName.Forensics, target, 36.0, 100.0)) { if (target is PlayerMobile && ((PlayerMobile)target).NpcGuild == NpcGuild.ThievesGuild) { from.SendLocalizedMessage(501004);//That individual is a thief! } else { from.SendLocalizedMessage(501003);//You notice nothing unusual. } } else { from.SendLocalizedMessage(501001);//You cannot determain anything useful. } } else if (target is ILockpickable) { if (skill < 41.0) { from.SendLocalizedMessage(501003); //You notice nothing unusual. } else if (from.CheckTargetSkill(SkillName.Forensics, target, 41.0, 100.0)) { ILockpickable p = (ILockpickable)target; if (p.Picker != null) { from.SendLocalizedMessage(1042749, p.Picker.Name);//This lock was opened by ~1_PICKER_NAME~ } else { from.SendLocalizedMessage(501003);//You notice nothing unusual. } } else { from.SendLocalizedMessage(501001);//You cannot determain anything useful. } } else if (target is Item) { Item item = (Item)target; if (item is IForensicTarget) { ((IForensicTarget)item).OnForensicEval(from); } else if (skill < 41.0) { from.SendLocalizedMessage(501001);//You cannot determain anything useful. return; } HonestyItemSocket honestySocket = item.GetSocket <HonestyItemSocket>(); if (honestySocket != null) { if (honestySocket.HonestyOwner == null) { Server.Services.Virtues.HonestyVirtue.AssignOwner(honestySocket); } if (from.CheckTargetSkill(SkillName.Forensics, target, 41.0, 100.0)) { string region = honestySocket.HonestyRegion == null ? "an unknown place" : honestySocket.HonestyRegion; if (from.Skills.Forensics.Value >= 61.0) { from.SendLocalizedMessage(1151521, String.Format("{0}\t{1}", honestySocket.HonestyOwner.Name, region)); // This item belongs to ~1_val~ who lives in ~2_val~. } else { from.SendLocalizedMessage(1151522, region); // You find seeds from a familiar plant stuck to the item which suggests that this item is from ~1_val~. } } } } }
protected override void OnTick() { Corpse toChannel = null; IPooledEnumerable eable = Caster.GetObjectsInRange(3); foreach (object objs in eable) { if (objs is Corpse && !((Corpse)objs).Channeled && !((Corpse)objs).Animated) { toChannel = (Corpse)objs; break; } else if (objs is Server.Engines.Khaldun.SageHumbolt) { if (((Server.Engines.Khaldun.SageHumbolt)objs).OnSpiritSpeak(Caster)) { eable.Free(); SpiritSpeak.Remove(Caster); Stop(); return; } } } eable.Free(); int max, min, mana, number; if (toChannel != null) { min = 1 + (int)(Caster.Skills[SkillName.SpiritSpeak].Value * 0.25); max = min + 4; mana = 0; number = 1061287; // You channel energy from a nearby corpse to heal your wounds. } else { min = 1 + (int)(Caster.Skills[SkillName.SpiritSpeak].Value * 0.25); max = min + 4; mana = 10; number = 1061286; // You channel your own spiritual energy to heal your wounds. } if (Caster.Mana < mana) { Caster.SendLocalizedMessage(1061285); // You lack the mana required to use this skill. } else { Caster.CheckSkill(SkillName.SpiritSpeak, 0.0, 120.0); if (Utility.RandomDouble() > (Caster.Skills[SkillName.SpiritSpeak].Value / 100.0)) { Caster.SendLocalizedMessage(502443); // You fail your attempt at contacting the netherworld. } else { if (toChannel != null) { toChannel.Channeled = true; toChannel.Hue = 0x835; } Caster.Mana -= mana; Caster.SendLocalizedMessage(number); if (min > max) { min = max; } Caster.Hits += Utility.RandomMinMax(min, max); Caster.FixedParticles(0x375A, 1, 15, 9501, 2100, 4, EffectLayer.Waist); } } SpiritSpeak.Remove(Caster); Stop(); }
public void DoLootRelease(ObjectGuid lguid) { Player player = GetPlayer(); Loot loot; if (player.GetLootGUID() == lguid) { player.SetLootGUID(ObjectGuid.Empty); } player.SendLootRelease(lguid); player.RemoveFlag(UnitFields.Flags, UnitFlags.Looting); if (!player.IsInWorld) { return; } if (lguid.IsGameObject()) { GameObject go = player.GetMap().GetGameObject(lguid); // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO if (!go || ((go.GetOwnerGUID() != player.GetGUID() && go.GetGoType() != GameObjectTypes.FishingHole) && !go.IsWithinDistInMap(player, SharedConst.InteractionDistance))) { return; } loot = go.loot; if (go.GetGoType() == GameObjectTypes.Door) { // locked doors are opened with spelleffect openlock, prevent remove its as looted go.UseDoorOrButton(); } else if (loot.isLooted() || go.GetGoType() == GameObjectTypes.FishingNode) { if (go.GetGoType() == GameObjectTypes.FishingHole) { // The fishing hole used once more go.AddUse(); // if the max usage is reached, will be despawned in next tick if (go.GetUseCount() >= go.m_goValue.FishingHole.MaxOpens) { go.SetLootState(LootState.JustDeactivated); } else { go.SetLootState(LootState.Ready); } } else { go.SetLootState(LootState.JustDeactivated); } loot.clear(); } else { // not fully looted object go.SetLootState(LootState.Activated, player); // if the round robin player release, reset it. if (player.GetGUID() == loot.roundRobinPlayer) { loot.roundRobinPlayer.Clear(); } } } else if (lguid.IsCorpse()) // ONLY remove insignia at BG { Corpse corpse = ObjectAccessor.GetCorpse(player, lguid); if (!corpse || !corpse.IsWithinDistInMap(player, SharedConst.InteractionDistance)) { return; } loot = corpse.loot; if (loot.isLooted()) { loot.clear(); corpse.RemoveFlag(CorpseFields.DynamicFlags, 0x0001); } } else if (lguid.IsItem()) { Item pItem = player.GetItemByGuid(lguid); if (!pItem) { return; } ItemTemplate proto = pItem.GetTemplate(); // destroy only 5 items from stack in case prospecting and milling if (proto.GetFlags().HasAnyFlag(ItemFlags.IsProspectable | ItemFlags.IsMillable)) { pItem.m_lootGenerated = false; pItem.loot.clear(); uint count = pItem.GetCount(); // >=5 checked in spell code, but will work for cheating cases also with removing from another stacks. if (count > 5) { count = 5; } player.DestroyItemCount(pItem, ref count, true); } else { if (pItem.loot.isLooted() || !proto.GetFlags().HasAnyFlag(ItemFlags.HasLoot)) // Only delete item if no loot or money (unlooted loot is saved to db) { player.DestroyItem(pItem.GetBagSlot(), pItem.GetSlot(), true); } } return; // item can be looted only single player } else { Creature creature = player.GetMap().GetCreature(lguid); bool lootAllowed = creature && creature.IsAlive() == (player.GetClass() == Class.Rogue && creature.loot.loot_type == LootType.Pickpocketing); if (!lootAllowed || !creature.IsWithinDistInMap(player, AELootCreatureCheck.LootDistance)) { return; } loot = creature.loot; if (loot.isLooted()) { creature.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Lootable); // skip pickpocketing loot for speed, skinning timer reduction is no-op in fact if (!creature.IsAlive()) { creature.AllLootRemovedFromCorpse(); } loot.clear(); } else { // if the round robin player release, reset it. if (player.GetGUID() == loot.roundRobinPlayer) { loot.roundRobinPlayer.Clear(); Group group = player.GetGroup(); if (group) { if (group.GetLootMethod() != LootMethod.MasterLoot) { group.SendLooter(creature, null); } } // force dynflag update to update looter and lootable info creature.ForceValuesUpdateAtIndex(ObjectFields.DynamicFlags); } } } //Player is not looking at loot list, he doesn't need to see updates on the loot list loot.RemoveLooter(player.GetGUID()); player.RemoveAELootedObject(loot.GetGUID()); }
protected override void OnTarget(Mobile from, object target) { if (target is Mobile) { if (from.CheckTargetSkill(SkillName.Forensics, target, 40.0, 100.0)) { if (target is PlayerMobile && ((PlayerMobile)target).NpcGuild == NpcGuild.ThievesGuild) { if (from.Skills.Forensics.Value > ((PlayerMobile)target).Skills.Forensics.Value) { from.SendMessage("Your intuition tells you this person displays all the signs of a thief."); } else { from.SendLocalizedMessage(501003); //You notice nothing unusual. } } else if (target is PlayerMobile && ((PlayerMobile)target).DisguiseTimeLeft > TimeSpan.FromSeconds(0)) { if (from.Skills.Forensics.Value > ((PlayerMobile)target).Skills.Forensics.Value) { from.SendMessage("This person appears to be wearing a disguise."); } else { from.SendLocalizedMessage(501003); //You notice nothing unusual. } } else { from.SendLocalizedMessage(501003); //You notice nothing unusual. } } else { from.SendLocalizedMessage(501001); //You cannot determine anything useful. } } else if (target is Corpse) { if (from.CheckTargetSkill(SkillName.Forensics, target, 0.0, 100.0)) { Corpse c = (Corpse)target; if (((Body)c.Amount).IsHuman) { if (c.Killer.NameMod != null) { c.LabelTo(from, 1042751, (c.Killer == null ? "no one" : c.Killer.NameMod)); } else { c.LabelTo(from, 1042751, (c.Killer == null ? "no one" : c.Killer.RawName)); } } if (c.Looters.Count > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < c.Looters.Count; i++) { if (i > 0) { sb.Append(", "); } if (c.Looters[i].NameMod != null) { sb.Append(((Mobile)c.Looters[i]).NameMod); } else { sb.Append(((Mobile)c.Looters[i]).RawName); } } c.LabelTo(from, 1042752, sb.ToString()); //This body has been distrubed by ~1_PLAYER_NAMES~ } else { c.LabelTo(from, 501002); //The corpse has not be desecrated. } } else { from.SendLocalizedMessage(501001); //You cannot determine anything useful. } } else if (target is ILockpickable) { ILockpickable p = (ILockpickable)target; if (p.Picker != null && p.Picker.NameMod != null) { from.SendLocalizedMessage(1042749, p.Picker.NameMod); } else if (p.Picker != null) { from.SendLocalizedMessage(1042749, p.Picker.RawName); } else { from.SendLocalizedMessage(501003);//You notice nothing unusual. } } else { from.SendLocalizedMessage(501003); //You notice nothing unusual. } EventSink.InvokeSkillUsed(new SkillUsedEventArgs(from, from.Skills[SkillName.Forensics])); }
public override void PawnDied(Corpse corpse) { GenExplosion.DoExplosion(radius: (corpse.InnerPawn.ageTracker.CurLifeStageIndex == 0) ? 1.9f : ((corpse.InnerPawn.ageTracker.CurLifeStageIndex != 1) ? 4.9f : 2.9f), center: corpse.Position, map: corpse.Map, damType: DamageDefOf.Flame, instigator: corpse.InnerPawn); }
void OnTriggerEnter2D(Collider2D other) { if(other.gameObject.tag == "Enemy" || other.gameObject.tag == "ShootingEnemy") { if (Input.GetKeyDown(ControllerConfig[7][0])|| Input.GetKeyDown(ControllerConfig[7][1])) { if (Time.time > timeOfLastAttack + secondsBetweenAttacks) { timeOfLastAttack = Time.time; other.gameObject.GetComponent<Stats>().enemyTakeDamage(stats.strength, stats.magic); stats.health += 10; } } } else if(other.gameObject.tag == "Corpse") { Corpse c = other.gameObject.GetComponent<Corpse>(); Corpse corpse = new Corpse(c.lifeTag, c.maxHealth, c.strength, c.defense, c.magic); corpseList.Add(corpse); Destroy(other.gameObject); foreach(Corpse item in corpseList) { Debug.Log(item.lifeTag + " " + item.maxHealth + " " + item.strength + " " + item.defense + " " + item.magic); } } else if(other.gameObject.tag == "Item") { Item i = other.gameObject.GetComponent<Item>(); Item item = new Item(i.nam, i.desc, i.quantity, i.goldValue); itemList.Add(item); Destroy(other.gameObject); } }
public static void MakeColony(params ColonyMakerFlag[] flags) { bool godMode = DebugSettings.godMode; DebugSettings.godMode = true; Thing.allowDestroyNonDestroyable = true; if (Autotests_ColonyMaker.usedCells == null) { Autotests_ColonyMaker.usedCells = new BoolGrid(Autotests_ColonyMaker.Map); } else { Autotests_ColonyMaker.usedCells.ClearAndResizeTo(Autotests_ColonyMaker.Map); } Autotests_ColonyMaker.overRect = new CellRect(Autotests_ColonyMaker.Map.Center.x - 50, Autotests_ColonyMaker.Map.Center.z - 50, 100, 100); Autotests_ColonyMaker.DeleteAllSpawnedPawns(); GenDebug.ClearArea(Autotests_ColonyMaker.overRect, Find.CurrentMap); if (flags.Contains(ColonyMakerFlag.Animals)) { foreach (PawnKindDef pawnKindDef in from k in DefDatabase <PawnKindDef> .AllDefs where k.RaceProps.Animal select k) { CellRect cellRect; if (!Autotests_ColonyMaker.TryGetFreeRect(6, 3, out cellRect)) { return; } cellRect = cellRect.ContractedBy(1); foreach (IntVec3 c in cellRect) { Autotests_ColonyMaker.Map.terrainGrid.SetTerrain(c, TerrainDefOf.Concrete); } GenSpawn.Spawn(PawnGenerator.GeneratePawn(pawnKindDef, null), cellRect.Cells.ElementAt(0), Autotests_ColonyMaker.Map, WipeMode.Vanish); IntVec3 intVec = cellRect.Cells.ElementAt(1); Pawn p = (Pawn)GenSpawn.Spawn(PawnGenerator.GeneratePawn(pawnKindDef, null), intVec, Autotests_ColonyMaker.Map, WipeMode.Vanish); HealthUtility.DamageUntilDead(p); Corpse thing = (Corpse)intVec.GetThingList(Find.CurrentMap).First((Thing t) => t is Corpse); CompRottable compRottable = thing.TryGetComp <CompRottable>(); if (compRottable != null) { compRottable.RotProgress += 1200000f; } if (pawnKindDef.RaceProps.leatherDef != null) { GenSpawn.Spawn(pawnKindDef.RaceProps.leatherDef, cellRect.Cells.ElementAt(2), Autotests_ColonyMaker.Map, WipeMode.Vanish); } if (pawnKindDef.RaceProps.meatDef != null) { GenSpawn.Spawn(pawnKindDef.RaceProps.meatDef, cellRect.Cells.ElementAt(3), Autotests_ColonyMaker.Map, WipeMode.Vanish); } } } if (flags.Contains(ColonyMakerFlag.ConduitGrid)) { Designator_Build designator_Build = new Designator_Build(ThingDefOf.PowerConduit); for (int i = Autotests_ColonyMaker.overRect.minX; i < Autotests_ColonyMaker.overRect.maxX; i++) { for (int j = Autotests_ColonyMaker.overRect.minZ; j < Autotests_ColonyMaker.overRect.maxZ; j += 7) { designator_Build.DesignateSingleCell(new IntVec3(i, 0, j)); } } for (int k2 = Autotests_ColonyMaker.overRect.minZ; k2 < Autotests_ColonyMaker.overRect.maxZ; k2++) { for (int l = Autotests_ColonyMaker.overRect.minX; l < Autotests_ColonyMaker.overRect.maxX; l += 7) { designator_Build.DesignateSingleCell(new IntVec3(l, 0, k2)); } } } if (flags.Contains(ColonyMakerFlag.PowerPlants)) { List <ThingDef> list = new List <ThingDef> { ThingDefOf.SolarGenerator, ThingDefOf.WindTurbine }; for (int m = 0; m < 8; m++) { if (Autotests_ColonyMaker.TryMakeBuilding(list[m % list.Count]) == null) { Log.Message("Could not make solar generator.", false); break; } } } if (flags.Contains(ColonyMakerFlag.Batteries)) { for (int n = 0; n < 6; n++) { Thing thing2 = Autotests_ColonyMaker.TryMakeBuilding(ThingDefOf.Battery); if (thing2 == null) { Log.Message("Could not make battery.", false); break; } ((Building_Battery)thing2).GetComp <CompPowerBattery>().AddEnergy(999999f); } } if (flags.Contains(ColonyMakerFlag.WorkTables)) { IEnumerable <ThingDef> enumerable = from def in DefDatabase <ThingDef> .AllDefs where typeof(Building_WorkTable).IsAssignableFrom(def.thingClass) select def; foreach (ThingDef thingDef in enumerable) { Thing thing3 = Autotests_ColonyMaker.TryMakeBuilding(thingDef); if (thing3 == null) { Log.Message("Could not make worktable: " + thingDef.defName, false); break; } Building_WorkTable building_WorkTable = thing3 as Building_WorkTable; if (building_WorkTable != null) { foreach (RecipeDef recipe in building_WorkTable.def.AllRecipes) { building_WorkTable.billStack.AddBill(recipe.MakeNewBill()); } } } } if (flags.Contains(ColonyMakerFlag.AllBuildings)) { IEnumerable <ThingDef> enumerable2 = from def in DefDatabase <ThingDef> .AllDefs where def.category == ThingCategory.Building && def.BuildableByPlayer select def; foreach (ThingDef thingDef2 in enumerable2) { if (thingDef2 != ThingDefOf.PowerConduit) { if (Autotests_ColonyMaker.TryMakeBuilding(thingDef2) == null) { Log.Message("Could not make building: " + thingDef2.defName, false); break; } } } } CellRect rect; if (!Autotests_ColonyMaker.TryGetFreeRect(33, 33, out rect)) { Log.Error("Could not get wallable rect", false); } rect = rect.ContractedBy(1); if (flags.Contains(ColonyMakerFlag.AllItems)) { List <ThingDef> itemDefs = (from def in DefDatabase <ThingDef> .AllDefs where DebugThingPlaceHelper.IsDebugSpawnable(def, false) && def.category == ThingCategory.Item select def).ToList <ThingDef>(); Autotests_ColonyMaker.FillWithItems(rect, itemDefs); } else if (flags.Contains(ColonyMakerFlag.ItemsRawFood)) { List <ThingDef> list2 = new List <ThingDef>(); list2.Add(ThingDefOf.RawPotatoes); Autotests_ColonyMaker.FillWithItems(rect, list2); } if (flags.Contains(ColonyMakerFlag.Filth)) { foreach (IntVec3 loc in rect) { GenSpawn.Spawn(ThingDefOf.Filth_Dirt, loc, Autotests_ColonyMaker.Map, WipeMode.Vanish); } } if (flags.Contains(ColonyMakerFlag.ItemsWall)) { CellRect cellRect2 = rect.ExpandedBy(1); Designator_Build designator_Build2 = new Designator_Build(ThingDefOf.Wall); designator_Build2.SetStuffDef(ThingDefOf.WoodLog); foreach (IntVec3 c2 in cellRect2.EdgeCells) { designator_Build2.DesignateSingleCell(c2); } } if (flags.Contains(ColonyMakerFlag.ColonistsMany)) { Autotests_ColonyMaker.MakeColonists(15, Autotests_ColonyMaker.overRect.CenterCell); } else if (flags.Contains(ColonyMakerFlag.ColonistOne)) { Autotests_ColonyMaker.MakeColonists(1, Autotests_ColonyMaker.overRect.CenterCell); } if (flags.Contains(ColonyMakerFlag.Fire)) { CellRect cellRect3; if (!Autotests_ColonyMaker.TryGetFreeRect(30, 30, out cellRect3)) { Log.Error("Could not get free rect for fire.", false); } ThingDef plant_TreeOak = ThingDefOf.Plant_TreeOak; foreach (IntVec3 loc2 in cellRect3) { GenSpawn.Spawn(plant_TreeOak, loc2, Autotests_ColonyMaker.Map, WipeMode.Vanish); } foreach (IntVec3 center in cellRect3) { if (center.x % 7 == 0 && center.z % 7 == 0) { GenExplosion.DoExplosion(center, Find.CurrentMap, 3.9f, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); } } } if (flags.Contains(ColonyMakerFlag.ColonistsHungry)) { Autotests_ColonyMaker.DoToColonists(0.4f, delegate(Pawn col) { col.needs.food.CurLevel = Mathf.Max(0f, Rand.Range(-0.05f, 0.05f)); }); } if (flags.Contains(ColonyMakerFlag.ColonistsTired)) { Autotests_ColonyMaker.DoToColonists(0.4f, delegate(Pawn col) { col.needs.rest.CurLevel = Mathf.Max(0f, Rand.Range(-0.05f, 0.05f)); }); } if (flags.Contains(ColonyMakerFlag.ColonistsInjured)) { Autotests_ColonyMaker.DoToColonists(0.4f, delegate(Pawn col) { DamageDef def3 = (from d in DefDatabase <DamageDef> .AllDefs where d.externalViolence select d).RandomElement <DamageDef>(); col.TakeDamage(new DamageInfo(def3, 10f, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); }); } if (flags.Contains(ColonyMakerFlag.ColonistsDiseased)) { foreach (HediffDef def2 in from d in DefDatabase <HediffDef> .AllDefs where d.hediffClass != typeof(Hediff_AddedPart) && (d.HasComp(typeof(HediffComp_Immunizable)) || d.HasComp(typeof(HediffComp_GrowthMode))) select d) { Pawn pawn = PawnGenerator.GeneratePawn(Faction.OfPlayer.def.basicMemberKind, Faction.OfPlayer); CellRect cellRect4; Autotests_ColonyMaker.TryGetFreeRect(1, 1, out cellRect4); GenSpawn.Spawn(pawn, cellRect4.CenterCell, Autotests_ColonyMaker.Map, WipeMode.Vanish); pawn.health.AddHediff(def2, null, null, null); } } if (flags.Contains(ColonyMakerFlag.Beds)) { IEnumerable <ThingDef> source = from def in DefDatabase <ThingDef> .AllDefs where def.thingClass == typeof(Building_Bed) select def; int freeColonistsCount = Autotests_ColonyMaker.Map.mapPawns.FreeColonistsCount; for (int num = 0; num < freeColonistsCount; num++) { if (Autotests_ColonyMaker.TryMakeBuilding(source.RandomElement <ThingDef>()) == null) { Log.Message("Could not make beds.", false); break; } } } if (flags.Contains(ColonyMakerFlag.Stockpiles)) { Designator_ZoneAddStockpile_Resources designator_ZoneAddStockpile_Resources = new Designator_ZoneAddStockpile_Resources(); IEnumerator enumerator11 = Enum.GetValues(typeof(StoragePriority)).GetEnumerator(); try { while (enumerator11.MoveNext()) { object obj = enumerator11.Current; StoragePriority priority = (StoragePriority)obj; CellRect cellRect5; Autotests_ColonyMaker.TryGetFreeRect(7, 7, out cellRect5); cellRect5 = cellRect5.ContractedBy(1); designator_ZoneAddStockpile_Resources.DesignateMultiCell(cellRect5.Cells); Zone_Stockpile zone_Stockpile = (Zone_Stockpile)Autotests_ColonyMaker.Map.zoneManager.ZoneAt(cellRect5.CenterCell); zone_Stockpile.settings.Priority = priority; } } finally { IDisposable disposable; if ((disposable = (enumerator11 as IDisposable)) != null) { disposable.Dispose(); } } } if (flags.Contains(ColonyMakerFlag.GrowingZones)) { Zone_Growing dummyZone = new Zone_Growing(Autotests_ColonyMaker.Map.zoneManager); Autotests_ColonyMaker.Map.zoneManager.RegisterZone(dummyZone); foreach (ThingDef plantDefToGrow in from d in DefDatabase <ThingDef> .AllDefs where d.plant != null && GenPlant.CanSowOnGrower(d, dummyZone) select d) { CellRect cellRect6; if (!Autotests_ColonyMaker.TryGetFreeRect(6, 6, out cellRect6)) { Log.Error("Could not get growing zone rect.", false); } cellRect6 = cellRect6.ContractedBy(1); foreach (IntVec3 c3 in cellRect6) { Autotests_ColonyMaker.Map.terrainGrid.SetTerrain(c3, TerrainDefOf.Soil); } Designator_ZoneAdd_Growing designator_ZoneAdd_Growing = new Designator_ZoneAdd_Growing(); designator_ZoneAdd_Growing.DesignateMultiCell(cellRect6.Cells); Zone_Growing zone_Growing = Autotests_ColonyMaker.Map.zoneManager.ZoneAt(cellRect6.CenterCell) as Zone_Growing; if (zone_Growing != null) { zone_Growing.SetPlantDefToGrow(plantDefToGrow); } } dummyZone.Delete(); } Autotests_ColonyMaker.ClearAllHomeArea(); Autotests_ColonyMaker.FillWithHomeArea(Autotests_ColonyMaker.overRect); DebugSettings.godMode = godMode; Thing.allowDestroyNonDestroyable = false; }
public override void OnCast() { Corpse toChannel = null; foreach (Item item in Caster.GetItemsInRange(3)) { if (item is Corpse && !((Corpse)item).Channeled) { toChannel = (Corpse)item; break; } } int max, min, mana, number; if (toChannel != null) { min = 1 + (int)(Caster.Skills[SkillName.SpiritSpeak].Value * 0.25); max = min + 4; mana = 0; number = 1061287; // You channel energy from a nearby corpse to heal your wounds. } else { min = 1 + (int)(Caster.Skills[SkillName.SpiritSpeak].Value * 0.25); max = min + 4; mana = 10; number = 1061286; // You channel your own spiritual energy to heal your wounds. } if (Caster.Mana < mana) { Caster.SendLocalizedMessage(1061285); // You lack the mana required to use this skill. } else { Caster.CheckSkill(SkillName.SpiritSpeak, 0.0, 120.0); if (Utility.RandomDouble() > (Caster.Skills[SkillName.SpiritSpeak].Value / 100.0)) { Caster.SendLocalizedMessage(502443); // You fail your attempt at contacting the netherworld. } else { if (toChannel != null) { toChannel.Channeled = true; toChannel.Hue = 0x835; } Caster.Mana -= mana; Caster.SendLocalizedMessage(number); if (min > max) { min = max; } Caster.Hits += Utility.RandomMinMax(min, max); Caster.FixedParticles(0x375A, 1, 15, 9501, 2100, 4, EffectLayer.Waist); } } FinishSequence(); }
public static int CorpseNotoriety(Mobile source, Corpse target) { if (target.AccessLevel > AccessLevel.Player) { return(Notoriety.CanBeAttacked); } #region UOACZ if (UOACZRegion.ContainsItem(target)) { PlayerMobile pm_Owner = target.Owner as PlayerMobile; BaseCreature bc_Owner = target.Owner as BaseCreature; if (pm_Owner != null) { UOACZPersistance.CheckAndCreateUOACZAccountEntry(pm_Owner); if (pm_Owner.IsUOACZUndead) { return(Notoriety.Murderer); } if (pm_Owner.m_UOACZAccountEntry.ActiveProfile == UOACZAccountEntry.ActiveProfileType.Human) { if (pm_Owner.m_UOACZAccountEntry.HumanProfile.HonorPoints <= UOACZSystem.HonorAggressionThreshold) { return(Notoriety.Enemy); } if (pm_Owner.Criminal) { return(Notoriety.CanBeAttacked); } return(Notoriety.Innocent); } } if (bc_Owner != null) { if (bc_Owner is UOACZBaseUndead) { if (bc_Owner.ControlMaster == source) { return(Notoriety.Ally); } return(Notoriety.CanBeAttacked); } if (bc_Owner is UOACZBaseWildlife) { return(Notoriety.CanBeAttacked); } if (bc_Owner is UOACZBaseHuman) { return(Notoriety.Innocent); } } return(Notoriety.CanBeAttacked); } #endregion Body body = (Body)target.Amount; BaseCreature cretOwner = target.Owner as BaseCreature; if (cretOwner != null) { //TEST: GUILD /* * Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); * Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); * * if (sourceGuild != null && targetGuild != null) * { * if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) * return Notoriety.Ally; * * else if (sourceGuild.IsEnemy(targetGuild)) * return Notoriety.Enemy; * } */ if (cretOwner.IsLoHBoss() || cretOwner.FreelyLootable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } int actual = Notoriety.CanBeAttacked; if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).IsMurderer() || ((BaseCreature)target.Owner).IsAnimatedDead))) { actual = Notoriety.Murderer; } if (DateTime.UtcNow >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice)) { return(actual); } Party sourceParty = Party.Get(source); List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source || (sourceParty != null && Party.Get(list[i]) == sourceParty)) { return(actual); } } return(Notoriety.Innocent); } else { if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).IsMurderer() || ((BaseCreature)target.Owner).IsAnimatedDead))) { return(Notoriety.Murderer); } if (target.Criminal) { return(Notoriety.Criminal); } //TEST: GUILD /* * Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); * Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); * * if (sourceGuild != null && targetGuild != null) * { * if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) * return Notoriety.Ally; * * else if (sourceGuild.IsEnemy(targetGuild)) * return Notoriety.Enemy; * } */ if (target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } if (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature)) { return(Notoriety.CanBeAttacked); } List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source) { return(Notoriety.CanBeAttacked); } } if (SpellHelper.InBuccs(target.Map, target.Location) || SpellHelper.InYewOrcFort(target.Map, target.Location) || SpellHelper.InYewCrypts(target.Map, target.Location)) { return(Notoriety.CanBeAttacked); } if (GreyZoneTotem.InGreyZoneTotemArea(target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } //Hotspot Nearby if (Custom.Hotspot.InHotspotArea(target.Location, target.Map, true)) { return(Notoriety.CanBeAttacked); } if (target.IsBones) { return(Notoriety.CanBeAttacked); } return(Notoriety.Innocent); } }
public override IEnumerable <Toil> MakeNewToils() { base.AddFinishAction(delegate { this.Map.attackTargetsCache.UpdateTarget(this.pawn); }); Toil prepareToEatCorpse = new Toil(); prepareToEatCorpse.initAction = delegate() { Pawn actor = prepareToEatCorpse.actor; Corpse corpse = this.Corpse; if (corpse == null) { Pawn prey = this.Prey; if (prey == null) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true, true); return; } corpse = prey.Corpse; if (corpse == null || !corpse.Spawned) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true, true); return; } } if (actor.Faction == Faction.OfPlayer) { corpse.SetForbidden(false, false); } else { corpse.SetForbidden(true, false); } actor.CurJob.SetTarget(TargetIndex.A, corpse); }; yield return(Toils_General.DoAtomic(delegate { this.Map.attackTargetsCache.UpdateTarget(this.pawn); })); Action hitAction = delegate() { Pawn prey = this.Prey; bool surpriseAttack = this.firstHit && !prey.IsColonist; if (this.pawn.meleeVerbs.TryMeleeAttack(prey, this.job.verbToUse, surpriseAttack)) { if (!this.notifiedPlayerAttacked && PawnUtility.ShouldSendNotificationAbout(prey)) { this.notifiedPlayerAttacked = true; Messages.Message("MessageAttackedByPredator".Translate(prey.LabelShort, this.pawn.LabelIndefinite(), prey.Named("PREY"), this.pawn.Named("PREDATOR")).CapitalizeFirst(), prey, MessageTypeDefOf.ThreatSmall, true); } this.Map.attackTargetsCache.UpdateTarget(this.pawn); this.firstHit = false; } }; Toil toil = Toils_Combat.FollowAndMeleeAttack(TargetIndex.A, hitAction).JumpIfDespawnedOrNull(TargetIndex.A, prepareToEatCorpse).JumpIf(() => this.Corpse != null, prepareToEatCorpse).FailOn(() => Find.TickManager.TicksGame > this.startTick + 5000 && (float)(this.job.GetTarget(TargetIndex.A).Cell - this.pawn.Position).LengthHorizontalSquared > 4f); toil.AddPreTickAction(new Action(this.CheckWarnPlayer)); yield return(toil); yield return(prepareToEatCorpse); Toil gotoCorpse = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch); yield return(gotoCorpse); float durationMultiplier = 1f / this.pawn.GetStatValue(StatDefOf.EatingSpeed, true); yield return(Toils_Ingest.ChewIngestible(this.pawn, durationMultiplier, TargetIndex.A, TargetIndex.None).FailOnDespawnedOrNull(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch)); yield return(Toils_Ingest.FinalizeIngest(this.pawn, TargetIndex.A)); yield return(Toils_Jump.JumpIf(gotoCorpse, () => this.pawn.needs.food.CurLevelPercentage < 0.9f)); yield break; }
protected override void OnTarget(Mobile from, object target) { if (target is Mobile) { if (from.CheckTargetSkill(SkillName.Forensics, target, 40.0, 100.0)) { if (target is PlayerMobile && ((PlayerMobile)target).NpcGuild == NpcGuild.ThievesGuild) { from.SendLocalizedMessage(501004); //That individual is a thief! } else { from.SendLocalizedMessage(501003); //You notice nothing unusual. } } else { from.SendLocalizedMessage(501001); //You cannot determain anything useful. } } else if (target is Corpse) { if (from.CheckTargetSkill(SkillName.Forensics, target, 0.0, 100.0)) { Corpse c = (Corpse)target; if (c.m_Forensicist != null) { from.SendLocalizedMessage(1042750, c.m_Forensicist); // The forensicist ~1_NAME~ has already discovered that: } else { c.m_Forensicist = from.Name; } if (((Body)c.Amount).IsHuman) { from.SendLocalizedMessage(1042751, (c.Killer == null ? "no one" : c.Killer.Name)); //This person was killed by ~1_KILLER_NAME~ } if (c.Looters.Count > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < c.Looters.Count; i++) { if (i > 0) { sb.Append(", "); } sb.Append(((Mobile)c.Looters[i]).Name); } from.SendLocalizedMessage(1042752, sb.ToString()); //This body has been distrubed by ~1_PLAYER_NAMES~ } else { from.SendLocalizedMessage(501002); //The corpse has not be desecrated. } } else { from.SendLocalizedMessage(501001); //You cannot determain anything useful. } } else if (target is ILockpickable) { ILockpickable p = (ILockpickable)target; if (p.Picker != null) { from.SendLocalizedMessage(1042749, p.Picker.Name); //This lock was opened by ~1_PICKER_NAME~ } else { from.SendLocalizedMessage(501003); //You notice nothing unusual. } } }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { if (!forced) //if (!(forced || RJWSettings.WildMode)) { //Log.Message("[RJW]WorkGiver_RJW_Sexchecks::not player interaction, exit:" + forced); return(false); } if (!(RJWSettings.RPG_direct_control || (RJWSettings.RPG_hero_control && pawn.IsDesignatedHero() && pawn.IsHeroOwner()))) { //Log.Message("[RJW]WorkGiver_RJW_Sexchecks::direct_control disabled or not hero, exit"); return(false); } Pawn target = t as Pawn; if (t is Corpse) { Corpse corpse = t as Corpse; target = corpse.InnerPawn; //Log.Message("[RJW]WorkGiver_RJW_Sexchecks::Pawn(" + xxx.get_pawnname(pawn) + "), Target corpse(" + xxx.get_pawnname(target) + ")"); } else { //Log.Message("[RJW]WorkGiver_RJW_Sexchecks::Pawn(" + xxx.get_pawnname(pawn) + "), Target pawn(" + xxx.get_pawnname(target) + ")"); } //Log.Message("1"); if (t == null || t.Map == null) { return(false); } //Log.Message("2"); if (!(xxx.can_fuck(pawn) || xxx.can_be_fucked(pawn))) { //Log.Message("[RJW]WorkGiver_RJW_Sexchecks::JobOnThing(" + xxx.get_pawnname(pawn) + ") is cannot f**k or be f****d."); return(false); } //Log.Message("3"); if (t is Pawn) { if (!(xxx.can_fuck(target) || xxx.can_be_fucked(target))) { //Log.Message("[RJW]WorkGiver_RJW_Sexchecks::JobOnThing(" + xxx.get_pawnname(target) + ") is cannot f**k or be f****d."); return(false); } } //Log.Message("4"); //investigate AoA, someday //move this? //if (xxx.is_animal(pawn) && xxx.is_animal(target) && !RJWSettings.animal_on_animal_enabled) //{ // return false; //} if (!xxx.is_human(pawn) && !(xxx.RoMIsActive && pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_ShapeshiftHD")))) { return(false); } //Log.Message("5"); if (!pawn.CanReach(t, PathEndMode, Danger.Some)) { if (RJWSettings.DevMode) { JobFailReason.Is( pawn.CanReach(t, PathEndMode, Danger.Deadly) ? "unable to reach target safely" : "target unreachable"); } return(false); } //Log.Message("6"); if (t.IsForbidden(pawn)) { if (RJWSettings.DevMode) { JobFailReason.Is("target is outside of allowed area"); } return(false); } //Log.Message("7"); if (!pawn.IsDesignatedHero()) { if (!RJWSettings.WildMode) { if (pawn.IsDesignatedComfort() || pawn.IsDesignatedBreeding()) { if (RJWSettings.DevMode) { JobFailReason.Is("designated pawns cannot initiate sex"); } return(false); } if (!xxx.is_healthy_enough(pawn)) { if (RJWSettings.DevMode) { JobFailReason.Is("not healthy enough for sex"); } return(false); } if (xxx.is_asexual(pawn)) { if (RJWSettings.DevMode) { JobFailReason.Is("refuses to have sex"); } return(false); } } } else { if (!pawn.IsHeroOwner()) { //Log.Message("[RJW]WorkGiver_Sexchecks::player interaction for not owned hero, exit"); return(false); } } if (!MoreChecks(pawn, t, forced)) { return(false); } return(true); }
//my functions public void addCorpse(Corpse inCorpse) { corpseList.Add(inCorpse); }
public void Target(object obj) { MaabusCoffinComponent comp = obj as MaabusCoffinComponent; if (comp != null) { MaabusCoffin addon = comp.Addon as MaabusCoffin; if (addon != null) { PlayerMobile pm = this.Caster as PlayerMobile; if (pm != null) { QuestSystem qs = pm.Quest; if (qs is DarkTidesQuest) { QuestObjective objective = qs.FindObjective(typeof(AnimateMaabusCorpseObjective)); if (objective != null && !objective.Completed) { addon.Awake(this.Caster); objective.Complete(); } } } return; } } Corpse c = obj as Corpse; if (c == null) { this.Caster.SendLocalizedMessage(1061084); // You cannot animate that. } else { Type type = null; if (c.Owner != null) { type = c.Owner.GetType(); } if (c.ItemID != 0x2006 || c.Animated || c.Channeled || type == typeof(PlayerMobile) || type == null || (c.Owner != null && c.Owner.Fame < 100) || ((c.Owner != null) && (c.Owner is BaseCreature) && (((BaseCreature)c.Owner).Summoned || ((BaseCreature)c.Owner).IsBonded))) { this.Caster.SendLocalizedMessage(1061085); // There's not enough life force there to animate. } else { CreatureGroup group = FindGroup(type); if (group != null) { if (group.m_Entries.Length == 0 || type == typeof(DemonKnight)) { this.Caster.SendLocalizedMessage(1061086); // You cannot animate undead remains. } else if (this.CheckSequence()) { Point3D p = c.GetWorldLocation(); Map map = c.Map; if (map != null) { Effects.PlaySound(p, map, 0x1FB); Effects.SendLocationParticles(EffectItem.Create(p, map, EffectItem.DefaultDuration), 0x3789, 1, 40, 0x3F, 3, 9907, 0); Timer.DelayCall(TimeSpan.FromSeconds(2.0), new TimerStateCallback(SummonDelay_Callback), new object[] { this.Caster, c, p, map, group }); } } } } } this.FinishSequence(); }
void leaveCorpse(Corpse corpseToLeave, Vector3 corpseLocation) { //here is where a corpse would be left when I implement corpses }
public static int CorpseNotoriety(Mobile source, Corpse target) { if (target.AccessLevel > AccessLevel.VIP) { return(Notoriety.CanBeAttacked); } Body body = target.Amount; BaseCreature cretOwner = target.Owner as BaseCreature; if (cretOwner != null) { Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild, target.Owner); if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild) { return(Notoriety.Ally); } if (sourceGuild.IsAlly(targetGuild)) { return(Notoriety.Ally); } if (sourceGuild.IsEnemy(targetGuild)) { return(Notoriety.Enemy); } } if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.IsEnemy(source, cretOwner) && (ViceVsVirtueSystem.EnhancedRules || source.Map == ViceVsVirtueSystem.Facet)) { return(Notoriety.Enemy); } if (CheckHouseFlag(source, cretOwner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } int actual = Notoriety.CanBeAttacked; if (target.Murderer) { actual = Notoriety.Murderer; } else if (body.IsMonster && IsSummoned(cretOwner)) { actual = Notoriety.Murderer; } else if (cretOwner.AlwaysMurderer || cretOwner.IsAnimatedDead) { actual = Notoriety.Murderer; } if (DateTime.UtcNow >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice)) { return(actual); } Party sourceParty = Party.Get(source); foreach (Mobile m in target.Aggressors) { if (m == source || (sourceParty != null && Party.Get(m) == sourceParty) || (sourceGuild != null && m.Guild == sourceGuild)) { return(actual); } } return(Notoriety.Innocent); } else { if (target.Murderer) { return(Notoriety.Murderer); } if (target.Criminal && target.Map != null && ((target.Map.Rules & MapRules.HarmfulRestrictions) == 0)) { return(Notoriety.Criminal); } Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild, target.Owner); if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) { return(Notoriety.Ally); } if (sourceGuild.IsEnemy(targetGuild)) { return(Notoriety.Enemy); } } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } if (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature)) { return(Notoriety.CanBeAttacked); } List <Mobile> list = target.Aggressors; foreach (Mobile m in list) { if (m == source) { return(Notoriety.CanBeAttacked); } } return(Notoriety.Innocent); } }
public override void Draw() { bool flag = this.flyingThing != null; if (flag) { if (this.spinRate > 0) { if (Find.TickManager.TicksGame % this.spinRate == 0) { this.rotation++; if (this.rotation >= 4) { this.rotation = 0; } } if (rotation == 0) { this.flyingThing.Rotation = Rot4.West; } else if (rotation == 1) { this.flyingThing.Rotation = Rot4.North; } else if (rotation == 2) { this.flyingThing.Rotation = Rot4.East; } else { this.flyingThing.Rotation = Rot4.South; } } bool flag2 = this.flyingThing is Pawn; if (flag2) { bool flag4 = !this.DrawPos.ToIntVec3().IsValid; if (flag4) { return; } Pawn pawn = this.flyingThing as Pawn; pawn.Drawer.DrawAt(this.DrawPos); } else if (this.flyingThing is Corpse) { bool flag4 = !this.DrawPos.ToIntVec3().IsValid; if (flag4) { return; } Corpse corpse = this.flyingThing as Corpse; corpse.InnerPawn.Rotation = this.flyingThing.Rotation; corpse.InnerPawn.Drawer.renderer.RenderPawnAt(this.DrawPos); } else { Graphics.DrawMesh(MeshPool.plane10, this.DrawPos, this.ExactRotation, this.flyingThing.def.DrawMatSingle, 0); } } else { if (this.spinRate > 0) { if (Find.TickManager.TicksGame % this.spinRate == 0) { this.rotation++; if (this.rotation >= 4) { this.rotation = 0; } } if (rotation == 0) { this.Rotation = Rot4.West; } else if (rotation == 1) { this.Rotation = Rot4.North; } else if (rotation == 2) { this.Rotation = Rot4.East; } else { this.Rotation = Rot4.South; } } Graphics.DrawMesh(MeshPool.plane10, this.DrawPos, this.ExactRotation, this.def.DrawMatSingle, 0); } base.Comps_PostDraw(); }
void HandleAutostoreLootItem(LootItemPkt packet) { Player player = GetPlayer(); AELootResult aeResult = player.GetAELootView().Count > 1 ? new AELootResult() : null; /// @todo Implement looting by LootObject guid foreach (LootRequest req in packet.Loot) { Loot loot = null; ObjectGuid lguid = player.GetLootWorldObjectGUID(req.Object); if (lguid.IsGameObject()) { GameObject go = player.GetMap().GetGameObject(lguid); // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO if (!go || ((go.GetOwnerGUID() != player.GetGUID() && go.GetGoType() != GameObjectTypes.FishingHole) && !go.IsWithinDistInMap(player, SharedConst.InteractionDistance))) { player.SendLootRelease(lguid); continue; } loot = go.loot; } else if (lguid.IsItem()) { Item pItem = player.GetItemByGuid(lguid); if (!pItem) { player.SendLootRelease(lguid); continue; } loot = pItem.loot; } else if (lguid.IsCorpse()) { Corpse bones = ObjectAccessor.GetCorpse(player, lguid); if (!bones) { player.SendLootRelease(lguid); continue; } loot = bones.loot; } else { Creature creature = player.GetMap().GetCreature(lguid); bool lootAllowed = creature && creature.IsAlive() == (player.GetClass() == Class.Rogue && creature.loot.loot_type == LootType.Pickpocketing); if (!lootAllowed || !creature.IsWithinDistInMap(player, AELootCreatureCheck.LootDistance)) { player.SendLootError(req.Object, lguid, lootAllowed ? LootError.TooFar : LootError.DidntKill); continue; } loot = creature.loot; } player.StoreLootItem((byte)(req.LootListID - 1), loot, aeResult); // If player is removing the last LootItem, delete the empty container. if (loot.isLooted() && lguid.IsItem()) { player.GetSession().DoLootRelease(lguid); } } if (aeResult != null) { foreach (var resultValue in aeResult.GetByOrder()) { player.SendNewItem(resultValue.item, resultValue.count, false, false, true); player.UpdateCriteria(CriteriaTypes.LootItem, resultValue.item.GetEntry(), resultValue.count); player.UpdateCriteria(CriteriaTypes.LootType, resultValue.item.GetEntry(), resultValue.count, (ulong)resultValue.lootType); player.UpdateCriteria(CriteriaTypes.LootEpicItem, resultValue.item.GetEntry(), resultValue.count); } } }
protected new void Impact(Thing hitThing) { bool flag = hitThing == null; if (flag) { Pawn pawn; bool flag2 = (pawn = base.Position.GetThingList(base.Map).FirstOrDefault((Thing x) => x == this.assignedTarget) as Pawn) != null; if (flag2) { hitThing = pawn; } } bool hasValue = this.impactDamage.HasValue; if (hasValue) { hitThing.TakeDamage(this.impactDamage.Value); } try { SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f); if (this.flyingThing != null) { GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); if (this.flyingThing is Pawn) { Pawn p = this.flyingThing as Pawn; if (p.IsColonist && this.drafted) { p.drafter.Drafted = true; } if (this.earlyImpact) { damageEntities(p, this.impactForce, DamageDefOf.Blunt); damageEntities(p, this.impactForce, DamageDefOf.Stun); } } else if (flyingThing.def.thingCategories != null && (flyingThing.def.thingCategories.Contains(ThingCategoryDefOf.Chunks) || flyingThing.def.thingCategories.Contains(ThingCategoryDef.Named("StoneChunks")))) { float radius = 4f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + (Quaternion.AngleAxis(180, Vector3.up) * this.direction * 3); } else if (wallFlag90) { center = center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction * 3); } else if (wallFlag90neg) { center = center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction * 3); } } List <IntVec3> damageRing = GenRadial.RadialCellsAround(base.Position, radius, true).ToList(); List <IntVec3> outsideRing = GenRadial.RadialCellsAround(base.Position, radius, false).Except(GenRadial.RadialCellsAround(base.Position, radius - 1, true)).ToList(); for (int i = 0; i < damageRing.Count; i++) { List <Thing> allThings = damageRing[i].GetThingList(base.Map); for (int j = 0; j < allThings.Count; j++) { var thing = allThings[j]; if (thing is Pawn) { damageEntities(thing, Rand.Range(14, 22), DamageDefOf.Blunt); } else if (thing is Building) { damageEntities(thing, Rand.Range(56, 88), DamageDefOf.Blunt); } else { if (Rand.Chance(.1f)) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_RubbleRock), damageRing[i], base.Map, ThingPlaceMode.Near); } } } } for (int i = 0; i < outsideRing.Count; i++) { IntVec3 intVec = outsideRing[i]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = TM_Calc.GetVector(this.ExactPosition.ToIntVec3(), intVec); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Rubble"), this.ExactPosition, base.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(8f, 13f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_Smoke, this.ExactPosition, base.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(5f, 8f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, DamageDefOf.Blunt, pawn, 0, 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, ThingDefOf.Filth_RubbleRock, .25f, 1, false, null, 0f, 1, 0, false); //MoteMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } //damageEntities(this.flyingThing, 305, DamageDefOf.Blunt); this.flyingThing.Destroy(DestroyMode.Vanish); } else if ((flyingThing.def.thingCategories != null && flyingThing.def.thingCategories.Contains(ThingCategoryDefOf.Corpses)) || this.flyingThing is Corpse) { Corpse flyingCorpse = this.flyingThing as Corpse; float radius = 3f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + (Quaternion.AngleAxis(180, Vector3.up) * this.direction * 3); } else if (wallFlag90) { center = center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction * 3); } else if (wallFlag90neg) { center = center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction * 3); } } List <IntVec3> damageRing = GenRadial.RadialCellsAround(base.Position, radius, true).ToList(); List <IntVec3> outsideRing = GenRadial.RadialCellsAround(base.Position, radius, false).Except(GenRadial.RadialCellsAround(base.Position, radius - 1, true)).ToList(); Filth filth = (Filth)ThingMaker.MakeThing(flyingCorpse.InnerPawn.def.race.BloodDef); for (int i = 0; i < damageRing.Count; i++) { List <Thing> allThings = damageRing[i].GetThingList(base.Map); for (int j = 0; j < allThings.Count; j++) { var thing = allThings[j]; if (thing is Pawn) { damageEntities(thing, Rand.Range(18, 28), DamageDefOf.Blunt); } else if (thing is Building) { damageEntities(thing, Rand.Range(56, 88), DamageDefOf.Blunt); } else { if (Rand.Chance(.05f)) { if (filth != null) { filth = (Filth)ThingMaker.MakeThing(flyingCorpse.InnerPawn.def.race.BloodDef); GenPlace.TryPlaceThing(filth, damageRing[i], base.Map, ThingPlaceMode.Near); } else { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_Blood), damageRing[i], base.Map, ThingPlaceMode.Near); } } if (Rand.Chance(.05f)) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_CorpseBile), damageRing[i], base.Map, ThingPlaceMode.Near); } } } } for (int i = 0; i < outsideRing.Count; i++) { IntVec3 intVec = outsideRing[i]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = TM_Calc.GetVector(this.ExactPosition.ToIntVec3(), intVec); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodSquirt, this.ExactPosition, base.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(4f, 13f), (Quaternion.AngleAxis(Rand.Range(60, 120), Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodMist, this.ExactPosition, base.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(5f, 8f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, DamageDefOf.Blunt, pawn, 0, 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, filth.def, .08f, 1, false, null, 0f, 1, 0, false); //MoteMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } //damageEntities(this.flyingThing, 305, DamageDefOf.Blunt); //this.flyingThing.Destroy(DestroyMode.Vanish); } } else { float radius = 2f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + (Quaternion.AngleAxis(180, Vector3.up) * this.direction * 3); } else if (wallFlag90) { center = center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction * 3); } else if (wallFlag90neg) { center = center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction * 3); } } List <IntVec3> damageRing = GenRadial.RadialCellsAround(base.Position, radius, true).ToList(); List <IntVec3> outsideRing = GenRadial.RadialCellsAround(base.Position, radius, false).Except(GenRadial.RadialCellsAround(base.Position, radius - 1, true)).ToList(); for (int i = 0; i < damageRing.Count; i++) { List <Thing> allThings = damageRing[i].GetThingList(base.Map); for (int j = 0; j < allThings.Count; j++) { var thing = allThings[j]; if (thing is Pawn) { damageEntities(thing, Rand.Range(10, 16), DamageDefOf.Blunt); } else if (thing is Building) { damageEntities(thing, Rand.Range(32, 88), DamageDefOf.Blunt); } else { if (Rand.Chance(.1f)) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_RubbleRock), damageRing[i], base.Map, ThingPlaceMode.Near); } } } } for (int i = 0; i < outsideRing.Count; i++) { IntVec3 intVec = outsideRing[i]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = TM_Calc.GetVector(this.ExactPosition.ToIntVec3(), intVec); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Rubble"), this.ExactPosition, base.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(8f, 13f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_Smoke, this.ExactPosition, base.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(5f, 8f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, DamageDefOf.Blunt, pawn, 0, 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, null, .4f, 1, false, null, 0f, 1, 0, false); //MoteMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } } this.Destroy(DestroyMode.Vanish); } catch { if (this.flyingThing != null) { if (!this.flyingThing.Spawned) { GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); Log.Message("catch"); } } this.Destroy(DestroyMode.Vanish); } }
public static int CorpseNotoriety(Mobile source, Corpse target) { if (target.AccessLevel > AccessLevel.Player) { return(Notoriety.CanBeAttacked); } Body body = (Body)target.Amount; BaseCreature cretOwner = target.Owner as BaseCreature; if (cretOwner != null) { //TEST: GUILD /* * Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); * Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); * * if (sourceGuild != null && targetGuild != null) * { * if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) * return Notoriety.Ally; * * else if (sourceGuild.IsEnemy(targetGuild)) * return Notoriety.Enemy; * } */ if (cretOwner.IsLoHBoss() || cretOwner.FreelyLootable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } int actual = Notoriety.CanBeAttacked; if (target.Kills >= Mobile.MurderCountsRequiredForMurderer || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).IsMurderer() || ((BaseCreature)target.Owner).IsAnimatedDead))) { actual = Notoriety.Murderer; } if (DateTime.UtcNow >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice)) { return(actual); } Party sourceParty = Party.Get(source); List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source || (sourceParty != null && Party.Get(list[i]) == sourceParty)) { return(actual); } } return(Notoriety.Innocent); } else { if (target.Kills >= Mobile.MurderCountsRequiredForMurderer || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).IsMurderer() || ((BaseCreature)target.Owner).IsAnimatedDead))) { return(Notoriety.Murderer); } if (target.Criminal) { return(Notoriety.Criminal); } //TEST: GUILD /* * Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); * Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); * * if (sourceGuild != null && targetGuild != null) * { * if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) * return Notoriety.Ally; * * else if (sourceGuild.IsEnemy(targetGuild)) * return Notoriety.Enemy; * } */ if (target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } if (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature)) { return(Notoriety.CanBeAttacked); } List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source) { return(Notoriety.CanBeAttacked); } } if (SpellHelper.InBuccs(target.Map, target.Location) || SpellHelper.InYewOrcFort(target.Map, target.Location) || SpellHelper.InYewCrypts(target.Map, target.Location)) { return(Notoriety.CanBeAttacked); } if (GreyZoneTotem.InGreyZoneTotemArea(target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } //Hotspot Nearby if (Custom.Hotspot.InHotspotArea(target.Location, target.Map, true)) { return(Notoriety.CanBeAttacked); } if (target.IsBones) { return(Notoriety.CanBeAttacked); } return(Notoriety.Innocent); } }
public override void OnActionCombat() { if (DateTime.Now > m_SpawnDelay) { Freeze(TimeSpan.FromSeconds(1.0)); Say("Kal An Mani Xen"); // Summon Negate Life Creature Animate(17, 6, 1, true, false, 0); Corpse c = null; Mobile mob = null; foreach (Item item in GetItemsInRange(5)) { c = item as Corpse; if (c == null) { continue; } else if (c.Channeled) { continue; } c.Channeled = true; Effects.SendLocationParticles( EffectItem.Create(c.Location, c.Map, EffectItem.DefaultDuration), 0x3709, 1, 30, 1, 6, 5052, 0); mob = new BlueKarrnathi(Combatant); mob.MoveToWorld(c.Location, c.Map); } m_SpawnDelay = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 60)); } else if (DateTime.Now > m_SoulDrainDelay) { Freeze(TimeSpan.FromSeconds(1.0)); Say("In Mani Ex Kal"); // Cause Life Freedom Summon Animate(17, 6, 1, false, false, 0); int amount = 0; foreach (Mobile m in GetMobilesInRange(30)) { if (m == null) { continue; } Effects.SendMovingParticles(m, this, 0x36D4, 15, 0, false, false, 1 /*hue*/, 0, 9502, 1, 5, (EffectLayer)255, 0x100); ++amount; } Hits += amount * 5; Stam += amount * 5; Mana += amount * 5; m_SoulDrainDelay = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(7, 14)); } else if (DateTime.Now > m_NegativeBurstDelay) { Freeze(TimeSpan.FromSeconds(1.0)); Say("Vas Corp Hur Grav"); // Great Death Wind Energy Animate(17, 6, 1, true, false, 0); new NegativeBurstTimer(this).Start(); m_NegativeBurstDelay = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 60)); } base.OnActionCombat(); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; int raisedPawns = 0; Pawn pawn = this.launcher as Pawn; Pawn victim = hitThing as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_pwr"); ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_ver"); Thing corpseThing = null; IntVec3 curCell; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius, true); for (int i = 0; i < targets.Count(); i++) { curCell = targets.ToArray <IntVec3>()[i]; TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .3f); if (curCell.InBounds(map)) { Corpse corpse = null; List <Thing> thingList; thingList = curCell.GetThingList(map); int z = 0; while (z < thingList.Count) { corpseThing = thingList[z]; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; Pawn undeadPawn = corpse.InnerPawn; CompRottable compRottable = corpse.GetComp <CompRottable>(); float rotStage = 0; if (compRottable != null && compRottable.Stage == RotStage.Dessicated) { rotStage = 1f; } if (compRottable != null) { rotStage += compRottable.RotProgressPct; } bool flag_SL = false; if (undeadPawn.def.defName == "SL_Runner" || undeadPawn.def.defName == "SL_Peon" || undeadPawn.def.defName == "SL_Archer" || undeadPawn.def.defName == "SL_Hero") { PawnGenerationRequest pgr = new PawnGenerationRequest(PawnKindDef.Named("Tribesperson"), pawn.Faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, false, true, 0, false, false, false, false, false, false, false, null, null, null, null, null, null, null, "Undead"); Pawn newUndeadPawn = PawnGenerator.GeneratePawn(pgr); GenSpawn.Spawn(newUndeadPawn, corpse.Position, corpse.Map, WipeMode.Vanish); corpse.Strip(); corpse.Destroy(DestroyMode.Vanish); rotStage = 1f; flag_SL = true; undeadPawn = newUndeadPawn; } if (undeadPawn.RaceProps.IsFlesh && (undeadPawn.Dead || flag_SL) && undeadPawn.def.thingClass.FullName != "TorannMagic.TMPawnSummoned") { bool wasVampire = false; IEnumerable <ThingDef> enumerable = from hd in DefDatabase <HediffDef> .AllDefs where (def.defName == "ROM_Vampirism") select def; if (enumerable.Count() > 0) { bool hasVampHediff = undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_Vampirism")) || undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_GhoulHediff")); if (hasVampHediff) { wasVampire = true; } } if (!wasVampire) { undeadPawn.SetFaction(pawn.Faction); if (undeadPawn.Dead) { ResurrectionUtility.Resurrect(undeadPawn); } raisedPawns++; if (!undeadPawn.kindDef.RaceProps.Animal && undeadPawn.kindDef.RaceProps.Humanlike) { CompAbilityUserMagic compMagic = undeadPawn.GetComp <CompAbilityUserMagic>(); if (TM_Calc.IsMagicUser(undeadPawn)) //(compMagic.IsMagicUser && !undeadPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) || { compMagic.Initialize(); compMagic.RemovePowers(); } CompAbilityUserMight compMight = undeadPawn.GetComp <CompAbilityUserMight>(); if (TM_Calc.IsMightUser(undeadPawn)) //compMight.IsMightUser || { compMight.Initialize(); compMight.RemovePowers(); } HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, .5f + ver.level); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); RedoSkills(undeadPawn); RemoveTraits(undeadPawn, undeadPawn.story.traits.allTraits); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Undead"), 0, false)); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Psychopath"), 0, false)); undeadPawn.needs.AddOrRemoveNeedsAsAppropriate(); RemoveClassHediff(undeadPawn); //Color undeadColor = new Color(.2f, .4f, 0); //undeadPawn.story.hairColor = undeadColor; //CompAbilityUserMagic undeadComp = undeadPawn.GetComp<CompAbilityUserMagic>(); //if (undeadComp.IsMagicUser) //{ // undeadComp.ClearPowers(); //} List <SkillRecord> skills = undeadPawn.skills.skills; for (int j = 0; j < skills.Count; j++) { skills[j].passion = Passion.None; } undeadPawn.playerSettings.hostilityResponse = HostilityResponseMode.Attack; undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds; for (int h = 0; h < 24; h++) { undeadPawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work); } } } else { Messages.Message("Vampiric powers have prevented undead reanimation of " + undeadPawn.LabelShort, MessageTypeDefOf.RejectInput); } if (undeadPawn.kindDef.RaceProps.Animal) { HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, .5f + ver.level); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Tameness).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Tameness)) { undeadPawn.training.Train(TrainableDefOf.Tameness, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Obedience)) { undeadPawn.training.Train(TrainableDefOf.Obedience, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Release).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Release)) { undeadPawn.training.Train(TrainableDefOf.Release, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Haul).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Haul)) { undeadPawn.training.Train(TorannMagicDefOf.Haul, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Rescue).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Rescue)) { undeadPawn.training.Train(TorannMagicDefOf.Rescue, pawn); } } undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds; undeadPawn.def.tradeability = Tradeability.None; } } } } z++; } } if (raisedPawns > pwr.level + 1) { i = targets.Count(); } } }
public static void ResurrectWithSideEffects(Pawn pawn) { Corpse corpse = pawn.Corpse; float x2; if (corpse != null) { CompRottable comp = corpse.GetComp <CompRottable>(); x2 = comp.RotProgress / 60000f; } else { x2 = 0f; } ResurrectionUtility.Resurrect(pawn); BodyPartRecord brain = pawn.health.hediffSet.GetBrain(); Hediff hediff = HediffMaker.MakeHediff(HediffDefOf.ResurrectionSickness, pawn, null); if (!pawn.health.WouldDieAfterAddingHediff(hediff)) { pawn.health.AddHediff(hediff, null, null, null); } float chance = ResurrectionUtility.DementiaChancePerRotDaysCurve.Evaluate(x2); if (Rand.Chance(chance) && brain != null) { Hediff hediff2 = HediffMaker.MakeHediff(HediffDefOf.Dementia, pawn, brain); if (!pawn.health.WouldDieAfterAddingHediff(hediff2)) { pawn.health.AddHediff(hediff2, null, null, null); } } float chance2 = ResurrectionUtility.BlindnessChancePerRotDaysCurve.Evaluate(x2); if (Rand.Chance(chance2)) { IEnumerable <BodyPartRecord> enumerable = from x in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null) where x.def == BodyPartDefOf.Eye select x; foreach (BodyPartRecord partRecord in enumerable) { Hediff hediff3 = HediffMaker.MakeHediff(HediffDefOf.Blindness, pawn, partRecord); pawn.health.AddHediff(hediff3, null, null, null); } } if (brain != null) { float chance3 = ResurrectionUtility.ResurrectionPsychosisChancePerRotDaysCurve.Evaluate(x2); if (Rand.Chance(chance3)) { Hediff hediff4 = HediffMaker.MakeHediff(HediffDefOf.ResurrectionPsychosis, pawn, brain); if (!pawn.health.WouldDieAfterAddingHediff(hediff4)) { pawn.health.AddHediff(hediff4, null, null, null); } } } if (pawn.Dead) { Log.Error("The pawn has died while being resurrected.", false); ResurrectionUtility.Resurrect(pawn); } }
public void CollectCorpse(Corpse corpse) { corpse.Center = Center; corpse.IsCollected = true; }
public static void Resurrect(Pawn pawn) { if (!pawn.Dead) { Log.Error("Tried to resurrect a pawn who is not dead: " + pawn.ToStringSafe <Pawn>(), false); } else if (pawn.Discarded) { Log.Error("Tried to resurrect a discarded pawn: " + pawn.ToStringSafe <Pawn>(), false); } else { Corpse corpse = pawn.Corpse; bool flag = false; IntVec3 loc = IntVec3.Invalid; Map map = null; if (corpse != null) { flag = corpse.Spawned; loc = corpse.Position; map = corpse.Map; corpse.InnerPawn = null; corpse.Destroy(DestroyMode.Vanish); } if (flag && pawn.IsWorldPawn()) { Find.WorldPawns.RemovePawn(pawn); } pawn.ForceSetStateToUnspawned(); PawnComponentsUtility.CreateInitialComponents(pawn); pawn.health.Notify_Resurrected(); if (pawn.Faction != null && pawn.Faction.IsPlayer) { if (pawn.workSettings != null) { pawn.workSettings.EnableAndInitialize(); } Find.Storyteller.intenderPopulation.Notify_PopulationGained(); } if (flag) { GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish); for (int i = 0; i < 10; i++) { MoteMaker.ThrowAirPuffUp(pawn.DrawPos, map); } if (pawn.Faction != null && pawn.Faction != Faction.OfPlayer && pawn.HostileTo(Faction.OfPlayer)) { LordMaker.MakeNewLord(pawn.Faction, new LordJob_AssaultColony(pawn.Faction, true, true, false, false, true), pawn.Map, Gen.YieldSingle <Pawn>(pawn)); } if (pawn.apparel != null) { List <Apparel> wornApparel = pawn.apparel.WornApparel; for (int j = 0; j < wornApparel.Count; j++) { wornApparel[j].Notify_PawnResurrected(); } } } PawnDiedOrDownedThoughtsUtility.RemoveDiedThoughts(pawn); } }