Skip to content

Commit

Permalink
feat(difficulty_rework): 💙Replace Difficulty TCon trait to new `Cha…
Browse files Browse the repository at this point in the history
…llenger`

Now, higher Difficulty⭐ increases mining speed, damage, and defense/toughness.
  • Loading branch information
Krutoy242 committed Jun 11, 2024
1 parent 7294a13 commit d0c7006
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 38 deletions.
12 changes: 6 additions & 6 deletions config/tweakersconstruct.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,14 @@ miscelleaneous {
essence_metal:core:apprentice_armor
essence_metal:plates:apprentice_armor
essence_metal:trim:apprentice_armor
pink_slime:head:tconevo.slimey_pink,difficulty
pink_slime:projectile:tconevo.slimey_pink,difficulty
pink_slime:extra:tconevo.slimey_pink,difficulty
pink_slime:handle:tconevo.slimey_pink,difficulty
pink_slime:bow:tconevo.slimey_pink,difficulty
pink_slime:head:tconevo.slimey_pink,challenger
pink_slime:projectile:tconevo.slimey_pink,challenger
pink_slime:extra:tconevo.slimey_pink,challenger
pink_slime:handle:tconevo.slimey_pink,challenger
pink_slime:bow:tconevo.slimey_pink,challenger
pink_slime:core:tconevo.slimey_pink_armor,bouncy_armor
pink_slime:plates:tconevo.slimey_pink_armor,bouncy_armor
pink_slime:trim:tconevo.slimey_pink_armor,difficulty_armor
pink_slime:trim:tconevo.slimey_pink_armor,challenger_armor
redstone_alloy:head:shocking,dire
redstone_alloy:projectile:crude1,dire
redstone_alloy:handle:writable1,dire
Expand Down
2 changes: 2 additions & 0 deletions resources/contenttweaker/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ e2ee.tconstruct.material.first_stand.name=First Stand
e2ee.tconstruct.material.first_stand.description=Consume experience before taking damage.
e2ee.tconstruct.material.robust.name=Robust
e2ee.tconstruct.material.robust.description=Increase health
e2ee.tconstruct.material.challenger.name=Challenger
e2ee.tconstruct.material.challenger.description=§oChallenger\n§rHigher difficulty increases mining speed, damage, and defense/toughness.

warp.sword.warning=§o§5 You are too sane to use that power!

Expand Down
2 changes: 2 additions & 0 deletions resources/contenttweaker/lang/ru_ru.lang
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ e2ee.tconstruct.material.first_stand.name=Первый стенд
e2ee.tconstruct.material.first_stand.description=Используйте опыт перед получением урона.
e2ee.tconstruct.material.robust.name=Прочный
e2ee.tconstruct.material.robust.description=Укрепление здоровья
e2ee.tconstruct.material.challenger.name=Испытатель
e2ee.tconstruct.material.challenger.description=§oИспытатель\n§rЧем выше сложность, тем выше скорость добычи, урон и защита/стойкость.

warp.sword.warning=§o§5 Вы слишком разумны, чтобы использовать эту силу!

Expand Down
2 changes: 2 additions & 0 deletions resources/contenttweaker/lang/zh_cn.lang
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ e2ee.tconstruct.material.first_stand.name=首当其冲
e2ee.tconstruct.material.first_stand.description=消耗经验来完全抵挡受到的伤害
e2ee.tconstruct.material.robust.name=稳健
e2ee.tconstruct.material.robust.description=提高健康水平
e2ee.tconstruct.material.challenger.name=挑战者
e2ee.tconstruct.material.challenger.description=§o挑战者\n§r难度越高,挖掘速度、伤害和防御/韧性越高。

warp.sword.warning=§o§5你太理智了,不会使用这种力量!

Expand Down
110 changes: 78 additions & 32 deletions scripts/cot/trait/mods/scalinghealth.zs
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,86 @@
#modloaded scalinghealth ctintegration

import crafttweaker.player.IPlayer;
import mods.zenutils.NetworkHandler;
import crafttweaker.entity.IEntity;
import mods.contenttweaker.tconstruct.Trait;
import crafttweaker.item.IItemStack;
import mods.contenttweaker.conarm.ArmorTrait;

//
// difficulty
//
val difficulty = mods.contenttweaker.tconstruct.TraitBuilder.create('difficulty');
difficulty.color = 0xD1310D;
difficulty.localizedName = 'Difficulty';
difficulty.localizedDescription = '§oScalling Difficulty\n§rMining, attacking and receive damage reduce player difficulty';
difficulty.afterBlockBreak = function (trait, tool, world, blockstate, miner, wasEffective, unknown) {
if (world.isRemote()) return;
if (!miner instanceof IPlayer) return;
val player as IPlayer = miner;
mods.ctintegration.scalinghealth.DifficultyManager.addDifficulty(player, -0.001);
// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
val a = mods.contenttweaker.tconstruct.TraitBuilder.create('challenger');
a.color = 0xD1310D;
a.maxLevel = 4;
a.localizedName = game.localize('e2ee.tconstruct.material.challenger.name');
a.localizedDescription = game.localize('e2ee.tconstruct.material.challenger.description');

a.getMiningSpeed = function(trait, tool, e) {
e.newSpeed = e.originalSpeed * getToolBonus(trait, tool, e.player);
};

a.calcDamage = function(trait, tool, attacker, target, originalDamage, newDamage, isCritical) {
return newDamage * getToolBonus(trait, tool, target);
};
difficulty.onHit = function (trait, tool, attacker, target, damage, isCritical) {
if (!attacker instanceof IPlayer) return;
val player as IPlayer = attacker;
if (player.world.isRemote()) return;
if (damage <= 0) return;
mods.ctintegration.scalinghealth.DifficultyManager.addDifficulty(player, -0.001 * damage);

a.afterHit = function(trait, tool, attacker, target, damageDealt, wasCritical, wasHit) {
if (attacker.world.remote || !wasHit) return;
showFX(attacker, target.x, target.y, target.z, damageDealt);
};
difficulty.register();

//
// difficulty_armor
//
val difficulty_armor = mods.contenttweaker.conarm.ArmorTraitBuilder.create('difficulty');
difficulty_armor.color = 0xD1310D;
difficulty_armor.localizedName = 'Difficulty';
difficulty_armor.localizedDescription = '§oScalling Difficulty\n§rMining, attacking and receive damage reduce player difficulty';
difficulty_armor.onDamaged = function (trait, armor, player, source, damage, newDamage, evt) {
if (player.world.isRemote()) return newDamage;
if (newDamage <= 0) return newDamage;
mods.ctintegration.scalinghealth.DifficultyManager.addDifficulty(player, -0.001 * newDamage);

a.afterBlockBreak = function(trait, tool, world, blockstate, blockPos, miner, wasEffective) {
if (miner.world.remote || !wasEffective) return;
showFX(miner, 0.5 + blockPos.x, 0.5 + blockPos.y, 0.5 + blockPos.z, 1.0);
};
// a.extraInfo = function(trait, tool, tag) {
// return [] as string[];
// };
a.register();

// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
val b = mods.contenttweaker.conarm.ArmorTraitBuilder.create('challenger');
b.color = 0xD1310D;
b.localizedName = game.localize('e2ee.tconstruct.material.challenger.name');
b.localizedDescription = game.localize('e2ee.tconstruct.material.challenger.description');
b.maxLevel = 4;
b.getModifications = function(trait, player, mods, armor, damageSource, damage, index) {
if (damage <= 0.0) return mods;
val bonus = getArmorBonus(trait, armor, player);
mods.armorMod *= bonus;
mods.toughnessMod *= bonus;
return mods;
};
b.onDamaged = function (trait, armor, player, source, damage, newDamage, evt) {
if (player.world.remote || newDamage <= 0) return newDamage;
val bonus = getArmorBonus(trait, armor, player);
showFX(player, player.x, player.y, player.z, bonus);
return newDamage;
};
difficulty_armor.register();
b.register();

// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
function showFX(entity as IEntity, x as double,y as double,z as double, value as double) as void {
NetworkHandler.sendToAllAround('acquire_star_and_flare',
entity.x, entity.y, entity.z, 30, entity.world.getDimension(), function(b){
b.writeData({ x: x, y: y, z: z, value: value });
});
}

function getToolBonus(trait as Trait, tool as IItemStack, entity as IEntity) as double {
return getAnyBonus(trait.getData(tool).level, entity);
}

function getArmorBonus(trait as ArmorTrait, tool as IItemStack, entity as IEntity) as double {
return getAnyBonus(trait.getData(tool).level, entity);
}

function getAnyBonus(level as double, entity as IEntity) as double {
val areaDiff = entity.world.getAreaDifficultyAt(entity.position);
return getBonus(areaDiff, level);
}

function getBonus(areaDiff as double, level as double) as double {
return (areaDiff / 100.0 + 1.0) * level;
}

0 comments on commit d0c7006

Please sign in to comment.