public override void GiveRewards(Caravan caravan) { base.GiveRewards(caravan); DarkNet net = Current.Game.GetComponent <DarkNet>(); TraderWorker_Eisenberg eisenberg = (TraderWorker_Eisenberg)net.Traders.First(x => x is TraderWorker_Eisenberg); eisenberg.Reputation = Mathf.Clamp(eisenberg.Reputation + 20, -100, 100); }
protected override bool CanFireNowSub(IncidentParms parms) { DarkNet darkNet = Current.Game.GetComponent <DarkNet>(); if (darkNet != null) { if (darkNet.Traders != null && !darkNet.Traders.Any(x => x.Online)) { return(false); } } return(true); }
public void GiveQuest() { labQuestIssued = true; var message = DarkNet.FormMessageFromDarkNet("EmailMessage_Eisenberg_Text".Translate(), "EmailMessage_Eisenberg_Subj".Translate(), def); message.Answers = new List <EmailMessageOption> { new EmailMessageOption_TakeQuest_Laboratory(), new EmailMessageOption_DeclineQuest_Laboratory() }; QuestsManager.Communications.PlayerBox.SendMessage(message); QuestsManager.Communications.RegisterComponent(new EmailMessageTimeComp_QuestLaboratory("EmailMessage_Eisenberg_Subj".Translate()) { id = QuestsManager.Communications.UniqueIdManager.GetNextComponentID() }); }
protected override bool TryExecuteWorker(IncidentParms parms) { if (!TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 7, 15, out int newTile, (int i) => !Find.WorldObjects.AnyWorldObjectAt(i))) { return(false); } if (GssRaids.GssFaction == null) { return(false); } DarkNet darkNet = Current.Game.GetComponent <DarkNet>(); if (darkNet == null || darkNet.Traders == null) { return(false); } DarkNetTrader trader = darkNet.Traders.RandomElement(); Quest_DarkNetKillInformator quest = new Quest_DarkNetKillInformator(trader.def); quest.GenerateRewards(quest.GetQuestThingFilter(), new FloatRange(1200, 2500), new IntRange(1, 4), null, null); quest.id = QuestsManager.Communications.UniqueIdManager.GetNextQuestID(); quest.TicksToPass = 10 * 60000; quest.Faction = GssRaids.GssFaction; string title = string.Format(def.letterLabel, trader.def.LabelCap, quest.Faction.Name); string desc = string.Format(def.letterText, trader.def.LabelCap, quest.Faction.Name); QuestSite site = QuestsHandler.CreateSiteFor(quest, newTile, quest.Faction); Find.WorldObjects.Add(site); QuestsManager.Communications.AddQuest(quest); Find.LetterStack.ReceiveLetter(title, desc, def.letterDef, new LookTargets(site)); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { DarkNet darkNet = Current.Game.GetComponent <DarkNet>(); if (darkNet == null || darkNet.Traders == null) { return(false); } DarkNetTrader trader = darkNet.Traders.RandomElement(); Faction attacker = Find.FactionManager.FirstFactionOfDef(MoreEvents.FactionDefOfLocal.Pirate); if (attacker == null || attacker.defeated) { return(false); } if (!TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 5, 12, out int newTile, (int i) => !Find.WorldObjects.AnyWorldObjectAt(i))) { return(false); } Quest_DarkNetCaptureMaterials quest = new Quest_DarkNetCaptureMaterials(trader.def); quest.id = QuestsManager.Communications.UniqueIdManager.GetNextQuestID(); quest.TicksToPass = 7 * 60000; quest.Faction = attacker; string title = string.Format(def.letterLabel, trader.def.LabelCap); string desc = string.Format(def.letterText, trader.def.LabelCap); QuestSite site = QuestsHandler.CreateSiteFor(quest, newTile, quest.Faction); Find.WorldObjects.Add(site); QuestsManager.Communications.AddQuest(quest); Find.LetterStack.ReceiveLetter(title, desc, def.letterDef, new LookTargets(site)); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { DarkNet darkNet = Current.Game.GetComponent <DarkNet>(); if (darkNet == null || darkNet.Traders == null) { return(false); } DarkNetTrader trader = darkNet.Traders.RandomElement(); List <Thing> allTraderThings = new List <Thing>(); Faction attacker = Find.FactionManager.RandomEnemyFaction(); if (attacker == null) { return(false); } if (!TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 5, 12, out int newTile, (int i) => !Find.WorldObjects.AnyWorldObjectAt(i))) { return(false); } if (!trader.TryGetGoods(allTraderThings)) { return(false); } Quest_DarkNetSupplyAttack quest = new Quest_DarkNetSupplyAttack(trader.def); int takeCount = Rand.Range(1, (int)Mathf.Max(1, allTraderThings.Count * 0.4f)); IEnumerable <Thing> rewards = allTraderThings.TakeRandom(takeCount); quest.Rewards = new List <Thing>(); foreach (var reward in rewards) { Thing copy = ThingMaker.MakeThing(reward.def, reward.Stuff); copy.stackCount = (int)Mathf.Max(1, reward.stackCount * 0.6f); quest.Rewards.Add(copy); } if (quest.Rewards.Count == 0) { return(false); } quest.id = QuestsManager.Communications.UniqueIdManager.GetNextQuestID(); quest.TicksToPass = 6 * 60000; quest.ShowInConsole = false; //release = false quest.Faction = attacker; string title = string.Format(def.letterLabel, trader.def.LabelCap); string desc = string.Format(def.letterText, trader.def.LabelCap); CommunicationDialog dialog = QuestsManager.Communications.AddCommunication(QuestsManager.Communications.UniqueIdManager.GetNextDialogID(), title, desc, incident: def); dialog.KnownFaction = false; quest.CommunicationDialog = dialog; QuestSite site = QuestsHandler.CreateSiteFor(quest, newTile, quest.Faction); Find.WorldObjects.Add(site); QuestsManager.Communications.AddQuest(quest); Find.LetterStack.ReceiveLetter(title, desc, def.letterDef, new LookTargets(site)); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { DarkNet darkNet = Current.Game.GetComponent <DarkNet>(); if (darkNet == null || darkNet.Traders == null) { return(false); } DarkNetTrader trader = darkNet.Traders.RandomElement(); List <Thing> allTraderThings = new List <Thing>(); Faction buyer = Find.FactionManager.RandomEnemyFaction(); Faction garant = null; if (!(from x in Find.FactionManager.AllFactions where !x.IsPlayer && !x.def.hidden && !x.defeated && x.def.humanlikeFaction && x.HostileTo(Faction.OfPlayer) && x != buyer select x).TryRandomElement(out garant)) { return(false); } if (buyer == null) { return(false); } if (!TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 3, 6, out int newTile, (int i) => !Find.WorldObjects.AnyWorldObjectAt(i))) { return(false); } if (!trader.TryGetGoods(allTraderThings)) { return(false); } Quest_DarkNetTraderSupply quest = new Quest_DarkNetTraderSupply(trader.def, garant); int takeCount = Rand.Range(1, (int)Mathf.Max(1, allTraderThings.Count * 0.4f)); IEnumerable <Thing> rewards = allTraderThings.Where(x => !(x is MinifiedThing)).ToList().TakeRandom(takeCount); quest.Rewards = new List <Thing>(); foreach (var reward in rewards) { Thing copy = ThingMaker.MakeThing(reward.def, reward.Stuff); copy.stackCount = (int)Mathf.Max(1, reward.stackCount * 0.6f); quest.Rewards.Add(copy); } if (quest.Rewards.Count == 0) { return(false); } quest.id = QuestsManager.Communications.UniqueIdManager.GetNextQuestID(); quest.TicksToPass = 4 * 60000; quest.Faction = buyer; quest.ShowInConsole = false; string title = string.Format(def.letterLabel, trader.def.LabelCap); string desc = string.Format(def.letterText, trader.def.LabelCap, buyer.Name, garant.Name); CommunicationDialog dialog = QuestsManager.Communications.AddCommunication(QuestsManager.Communications.UniqueIdManager.GetNextDialogID(), title, desc, incident: def); dialog.KnownFaction = true; quest.CommunicationDialog = dialog; QuestSite site = QuestsHandler.CreateSiteFor(quest, newTile, quest.Faction); Find.WorldObjects.Add(site); QuestsManager.Communications.AddQuest(quest); Find.LetterStack.ReceiveLetter(title, desc, def.letterDef, new LookTargets(site)); return(true); }