//On hit set timer to 5 seconds, generate 5 seconds worth of power then stop unless hit again public void OnLightningHit(float duration, float damage) { if (IsWrenched == false) { //We do damage here as the lightning check in TeslaEnergyBall ignores these machines as //they are lightning proof, but we dont want that when they're unwrenched integrity.ApplyDamage(damage, AttackType.Magic, DamageType.Burn, explodeOnDestroy: true); return; } hitTimer = 5; if (CurrentState == TeslaCoilState.Grounding && spriteHandler.CurrentSpriteIndex != 2) { spriteHandler.ChangeSprite(2); return; } if (spriteHandler.CurrentSpriteIndex < 2) { spriteHandler.ChangeSprite(2); } else if (spriteHandler.CurrentSpriteIndex != 2 && spriteHandler.CurrentSpriteIndex < 5) { spriteHandler.ChangeSprite(5); } }
public void ServerPerformInteraction(PositionalHandApply interaction) { PlayerNetworkActions pna = interaction.Performer.GetComponent <PlayerNetworkActions>(); if (interaction.HandObject == null) { // No item in hand, so let's TEACH THIS RACK A LESSON Chat.AddCombatMsgToChat(interaction.Performer, "You kick the rack. Nice job!", interaction.Performer.ExpensiveName() + " kicks the rack."); integrity.ApplyDamage(Random.Range(4, 8), AttackType.Melee, DamageType.Brute); return; } // If the player is using a wrench on the rack, deconstruct it if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Wrench) && interaction.Intent != Intent.Help) { SoundManager.PlayNetworkedAtPos("Wrench", interaction.WorldPositionTarget, 1f); Spawn.ServerPrefab(rackParts, interaction.WorldPositionTarget.RoundToInt(), interaction.TargetObject.transform.parent); Despawn.ServerSingle(gameObject); return; } // Like a table, but everything is neatly stacked. Vector3 targetPosition = interaction.WorldPositionTarget.RoundToInt(); targetPosition.z = -0.2f; pna.CmdPlaceItem(interaction.HandSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), targetPosition, interaction.Performer, true); }
public void ServerPerformInteraction(PositionalHandApply interaction) { PlayerNetworkActions pna = interaction.Performer.GetComponent <PlayerNetworkActions>(); if (interaction.HandObject == null) { // No item in hand, so let's TEACH THIS RACK A LESSON Chat.AddCombatMsgToChat(interaction.Performer, "You kick the rack. Nice job!", interaction.Performer.ExpensiveName() + " kicks the rack."); integrity.ApplyDamage(Random.Range(4, 8), AttackType.Melee, DamageType.Brute); return; } // If the player is using a wrench on the rack, deconstruct it if (Validations.IsTool(interaction.HandObject, ToolType.Wrench) && !interaction.Performer.Player().Script.playerMove.IsHelpIntent) { SoundManager.PlayNetworkedAtPos("Wrench", interaction.WorldPositionTarget, 1f); PoolManager.PoolNetworkInstantiate(rackParts, interaction.WorldPositionTarget.RoundToInt(), interaction.TargetObject.transform.parent); PoolManager.PoolNetworkDestroy(gameObject); return; } // Like a table, but everything is neatly stacked. Vector3 targetPosition = interaction.WorldPositionTarget.RoundToInt(); targetPosition.z = -0.2f; pna.CmdPlaceItem(interaction.HandSlot.equipSlot, targetPosition, interaction.Performer, true); }
public void ServerPerformInteraction(PositionalHandApply interaction) { PlayerNetworkActions pna = interaction.Performer.GetComponent <PlayerNetworkActions>(); if (interaction.HandObject == null) { // No item in hand, so let's TEACH THIS RACK A LESSON Chat.AddCombatMsgToChat(interaction.Performer, "You kick the rack. Nice job!", interaction.Performer.ExpensiveName() + " kicks the rack."); integrity.ApplyDamage(Random.Range(4, 8), AttackType.Melee, DamageType.Brute); return; } // If the player is using a wrench on the rack, deconstruct it if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Wrench) && interaction.Intent != Intent.Help) { SoundManager.PlayNetworkedAtPos("Wrench", interaction.WorldPositionTarget, 1f); Spawn.ServerPrefab(rackParts, interaction.WorldPositionTarget.RoundToInt(), interaction.TargetObject.transform.parent); Despawn.ServerSingle(gameObject); return; } //drop it right in the middle of the rack. IN order to do that we have to calculate //that position as an offset from the performer //TODO: Make it less awkward by adding a serverdrop method that accepts absolute position instead of vector. var targetTileWorldPosition = gameObject.TileWorldPosition(); var targetTileVector = (Vector3Int)targetTileWorldPosition - interaction.PerformerPlayerScript.registerTile.WorldPositionServer; Inventory.ServerDrop(interaction.HandSlot, targetTileVector.To2Int()); }
public void AddDamage() { integrity.ApplyDamage(damageOnHit, AttackType.Melee, DamageType.Brute); if (integrity.integrity <= integrityHealth) { ChangeState(); } }