Skip to content

Commit

Permalink
1.0.32.940
Browse files Browse the repository at this point in the history
  • Loading branch information
SphereII committed Jul 27, 2024
1 parent f17e32b commit f1216d5
Show file tree
Hide file tree
Showing 17 changed files with 352 additions and 62 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
!Mods/Tools/**
#!BetterBiomeEffects/**
!Mods/ReadMe.md
!Mods/CompoPackTweaks/**
*.zip
obj

2 changes: 1 addition & 1 deletion Mods/0-SCore/ModInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<Description value="SCore Mod" />
<DisplayName value="0-SCore" />
<Website value="" />
<Version value="1.0.31.1121" />
<Version value="1.0.32.940" />
</xml>
4 changes: 2 additions & 2 deletions Mods/0-SCore/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("20.0.*")]

[assembly: AssemblyVersion("1.0.31.1121")]
[assembly: AssemblyFileVersion("1.0.31.1121")]
[assembly: AssemblyVersion("1.0.32.0940")]
[assembly: AssemblyFileVersion("1.0.32.0940")]
53 changes: 53 additions & 0 deletions Mods/0-SCore/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,59 @@ Direct Download to the 0-SCore.zip available on gitlab mirror:
### Change Logs

[ Change Log ]
Version: 1.0.32.940

[ CompoPackTweaks ]
- main host for the CompoPackTeaks, which is used by the CompoPack Team
- You do not need to install this yourself for compopack; they supply it.
- Removes the warning for the DMS when new traders are added.
- Can be used by other groups for the same purpose.

[ ObjectiveGiveBuffSDX ]
- Removed the hard-coded "buff" word after the "Get <Buff>" string.

[ Take And Replace ]
- Added a property option to block / shape to allow filtering based on hand item.
<property name="TakeWithTool" value="clawHammer,stoneAxe" />
- If this property is specified, the Take Prompt will only show when you are holding that item.
- This happens after we've checked ValidMaterial, and passed the material check for pick up.
- If this property is not specified, then the Take Prompt will show up for those blocks.
- Note: HoldingItem property is still valid. The item(s) specified in this property will half the time it takes for the block.

- If the item that you are holding has the tag "silenttake", then no sound will be played when a block is taken.
- This happens regardless if the tool is specified in TakeWithTool or HoldingItem.
- If you can take a block, and have that tag on your hand item, no sound will be played.
- Updated the "Take Sound" to be more appropriate for the material you are taking.
- Wooden sound for wood materials. Steel sound for steel materials.

- Added a property option CheckToolForMaterial, with the default being false.
<property name="CheckToolForMaterial" value="true"/
- If this property is defined and set to true, then the block will check for a tag on the holding item
- The tag on the holding item must be the material ID that is allowed to be picked up.
<item name="meleeToolRepairT0StoneAxe">
<!-- Allow the stone axe to pick up any block that is Mwood_weak or Mwood_regular.
<property name="Tags" value="<ommitted for clarity>,Mwood_weak, Mwood_regular"/>

<!-- full example : -->
<append xpath="/shapes/shape[@name='windowBoarded']">
<property name="Class" value="TakeAndReplace, SCore"/>
<property name="CanPickup" value="true"/>
<property name="TakeDelay" value="8"/>
<property name="PickUpBlock" value="woodShapes:VariantHelper"/>

<!-- Only allow picking up window board blocks that are weak or regular wood -->
<property name="ValidMaterials" value="Mwood_weak,Mwood_regular"/>

<!-- Only allow picking up blocks with this tool being held. -->
<property name="TakeWithTool" value="meleeToolRepairT0StoneAxe,meleeToolRepairTazaStoneAxe"/>
<!-- Check the currently held tool's tag for the material of the block / shape being picked up -->
<!-- note: That means that the stone axes must have a Mwood_weak tags in order to pick up those blocks -->
<property name="CheckToolForMaterial" value="true" />
</append>



Version: 1.0.31.1121
[ Events ]
- Added a new folder Scripts/Events
Expand Down
Binary file modified Mods/0-SCore/SCore.dll
Binary file not shown.
Binary file modified Mods/0-SCore/SCore.pdb
Binary file not shown.
118 changes: 70 additions & 48 deletions Mods/0-SCore/Scripts/Blocks/BlockPickUpAndReplace.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
using UniLinq;
using UnityEngine;

public class BlockTakeAndReplace : Block
{
public class BlockTakeAndReplace : Block {
// By default, all blocks using this class will have a take delay of 15 seconds, unless over-ridden by the XML.
private float fTakeDelay = 6f;
private string itemNames = "meleeToolRepairT1ClawHammer";
private string pickupBlock;
private string validMaterials = "Mwood_weak,Mwood_weak_shapes,Mwood_shapes";
public override void Init()
{
private string takeWithTool;
private bool validateToolToMaterial;
private FastTags<TagGroup.Global> silentTags = FastTags<TagGroup.Global>.Parse("silenttake");

public override void Init() {
base.Init();
if (Properties.Values.ContainsKey("TakeDelay")) fTakeDelay = StringParsers.ParseFloat(Properties.Values["TakeDelay"]);
if (Properties.Values.ContainsKey("TakeDelay"))
fTakeDelay = StringParsers.ParseFloat(Properties.Values["TakeDelay"]);
if (Properties.Values.ContainsKey("HoldingItem")) itemNames = Properties.GetString("HoldingItem");
if (Properties.Values.ContainsKey("PickUpBlock")) pickupBlock = Properties.GetString("PickUpBlock");
if (Properties.Values.ContainsKey("ValidMaterials")) validMaterials = Properties.GetString("ValidMaterials");
if (Properties.Values.ContainsKey("TakeWithTool")) takeWithTool = Properties.GetString("TakeWithTool");
if (Properties.Values.ContainsKey("CheckToolForMaterial")) validateToolToMaterial = Properties.GetBool("CheckToolForMaterial");

}

// Override the on Block activated, so we can pop up our timer
public override bool OnBlockActivated(WorldBase world, int clrIdx, Vector3i blockPos,
BlockValue blockValue, EntityPlayerLocal player) {
if (!ValidMaterialCheck(blockValue)) return false;
if (!ValidMaterialCheck(blockValue,player)) return false;
TakeItemWithTimer(clrIdx, blockPos, blockValue, player);
return true;
}
Expand All @@ -35,48 +40,53 @@ private ItemStack CreateItemStack(string item) {

return null;
}

// Take logic to replace it with the Downgrade block, matching rotations.
private void TakeTarget(TimerEventData timerData)
{
private void TakeTarget(TimerEventData timerData) {
var world = GameManager.Instance.World;
var array = (object[])timerData.Data;
var clrIdx = (int)array[0];
var blockValue = (BlockValue)array[1];
var vector3I = (Vector3i)array[2];
var block = world.GetBlock(vector3I);
var entityPlayerLocal = array[3] as EntityPlayerLocal;

if (entityPlayerLocal == null) return;
var itemStack = CreateItemStack(blockValue.Block.GetBlockName());

// Find the block value for the pick up value, and add it to the inventory
if (!string.IsNullOrEmpty(PickedUpItemValue) && PickedUpItemValue.Contains(":"))
{
itemStack = CreateItemStack(PickedUpItemValue);
}

if (!string.IsNullOrEmpty(pickupBlock))
{
itemStack = CreateItemStack(pickupBlock);
}

var uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
// var itemStack = new ItemStack(targetBlock.ToItemValue(), 1);
if (!uiforPlayer.xui.PlayerInventory.AddItem(itemStack, true))
uiforPlayer.xui.PlayerInventory.DropItem(itemStack);
entityPlayerLocal.PlayOneShot("Sounds/DestroyBlock/wooddestroy1");

if (!entityPlayerLocal.inventory.holdingItem.HasAnyTags(silentTags))
{
var sound = blockMaterial.SurfaceCategory + "destroy";
entityPlayerLocal.PlayOneShot(sound);
}

// Damage the block for its full health
DamageBlock(world, clrIdx, vector3I, block, block.Block.blockMaterial.MaxDamage, entityPlayerLocal.entityId);
}


// Displays the UI for the timer, calling TakeTarget when its done.
public void TakeItemWithTimer(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player)
{
var playerUI = (_player as EntityPlayerLocal).PlayerUI;
public void TakeItemWithTimer(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) {
var playerUI = (_player as EntityPlayerLocal)?.PlayerUI;
if (playerUI == null) return;
playerUI.windowManager.Open("timer", true);
var xuiC_Timer = playerUI.xui.GetChildByType<XUiC_Timer>();
var xuiCTimer = playerUI.xui.GetChildByType<XUiC_Timer>();
var timerEventData = new TimerEventData();
timerEventData.Data = new object[]
{
timerEventData.Data = new object[] {
_cIdx,
_blockValue,
_blockPos,
Expand All @@ -89,45 +99,57 @@ public void TakeItemWithTimer(int _cIdx, Vector3i _blockPos, BlockValue _blockVa
foreach (var item in itemNames.Split(','))
{
// If the entity is holding a crow bar or hammer, then reduce the take time.
if (_player.inventory.holdingItem.Name == item)
{
// Make sure the item can still be used
if (_player.inventory.holdingItemItemValue.MaxUseTimes > 0)
{
// Bump the Use time by one.
var itemValue = _player.inventory.holdingItemItemValue;


// Calculate the degradation value.
itemValue.UseTimes += (int)EffectManager.GetValue(PassiveEffects.DegradationPerUse, itemValue, 1f, _player);
_player.inventory.holdingItemData.itemValue = itemValue;

// Automatically reduce the take delay by half if you have a crow bar or claw hammer.
newTakeTime = fTakeDelay / 2;

// Reduce time based on the quality.
newTakeTime -= itemValue.Quality;
if (newTakeTime < 1)
newTakeTime = 1;
break;
}
}
if (_player.inventory.holdingItem.Name != item) continue;
// Make sure the item can still be used
if (_player.inventory.holdingItemItemValue.MaxUseTimes <= 0) continue;
// Bump the Use time by one.
var itemValue = _player.inventory.holdingItemItemValue;

// Calculate the degradation value.
itemValue.UseTimes +=
(int)EffectManager.GetValue(PassiveEffects.DegradationPerUse, itemValue, 1f, _player);
_player.inventory.holdingItemData.itemValue = itemValue;

// Automatically reduce the take delay by half if you have a crow bar or claw hammer.
newTakeTime = fTakeDelay / 2;

// Reduce time based on the quality.
newTakeTime -= itemValue.Quality;
if (newTakeTime < 1)
newTakeTime = 1;
break;
}


xuiC_Timer.SetTimer(newTakeTime, timerEventData);
xuiCTimer.SetTimer(newTakeTime, timerEventData);
}

private bool ValidMaterialCheck(BlockValue blockValue) {
private bool ValidMaterialCheck(BlockValue blockValue, EntityAlive entityAlive) {
var result = false;
var holdingItem = entityAlive.inventory.holdingItem;

if (validateToolToMaterial)
{
return entityAlive.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse(blockMaterial.id));
}
// Check to see if the material is valid to pick up
foreach (var material in validMaterials.Split(','))
{
if (blockMaterial.id.Contains(material)) return true;
if (!blockMaterial.id.Contains(material)) continue;
result = true;
break;
}

return false;
// Check to see if we are filtering based on any tool
if (string.IsNullOrEmpty(takeWithTool)) return result;

// Check to see if we are holding a supported tool.
return takeWithTool.Contains(holdingItem.Name) || result;
}
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) {
if (!ValidMaterialCheck(_blockValue))

public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos,
EntityAlive _entityFocusing) {
if (!ValidMaterialCheck(_blockValue, _entityFocusing))
return string.Empty;
return string.Format(Localization.Get("takeandreplace"), Localization.Get(_blockValue.Block.GetBlockName()));
// return "Press <E> to remove the wood from this block.";
Expand Down
23 changes: 23 additions & 0 deletions Mods/0-SCore/Scripts/Entities/EntityAliveSDX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,29 @@ public void ConfigureBoundaryBox(Vector3 newSize, Vector3 center) {
DisplayLog(" After BoundaryBox: " + boundingBox.ToCultureInvariantString());
}

public override void updateSpeedForwardAndStrafe(Vector3 _dist, float _partialTicks)
{
if (this.isEntityRemote && _partialTicks > 1f)
{
_dist /= _partialTicks;
}
this.speedForward *= 0.5f;
this.speedStrafe *= 0.5f;
this.speedVertical *= 0.5f;
if (Mathf.Abs(_dist.x) > 0.001f || Mathf.Abs(_dist.z) > 0.001f)
{
float num = Mathf.Sin(-this.rotation.y * 3.1415927f / 180f);
float num2 = Mathf.Cos(-this.rotation.y * 3.1415927f / 180f);
this.speedForward += num2 * _dist.z - num * _dist.x;
this.speedStrafe += num2 * _dist.x + num * _dist.z;
}
if (Mathf.Abs(_dist.y) > 0.001f)
{
this.speedVertical += _dist.y;
}
this.SetMovementState();
}

public void RestoreSpeed() {
// Reset the movement speed when an attack target is set
moveSpeed = EntityUtilities.GetFloatValue(entityId, "MoveSpeed");
Expand Down
20 changes: 9 additions & 11 deletions Mods/0-SCore/Scripts/Quests/ObjectiveBuffSDX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ protected void CopyValues(ObjectiveBuffSDX objective)
}

public override void AddHooks() {
EventOnBuffAdded.BuffAdded += OnAddBuff;
EventOnBuffAdded.BuffAdded += CheckForBuff;

}

public override void RemoveHooks()
{
EventOnBuffAdded.BuffAdded -= OnAddBuff;
EventOnBuffAdded.BuffAdded -= CheckForBuff;
}


Expand All @@ -48,22 +48,20 @@ public override void SetupDisplay()
var buff = BuffManager.GetBuff(strBuff);
if (buff == null) return;

Description = $"{keyword} {buff.LocalizedName} buff";
Description = $"{keyword} {buff.LocalizedName}";
}

public override void Update(float deltaTime) {
if (Time.time > this.updateTime)
{
this.updateTime = Time.time + 1f;
var buffClass = BuffManager.GetBuff(strBuff);
OnAddBuff(buffClass);
}
if (!(Time.time > this.updateTime)) return;
updateTime = Time.time + 1f;
var buffClass = BuffManager.GetBuff(strBuff);
CheckForBuff(buffClass);
}

public void OnAddBuff(BuffClass buffClass) {
public void CheckForBuff(BuffClass buffClass) {
if (string.IsNullOrEmpty(strBuff)) return;
if (!string.Equals(buffClass.Name, strBuff, StringComparison.CurrentCultureIgnoreCase)) return;
if (base.Complete) return;
if (Complete) return;

Complete= OwnerQuest.OwnerJournal.OwnerPlayer.Buffs.HasBuff(strBuff);
if (Complete == false) return;
Expand Down
Loading

0 comments on commit f1216d5

Please sign in to comment.