// Unit moved to a hex adjacent to this edge. Increase the cost of this edge for enemy units to traverse public void SetZoneOfControl(Faction faction) { if (faction.faction_ID == 1) cost[2] = 5; else if (faction.faction_ID == 2) cost[1] = 5; }
private Faction InitFaction(XmlNode factionNode) { Faction faction = new Faction(village, factionNode.SelectSingleNode("Name").InnerText); if (factionNode.SelectSingleNode("Evil") != null) { faction.Alignment = Alignment.Evil; } if(factionNode.SelectSingleNode("Nightkill") != null ) { faction.AddPower(new Powers.NightkillPower()); } if(factionNode.SelectSingleNode("KnowsGroup") != null) { faction.AddPower(new Powers.MembersPower()); } string[] conditions = factionNode.SelectSingleNode("WinsWhen").InnerText.Split('|'); foreach (string condition in conditions) { switch (condition) { case "MajorityOrEqual": faction.WinConditions.Add(new MajorityOrEqualCondition()); break; case "NoEvilLeft": faction.WinConditions.Add(new NoEvilLeftCondition()); break; } } return faction; }
/// <summary> /// add a new character to this account, if the newly created character abides to some rules /// </summary> /// <param name="name">name of the character</param> /// <param name="level">level of the character</param> /// <param name="race">race of the character</param> /// <param name="faction">faction of the character</param> /// <param name="class">class of the character</param> /// <returns>return true if the creation wnet smoothly</returns> public bool AddNewCharacter(Guid id, string name, int level, Race race, Faction faction, Class @class) { var newCharacter = new Character() { Id = id, Name = name, Level = level, Race = race, Faction = faction, Class = @class }; if ( CharacterSpecifications.Factions .And(CharacterSpecifications.DruidSpecifications) .And(CharacterSpecifications.BloodElfSpecifications) .IsSatisfiedBy(newCharacter) && AccountSpecifications.DeathKnightSpecifications(newCharacter) .IsSatisfiedBy(this)) { Characters.Add(newCharacter); return true; } else return false; }
void Start() { rigidbody.freezeRotation = true; faction = gameObject.GetComponent<Faction> (); walking = gameObject.GetComponent<Walking> (); rotating = gameObject.GetComponent<Rotating> (); }
public void ApplyCollarEffects( Pawn pawn, Apparel collar ) { if( originalFaction == null ) { if( pawn.Faction == Faction.OfPlayer ) { originalFaction = Find.FactionManager.FirstFactionOfDef( FactionDefOf.Spacer ); } else { originalFaction = pawn.Faction; } } if( originalPawnKind == null ) { originalPawnKind = pawn.kindDef; } pawn.kindDef = Data.PawnKindDefOf.Slave; if( ( pawn.story != null )&& ( pawn.story.traits != null )&& ( !pawn.story.traits.HasTrait( Data.TraitDefOf.Enslaved ) ) ) { pawn.story.traits.GainTrait( new Trait( Data.TraitDefOf.Enslaved ) ); } }
/// <summary> /// Gets the node closest from any enemy combatants, inclusive of current nodea. /// /// FUTURE: Add calculations for safety based on effective range of the weapon they are holding. /// e.g., One is much safer ten meters away from a sniper than one half-kilometer away. /// </summary> /// <returns> /// The most dangerous node. /// </returns> public PFNode getNodeClosestToEnemies(GameObject[] enemies, Faction allegiance = Faction.Evil) { float leastDangerous = 0f; int index = -1; int i = 0; foreach (GameObject e in enemies) { // Change the != to whatever the faction relationship system is. if (e.GetComponent<Enemy>().faction != allegiance) leastDangerous += (currentNode.transform.position- e.transform.position).sqrMagnitude; } if (debugMode) print ("Risk for " + currentNode.name + " is "+leastDangerous); foreach (PFNodeEntry node in currentNode.Nodes) { float riskFactor = 0; if (debugMode) foreach (GameObject g in enemies)print (g.name); foreach (GameObject e in enemies) { if (e.GetComponent<Enemy>().faction != allegiance) riskFactor += (node.node.transform.position - e.transform.position).sqrMagnitude; //if (debugMode) print ("Calculated for " + e.name + " near " + node.node.gameObject.name); } if (debugMode) print ("Risk for " + node.node.name + " is "+riskFactor); if (riskFactor < leastDangerous) { index = i; leastDangerous = riskFactor; } i++; } choice=(index == -1) ? currentNode : currentNode.Nodes[index].node; return (index == -1) ? currentNode : currentNode.Nodes[index].node; }
public void nextTurn() { turnNumber++; active.endTurn(); active = factions[turnNumber % factions.Length]; active.startTurn(); }
public Damageable(Sprite sprite, Faction faction, int maxHP, int currentHP, bool collideable) : base(sprite, collideable) { this.Faction = faction; this.MaxHealth = maxHP; this.Health = currentHP; }
private void createFactions() { factions = new List<Faction>(); Random random = new Random(); //Erstelle alle Factions zuerst foreach (FactionEnum item in Enum.GetValues(typeof(FactionEnum))) { Faction tmpFaction = new Faction(item); factions.Add(tmpFaction); } //Bilde in jeder Faction eine Referenz auf jede andere Faction mit einem Zufallswert zwischen 0 und 100 foreach (Faction faction in factions) { foreach (Faction faction2 in factions) { if (faction == faction2) { faction.addItem(new BehaviourItem<Faction>(faction2, 100)); } else { faction.addItem(new BehaviourItem<Faction>(faction2, random.Next(0, 100))); } } } }
float y_offset = 1.622f; //1.89f; #endregion Fields #region Methods // Finds the most efficient path between two hexes, using the cost of the edges between the edges as the evaluator public List<Hex> AStarFindPath(Hex start, Hex finish, int maximum_cost_allowed, Faction faction) { // Reset hex search scores resetCellSearchScores(); List<Hex> closedSet = new List<Hex>(); List<Hex> openSet = new List<Hex>(); openSet.Add(start); start.came_from = null; start.g_score = 0; // Cost of best known path start.f_score = start.g_score + estimatedCost(start.coordinate, finish.coordinate); // Estimated cost of path from start to finish // Keep going until openset is empty while (openSet.Count > 0) { openSet.Sort(); Hex current = openSet[0]; // Check if we found the goal if (current == finish && current.g_score <= maximum_cost_allowed) { return constructPath(current, start); } openSet.Remove(current); closedSet.Add(current); foreach (Edge neighbourEdge in current.neighbours) { int tentative_g_score = current.g_score + neighbourEdge.GetCost(faction); // Check if have exceeded our allowed movement if (current.g_score >= maximum_cost_allowed || (closedSet.Contains(neighbourEdge.destination) && tentative_g_score >= neighbourEdge.destination.g_score)) { continue; } if (!openSet.Contains(neighbourEdge.destination) || tentative_g_score < neighbourEdge.destination.g_score) { neighbourEdge.destination.came_from = current; neighbourEdge.destination.g_score = tentative_g_score; neighbourEdge.destination.f_score = neighbourEdge.destination.g_score + estimatedCost(neighbourEdge.destination.coordinate, finish.coordinate); if (!openSet.Contains(neighbourEdge.destination)) { openSet.Add(neighbourEdge.destination); neighbourEdge.destination.came_from = current; } } } } // Return failure Debug.Log("Failed to find path between " + start.coordinate + " and " + finish.coordinate); return new List<Hex>(); }
public GameObject SpawnBase(Faction a_faction) { GameObject prefab = null; switch (a_faction) { case Faction.NONE: Debug.LogError("Can't load 'NONE' faction!"); return null; case Faction.NAVY: prefab = navyBase; break; case Faction.PIRATES: prefab = piratesBase; break; case Faction.TINKERERS: prefab = tinkerersBase; break; case Faction.VIKINGS: prefab = vikingsBase; break; } // Spawn base and setup base if (baseType == BaseSpawnerType.FFA_ONLY && m_scoreManager.gameType != EGameType.FreeForAll) { // Don't spawn FFA base in teams gamemode return null; } else if ((baseType == BaseSpawnerType.TEAM_ALPHA || baseType == BaseSpawnerType.TEAM_OMEGA) && m_scoreManager.gameType != EGameType.TeamGame) { // Don't spawn Team base in FFA gamemode return null; } GameObject baseObject = Instantiate(prefab, transform.position, transform.rotation) as GameObject; baseObject.tag = this.tag; switch (m_scoreManager.gameType) { case EGameType.FreeForAll: SetupBaseForFFA(baseObject); break; case EGameType.TeamGame: SetupBaseForTeams(baseObject); break; } DestroyImmediate(this.gameObject); return baseObject; }
public int GetBribeCount(Faction faction) { if (faction == null) throw new NullReferenceException("Faction not set."); int result; if (bribeCount.TryGetValue(faction.randomKey, out result)) return result; return 0; }
public void Bribe(Faction faction) { if (faction == null) throw new NullReferenceException("Faction not set."); bribeCount[faction.randomKey] = GetBribeCount(faction) + 1; CheckForMapComponent(); }
public Card(string name, Faction faction, GameAction mainAction, GameAction allyAction = null, GameAction trashAction = null) { Name = name; Faction = faction; MainAction = mainAction; AllyAction = allyAction; TrashAction = trashAction; }
public Tower(TowerBase towerBase, Faction faction, int _towerNum) { sections = new List<Section>(); dotManager = new DotManager(); this.towerBase = towerBase; this.faction = faction; towerNum = _towerNum; }
virtual public Boolean IsAvailableTo(Faction faction) { switch (faction) { case Faction.Heroes: return true; } return false; }
public static GameObject CreateInstance( double time , Vector3 pos, Vector3 dir , Faction faction, FireBallCaster caster) { GameObject obj = (GameObject)GameObject.Instantiate( Resources.Load("Prefab/Skill/FireBallBullet"), pos, Quaternion.LookRotation(dir) ); obj.GetComponent<FireBallBullet>().SetCreationParameters(pos, dir, time, caster); obj.GetComponent<Faction>().SetFaction(faction); return obj; }
public Boolean HasActionsFor(Faction faction) { foreach (AbstractTileAction action in _actions) { if (action.IsAvailableTo(faction)) { return true; } } return false; }
// Use this for initialization void Start() { int turnNumber = 0; GameState state = Grid.gameState; //hopefull gamestate and turnMangager initialize in the right order. //factions = state.factions; //factions[0] = new PlayerFaction(); //TODO make the factions not be initialized by the GameState class //sfactions[1] = new AIFaction(); active = factions[0]; player = (PlayerFaction)factions[0]; }
public async Task<bool> CreateCharacterAsync(Guid accountId, Guid id, string name, int level, Race race, Faction faction, Class @class) { var account = await _repoAccount.GetByIdAsync(accountId); if (account.AddNewCharacter(id,name, level, race, faction, @class)) return await _repoAccount.SaveAsync(account); else return await Task.FromResult(false); }
public NeverStopsMovingBehavior(Faction faction, float delay, int damage, int range) { _attackDelay = delay; _attackDamage = damage; _attackRange = range; _currentAttackRange = range; _currentAttackDamage = damage; _currentAttackDelay = delay; _faction = faction; }
public static void SpawnPawnCorpse(IntVec3 spawnCell, PawnKindDef pawnKindDef, Faction faction, float rotProgressInTicks, bool removeEquipment = false) { Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDef, faction); GenSpawn.Spawn(pawn, spawnCell); if (removeEquipment) { pawn.equipment.DestroyAllEquipment(); pawn.inventory.DestroyAll(); } KillAndRotPawn(pawn, rotProgressInTicks); }
public void ChangeOutpostThingsFaction(Faction newFaction) { if (this.outpostThingList.NullOrEmpty()) { return; } foreach (Thing thing in this.outpostThingList) { thing.SetFaction(newFaction); } }
private void Awake() { controller = GetComponent<CharacterController>(); ConeColliderAxe.enabled = false; SphereColliderShield.enabled = false; animator = gameObject.GetComponent<Animator>(); faction = Faction.Player; Health = maxHealth; MaxHealth = maxHealth; }
public void TryToCaptureOutpost(string eventTitle, string eventText, LetterType letterType, Faction turretsNewFaction, bool deactivateTurrets, Faction doorsNewFaction, bool deactivateDoors, int dropPodsNumber, PawnKindDef securityForcesDef) { SetOutpostSecurityForcesHostileToColony(); this.outpostThingList = OG_Util.RefreshThingList(this.outpostThingList); ChangeOutpostThingsFaction(null); ChangeOutpostTurretsFaction(turretsNewFaction, deactivateTurrets); ChangeOutpostDoorsFaction(doorsNewFaction, deactivateDoors); LaunchSecurityDropPods(dropPodsNumber, securityForcesDef, true); OG_Util.DestroyOutpostArea(); Find.LetterStack.ReceiveLetter(eventTitle, eventText, letterType, new TargetInfo(this.Position)); }
public Brain GetBrain(Faction faction, IEnumerable<Brain> brains) { foreach (Brain b in brains) { if (b.faction != faction) continue; if (!b.ownedPawns.Any()) continue; return b; } return null; }
public StopsToAttackBehavior(Faction fact, float delay, int damage, int range) { _attackDelay = delay; _timeUntilNextAttack = 0; _attackDamage = damage; _attackRange = range; _currentAttackRange = range; _currentAttackDamage = damage; _currentAttackDelay = delay; _faction = fact; _allowedToMove = true; }
/// <summary> /// Default Constructor for the Type Mapper. /// </summary> /// <param name="faction">Faction</param> /// <param name="item">Item</param> /// <param name="interop">UnitInterop</param> public RecognitionInterop(Faction faction, FactionItem item, UnitInterop interop) : base(faction, item, interop) { // Get Sniffer Reference var sniffer = Item.GetProperty<SnifferProperty>(); if (sniffer == null) throw new ArgumentException("Item does not contain SnifferProperty"); // Insert sniffed Items into the List. sniffer.OnNewSmellableItem += property => { var info = property.Item.GetItemInfo(Item); if (!smellableItems.Contains(info)) smellableItems.Add(info); }; // Remove sniffed Items from List. sniffer.OnLostSmellableItem += property => { var info = property.Item.GetItemInfo(Item); if (smellableItems.Contains(info)) smellableItems.Remove(info); }; // Get Sighting Property sighting = Item.GetProperty<SightingProperty>(); if (sighting == null) throw new ArgumentException("Item does not contain SightingProperty"); // Add visible items to List. sighting.OnNewVisibleItem += property => { var info = property.Item.GetItemInfo(Item); if (!visibleItems.Contains(info)) visibleItems.Add(info); }; // Remove visible Items from List. sighting.OnLostVisibleItem += property => { var info = property.Item.GetItemInfo(Item); if (visibleItems.Contains(info)) visibleItems.Remove(info); }; // Set new Environment on Cell Switch sighting.OnEnvironmentChanged += (i, value) => { if (OnEnvironmentChanged != null) OnEnvironmentChanged(value); }; }
public static Missile FromWeapon(Weapon weapon, Vector2 start, Vector2 target, TimeSpan timeStart, Faction faction, GameTime gameTime) { switch (weapon) { case Weapon.Gun: return new Gun(start, target, timeStart, faction, gameTime); case Weapon.Grenade: break; case Weapon.Mine: break; } return new Gun(start, target, timeStart, faction, gameTime); }
public void Fire(Faction faction, Transform target, float damageMultiplier = 1f) { bool hasAmmo = characterAmmoSlot.count != 0; if (chambered && hasAmmo) { StartCoroutine (DoFire (faction, target, damageMultiplier)); }else if (!hasAmmo && !isReloading) { Game.AddMessage (character.unitName + " is reloading!"); isReloading = true; InvokeReload (); } }
public void SetFaction(Faction faction) { this.faction = faction; }
public override void Generate(Map map, GenStepParams parms) { CellRect rectToDefend; if (!MapGenerator.TryGetVar <CellRect>("RectOfInterest", out rectToDefend)) { rectToDefend = CellRect.SingleCell(map.Center); } TerrainDef floorDef = TerrainDef.Named("FlagstoneGranite"); // rp.floorDef ?? BaseGenUtility.CorrespondingTerrainDef(thingDef, true); Faction faction = Find.FactionManager.FirstFactionOfDef(DwarfDefOf.LotRD_MonsterFaction); ResolveParams rp = default(ResolveParams); rp.rect = this.GetOutpostRect(rectToDefend, map); rp.rect = rp.rect.ExpandedBy(30); Log.Message(rp.rect.minX.ToString() + " " + rp.rect.minZ.ToString()); rp.faction = faction; rp.floorDef = floorDef; rp.wallStuff = ThingDefOf.BlocksGranite; rp.pathwayFloorDef = TerrainDef.Named("SilverTile"); rp.edgeDefenseWidth = new int?(2); rp.edgeDefenseTurretsCount = 0; // new int?(Rand.RangeInclusive(0, 1)); rp.edgeDefenseMortarsCount = new int?(0); rp.settlementPawnGroupPoints = new float?(0.4f); rp.chanceToSkipWallBlock = 0.1f; BaseGen.globalSettings.map = map; // BaseGen.globalSettings.minBuildings = 1; // BaseGen.globalSettings.minBarracks = 1; // BaseGen.symbolStack.Push("factionBase", resolveParams); Lord singlePawnLord = rp.singlePawnLord ?? LordMaker.MakeNewLord(faction, new LordJob_DefendPoint(rp.rect.CenterCell), map, null); BaseGen.symbolStack.Push("outdoorLighting", rp); ResolveParams resolveParams3 = rp; Pawn pawn = PawnGenerator.GeneratePawn(DwarfDefOf.LotRD_DragonFireDrake, faction); resolveParams3.singlePawnToSpawn = pawn; resolveParams3.rect = new CellRect(rp.rect.CenterCell.x, rp.rect.CenterCell.z, 5, 5); resolveParams3.singlePawnLord = singlePawnLord; BaseGen.symbolStack.Push("pawn", resolveParams3); ThingDef thingDef = ThingDefOf.BlocksGranite; //rp.wallStuff ?? BaseGenUtility.RandomCheapWallStuff(rp.faction, false); ///Dragon Room var dragonRoomParams = default(ResolveParams); var dragonRoomRect = rp.rect.ContractedBy(Rand.Range(20, 25)); //Rubble strewn about ResolveParams rubbleEverywhere = rp; rubbleEverywhere.rect = rp.rect.ContractedBy(1); rubbleEverywhere.filthDef = ThingDefOf.Filth_RubbleBuilding; rubbleEverywhere.chanceToSkipFloor = 0.25f; BaseGen.symbolStack.Push("filthMaker", rubbleEverywhere); //Corpses strewn about ResolveParams corpsesEverywhere = rp; corpsesEverywhere.rect = dragonRoomRect.ContractedBy(1); corpsesEverywhere.hivesCount = Rand.Range(12, 18); corpsesEverywhere.faction = Find.FactionManager.RandomEnemyFaction(); BaseGen.symbolStack.Push("corpseMaker", corpsesEverywhere); //Corpses strewn about (2) ResolveParams corpsesEverywhereTwo = rp; corpsesEverywhereTwo.rect = rp.rect.ContractedBy(1); corpsesEverywhereTwo.hivesCount = Rand.Range(12, 18); corpsesEverywhereTwo.faction = Find.FactionManager.RandomEnemyFaction(); BaseGen.symbolStack.Push("corpseMaker", corpsesEverywhereTwo); //Just place a dwaven throne. ResolveParams throneArea = rp; throneArea.rect = CellRect.SingleCell(BottomHalf(dragonRoomRect).CenterCell); throneArea.singleThingDef = ThingDef.Named("LotRD_DwarvenThrone"); throneArea.singleThingStuff = ThingDefOf.BlocksGranite; BaseGen.symbolStack.Push("thing", throneArea); //Gold coins strewn about ResolveParams coinsEverywhere = rp; coinsEverywhere.rect = BottomHalf(dragonRoomRect).ContractedBy(4); coinsEverywhere.filthDef = ThingDef.Named("LotRD_Filth_GoldCoins"); coinsEverywhere.chanceToSkipFloor = 0f; coinsEverywhere.filthDensity = new FloatRange(1, 5); coinsEverywhere.streetHorizontal = true; BaseGen.symbolStack.Push("filthMaker", coinsEverywhere); //Dragon horde ResolveParams dragonHorde = rp; dragonHorde.rect = BottomHalf(dragonRoomRect).ContractedBy(5); //new CellRect(dragonRoomRect.minX, (int)(dragonRoomRect.minZ + dragonRoomRect.Height / 2f), dragonRoomRect.Width, (int)(dragonRoomRect.Height / 2f)); dragonHorde.thingSetMakerDef = DwarfDefOf.LotRD_Treasure; var newParamsForItemGen = new ThingSetMakerParams(); newParamsForItemGen.countRange = new IntRange(15, 20); newParamsForItemGen.maxThingMarketValue = Rand.Range(10000, 15000); dragonHorde.thingSetMakerParams = newParamsForItemGen; dragonHorde.singleThingStackCount = 250; BaseGen.symbolStack.Push("stockpile", dragonHorde); // dragonRoomParams.rect = dragonRoomRect; BaseGen.symbolStack.Push("roof", dragonRoomParams); ResolveParams dragonDoorParams = dragonRoomParams; dragonDoorParams.rect = dragonRoomRect; BaseGen.symbolStack.Push("doors", dragonDoorParams); dragonDoorParams.rect = dragonRoomRect; ResolveParams dragonRoomWalls = dragonRoomParams; dragonRoomWalls.rect = dragonRoomRect; dragonRoomWalls.wallStuff = thingDef; dragonRoomWalls.floorDef = floorDef; dragonRoomWalls.chanceToSkipWallBlock = 0.25f; BaseGen.symbolStack.Push("edgeWalls", dragonRoomWalls); BaseGen.symbolStack.Push("clear", dragonRoomParams); /// /// Abandoned Dwarven Mountain Fortress int num = 0; int? edgeDefenseWidth = rp.edgeDefenseWidth; float num2 = (float)rp.rect.Area / 144f * 0.17f; BaseGen.globalSettings.minEmptyNodes = ((num2 >= 1f) ? GenMath.RoundRandom(num2) : 0); TraverseParms traverseParms = TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false); ResolveParams abandonedBase = rp; abandonedBase.rect = rp.rect; abandonedBase.faction = faction; ResolveParams resolveParams4 = abandonedBase; resolveParams4.rect = rp.rect.ContractedBy(num + 10); resolveParams4.faction = faction; BaseGen.symbolStack.Push("ensureCanReachMapEdge", resolveParams4); ResolveParams resolveParams5 = abandonedBase; resolveParams5.rect = rp.rect.ContractedBy(num + 10); resolveParams5.faction = faction; resolveParams5.wallStuff = thingDef; resolveParams5.floorDef = floorDef; BaseGen.symbolStack.Push("basePart_outdoors", resolveParams5); /// ///Four Corners -- Four Guardtowers for (int i = 0; i < 3; i++) { IntVec3 towerCorner = rp.rect.Corners.ElementAt(i); CellRect towerRect = new CellRect(towerCorner.x, towerCorner.z, 10, 10); var towerParams = default(ResolveParams); towerParams.rect = towerRect; BaseGen.symbolStack.Push("roof", towerRect); ResolveParams towerDoorParams = towerParams; towerDoorParams.rect = towerRect; BaseGen.symbolStack.Push("doors", towerDoorParams); towerDoorParams.rect = towerRect; ResolveParams towerWallParams = towerParams; towerWallParams.rect = towerRect; towerWallParams.wallStuff = thingDef; towerWallParams.floorDef = floorDef; towerWallParams.chanceToSkipWallBlock = 0.1f; BaseGen.symbolStack.Push("edgeWalls", towerWallParams); BaseGen.symbolStack.Push("clear", towerParams); } BaseGen.symbolStack.Push("roof", rp); ResolveParams doorParams = rp; BaseGen.symbolStack.Push("doors", doorParams); ResolveParams resolveParams = rp; resolveParams.wallStuff = thingDef; resolveParams.chanceToSkipWallBlock = 0.1f; BaseGen.symbolStack.Push("edgeWalls", resolveParams); ResolveParams thickwallParams = rp; thickwallParams.rect = thickwallParams.rect.ContractedBy(1); thickwallParams.wallStuff = thingDef; thickwallParams.chanceToSkipWallBlock = 0.3f; BaseGen.symbolStack.Push("edgeWalls", thickwallParams); ResolveParams dthickwallParams = thickwallParams; dthickwallParams.rect = dthickwallParams.rect.ContractedBy(1); dthickwallParams.chanceToSkipWallBlock = 0.6f; BaseGen.symbolStack.Push("edgeWalls", dthickwallParams); ResolveParams resolveParams2 = rp; resolveParams2.floorDef = floorDef; BaseGen.symbolStack.Push("floor", resolveParams2); BaseGen.symbolStack.Push("clear", rp); if (rp.addRoomCenterToRootsToUnfog != null && rp.addRoomCenterToRootsToUnfog.Value && Current.ProgramState == ProgramState.MapInitializing) { MapGenerator.rootsToUnfog.Add(rp.rect.CenterCell); } Log.Message("generated dragon lair"); BaseGen.Generate(); }
/// <summary> /// preform the requested transform /// </summary> /// <param name="request">The request.</param> /// <returns></returns> protected override MergedPawns TransformImpl(TransformationRequest request) { Pawn firstPawn = request.originals[0]; Pawn secondPawn = request.originals[1]; float averageAge = firstPawn.ageTracker.AgeBiologicalYearsFloat + secondPawn.ageTracker.AgeBiologicalYearsFloat; averageAge /= 2; float newAge = averageAge * request.outputDef.race.race.lifeExpectancy / firstPawn.RaceProps.lifeExpectancy; Faction faction = request.forcedFaction ?? Faction.OfPlayer; var pRequest = FormerHumanUtilities.CreateMergedAnimalRequest(request.outputDef, request.originals, faction); Pawn meldToSpawn = PawnGenerator.GeneratePawn(pRequest); HediffDef hediffToAdd = HediffDef.Named(FORMER_HUMAN_HEDIFF); //make sure hediff is added before spawning meld //make them count as former humans var tracker = meldToSpawn.GetSapienceTracker(); if (tracker == null) { Log.Error($"{meldToSpawn.def.defName} is a meld but does not have a former human tracker!"); } else { GiveTransformedPawnSapienceState(meldToSpawn, 1); } Hediff hediff = HediffMaker.MakeHediff(hediffToAdd, meldToSpawn); hediff.Severity = Rand.Range(request.minSeverity, request.maxSeverity); meldToSpawn.health.AddHediff(hediff); Pawn_NeedsTracker needs = meldToSpawn.needs; needs.food.CurLevel = firstPawn.needs.food.CurLevel; needs.rest.CurLevel = firstPawn.needs.rest.CurLevel; meldToSpawn.training.SetWantedRecursive(TrainableDefOf.Obedience, true); meldToSpawn.training.Train(TrainableDefOf.Obedience, null, true); meldToSpawn.Name = firstPawn.Name; var meld = (Pawn)GenSpawn.Spawn(meldToSpawn, firstPawn.PositionHeld, firstPawn.MapHeld); for (var i = 0; i < 10; i++) { IntermittentMagicSprayer.ThrowMagicPuffDown(meld.Position.ToVector3(), meld.MapHeld); IntermittentMagicSprayer.ThrowMagicPuffUp(meld.Position.ToVector3(), meld.MapHeld); } meld.SetFaction(Faction.OfPlayer); ReactionsHelper.OnPawnsMerged(firstPawn, firstPawn.IsPrisoner, secondPawn, secondPawn.IsPrisoner, meld); MergedPawnUtilities.TransferToMergedPawn(request.originals, meld); //apply any other post tf effects ApplyPostTfEffects(request.originals[0], meld, request); TransformerUtility.CleanUpHumanPawnPostTf(firstPawn, null); TransformerUtility.CleanUpHumanPawnPostTf(secondPawn, null); var inst = new MergedPawns(request.transformedTick) { originals = request.originals.ToList(), //we want to make a copy here meld = meld, mutagenDef = def, factionResponsible = Faction.OfPlayer }; return(inst); }
/*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target ) * { * if ( from == GuildStatus.Waring && target == GuildStatus.Waring ) * return true; * * return false; * }*/ public static bool Mobile_AllowBeneficial(Mobile from, Mobile target) { if (from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player) { return(true); } #region Dueling PlayerMobile pmFrom = from as PlayerMobile; PlayerMobile pmTarg = target as PlayerMobile; if (pmFrom == null && from is BaseCreature) { BaseCreature bcFrom = (BaseCreature)from; if (bcFrom.Summoned) { pmFrom = bcFrom.SummonMaster as PlayerMobile; } } if (pmTarg == null && target is BaseCreature) { BaseCreature bcTarg = (BaseCreature)target; if (bcTarg.Summoned) { pmTarg = bcTarg.SummonMaster as PlayerMobile; } } if (pmFrom != null && pmTarg != null) { // only check this if one of them hasn't been eliminated if ((pmFrom.DuelPlayer != null && !pmFrom.DuelPlayer.Eliminated) || (pmTarg.DuelPlayer != null && !pmTarg.DuelPlayer.Eliminated)) { if (pmFrom.DuelContext != pmTarg.DuelContext && ((pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg.DuelContext != null && pmTarg.DuelContext.Started))) { return(false); } if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated)) { return(false); } if (pmFrom.DuelPlayer != null && !pmFrom.DuelPlayer.Eliminated && pmFrom.DuelContext != null && pmFrom.DuelContext.IsSuddenDeath) { return(false); } if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant) { return(false); } if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started) { return(true); } } } if ((pmFrom != null && pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg != null && pmTarg.DuelContext != null && pmTarg.DuelContext.Started)) { return(false); } Engines.ConPVP.SafeZone sz = from.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) as Engines.ConPVP.SafeZone; if (sz != null /*&& sz.IsDisabled()*/) { return(false); } sz = target.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) as Engines.ConPVP.SafeZone; if (sz != null /*&& sz.IsDisabled()*/) { return(false); } #endregion #region Factions Faction targetFaction = Faction.Find(target, true); if (targetFaction != null) { if (Faction.Find(from, true) != targetFaction) { return(false); } } #endregion Map map = from.Map; if (map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0) { return(true); // In felucca, anything goes } if (!from.Player) { return(true); // NPCs have no restrictions } if (target is BaseCreature && !((BaseCreature)target).Controlled) { return(false); // Players cannot heal uncontrolled mobiles } if (from is PlayerMobile && ((PlayerMobile)from).Young && (!(target is PlayerMobile) || !((PlayerMobile)target).Young)) { return(false); // Young players cannot perform beneficial actions towards older players } Guild fromGuild = from.Guild as Guild; Guild targetGuild = target.Guild as Guild; if (fromGuild != null && targetGuild != null && (targetGuild == fromGuild || fromGuild.IsAlly(targetGuild))) { return(true); // Guild members can be beneficial } return(CheckBeneficialStatus(GetGuildStatus(from), GetGuildStatus(target))); }
public static ReanimatedPawn DoGenerateZombiePawnFromSource(Pawn sourcePawn, bool isBerserk = true, bool oathOfHastur = false) { PawnKindDef pawnKindDef = PawnKindDef.Named("ReanimatedCorpse"); Faction factionDirect = isBerserk ? Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile) : Faction.OfPlayer; ReanimatedPawn pawn = (ReanimatedPawn)ThingMaker.MakeThing(pawnKindDef.race, null); try { pawn.kindDef = pawnKindDef; pawn.SetFactionDirect(factionDirect); PawnComponentsUtility.CreateInitialComponents(pawn); pawn.gender = sourcePawn.gender; pawn.ageTracker.AgeBiologicalTicks = sourcePawn.ageTracker.AgeBiologicalTicks; pawn.ageTracker.AgeChronologicalTicks = sourcePawn.ageTracker.AgeChronologicalTicks; pawn.workSettings = new Pawn_WorkSettings(pawn); if (pawn.workSettings != null && sourcePawn.Faction.IsPlayer) { pawn.workSettings.EnableAndInitialize(); } pawn.needs.SetInitialLevels(); //Add hediffs? //Add relationships? if (pawn.RaceProps.Humanlike) { pawn.story.melanin = sourcePawn.story.melanin; pawn.story.crownType = sourcePawn.story.crownType; pawn.story.hairColor = sourcePawn.story.hairColor; pawn.story.childhood = sourcePawn.story.childhood; pawn.story.adulthood = sourcePawn.story.adulthood; pawn.story.bodyType = sourcePawn.story.bodyType; pawn.story.hairDef = sourcePawn.story.hairDef; if (!oathOfHastur) { foreach (Trait current in sourcePawn.story.traits.allTraits) { pawn.story.traits.GainTrait(current); } } else { pawn.story.traits.GainTrait(new Trait(TraitDef.Named("Cults_OathtakerHastur2"), 0, true)); pawn.story.traits.GainTrait(new Trait(TraitDefOf.Psychopath, 0, true)); SkillFixer(pawn, sourcePawn); RelationshipFixer(pawn, sourcePawn); AddedPartFixer(pawn, sourcePawn); } //pawn.story.GenerateSkillsFromBackstory(); NameTriple nameTriple = sourcePawn.Name as NameTriple; if (!oathOfHastur) { pawn.Name = new NameTriple(nameTriple.First, string.Concat(new string[] { "* ", Translator.Translate("Reanimated"), " ", nameTriple.Nick, " *" }), nameTriple.Last); } else { pawn.Name = nameTriple; } } string headGraphicPath = sourcePawn.story.HeadGraphicPath; typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pawn.story, headGraphicPath); GenerateZombieApparelFromSource(pawn, sourcePawn); PawnGenerationRequest con = new PawnGenerationRequest(); PawnInventoryGenerator.GenerateInventoryFor(pawn, con); GiveZombieSkinEffect(pawn, sourcePawn as ReanimatedPawn, oathOfHastur); if (isBerserk) { pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk); } //Log.Message(pawn.Name.ToStringShort); return(pawn); } catch (Exception e) { Cthulhu.Utility.DebugReport(e.ToString()); } return(null); }
public void PlacePiece(int row, int col, Faction faction) { grid[row, col] = faction; }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Widgets.Label(new Rect(0, 0, 290, 20), Translator.Translate("DownedRefugeeMenuTitle")); Widgets.Label(new Rect(0, 40, 400, 20), Translator.Translate("ThreatTypes")); int size2 = DefDatabase <SitePartDef> .AllDefsListForReading.Count * 25; Rect scrollRectFact = new Rect(0, 65, 485, 200); Rect scrollVertRectFact = new Rect(0, 0, scrollRectFact.x, size2); Widgets.BeginScrollView(scrollRectFact, ref scroll, scrollVertRectFact); int x = 0; foreach (var sitePart in DefDatabase <SitePartDef> .AllDefsListForReading) { if (Widgets.RadioButtonLabeled(new Rect(0, x, 480, 20), sitePart.defName, parts.Contains(sitePart))) { if (parts.Contains(sitePart)) { parts.Remove(sitePart); } else { parts.Add(sitePart); } } x += 22; } Widgets.EndScrollView(); if (Widgets.ButtonText(new Rect(0, 240, 490, 20), Translator.Translate("OpenPawnMenu"))) { DrawPawnMenu(); } Widgets.Label(new Rect(0, 270, 490, 20), $"Pawns: {pawnList.Count}"); Widgets.Label(new Rect(0, 300, 490, 20), Translator.Translate("DurationTimeDaysLump")); time = Widgets.TextField(new Rect(0, 300, 480, 20), time); Widgets.Label(new Rect(0, 330, 100, 40), Translator.Translate("ThreatPoint")); Widgets.TextFieldNumeric(new Rect(110, 330, 370, 20), ref threatsFloat, ref threats, 0, 2000000); Widgets.Label(new Rect(0, 365, 290, 20), Translator.Translate("FactionForSort")); int factionDefSize = Find.FactionManager.AllFactionsListForReading.Count * 25; Rect scrollRectFact3 = new Rect(0, 390, 490, 110); Rect scrollVertRectFact3 = new Rect(0, 0, scrollRectFact3.x, factionDefSize); Widgets.BeginScrollView(scrollRectFact3, ref scroll2, scrollVertRectFact3); x = 0; foreach (var spawnedFaction in Find.FactionManager.AllFactionsListForReading) { if (Widgets.ButtonText(new Rect(0, x, 485, 20), spawnedFaction.Name)) { selectedFaction = spawnedFaction; } x += 22; } Widgets.EndScrollView(); Widgets.Label(new Rect(0, 510, 290, 20), $"Selected tile ID: {Find.WorldSelector.selectedTile}"); if (Widgets.ButtonText(new Rect(0, 550, 490, 20), Translator.Translate("AddNewDownedRefugee"))) { AddNewDownedRefugee(); } }
public static void DrawFactionWarBar(Rect fillRect) { if (!Find.World.GetComponent <WorldComponent_MFI_FactionWar>().StuffIsGoingDown) { return; } Faction factionOne = Find.World.GetComponent <WorldComponent_MFI_FactionWar>().WarringFactionOne; Faction factionInstigator = Find.World.GetComponent <WorldComponent_MFI_FactionWar>().WarringFactionTwo; Rect position = new Rect(fillRect.x, fillRect.y, fillRect.width, fillRect.height); GUI.BeginGroup(position); Text.Font = GameFont.Small; GUI.color = Color.white; //4 boxes: faction name and faction call label. Rect leftFactionLabel = new Rect(x: 0f, y: 0f, width: position.width / 2f, height: TitleHeight); Rect leftBox = new Rect(x: 0f, y: leftFactionLabel.yMax, width: leftFactionLabel.width, height: InfoHeight); Rect rightFactionLabel = new Rect(x: position.width / 2f, y: 0f, width: position.width / 2f, height: TitleHeight); Rect rightBox = new Rect(x: position.width / 2f, y: leftFactionLabel.yMax, width: leftFactionLabel.width, height: InfoHeight); //big central box Rect centreBoxForBigFactionwar = new Rect(0f, leftFactionLabel.yMax, width: position.width, height: TitleHeight); Text.Font = GameFont.Medium; GUI.color = Color.cyan; Text.Anchor = TextAnchor.MiddleCenter; string factionWarStatus = Find.World.GetComponent <WorldComponent_MFI_FactionWar>().WarIsOngoing ? "MFI_FactionWarProgress".Translate() : "MFI_UnrestIsBrewing".Translate(); Widgets.Label(centreBoxForBigFactionwar, factionWarStatus); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; //"score card" bar Rect leftFactionOneScoreBox = new Rect(0f, yPositionBar, position.width * Find.World.GetComponent <WorldComponent_MFI_FactionWar>().ScoreForFaction(factionOne), barHeight); GUI.DrawTexture(leftFactionOneScoreBox, FactionOneColorTexture(factionOne)); Rect rightFactionTwoScoreBox = new Rect(position.width * Find.World.GetComponent <WorldComponent_MFI_FactionWar>().ScoreForFaction(factionOne), yPositionBar, position.width * Find.World.GetComponent <WorldComponent_MFI_FactionWar>().ScoreForFaction(factionInstigator), barHeight); GUI.DrawTexture(rightFactionTwoScoreBox, FactionTwoColorTexture(factionInstigator)); //stuff that fills up and does the faction name and call label boxes. Text.Font = GameFont.Medium; Widgets.Label(rect: leftFactionLabel, label: factionOne.GetCallLabel()); Text.Anchor = TextAnchor.UpperRight; Widgets.Label(rect: rightFactionLabel, label: factionInstigator.GetCallLabel()); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; GUI.color = new Color(r: 1f, g: 1f, b: 1f, a: 0.7f); Widgets.Label(rect: leftBox, label: factionOne.GetInfoText()); if (factionOne != null) { FactionRelationKind playerRelationKind = factionOne.PlayerRelationKind; GUI.color = playerRelationKind.GetColor(); Rect factionOneRelactionBox = new Rect(x: leftBox.x, y: leftBox.y + Text.CalcHeight(text: factionOne.GetInfoText(), width: leftBox.width) + Text.SpaceBetweenLines, width: leftBox.width, height: 30f); Widgets.Label(rect: factionOneRelactionBox, label: playerRelationKind.GetLabel()); } GUI.color = new Color(r: 1f, g: 1f, b: 1f, a: 0.7f); Text.Anchor = TextAnchor.UpperRight; Widgets.Label(rect: rightBox, label: factionInstigator.GetInfoText()); if (factionInstigator != null) { FactionRelationKind playerRelationKind = factionInstigator.PlayerRelationKind; GUI.color = playerRelationKind.GetColor(); Rect factionInstigatorRelactionBox = new Rect(x: rightBox.x, y: rightBox.y + Text.CalcHeight(text: factionInstigator.GetInfoText(), width: rightBox.width) + Text.SpaceBetweenLines, width: rightBox.width, height: 30f); Widgets.Label(rect: factionInstigatorRelactionBox, label: playerRelationKind.GetLabel()); } Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; GUI.EndGroup(); }
public static bool TryAffectGoodwillWith_Reduction_Prefix(Faction __instance, Faction other, ref int goodwillChange, bool canSendMessage = true, bool canSendHostilityLetter = true, string reason = null, GlobalTargetInfo?lookTarget = default(GlobalTargetInfo?)) { //if((__instance.IsPlayer || other.IsPlayer)) //{ // if (reason == null || (reason != null && reason != "Rim War")) // { // goodwillChange = Mathf.RoundToInt(goodwillChange / 5); // } //} return(true); }
private static bool Prefix(Faction __instance, List <FactionRelation> ___relations, Faction other, ref FactionRelation __result, bool allowNull = false) { if (other == __instance) { return(true); } for (int i = 0; i < ___relations.Count; i++) { if (___relations[i].other == other) { __result = ___relations[i]; return(false); } } if (!allowNull) { WorldUtility.CreateFactionRelation(__instance, other); //Log.Message("forced faction relation between " + __instance.Name + " and " + other.Name); } return(true); }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Widgets.Label(new Rect(0, 0, 290, 20), Translator.Translate("PreciousLumpMenuTitle")); Widgets.Label(new Rect(0, 40, 80, 20), Translator.Translate("ResourceType")); if (Widgets.ButtonText(new Rect(90, 40, 200, 20), resource.label)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (var thing in DefDatabase <ThingDef> .AllDefsListForReading) { if (thing.mineable) { list.Add(new FloatMenuOption(thing.defName, delegate { resource = thing; })); } } Find.WindowStack.Add(new FloatMenu(list)); } Widgets.Label(new Rect(0, 70, 290, 20), Translator.Translate("DurationTimeDaysLump")); time = Widgets.TextField(new Rect(0, 95, 280, 20), time); Widgets.Label(new Rect(0, 125, 80, 20), Translator.Translate("ThreatType")); if (Widgets.ButtonText(new Rect(90, 125, 200, 20), part.defName)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (var p in DefDatabase <SitePartDef> .AllDefsListForReading) { list.Add(new FloatMenuOption(p.defName, delegate { part = p; })); } Find.WindowStack.Add(new FloatMenu(list)); } int factionDefSize = Find.FactionManager.AllFactionsListForReading.Count * 25; Rect scrollRectFact3 = new Rect(310, 40, 280, 200); Rect scrollVertRectFact3 = new Rect(0, 0, scrollRectFact3.x, factionDefSize); Widgets.BeginScrollView(scrollRectFact3, ref scroll2, scrollVertRectFact3); int x = 0; foreach (var spawnedFaction in Find.FactionManager.AllFactionsListForReading) { if (Widgets.ButtonText(new Rect(0, x, 290, 20), spawnedFaction.Name)) { selectedFaction = spawnedFaction; } x += 22; } Widgets.EndScrollView(); Widgets.Label(new Rect(0, 155, 100, 40), Translator.Translate("ThreatPoint")); Widgets.TextFieldNumeric(new Rect(110, 155, 170, 20), ref threatsFloat, ref threats, 0, 2000000); Widgets.Label(new Rect(0, 210, 290, 20), $"Selected tile ID: {Find.WorldSelector.selectedTile}"); if (Widgets.ButtonText(new Rect(0, 240, 620, 20), Translator.Translate("AddNewItemStash"))) { AddLump(); } }
public override int MinShipCost(Faction faction) { return(12); }
public Warrior(string name, Faction faction) : base(name, BASE_HEALTH, BASE_ARMOR, ABILITY_POINTS, new Satchel(), faction) { }
public static void AddFaction(Faction factionType) { playerFactions.Add(factionType); }
public Warrior(string name, Faction faction) : base(name, WarriorBaseHealth, WarriorBaseArmor, WarriorAbilityPoints, new Satchel(), faction) { }
private Item TryStealItem(Item toSteal, ref bool caught) { Item stolen = null; object root = toSteal.RootParent; StealableArtifactsSpawner.StealableInstance si = null; if (toSteal.Parent == null || !toSteal.Movable) { si = toSteal is AddonComponent?StealableArtifactsSpawner.GetStealableInstance(((AddonComponent)toSteal).Addon) : StealableArtifactsSpawner.GetStealableInstance(toSteal); } if (!IsEmptyHanded(m_Thief)) { m_Thief.SendLocalizedMessage(1005584); // Both hands must be free to steal. } else if (root is Mobile && ((Mobile)root).Player && !IsInGuild(m_Thief)) { m_Thief.SendLocalizedMessage(1005596); // You must be in the thieves guild to steal from other players. } else if (SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild(m_Thief) && m_Thief.Kills > 0) { m_Thief.SendLocalizedMessage(502706); // You are currently suspended from the thieves guild. } else if (root is BaseVendor && ((BaseVendor)root).IsInvulnerable) { m_Thief.SendLocalizedMessage(1005598); // You can't steal from shopkeepers. } else if (root is PlayerVendor) { m_Thief.SendLocalizedMessage(502709); // You can't steal from vendors. } else if (!m_Thief.CanSee(toSteal)) { m_Thief.SendLocalizedMessage(500237); // Target can not be seen. } else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, toSteal, false, true)) { m_Thief.SendLocalizedMessage(1048147); // Your backpack can't hold anything else. } #region Sigils else if (toSteal is Sigil) { PlayerState pl = PlayerState.Find(m_Thief); Faction faction = (pl == null ? null : pl.Faction); Sigil sig = (Sigil)toSteal; if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1)) { m_Thief.SendLocalizedMessage(502703); // You must be standing next to an item to steal it. } else if (root != null) // not on the ground { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if (faction != null) { if (!m_Thief.CanBeginAction(typeof(IncognitoSpell))) { m_Thief.SendLocalizedMessage(1010581); // You cannot steal the sigil when you are incognito } else if (DisguiseTimers.IsDisguised(m_Thief)) { m_Thief.SendLocalizedMessage(1010583); // You cannot steal the sigil while disguised } else if (!m_Thief.CanBeginAction(typeof(PolymorphSpell))) { m_Thief.SendLocalizedMessage(1010582); // You cannot steal the sigil while polymorphed } else if (TransformationSpellHelper.UnderTransformation(m_Thief)) { m_Thief.SendLocalizedMessage(1061622); // You cannot steal the sigil while in that form. } else if (AnimalForm.UnderTransformation(m_Thief)) { m_Thief.SendLocalizedMessage(1063222); // You cannot steal the sigil while mimicking an animal. } else if (pl.IsLeaving) { m_Thief.SendLocalizedMessage(1005589); // You are currently quitting a faction and cannot steal the town sigil } else if (sig.IsBeingCorrupted && sig.LastMonolith.Faction == faction) { m_Thief.SendLocalizedMessage(1005590); // You cannot steal your own sigil } else if (sig.IsPurifying) { m_Thief.SendLocalizedMessage(1005592); // You cannot steal this sigil until it has been purified } else if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, 80.0, 80.0)) { if (Sigil.ExistsOn(m_Thief)) { m_Thief.SendLocalizedMessage(1010258); // The sigil has gone back to its home location because you already have a sigil. } else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, sig, false, true)) { m_Thief.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full } else { if (sig.IsBeingCorrupted) { sig.GraceStart = DateTime.UtcNow; // begin grace period } m_Thief.SendLocalizedMessage(1010586); // YOU STOLE THE SIGIL!!! (woah, calm down now) if (sig.LastMonolith != null && sig.LastMonolith.Sigil != null) { sig.LastMonolith.Sigil = null; sig.LastStolen = DateTime.UtcNow; } return(sig); } } else { m_Thief.SendLocalizedMessage(1005594); // You do not have enough skill to steal the sigil } } else { m_Thief.SendLocalizedMessage(1005588); // You must join a faction to do that } } #endregion #region VvV Sigils else if (toSteal is VvVSigil && ViceVsVirtueSystem.Instance != null) { VvVPlayerEntry entry = ViceVsVirtueSystem.Instance.GetPlayerEntry <VvVPlayerEntry>(m_Thief); VvVSigil sig = (VvVSigil)toSteal; if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1)) { m_Thief.SendLocalizedMessage(502703); // You must be standing next to an item to steal it. } else if (root != null) // not on the ground { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if (entry != null) { if (!m_Thief.CanBeginAction(typeof(IncognitoSpell))) { m_Thief.SendLocalizedMessage(1010581); // You cannot steal the sigil when you are incognito } else if (DisguiseTimers.IsDisguised(m_Thief)) { m_Thief.SendLocalizedMessage(1010583); // You cannot steal the sigil while disguised } else if (!m_Thief.CanBeginAction(typeof(PolymorphSpell))) { m_Thief.SendLocalizedMessage(1010582); // You cannot steal the sigil while polymorphed } else if (TransformationSpellHelper.UnderTransformation(m_Thief)) { m_Thief.SendLocalizedMessage(1061622); // You cannot steal the sigil while in that form. } else if (AnimalForm.UnderTransformation(m_Thief)) { m_Thief.SendLocalizedMessage(1063222); // You cannot steal the sigil while mimicking an animal. } else if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, 100.0, 120.0)) { if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, sig, false, true)) { m_Thief.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full } else { m_Thief.SendLocalizedMessage(1010586); // YOU STOLE THE SIGIL!!! (woah, calm down now) sig.OnStolen(entry); return(sig); } } else { m_Thief.SendLocalizedMessage(1005594); // You do not have enough skill to steal the sigil } } else { m_Thief.SendLocalizedMessage(1155415); // Only participants in Vice vs Virtue may use this item. } } #endregion else if (si == null && (toSteal.Parent == null || !toSteal.Movable) && !ItemFlags.GetStealable(toSteal)) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if ((toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed(root)) && !ItemFlags.GetStealable(toSteal)) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if (Core.AOS && si == null && toSteal is Container && !ItemFlags.GetStealable(toSteal)) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1)) { m_Thief.SendLocalizedMessage(502703); // You must be standing next to an item to steal it. } else if (si != null && m_Thief.Skills[SkillName.Stealing].Value < 100.0) { m_Thief.SendLocalizedMessage(1060025, "", 0x66D); // You're not skilled enough to attempt the theft of this item. } else if (toSteal.Parent is Mobile) { m_Thief.SendLocalizedMessage(1005585); // You cannot steal items which are equiped. } else if (root == m_Thief) { m_Thief.SendLocalizedMessage(502704); // You catch yourself red-handed. } else if (root is Mobile && ((Mobile)root).IsStaff()) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if (root is Mobile && !m_Thief.CanBeHarmful((Mobile)root)) { } else if (root is Corpse) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else { double w = toSteal.Weight + toSteal.TotalWeight; if (w > 10) { m_Thief.SendMessage("That is too heavy to steal."); } else { if (toSteal.Stackable && toSteal.Amount > 1) { int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight); if (maxAmount < 1) { maxAmount = 1; } else if (maxAmount > toSteal.Amount) { maxAmount = toSteal.Amount; } int amount = Utility.RandomMinMax(1, maxAmount); if (amount >= toSteal.Amount) { int pileWeight = (int)Math.Ceiling(toSteal.Weight * toSteal.Amount); pileWeight *= 10; if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5)) { stolen = toSteal; } } else { int pileWeight = (int)Math.Ceiling(toSteal.Weight * amount); pileWeight *= 10; if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5)) { stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount); if (stolen == null) { stolen = toSteal; } } } } else { int iw = (int)Math.Ceiling(w); iw *= 10; if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5)) { stolen = toSteal; } } // Non-movable stealable items cannot result in the stealer getting caught if (stolen != null && stolen.Movable) { caught = (m_Thief.Skills[SkillName.Stealing].Value < Utility.Random(150)); } else { caught = false; } if (stolen != null) { m_Thief.SendLocalizedMessage(502724); // You succesfully steal the item. ItemFlags.SetTaken(stolen, true); ItemFlags.SetStealable(stolen, false); stolen.Movable = true; if (si != null) { toSteal.Movable = true; si.Item = null; } } else { m_Thief.SendLocalizedMessage(502723); // You fail to steal the item. } } } return(stolen); }
private void AddNewDownedRefugee() { if (pawnList.Count == 0) { Messages.Message($"Select minimum 1 pawn", MessageTypeDefOf.NeutralEvent, false); return; } if (edit) { editSite.parts.Clear(); foreach (var p in parts) { editSite.parts.Add(new SitePart(editSite, p, p.Worker.GenerateDefaultParams(threatsFloat, editSite.Tile, editSite.Faction))); } var pawns = editSite.GetComponent <DownedRefugeeComp>(); pawns.pawn.Clear(); foreach (var p in pawnList) { pawns.pawn.TryAdd(p); } if (!string.IsNullOrEmpty(time) && int.TryParse(time, out int t)) { editSite.GetComponent <TimeoutComp>().StartTimeout(t * 60000); } else { editSite.GetComponent <TimeoutComp>().StartTimeout(-1); } if (selectedFaction != null) { editSite.SetFaction(selectedFaction); } Messages.Message($"Success", MessageTypeDefOf.NeutralEvent, false); return; } if (Find.WorldSelector.selectedTile == -1) { Messages.Message($"Select tile", MessageTypeDefOf.NeutralEvent, false); return; } if (selectedFaction == null) { selectedFaction = Find.FactionManager.AllFactionsListForReading.RandomElement(); } Site site = SiteMaker.MakeSite(parts, Find.WorldSelector.selectedTile, selectedFaction, threatPoints: threatsFloat); site.sitePartsKnown = true; var comp = site.GetComponent <DownedRefugeeComp>(); foreach (var p in pawnList) { comp.pawn.TryAdd(p); } if (!string.IsNullOrEmpty(time) && int.TryParse(time, out int timeInt)) { site.GetComponent <TimeoutComp>().StartTimeout(timeInt * 60000); } Find.WorldObjects.Add(site); }
public static int MobileNotoriety2(Mobile source, Mobile target) { if (Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier)) { return(Notoriety.Invulnerable); } if (target.AccessLevel > AccessLevel.Player) { return(Notoriety.CanBeAttacked); } if (source.Player && !target.Player && source is PlayerMobile && target is BaseCreature) { BaseCreature bc = (BaseCreature)target; Mobile master = bc.GetMaster(); if (master != null && master.AccessLevel > AccessLevel.Player) { return(Notoriety.CanBeAttacked); } master = bc.ControlMaster; if (Core.ML && master != null) { if ((source == master && CheckAggressor(target.Aggressors, source)) || (CheckAggressor(source.Aggressors, bc))) { return(Notoriety.CanBeAttacked); } else { return(MobileNotoriety(source, master)); } } if (!bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType()) { return(Notoriety.Enemy); } } if (target.Kills >= 5 || (target.Body.IsMonster && IsSummoned(target as BaseCreature) && !(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead))) { return(Notoriety.Murderer); } if (target.Criminal) { return(Notoriety.Criminal); } Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target); 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, true, true); if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet) { return(Notoriety.Enemy); } if (SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source)) { return(Notoriety.CanBeAttacked); } if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent)) //If Target is NOT A baseCreature, OR it's a BC and the BC is initial innocent... { if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !(target is PlayerMobile) || !Core.ML && !target.CanBeginAction(typeof(Server.Spells.Seventh.PolymorphSpell))) { return(Notoriety.CanBeAttacked); } } if (CheckAggressor(source.Aggressors, target)) { return(Notoriety.CanBeAttacked); } if (CheckAggressed(source.Aggressed, target)) { return(Notoriety.CanBeAttacked); } if (target is BaseCreature) { BaseCreature bc = (BaseCreature)target; if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source) { return(Notoriety.CanBeAttacked); } } if (source is BaseCreature) { BaseCreature bc = (BaseCreature)source; Mobile master = bc.GetMaster(); if (master != null) { if (CheckAggressor(master.Aggressors, target) || MobileNotoriety(master, target) == Notoriety.CanBeAttacked) { return(Notoriety.CanBeAttacked); } } } return(Notoriety.Innocent); }
void PlaceBuildings2(List <Vector2> factionPoints, Faction fac) { GameObject capital = objectToPlace[0]; //one per faction, can hire troops or get resources GameObject city = objectToPlace[1]; //can hire troops here GameObject village = objectToPlace[2]; //can get resources here fac.SetChallengersToFaction(); //makes sure challengers in list of faction have this faction as their faction //Debug.Log(" length is : " + factionPoints.Count); var result = PickNPoints(factionPoints, 1); //place city float posy = Terrain.activeTerrain.SampleHeight(new Vector3(result.GetFirst()[0].x, 0, result.GetFirst()[0].y)); //finds the y given x and z //generate the object Vector3 capPos = new Vector3(result.GetFirst()[0].x, posy + cubeOffset, result.GetFirst()[0].y); GameObject capitalObj = (GameObject)Instantiate(capital, capPos, Quaternion.identity); Town capitalRef = capitalObj.GetComponent <Town>(); //set capital cities properties capitalRef.Setup(true, 3, 10, fac, capPos); //todo randomise as appropr capitalRef.buildingName = SpawnManager.AssignName(); capitalRef.AddTroops(new Unit(troopPic, 10), 10); //10 as setup is 10 above fac.capital = capitalRef; //sets capital of faction in class factionAPoints = result.GetSecond(); int aSize = factionAPoints.Count; int offset = aSize % 3; //we want every town to have 2 villages so we are splitting array into chunks of 3 VectorTuple threePoints; List <Vector2> t; VectorTuple t2; Vector2 townPoint; List <Vector2> villagePoints; float posY; //int count = 1; for (int i = 0; i < targetPoints / 2; i += 3) { threePoints = PickNPoints(factionAPoints, 3); factionAPoints = threePoints.GetSecond(); t = threePoints.GetFirst(); t2 = PickNPoints(t, 1); townPoint = t2.GetFirst()[0]; //this is the town, the other 2 are the attached smaller villages villagePoints = t2.GetSecond(); posY = Terrain.activeTerrain.SampleHeight(new Vector3(townPoint.x, 0, townPoint.y)); //finds the y given x and z //placing town Vector3 townPos = new Vector3(townPoint.x, posY, townPoint.y); GameObject cityObj = (GameObject)Instantiate(city, townPos, Quaternion.identity); Town cityRef = cityObj.GetComponent <Town>(); //set capital cities properties cityRef.Setup(false, 2, 5, fac, townPos); //todo randomise as appropr cityRef.buildingName = SpawnManager.AssignName(); cityRef.AddTroops(new Unit(troopPic, 5), 5); fac.towns.Add(cityRef); //adds town //place villages //Debug.Log("village length (should be 2): " + villagePoints.Count); foreach (Vector2 v in villagePoints) { float y = Terrain.activeTerrain.SampleHeight(new Vector3(v.x, 0, v.y)); //finds the y given x and z Vector3 pos = new Vector3(v.x, y + cubeOffset, v.y); GameObject villageObj = (GameObject)Instantiate(village, pos, Quaternion.identity); //setup village objects (TODO) Village vilRef = villageObj.GetComponent <Village>(); vilRef.buildingName = SpawnManager.AssignName(); vilRef.Setup(fac, pos); fac.villages.Add(vilRef); } //factionAPoints = threePoints.GetSecond(); // count += 3; } }
public static void Postfix(int tile, Faction faction) { StoryHandler.Notify_Explored(tile); }
// Credit goes to Justin C for the Zombie Apocalypse code. // Taken from Verse.ZombieMod_Utility public static Pawn GenerateZombiePawnFromSource(Pawn sourcePawn) { PawnKindDef pawnKindDef = PawnKindDef.Named("ReanimatedCorpse"); Faction factionDirect = Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile); Pawn pawn = (Pawn)ThingMaker.MakeThing(pawnKindDef.race, null); pawn.kindDef = pawnKindDef; pawn.SetFactionDirect(factionDirect); pawn.pather = new Pawn_PathFollower(pawn); pawn.ageTracker = new Pawn_AgeTracker(pawn); pawn.health = new Pawn_HealthTracker(pawn); pawn.jobs = new Pawn_JobTracker(pawn); pawn.mindState = new Pawn_MindState(pawn); pawn.filth = new Pawn_FilthTracker(pawn); pawn.needs = new Pawn_NeedsTracker(pawn); pawn.stances = new Pawn_StanceTracker(pawn); pawn.natives = new Pawn_NativeVerbs(pawn); PawnComponentsUtility.CreateInitialComponents(pawn); if (pawn.RaceProps.ToolUser) { pawn.equipment = new Pawn_EquipmentTracker(pawn); pawn.carryTracker = new Pawn_CarryTracker(pawn); pawn.apparel = new Pawn_ApparelTracker(pawn); pawn.inventory = new Pawn_InventoryTracker(pawn); } if (pawn.RaceProps.Humanlike) { pawn.ownership = new Pawn_Ownership(pawn); pawn.skills = new Pawn_SkillTracker(pawn); pawn.relations = new Pawn_RelationsTracker(pawn); pawn.story = new Pawn_StoryTracker(pawn); pawn.workSettings = new Pawn_WorkSettings(pawn); } if (pawn.RaceProps.intelligence <= Intelligence.ToolUser) { pawn.caller = new Pawn_CallTracker(pawn); } //pawn.gender = Gender.None; pawn.gender = sourcePawn.gender; Cthulhu.Utility.GenerateRandomAge(pawn, pawn.Map); pawn.needs.SetInitialLevels(); if (pawn.RaceProps.Humanlike) { string headGraphicPath = sourcePawn.story.HeadGraphicPath; typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pawn.story, headGraphicPath); pawn.story.melanin = sourcePawn.story.melanin; pawn.story.crownType = sourcePawn.story.crownType; pawn.story.hairColor = sourcePawn.story.hairColor; NameTriple name = sourcePawn.Name as NameTriple; pawn.Name = name; pawn.story.childhood = sourcePawn.story.childhood; pawn.story.adulthood = sourcePawn.story.adulthood; pawn.story.hairDef = sourcePawn.story.hairDef; foreach (Trait current in sourcePawn.story.traits.allTraits) { pawn.story.traits.GainTrait(current); } //pawn.story.GenerateSkillsFromBackstory(); } GenerateZombieApparelFromSource(pawn, sourcePawn); PawnGenerationRequest con = new PawnGenerationRequest(); PawnInventoryGenerator.GenerateInventoryFor(pawn, con); //Graphic nakedBodyGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(sourcePawn.story.bodyType, ShaderDatabase.CutoutSkin, new Color(0.37f, 0.48f, 0.35f, 1f)); Graphic nakedBodyGraphic = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.bodyType.bodyNakedGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, new Color(0.37f, 0.48f, 0.35f, 1f)); Graphic headGraphic = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.HeadGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, new Color(0.37f, 0.48f, 0.35f, 1f)); Graphic hairGraphic = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, sourcePawn.story.hairColor); pawn.Drawer.renderer.graphics.headGraphic = headGraphic; pawn.Drawer.renderer.graphics.nakedGraphic = nakedBodyGraphic; pawn.Drawer.renderer.graphics.hairGraphic = hairGraphic; return(pawn); }
private void importFactions(DataTable source) { int colGame = -1; int colTitle = -1; int colIconPath = -1; int colColourText = -1; int colColourBackground = -1; #region Map column headers //Determine what the column maps to int counter = 0; foreach (DataColumn col in source.Columns) { String column = col.ColumnName.ToLower(); switch (column) { case "game_name": case "game": case "name": colGame = counter; break; case "faction": case "title": colTitle = counter; break; case "icon": case "iconpath": colIconPath = counter; break; case "text": case "colourtext": case "textcolour": colColourText = counter; break; case "background": case "colourbackground": case "backgroundcolour": colColourBackground = counter; break; default: //TODO: Move this to logging Console.WriteLine("Unhandled column in Faction: {0}", col.ColumnName); break; } counter++; } #endregion #region Process and import data int totalRows = source.Rows.Count; int rowCount = 0; if (colTitle != -1) { foreach (DataRow row in source.Rows) { if (worker.CancellationPending) { eventArgs.Cancel = true; break; } Game game = null; Faction faction = null; bool updated = false; //Game if (colGame != -1 && !DBNull.Value.Equals(row[colGame])) { game = repositories.GameRepository.CreateOrGetGame(Convert.ToString(row[colGame]), false); } //Title if (game != null && colTitle != -1 && !DBNull.Value.Equals(row[colTitle])) { faction = repositories.FactionRepository.CreateOrGetFaction(game, Convert.ToString(row[colTitle]), false); } //IconPath if (faction != null && colIconPath != -1 && !DBNull.Value.Equals(row[colIconPath])) { string _path = Convert.ToString(row[colIconPath]); if (faction.IconPath == null || faction.IconPath.Equals("")) { //Only overwrite blank values faction.IconPath = _path; updated = true; } else { //TODO: Update this for user confirmation if (!faction.IconPath.Equals(_path)) { Console.WriteLine("{0}: IconPath {1} blocked by existing value {2};", faction.Title, _path, faction.IconPath); } } } //ColourText if (faction != null && colColourText != -1 && !DBNull.Value.Equals(row[colColourText])) { string _colour = Convert.ToString(row[colColourText]); if (faction.ColourText == null || faction.ColourText.Equals("")) { //Only overwrite blank values faction.ColourText = _colour; updated = true; } else { //TODO: Update this for user confirmation if (!faction.ColourText.Equals(_colour)) { Console.WriteLine("{0}: ColourText {1} blocked by existing value {2};", faction.Title, _colour, faction.ColourText); } } } //ColourBackground if (faction != null && colColourBackground != -1 && !DBNull.Value.Equals(row[colColourBackground])) { string _banner = Convert.ToString(row[colColourBackground]); if (faction.ColourBackground == null || faction.ColourBackground.Equals("")) { //Only overwrite blank values faction.ColourBackground = _banner; updated = true; } else { //TODO: Update this for user confirmation if (!faction.ColourBackground.Equals(_banner)) { Console.WriteLine("{0}: ColourBackground {1} blocked by existing value {2};", faction.Title, _banner, faction.ColourBackground); } } } //Save if needed, delayed persist if (updated) { repositories.GameRepository.UpdateGame(game, false); } //Report progress rowCount++; if (worker.WorkerReportsProgress) { worker.ReportProgress(rowCount * 100 / totalRows, String.Format("{0} of {1} rows imported.", rowCount, totalRows)); } } } #endregion }
public static int MobileNotoriety(Mobile source, Mobile target) { if (Core.AOS && (target.Blessed || target is PlayerVendor || target is TownCrier)) { return(Notoriety.Invulnerable); } if (source is BaseGuard && !(target is BaseGuard)) { return(Notoriety.CanBeAttacked); } #region Dueling if (source is PlayerMobile && target is PlayerMobile) { PlayerMobile pmFrom = (PlayerMobile)source; PlayerMobile pmTarg = (PlayerMobile)target; // only check this if one of them hasn't been eliminated if ((pmFrom.DuelPlayer != null && !pmFrom.DuelPlayer.Eliminated) || (pmTarg.DuelPlayer != null && !pmTarg.DuelPlayer.Eliminated)) { if (pmFrom.DuelContext != null && pmFrom.DuelContext.StartedBeginCountdown && !pmFrom.DuelContext.Finished && pmFrom.DuelContext == pmTarg.DuelContext) { return(pmFrom.DuelContext.IsAlly(pmFrom, pmTarg) ? Notoriety.Ally : Notoriety.Enemy); } } } #endregion if (target.AccessLevel > AccessLevel.Player) { return(Notoriety.CanBeAttacked); } if (source.Player && !target.Player && source is PlayerMobile && target is BaseCreature) { BaseCreature bc = (BaseCreature)target; if (!bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType()) { return(Notoriety.Enemy); } } if (target.Kills >= 5 || (target.Body.IsMonster && IsSummoned(target as BaseCreature) && !(target is BaseFamiliar) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead))) { return(Notoriety.Murderer); } if (target.Criminal) { return(Notoriety.Criminal); } Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target); 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, true, true); if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet) { return(Notoriety.Enemy); } if (SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source)) { return(Notoriety.CanBeAttacked); } if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent)) { if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !TransformationSpellHelper.UnderTransformation(target) && !AnimalForm.UnderTransformation(target)) { return(Notoriety.CanBeAttacked); } } if (CheckAggressor(source.Aggressors, target)) { return(Notoriety.CanBeAttacked); } if (CheckAggressed(source.Aggressed, target)) { return(Notoriety.CanBeAttacked); } if (target is BaseCreature) { BaseCreature bc = (BaseCreature)target; if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source) { return(Notoriety.CanBeAttacked); } // make all vendors on buc's be red if (target is BaseVendor) { if ((bc.Home == Point3D.Zero && target.Region.Name == "Buccaneer's Den") || Region.Find(((BaseVendor)target).Home, target.Map).Name == "Buccaneer's Den") { return(Notoriety.Murderer); } } } if (source is BaseCreature) { BaseCreature bc = (BaseCreature)source; Mobile master = bc.GetMaster(); if (master != null && CheckAggressor(master.Aggressors, target)) { return(Notoriety.CanBeAttacked); } } return(Notoriety.Innocent); }
public Faction ParseFaction(object response) { try { IDictionary <string, object> factionJson = Deserializtion.DeserializeData(response.ToString()); Faction faction = new Faction { EDDBID = (long)factionJson["eddb_id"], name = (string)factionJson["name"], updatedAt = (DateTime)factionJson["updated_at"], Government = Government.FromName((string)factionJson["government"]), Allegiance = Superpower.FromName((string)factionJson["allegiance"]), }; foreach (object presence in (List <object>)factionJson["faction_presence"]) { IDictionary <string, object> presenceJson = (IDictionary <string, object>)presence; FactionPresence factionPresence = new FactionPresence() { systemName = JsonParsing.getString(presenceJson, "system_name"), influence = (JsonParsing.getOptionalDecimal(presenceJson, "influence") ?? 0) * 100, // Convert from a 0-1 range to a percentage FactionState = FactionState.FromEDName(JsonParsing.getString(presenceJson, "state")) ?? FactionState.None, }; // These properties may not be present in the json, so we pass them after initializing our FactionPresence object. factionPresence.Happiness = Happiness.FromEDName(JsonParsing.getString(presenceJson, "happiness")) ?? Happiness.None; presenceJson.TryGetValue("updated_at", out object updatedVal); factionPresence.updatedAt = (DateTime?)updatedVal ?? DateTime.MinValue; // Active states presenceJson.TryGetValue("active_states", out object activeStatesVal); if (activeStatesVal != null) { var activeStatesList = (List <object>)activeStatesVal; foreach (IDictionary <string, object> activeState in activeStatesList) { factionPresence.ActiveStates.Add(FactionState.FromEDName(JsonParsing.getString(activeState, "state")) ?? FactionState.None); } } // Pending states presenceJson.TryGetValue("pending_states", out object pendingStatesVal); if (pendingStatesVal != null) { var pendingStatesList = (List <object>)pendingStatesVal; foreach (IDictionary <string, object> pendingState in pendingStatesList) { FactionTrendingState pTrendingState = new FactionTrendingState( FactionState.FromEDName(JsonParsing.getString(pendingState, "state")) ?? FactionState.None, JsonParsing.getInt(pendingState, "trend") ); factionPresence.PendingStates.Add(pTrendingState); } } // Recovering states presenceJson.TryGetValue("recovering_states", out object recoveringStatesVal); if (recoveringStatesVal != null) { var recoveringStatesList = (List <object>)recoveringStatesVal; foreach (IDictionary <string, object> recoveringState in recoveringStatesList) { FactionTrendingState rTrendingState = new FactionTrendingState( FactionState.FromEDName(JsonParsing.getString(recoveringState, "state")) ?? FactionState.None, JsonParsing.getInt(recoveringState, "trend") ); factionPresence.RecoveringStates.Add(rTrendingState); } } faction.presences.Add(factionPresence); } return(faction); } catch (Exception ex) { Dictionary <string, object> data = new Dictionary <string, object>() { { "input", response }, { "exception", ex } }; Logging.Error("Failed to parse BGS faction data.", data); return(null); } }
public Character(string name, double health, double armor, double abilityPoints, Bag bag, Faction faction) { this.IsAlive = true; this.RestHealMultiplier = defaultRestHealMultiplier; this.Name = name; this.baseHealth = health; this.Health = health; this.BaseArmor = armor; this.Armor = armor; this.AbilityPoints = abilityPoints; this.Bag = bag; this.Faction = faction; }
protected override void OnTarget(Mobile src, object targ) { var foundAnyone = false; Point3D p = targ switch { Mobile mobile => mobile.Location, Item item => item.Location, IPoint3D d => new Point3D(d), _ => src.Location }; var srcSkill = src.Skills.DetectHidden.Value; var range = (int)(srcSkill / 10.0); if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0)) { range /= 2; } var house = BaseHouse.FindHouseAt(p, src.Map, 16); var inHouse = house?.IsFriend(src) == true; if (inHouse) { range = 22; } if (range > 0) { var inRange = src.Map.GetMobilesInRange(p, range); foreach (var trg in inRange) { if (trg.Hidden && src != trg) { var ss = srcSkill + Utility.Random(21) - 10; var ts = trg.Skills.Hiding.Value + Utility.Random(21) - 10; if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || inHouse && house.IsInside(trg))) { if (trg is ShadowKnight && (trg.X != p.X || trg.Y != p.Y)) { continue; } trg.RevealingAction(); trg.SendLocalizedMessage(500814); // You have been revealed! foundAnyone = true; } } } inRange.Free(); if (Faction.Find(src) != null) { var itemsInRange = src.Map.GetItemsInRange <BaseFactionTrap>(p, range); foreach (var trap in itemsInRange) { if (src.CheckTargetSkill(SkillName.DetectHidden, trap, 80.0, 100.0)) { src.SendLocalizedMessage( 1042712, true, $" {(trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName)}" ); // You reveal a trap placed by a faction: trap.Visible = true; trap.BeginConceal(); foundAnyone = true; } } itemsInRange.Free(); } } if (!foundAnyone) { src.SendLocalizedMessage(500817); // You can see nothing hidden there. } } }
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) { 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.Now >= (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) { 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); } }
public override object CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool == null || tool.Deleted || tool.UsesRemaining < 0) { return(1044038); // You have worn out your tool! } else if (!BaseTool.CheckAccessible(tool, from)) { return(1044263); // The tool must be on your person to use. } else if (itemType != null && (itemType.IsSubclassOf(typeof(BaseFactionTrapDeed)) || itemType == typeof(FactionTrapRemovalKit)) && Faction.Find(from) == null) { return(1044573); // You have to be in a faction to do that. } return(0); }
public LordJob_Arson(IntVec3 spot, Faction faction) { FireSpot = spot; Faction = faction; }
public void ReceiveLetter(string label, string text, LetterDef textLetterDef, LookTargets lookTargets, Faction relatedFaction = null, string debugInfo = null) { ChoiceLetter let = LetterMaker.MakeLetter(label, text, textLetterDef, lookTargets, relatedFaction); this.ReceiveLetter(let, debugInfo); }