Skip to content

Commit 79e11b8

Browse files
committed
Star Vampire Spawner Bugfix
Fixed a bug where the Star Vampire would not spawn and had no AI behavior
1 parent 3bd0134 commit 79e11b8

File tree

11 files changed

+406
-147
lines changed

11 files changed

+406
-147
lines changed

1.3/Assemblies/CosmicHorror.dll

3.5 KB
Binary file not shown.

About/About.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<li>jecrell.jecstools</li>
2929
<li>CETeam.CombatExtended</li>
3030
</loadAfter>
31-
<description>1.3.0.1 (07-25-2021)
31+
<description>1.3.0.2 (08-01-2021)
3232

3333
*Add Lovecraftian monsters to your RimWorld experience!* There is a lingering fear that strokes the hairs on the back of the necks of your colonists. Something terrible is coming, and there is little time to prepare. Cosmic horrors are already upon us.
3434

@@ -107,9 +107,13 @@ Michael Cailler, Jigsawjohn , Daniel Schott, Penelope Charli Whitman, Jerome Gon
107107
========================
108108
Changelog
109109
========================
110+
1.3.0.2 (08-01-2021)
111+
========================
112+
Fixes a bug where the Star Vampire would not spawn appropriately after the delay.
113+
110114
1.3.0.1 (07-25-2021)
111115
========================
112-
Added Combat Extended support from mlie's build. Added a short warning message when first having sanity hediff.
116+
Readded Combat Extended support from mlie. Added short warning message for first time experiencing sanity loss.
113117

114118
1.3.0.0 (07-24-2021)
115119
========================

About/Changelog.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
1.3.0.2 (08-01-2021)
2+
========================
3+
Fixes a bug where the Star Vampire would not spawn appropriately after the delay.
4+
15
1.3.0.1 (07-25-2021)
26
========================
3-
Added Combat Extended support from mlie's build. Added a short warning message when first having sanity hediff.
7+
Readded Combat Extended support from mlie. Added short warning message for first time experiencing sanity loss.
48

59
1.3.0.0 (07-24-2021)
610
========================

About/Manifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<Manifest>
33
<identifier>CallofCthulhuCosmicHorrors</identifier>
4-
<version>1.3.0.1</version>
4+
<version>1.3.0.2</version>
55
<dependencies />
66
<incompatibleWith />
77
<loadBefore />

About/Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.0.1
1+
1.3.0.2

Source/.vs/CosmicHorrors/v16/.suo

14.5 KB
Binary file not shown.

Source/CosmicHorrors/CosmicHorrors.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@
8383
<Compile Include="HediffWithComps_GutWorms.cs" />
8484
<Compile Include="HediffWithComps_SanityLoss.cs" />
8585
<Compile Include="IncidentWorker_ScoutCosmicHorror.cs" />
86+
<Compile Include="IncidentWorker_StarVampireAttack.cs" />
87+
<Compile Include="MapComponent_StarVampireTracker.cs" />
8688
<Compile Include="ModInfo.cs" />
8789
<Compile Include="ModSettings.cs" />
8890
<Compile Include="IncidentWorker_Cthonian.cs" />
8991
<Compile Include="IncidentWorker_DarkYoung.cs" />
9092
<Compile Include="IncidentWorker_RaidCosmicHorrors.cs" />
91-
<Compile Include="IncidentWorker_StarVampireAttack.cs" />
9293
<Compile Include="JobDriver_FillChthonianPit.cs" />
9394
<Compile Include="JobDriver_HaulSacrifice.cs" />
9495
<Compile Include="JobGiver_StarVampireFeed.cs" />
Lines changed: 58 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,65 @@
1-
///Always required
2-
///Possible libraries
3-
using RimWorld;
1+
using RimWorld;
2+
using System;
3+
using System.Linq;
4+
using UnityEngine;
45
using Verse;
56
using Verse.Sound;
6-
using Verse.AI.Group;
7-
//using RimWorld.Planet;
8-
//using Verse.AI;
9-
//using Verse.AI.Group;
10-
117

128
namespace CosmicHorror
139
{
14-
public class IncidentWorker_StarVampireAttack : IncidentWorker
15-
{
16-
private CosmicHorrorPawn iwVampire; //The Star Vampire Pawn
17-
private ThingDef iwDef; //For the custom Spawner from JecsTools
18-
private Faction iwFac; //The Star Vampire Faction
19-
private IntVec3 iwLoc; //The Star Vampire location
20-
private SoundDef iwWarn; //The Star Vampire Warning Noise
21-
private Lord lord; //The Star Vampire AI manager
22-
23-
protected override bool CanFireNowSub(IncidentParms parms)
24-
{
25-
if (GenDate.DaysPassed < (ModInfo.cosmicHorrorRaidDelay + this.def.earliestDay))
26-
{
27-
Log.Message("Cosmic Horrors :: CantFireDueTo Time :: " + GenDate.DaysPassed + " days passed, but we need " + ModInfo.cosmicHorrorRaidDelay.ToString() + " days + " + this.def.earliestDay);
28-
return false;
29-
}
30-
return true;
31-
}
32-
33-
protected override bool TryExecuteWorker(IncidentParms parms)
34-
{
35-
36-
//Resolve parameters.
37-
ResolveSpawnCenter(parms);
38-
39-
//Initialize variables.
40-
this.iwDef = ResolveSpawner(parms);
41-
this.iwWarn = MonsterDefOf.Pawn_ROM_StarVampire_Warning;
42-
this.iwVampire = null; //iwPawn as CosmicHorrorPawn;
43-
this.iwLoc = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, (Map)parms.target, 8);
44-
45-
//In-case there's something silly happening...
46-
if (this.iwFac == null)
47-
{
48-
this.iwFac = Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile);
49-
}
50-
51-
//Slow down time
52-
Find.TickManager.slower.SignalForceNormalSpeed();
53-
//Play a sound.
54-
this.iwWarn.PlayOneShotOnCamera();
55-
//Show the warning message.
56-
Messages.Message("StarVampireIncidentMessage".Translate(), new RimWorld.Planet.GlobalTargetInfo(IntVec3.Invalid, (Map)parms.target), MessageTypeDefOf.SituationResolved);
57-
//Spawn the Star Vampire.
58-
SpawnStarVampires(parms);
59-
return true;
60-
}
61-
62-
private static ThingDef ResolveSpawner(IncidentParms parms)
10+
public class IncidentWorker_StarVampireAttack : IncidentWorker
11+
{
12+
protected override bool CanFireNowSub(IncidentParms parms)
13+
{
14+
if (!base.CanFireNowSub(parms))
15+
{
16+
return false;
17+
}
18+
Map map = (Map)parms.target;
19+
IntVec3 intVec;
20+
return RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null);
21+
}
22+
23+
private int NumberToSpawn(IncidentParms parms)
6324
{
64-
Map iwMap = (Map)parms.target;
65-
var abberation = (GenCelestial.IsDaytime(GenCelestial.CelestialSunGlow(iwMap, Find.TickManager.TicksAbs)))
66-
? MonsterDefOf.ROM_StarVampireSpawnerAbberation
67-
: MonsterDefOf.ROM_StarVampireSpawnerNight;
68-
69-
var chance = Rand.Value;
70-
if (chance > 0.3)
71-
return MonsterDefOf.ROM_StarVampireSpawner;
72-
else if (chance > 0.05)
73-
return abberation;
74-
else
75-
return MonsterDefOf.ROM_StarVampireSpawnerAlbino;
76-
}
77-
78-
/// <summary>
79-
/// Where to, Cthulhu?
80-
/// </summary>
81-
/// <param name="parms"></param>
82-
protected void ResolveSpawnCenter(IncidentParms parms)
83-
{
84-
Map iwMap = (Map)parms.target;
85-
if (parms.spawnCenter.IsValid)
86-
{
87-
return;
88-
}
89-
if (Rand.Value < 0.4f && iwMap.listerBuildings.ColonistsHaveBuildingWithPowerOn(ThingDefOf.OrbitalTradeBeacon))
90-
{
91-
parms.spawnCenter = DropCellFinder.TradeDropSpot(iwMap);
92-
}
93-
else
94-
{
95-
RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, iwMap, 0.0f);
96-
}
97-
}
98-
99-
/// <summary>
100-
/// Finds the best number of Star Vampires
101-
/// to spawn. Then spawns them according
102-
/// to a previously resolved location.
103-
/// </summary>
104-
/// <param name="parms"></param>
105-
protected void SpawnStarVampires(IncidentParms parms)
106-
{
107-
Map iwMap = (Map)parms.target;
108-
109-
int iwCount = 1;
110-
111-
if (parms.points <= 2000f)
112-
{
113-
iwCount = 1;
114-
}
115-
else if (parms.points <= 3000f)
116-
{
117-
iwCount = 2;
118-
}
119-
else if (parms.points <= 5000f)
120-
{
121-
iwCount = 3;
122-
}
123-
124-
for (int i = 0; i < iwCount; i++)
125-
{
126-
Thing iwSpawner = ThingMaker.MakeThing(iwDef, null);
127-
GenPlace.TryPlaceThing(iwSpawner, iwLoc, iwMap, ThingPlaceMode.Near);
128-
// CosmicHorrorPawn temp = null;
129-
// this.iwVampire = null;
130-
// this.iwSpawner = ThingMaker.MakeThing(this.iwKind, this.iwFac);
131-
// this.iwVampire = this.iwPawn as CosmicHorrorPawn;
132-
133-
//if (this.lord == null)
134-
//{
135-
// LordJob_StarVampire lordJob = new LordJob_StarVampire(this.iwFac, this.iwLoc);
136-
// this.lord = LordMaker.MakeNewLord(this.iwFac, lordJob, iwMap, null);
137-
//}
138-
//temp = (CosmicHorrorPawn)GenSpawn.Spawn(this.iwVampire, this.iwLoc, iwMap);
139-
//this.lord.AddPawn(temp);
140-
}
141-
}
142-
}
25+
Map iwMap = (Map)parms.target;
26+
27+
int iwCount = 1;
28+
29+
if (parms.points <= 2000f)
30+
{
31+
iwCount = 1;
32+
}
33+
else if (parms.points <= 3000f)
34+
{
35+
iwCount = 2;
36+
}
37+
else
38+
{
39+
iwCount = 3;
40+
}
41+
return iwCount;
42+
}
43+
44+
protected override bool TryExecuteWorker(IncidentParms parms)
45+
{
46+
Map map = (Map)parms.target;
47+
IntVec3 intVec;
48+
if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null))
49+
{
50+
return false;
51+
}
52+
map.GetComponent<MapComponent_StarVampireTracker>().AddNewStarVampireSpawner(intVec, NumberToSpawn(parms));
53+
54+
//Slow down time
55+
Find.TickManager.slower.SignalForceNormalSpeed();
56+
//Play a sound.
57+
MonsterDefOf.Pawn_ROM_StarVampire_Warning.PlayOneShotOnCamera();
58+
//Show the warning message.
59+
Messages.Message("StarVampireIncidentMessage".Translate(), new RimWorld.Planet.GlobalTargetInfo(IntVec3.Invalid, (Map)parms.target), MessageTypeDefOf.SituationResolved);
60+
61+
return true;
62+
}
63+
64+
}
14365
}

0 commit comments

Comments
 (0)