Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Damage Scripting


peekay
 Share

Recommended Posts

Hey there well i got a script for randomizing player damage to npc's but now i need to know how to randomise the damage that npcs do to players

this is the player damage to npc script im using

Quote

    ' Executes when a player presses the CONTROL key.
    Sub OnAttack(Index, Damage)
      Dim Target
      Dim DmgRange

      DmgRange = Rand(Int(Damage) - 3, Int(Damage) + 3)

      If Int(Damage) > 0 Then
          If Int(GetPlayerTarget(Index)) > 0 Then
            Target = GetPlayerTarget(Index)
            Call DamagePlayer(Index, Target, DmgRange)
          Else
            Target = GetPlayerTargetNPC(Index)
            Call DamageNPC(Index, Target, DmgRange)
          End If
      End If
    End Sub

If anyone can give me a script to randomize damage done to a player ill be thankful
Link to comment
Share on other sites

that should do both already

```
    ' Executes when a player presses the CONTROL key.
    Sub OnAttack(Index, Damage)
      Dim Target
      Dim DmgRange

      DmgRange = Rand(Int(Damage) - 3, Int(Damage) + 3) 'here we make some random damage no matter what

      If Int(Damage) > 0 Then  'if damage is 1 or more continue
          If Int(GetPlayerTarget(Index)) > 0 Then  'if target is player continue
            Target = GetPlayerTarget(Index) 'make Target point to target player
            Call DamagePlayer(Index, Target, DmgRange)  'damage target player
          Else  'we already know the target is an npc
            Target = GetPlayerTargetNPC(Index)  'target is now the target npc
            Call DamageNPC(Index, Target, DmgRange) 'damage the npc
          End If
      End If
    End Sub

```see?
Link to comment
Share on other sites

peekay, I think you want to add these lines:
```
Dim DmgRange
DmgRange = Rand(Int(Damage) - 3, Int(Damage) + 3)
```

to Sub PlayerHit, so that it'll look like this:
```
Sub PlayerHit(Index, NPCNum, Damage)
Dim DmgRange

DmgRange = Rand(Int(Damage) - 3, Int(Damage) + 3)

If Damage > 0 Then
Call NPCAttack(NPCNum, Index, DmgRange)
End If
End Sub
```

Also, be sure to add the same lines to Sub OnArrowHit, so ranged attack damage is randomized, too.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...