@@ -181,10 +181,11 @@ export default class TankBody extends LivingEntity implements BarrelBase {
181181 camera . setFieldFactor ( tank . fieldFactor ) ;
182182
183183 this . scale ( 1 ) ; // Update addons and etc
184+ this . calculateStatData ( ) ;
184185 }
185186 /** See LivingEntity.onKill */
186187 public onKill ( entity : LivingEntity ) {
187- if ( Entity . exists ( this . cameraEntity . cameraData . values . player ) && entity !== this ) this . scoreData . score = this . cameraEntity . cameraData . score += entity . scoreReward ;
188+ if ( Entity . exists ( this . cameraEntity . cameraData . values . player ) && entity !== this ) this . cameraEntity . addScore ( entity . scoreReward ) ;
188189
189190 if ( ( entity . nameData && ! ( entity . nameData . values . flags & NameFlags . hiddenName ) ) ) {
190191 const client = this . cameraEntity . getClient ( ) ;
@@ -244,6 +245,30 @@ export default class TankBody extends LivingEntity implements BarrelBase {
244245 super . receiveDamage ( source , amount ) ;
245246
246247 }
248+
249+ public calculateStatData ( ) {
250+ // Damage
251+ this . damagePerTick = this . cameraEntity . cameraData . statLevels [ Stat . BodyDamage ] + 5 + ( this . definition . bodyDamage ?? 0 ) ;
252+
253+ // Max Health
254+ const maxHealthCache = this . healthData . values . maxHealth ;
255+
256+ this . healthData . maxHealth = this . definition . maxHealth + 2 * ( this . cameraEntity . cameraData . values . level - 1 ) + this . cameraEntity . cameraData . values . statLevels . values [ Stat . MaxHealth ] * 20 ;
257+ if ( this . healthData . values . health === maxHealthCache ) this . healthData . health = this . healthData . maxHealth ; // just in case
258+ else if ( this . healthData . values . maxHealth !== maxHealthCache ) {
259+ this . healthData . health *= this . healthData . values . maxHealth / maxHealthCache
260+ }
261+
262+ // Regen
263+ this . regenPerTick = ( this . healthData . values . maxHealth * 4 * this . cameraEntity . cameraData . values . statLevels . values [ Stat . HealthRegen ] + this . healthData . values . maxHealth ) / 25000 ;
264+
265+ // Reload
266+ this . reloadTime = 15 * Math . pow ( 0.914 , this . cameraEntity . cameraData . values . statLevels . values [ Stat . Reload ] ) ;
267+
268+ // Movement speed
269+ this . cameraEntity . cameraData . movementSpeed =
270+ this . definition . speed * 2.55 * Math . pow ( 1.07 , this . cameraEntity . cameraData . values . statLevels . values [ Stat . MovementSpeed ] ) / Math . pow ( 1.015 , this . cameraEntity . cameraData . values . level - 1 ) ;
271+ }
247272
248273 /** See LivingEntity.onDeath */
249274 public onDeath ( killer : LivingEntity ) {
@@ -326,31 +351,6 @@ export default class TankBody extends LivingEntity implements BarrelBase {
326351 this . styleData . opacity = util . constrain ( this . styleData . values . opacity , 0 , 1 ) ;
327352 }
328353
329-
330- // Update stat related
331- updateStats: {
332- // Damage
333- this . damagePerTick = this . cameraEntity . cameraData . statLevels [ Stat . BodyDamage ] + 5 ;
334- if ( this . _currentTank === Tank . Spike ) this . damagePerTick += 2 ;
335-
336- // Max Health
337- const maxHealthCache = this . healthData . values . maxHealth ;
338-
339- this . healthData . maxHealth = this . definition . maxHealth + 2 * ( this . cameraEntity . cameraData . values . level - 1 ) + this . cameraEntity . cameraData . values . statLevels . values [ Stat . MaxHealth ] * 20 ;
340- if ( this . healthData . values . health === maxHealthCache ) this . healthData . health = this . healthData . maxHealth ; // just in case
341- else if ( this . healthData . values . maxHealth !== maxHealthCache ) {
342- this . healthData . health *= this . healthData . values . maxHealth / maxHealthCache
343- }
344-
345- // Regen
346- this . regenPerTick = ( this . healthData . values . maxHealth * 4 * this . cameraEntity . cameraData . values . statLevels . values [ Stat . HealthRegen ] + this . healthData . values . maxHealth ) / 25000 ;
347-
348- // Reload
349- this . reloadTime = 15 * Math . pow ( 0.914 , this . cameraEntity . cameraData . values . statLevels . values [ Stat . Reload ] ) ;
350- }
351-
352- this . scoreData . score = this . cameraEntity . cameraData . values . score ;
353-
354354 if ( ( this . styleData . values . flags & StyleFlags . isFlashing ) && ( this . game . tick >= this . cameraEntity . cameraData . values . spawnTick + 374 || this . inputs . attemptingShot ( ) || this . inputs . movement . magnitude > 0 ) ) {
355355 this . styleData . flags ^= StyleFlags . isFlashing ;
356356 // Dont worry about invulnerability here - not gonna be invulnerable while flashing ever (see setInvulnerability)
0 commit comments