Skip to content

Commit

Permalink
1.0.81.1118
Browse files Browse the repository at this point in the history
  • Loading branch information
SphereII committed Sep 14, 2024
1 parent 2568ed6 commit a8a0e4c
Show file tree
Hide file tree
Showing 35 changed files with 1,179 additions and 31 deletions.
8 changes: 8 additions & 0 deletions Mods/0-SCore/0-SCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@
<Deterministic>false</Deterministic>
</PropertyGroup>
<ItemGroup>
<Compile Include="Features\Challenges\ChallengeTypeSCoreEnums.cs" />
<Compile Include="Features\Challenges\Harmony\ChallengeReadObjective.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveCompleteQuestStealth.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveEnterPOI.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveKillWithItem.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveStealthKillStreak.cs" />
<Compile Include="Features\Challenges\Scripts\SCoreChallengeUtils.cs" />
<Compile Include="Features\Drones\Harmony\EntityDronePatches.cs" />
<Compile Include="Features\EntityPooling\Harmony\EntityFactoryPatch.cs" />
<Compile Include="Features\EntityPooling\Scripts\EntityFactoryPool.cs" />
Expand Down Expand Up @@ -335,6 +340,8 @@
<Compile Include="Scripts\Entities\IEntityOrderReceiverSDX.cs" />
<Compile Include="Scripts\Entities\LegacyEntityClasses.cs" />
<Compile Include="Scripts\Entities\ModGeneralUtilities.cs" />
<Compile Include="Scripts\Events\EventOnClientKill.cs" />
<Compile Include="Scripts\Events\OnRallyPointActivated.cs" />
<Compile Include="Scripts\Events\OnBloodMoonEnd.cs" />
<Compile Include="Scripts\Events\OnBloodMoonStart.cs" />
<Compile Include="Scripts\Events\OnBuffAdded.cs" />
Expand Down Expand Up @@ -515,6 +522,7 @@
<Compile Include="Scripts\UtilityAI\UAITaskMoveToTargetSDX.cs" />
<Compile Include="Scripts\UtilityAI\UAITaskFollowSDX.cs" />
<Compile Include="Scripts\UtilityAI\UAITaskWanderSDX.cs" />
<Compile Include="Scripts\WorldGen\CaveTunnelerV2.cs" />
<Compile Include="Scripts\WorldGen\HeightMapTunneler.cs" />
<Compile Include="Scripts\WorldGen\LegacyCaveTunneler.cs" />
<Compile Include="Scripts\WorldGen\SCoreTunneler.cs" />
Expand Down
36 changes: 35 additions & 1 deletion Mods/0-SCore/Config/Localization.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,38 @@ xuiSCoreUtilsWeaponSwayToolTip,"Toggles weapon and camera bob and sway to help a
xuiSCoreUtilsMemoryBudget,"Run GFX st budget 0 on game load",""
xuiSCoreUtilsMemoryBudgetToolTip,"Automatically sets the GFX st budget 0 when you enter a game. Effective on next game start.",""
xuiSCoreUtilsPPEnable,"Run GFX pp enable 0 on game load",""
xuiSCoreUtilsPPEnableToolTip,"Automatically sets the GFX pp enable 0 when you enter a game. Effective on next game start.",""
xuiSCoreUtilsPPEnableToolTip,"Automatically sets the GFX pp enable 0 when you enter a game. Effective on next game start.",""
xuiCraftFromContainersSCore,"Enemies are nearby! Remote repairing is disabled!",""
ChallengeObjectiveCompleteQuestStealth,"Clear a quest with stealth only.",""
challengeObjectiveKillWithItem,"Kill [] Zombies"
challengeObjectiveStealthKillStreak,"Kill [] Zombies in a kill streak"
challengeObjectiveWith,"with a"
itemWithTags,"items with the tag of "
perceptionChallenges_key,"Perception Challenges"
strengthChallenges_key,"Strength Challenges"
fortitudeChallenges_key,"Fortitude Challenges"
agilityChallenges_key,"Agility Challenges"
intellectChallenges_key,"Intellect Challenges"
bonusChallenges_key,"Bonus Challenge Group"
pistols_challenges,"Pipe Pistol, Pistol, or SMG"
crossbow_challenges,"Any crossbow"
turrent_challenges,"Auto Turret or Shotgun Turret"
challengePlaceElectricFencePost,"Place Electric Fencepost"
challengePlaceelectricwirerelay,"Place Electric Relay"
meleeSneakChallenge,"Melee Sneak Challenge"
meleeSneakChallengeDesc,"Kill any zombie with melee weapon while sneaking."
rangedGunSneakChallenge,"Gun Sneak Challenge"
rangedGunSneakChallengeDesc,"Kill any zombie with any guns while sneaking."
rangedSneakChallenge,"Ranged Sneak Challenge"
rangedSneakChallengeDesc,"Kill any zombies with any ranged weapons."
killzombieswithstealthStreak,"Sneak Kill Streak"
killzombieswithstealthStreakDesc,"Kill multiple zombies with sneak damage in a row."
killzombieswithstealthStreakBow,"Kill Streak using a bow while sneaking"
killzombieswithstealthStreakBowDesc,"Kill multiple zombies in a row with a bow while sneaking."
killzombieswithstealthStreakKnife,"Kill Streak using a Knife while sneaking."
killzombieswithstealthStreakKnifeDesc,"Kill multiple zombies in a row with a knife while sneaking."
killzombieswithstealthStreakClub,"Kill Streak using a club while sneaking."
killzombieswithstealthStreakClubDesc,"Kill multiple zombies in a row with a club while sneaking."
killzombieswithstealthStreakSpear,"Kill Streak using a spear while sneaking."
killzombieswithstealthStreakSpearDesc,"Kill multiple zombies in a row with a spear while sneaking."

6 changes: 6 additions & 0 deletions Mods/0-SCore/Features/Challenges/ChallengeTypeSCoreEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public enum ChallengeObjectiveTypeSCore : byte {
ChallengeObjectiveEnterPOI,
ChallengeObjectiveCompleteQuestStealth,
ChallengeObjectiveKillWithItem,
ChallengeObjectiveStealthKillStreak
}
29 changes: 24 additions & 5 deletions Mods/0-SCore/Features/Challenges/Harmony/ChallengeReadObjective.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
using Challenges;
using HarmonyLib;

public enum ChallengeObjectiveTypeSCore : byte {
ChallengeObjectiveEnterPOI
}

namespace SCore.Features.Challenges.Harmony {
[HarmonyPatch(typeof(BaseChallengeObjective))]
[HarmonyPatch("ReadObjective")]
Expand All @@ -18,7 +14,30 @@ public static bool Prefix(ref BaseChallengeObjective __result, byte _currentVers
__result.Read(_currentVersion, _br);
return false;
}


if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveCompleteQuestStealth)
{
__result = new ChallengeObjectiveCompleteQuestStealth();
__result.Read(_currentVersion, _br);
return false;
}

if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveStealthKillStreak)
{
__result = new ChallengeObjectiveStealthKillStreak();
__result.Read(_currentVersion, _br);
return false;
}

if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveKillWithItem)
{
__result = new ChallengeObjectiveKillWithItem();
__result.Read(_currentVersion, _br);
return false;
}



return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using HarmonyLib;
using Challenges;
using UnityEngine;

namespace Challenges {

/*
* A new challenge objective to monitor your stealth kills during a quest.
* To pass this challenge, you must do consecutive stealth kills until you've reached the desired count.
* If the intention is that the full quest be done 100% stealth, set the count to be higher than the expected number of zombies
* Once the Sleeper volumes are all cleared for the QuestObjectiveClear, then the challenge will complete, regardless if
* the Count is equaled to the count specified.
*
* <!-- Kill two entities in a row with a stealth kill, during a quest. -->
* <objective type="CompleteQuestStealth, SCore" count="2"/>
*
* <!-- Kill all entities in a row with a stealth kill, during a quest. -->
* <objective type="CompleteQuestStealth, SCore" count="1000"/>
*/
public class ChallengeObjectiveCompleteQuestStealth : BaseChallengeObjective {

public override ChallengeObjectiveType ObjectiveType =>
(ChallengeObjectiveType)ChallengeObjectiveTypeSCore.ChallengeObjectiveCompleteQuestStealth;

public override string DescriptionText =>
Localization.Get("ChallengeObjectiveCompleteQuestStealth");

public override void Init() {
}

public override void HandleAddHooks() {
EventOnRallyPointActivated.OnActivated += OnQuestActivated;
}

private void Reset() {
Current = 0;
Complete = false;
HandleRemoveHooks();
}

public override void HandleRemoveHooks() {
EventOnRallyPointActivated.OnActivated -= OnQuestActivated;
QuestEventManager.Current.SleepersCleared -= Current_SleepersCleared;
EventOnClientKill.OnClientKillEvent -= Current_EntityDamaged;
}

// Start listening to the other hooks only after we've activated a quest.
private void OnQuestActivated() {
Reset();
EventOnClientKill.OnClientKillEvent += Current_EntityDamaged;
QuestEventManager.Current.SleepersCleared += Current_SleepersCleared;
}

// The only way this event should still be listened to here, is if we didn't end the kill streak.
private void Current_SleepersCleared(Vector3 prefabPos) {
Current = MaxCount;
CheckObjectiveComplete();
}
private bool Current_EntityDamaged(DamageResponse _dmresponse, EntityAlive entityDamaged) {
// We didn't damage the zombie. Don't count it.
var entityId = _dmresponse.Source.getEntityId();
if (entityId == -1) return false;

var player = GameManager.Instance.World.GetEntity(entityId) as EntityPlayerLocal;
if (player == null) return false;

// Is the zombies still without the bounds?
var position = entityDamaged.position;
position.y = position.z;
if (!player.ZombieCompassBounds.Contains(position)) return false;

// Were we sneaking?
if (_dmresponse.Source.BonusDamageType != EnumDamageBonusType.Sneak)
{
Reset();
return false;
}

// Check to see if we have a max counter to complete the challenge.
Current++;
CheckObjectiveComplete();
return true;
}

public override BaseChallengeObjective Clone() {
return new ChallengeObjectiveCompleteQuestStealth {

};
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using HarmonyLib;
using Challenges;
using UnityEngine;
using UnityEngine.Animations;

namespace Challenges {
/*
*
* To pass this challenge, you must killed zombies with the specified item. This extends the KillByTag objective, and thus supports
* all those attributes as well. Multiple item="" can be listed as a comma-delimited list.
*
* <!-- Kill two zombies in a row with a gunHandgunT1Pistol -->
* <objective type="KillWithItem, SCore" count="2" item="gunHandgunT1Pistol" />
*
* Rather than item name itself, you could also use item_tag
* <objective type="KillWithItem, SCore" count="2" item_tags="handgunSkill" />
*
* ItemName is checked first, then item tags. If either passes, then vanilla code is checked for the other tags and checks.
*
* You may also add the option entity tags and target_name_key for localization.
* By default, the entity_tags and target_name_key is zombie and xuiZombies, respectively.
* <objective type="KillWithItem, SCore" count="2" item="gunHandgunT1Pistol" entity_tags="zombie" target_name_key="xuiZombies" />
*
* Other attributes available are:
* target_name="zombieMarlene"
* biome="snow"
* killer_has_bufftag="buff_tags"
* killed_has_bufftag="buff_tags"
* is_twitch_spawn="true/false"
*/
public class ChallengeObjectiveKillWithItem : ChallengeObjectiveKillByTag {
public override ChallengeObjectiveType ObjectiveType =>
(ChallengeObjectiveType)ChallengeObjectiveTypeSCore.ChallengeObjectiveKillWithItem;

public string ItemClass;
public string ItemTag;
public bool StealthCheck;
public string LocalizationKey = "challengeObjectiveKillWithItem";

public override void Init() {
if ( string.IsNullOrEmpty(entityTag))
entityTag = "zombie";
if ( string.IsNullOrEmpty(targetName))
targetName = Localization.Get("xuiZombies");
base.Init();
}

public override string DescriptionText {
get {
var objectiveDesc = Localization.Get(LocalizationKey);
objectiveDesc = objectiveDesc.Replace("[]", MaxCount.ToString());
if (!string.IsNullOrEmpty(ItemClass))
{
// Use a counter to know if there needs to be ,'s
var itemDisplay = $" {Localization.Get("challengeObjectiveWith")} ";
var counter = 0;
foreach (var item in ItemClass.Split(','))
{
if (counter>0)
itemDisplay += ", ";
itemDisplay += $"{Localization.Get(item)}";
counter++;
}

return $"{objectiveDesc} {itemDisplay}";
}

if (string.IsNullOrEmpty(ItemTag)) return base.DescriptionText;
var itemWithTags = Localization.Get("itemWithTags");
return $"{objectiveDesc} {itemWithTags} {ItemTag}";

}
}

public override void HandleAddHooks() {
EventOnClientKill.OnClientKillEvent += Check_EntityKill;
}

public override void HandleRemoveHooks() {
EventOnClientKill.OnClientKillEvent -= Check_EntityKill;
}

public virtual bool HasPrerequisiteCondition(DamageResponse dmgResponse) {
if (!dmgResponse.Fatal) return false;
if (StealthCheck)
{
if (dmgResponse.Source.BonusDamageType != EnumDamageBonusType.Sneak) return false;
}

if (SCoreChallengeUtils.IsKilledByTrap(dmgResponse, ItemClass)) return true;
if (SCoreChallengeUtils.IsHoldingItemName(ItemClass)) return true;
if (SCoreChallengeUtils.IsHoldingItemHasTag(ItemTag)) return true;
return false;
}


// If we pass the pre-requisite, call the base class of the KillWithTags to do the heavy lifting for us.
protected virtual bool Check_EntityKill(DamageResponse _dmresponse, EntityAlive killedEntity) {
if (!HasPrerequisiteCondition(_dmresponse)) return false;
var player = GameManager.Instance.World.GetPrimaryPlayer();
base.Current_EntityKill(player, killedEntity);
return true;
}

public override void ParseElement(XElement e) {
base.ParseElement(e);
if (e.HasAttribute("item"))
{
ItemClass = e.GetAttribute("item");
}

if (e.HasAttribute("item_tag"))
{
ItemTag = e.GetAttribute("item_tag");
}

if (e.HasAttribute("stealth"))
{
var temp = e.GetAttribute("stealth");
StringParsers.TryParseBool(temp, out StealthCheck);
}

}

public override BaseChallengeObjective Clone() {
return new ChallengeObjectiveKillWithItem {
entityTag = entityTag,
entityTags = entityTags,
biome = biome,
targetName = targetName,
isTwitchSpawn = isTwitchSpawn,
killerHasBuffTag = killerHasBuffTag,
killedHasBuffTag = killedHasBuffTag,
ItemClass = ItemClass,
ItemTag = ItemTag,
StealthCheck = StealthCheck
};
}
}
}
Loading

0 comments on commit a8a0e4c

Please sign in to comment.