@@ -23,14 +23,18 @@ import team.lodestar.lodestone.registry.common.LodestoneAttributeRegistry
23
23
class VoidBoundPlayerItemAbilityComponent (private val player : Player ) : AutoSyncedComponent, CommonTickingComponent {
24
24
25
25
private var vampirismCooldown: Int = 0
26
- private var wrathCooldown : Int = 0
27
- private val wrathCooldownMax = 20 * 60
26
+ private var wrathStackKiller : Int = 0
27
+ private val wrathStackKillerMax = 20 * 60
28
28
private var finalStrike = false
29
29
private val finalStrikeCooldownMax = 20 * 20
30
30
private var finalStrikeDuration = 0
31
31
private var wrathCounter = 0
32
32
33
- fun tryUseVampirism (target : LivingEntity ){
33
+ // VAMPIRISM start
34
+ /* *
35
+ * If the cooldown is 0, perform Vamp, if vamp is successful, heal and play sound
36
+ */
37
+ fun tryUseVampirism (target : LivingEntity , amount : Float ) : Float {
34
38
if (vampirismCooldown <= 0 ) {
35
39
val healing = performVampirism(target)
36
40
if (healing > 0 ) {
@@ -40,8 +44,12 @@ class VoidBoundPlayerItemAbilityComponent(private val player: Player) : AutoSync
40
44
sync()
41
45
}
42
46
}
47
+ return amount
43
48
}
44
49
50
+ /* *
51
+ * Get amount of health to heal, healing is dependent on amount of spirits or a players armor value. Defaults at half a heart
52
+ */
45
53
private fun performVampirism (target : LivingEntity ): Int {
46
54
var healing = 0
47
55
if (target is Player ) {
@@ -54,46 +62,79 @@ class VoidBoundPlayerItemAbilityComponent(private val player: Player) : AutoSync
54
62
healing + = it.count
55
63
}
56
64
} else {
57
- healing + = 2
65
+ healing + = 1
58
66
}
59
67
}
60
68
61
69
return healing
62
70
}
63
71
72
+ // VAMPIRISM end
73
+
74
+ // OPENER - FINALE start
75
+
76
+ /* *
77
+ * If final strike is not active, increase the wrath counter and start the cooldown
78
+ */
64
79
fun increaseWrath () {
65
80
if (! finalStrike) {
66
81
wrathCounter++
67
- wrathCooldown = wrathCooldownMax
82
+ wrathStackKiller = wrathStackKillerMax
68
83
}
69
84
sync()
70
85
}
71
86
72
- override fun readFromNbt (tag : CompoundTag ) {
73
- vampirismCooldown = tag.getInt(" vampirismCooldown" )
74
- wrathCooldown = tag.getInt(" wrathCooldown" )
75
- wrathCounter = tag.getInt(" wrathCounter" )
76
- finalStrike = tag.getBoolean(" finalStrike" )
87
+ /* *
88
+ * if wrath is not maxed out and target has more than 95% health, increase wrath and increase the damage
89
+ */
90
+ fun tryUseOpener (target : LivingEntity , amount : Float ) : Float {
91
+ var outDamage = amount
92
+ if (wrathCounter < 10 && target.health / target.maxHealth > 0.95 ) {
93
+ increaseWrath()
94
+ outDamage * = 1.2f
95
+ }
96
+ return outDamage
77
97
}
78
98
79
- override fun writeToNbt (tag : CompoundTag ) {
80
- tag.putInt(" vampirismCooldown" , vampirismCooldown)
81
- tag.putInt(" wrathCooldown" , wrathCooldown)
82
- tag.putInt(" wrathCounter" , wrathCounter)
83
- tag.putBoolean(" finalStrike" , finalStrike)
99
+ /* *
100
+ * if final strike is active, multiply output damage with wrath and reset
101
+ */
102
+ fun tryUseFinale (entity : LivingEntity ? , amount : Float ): Float {
103
+ var outAmount = amount
104
+ if (finalStrike) {
105
+ finalStrike = false
106
+ outAmount * = (wrathCounter / 2 )
107
+ wrathCounter = 0
108
+ }
109
+ return outAmount
84
110
}
85
111
112
+ // OPENER - FINALE end
113
+
86
114
override fun tick () {
115
+ // Count down vampirism only when vampirism ability is selected
87
116
if (vampirismCooldown > 0 && VoidBoundItemUtils .getActiveAbility(player.mainHandItem) == ItemAbility .VAMPIRISM ) {
88
117
vampirismCooldown--
89
118
sync()
90
119
}
91
120
121
+ if (VoidBoundItemUtils .getActiveAbility(player.mainHandItem) != ItemAbility .OPENER ) {
122
+ if (finalStrike) {
123
+ finalStrike = false
124
+ sync()
125
+ }
126
+ if (wrathCounter > 0 ) {
127
+ wrathCounter = 0
128
+ sync()
129
+ }
130
+ }
131
+
92
132
if (! finalStrike) {
93
133
// Wrath logic
94
134
if (wrathCounter in 1 .. 9 ) {
95
- if (wrathCooldown > 0 ) {
96
- wrathCooldown--
135
+ // if cooldown hits 0
136
+ if (wrathStackKiller > 0 ) {
137
+ wrathStackKiller--
97
138
} else {
98
139
// If cooldown hits 0, reset the wrath counter
99
140
wrathCounter = 0
@@ -104,28 +145,46 @@ class VoidBoundPlayerItemAbilityComponent(private val player: Player) : AutoSync
104
145
// FinalStrike logic when wrathCounter reaches 10
105
146
if (wrathCounter == 10 ) {
106
147
finalStrike = true
107
- wrathCounter = 0
108
- wrathCooldown = 0
148
+ wrathStackKiller = 0
109
149
finalStrikeDuration = finalStrikeCooldownMax
110
150
sync()
111
151
}
152
+
112
153
} else {
113
154
// Handle ticking down the finalStrike duration
114
155
if (finalStrikeDuration > 0 ) {
115
156
finalStrikeDuration--
116
157
} else {
158
+ wrathCounter = 0
117
159
finalStrike = false
118
160
}
119
161
sync()
120
162
}
121
163
}
122
164
165
+ override fun readFromNbt (tag : CompoundTag ) {
166
+ vampirismCooldown = tag.getInt(" vampirismCooldown" )
167
+ wrathStackKiller = tag.getInt(" wrathCooldown" )
168
+ wrathCounter = tag.getInt(" wrathCounter" )
169
+ finalStrike = tag.getBoolean(" finalStrike" )
170
+ finalStrikeDuration = tag.getInt(" finalStrikeDuration" )
171
+ }
172
+
173
+ override fun writeToNbt (tag : CompoundTag ) {
174
+ tag.putInt(" vampirismCooldown" , vampirismCooldown)
175
+ tag.putInt(" wrathCooldown" , wrathStackKiller)
176
+ tag.putInt(" wrathCounter" , wrathCounter)
177
+ tag.putBoolean(" finalStrike" , finalStrike)
178
+ tag.putInt(" finalStrikeDuration" , finalStrikeDuration)
179
+ }
180
+
181
+
123
182
private fun sync (){
124
183
VoidBoundComponentRegistry .VOID_BOUND_PLAYER_ITEM_ABILITY_COMPONENT .sync(player)
125
184
}
126
185
127
186
companion object {
128
- fun onRightClickItem (player : ServerPlayer , interactionHand : InteractionHand ? , stack : ItemStack ): Boolean {
187
+ fun onRightClickItem (player : ServerPlayer , interactionHand : InteractionHand , stack : ItemStack ): Boolean {
129
188
if (VoidBoundItemUtils .getActiveAbility(stack) == ItemAbility .TRIPLE_REBOUND ) {
130
189
val level = player.level()
131
190
if (! level.isClientSide) {
@@ -157,5 +216,7 @@ class VoidBoundPlayerItemAbilityComponent(private val player: Player) : AutoSync
157
216
158
217
return false
159
218
}
219
+
220
+
160
221
}
161
222
}
0 commit comments