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

[EO] Randomize spell damage


Kay-No
 Share

Recommended Posts

Hello, im trying to balance my caster classes to match my melee classes.
Since a spell is always doing the same damage independent of the characters stats and level i've added a spell damage formula based of the melee damage. (just switched the weapon vital with spell vital and str with int)

I've added the formula to the spell vital in CastSpell Sub and the Hot's and Dot's player and npc subs

```
Vital = 0.085 * 5 * GetPlayerStat(Index, Intelligence) * Spell(spellnum).Vital + (GetPlayerLevel(Index) / 5)
```
Like this and it works pretty decent. Altough i've seen that the melee damage is randomized and thats where i need some help.
I can't find any randomization in the GetPlayerDamage Sub.

I know this is a simple way of doing this, so if anyone got better ideas on how to do this, feel free to share.  :cheesy:
Link to comment
Share on other sites

random(min,max)

```
        ' Can we attack the npc?
        If CanAttackNpc(Index, i) Then

            ' Get the damage we can do
            If Not CanPlayerCriticalHit(Index) Then
                Damage = GetPlayerDamage(Index) - (Npc(MapNpc(GetPlayerMap(Index)).Npc(i).Num).Stat(Stats.endurance) \ 2)
            Else
                n = GetPlayerDamage(Index)
                Damage = n + Int(Rnd * (n \ 2)) + 1 - (Npc(MapNpc(GetPlayerMap(Index)).Npc(i).Num).Stat(Stats.endurance) \ 2)
                'Call PlayerMsg(Index, "You feel a surge of energy upon swinging!", BrightCyan)
                SendActionMsg GetPlayerMap(Index), "CRITICAL HIT!", BrightCyan, 1, (GetPlayerX(Index) * 32), (GetPlayerY(Index) * 32)
            End If

            If Damage > 0 Then
                Call AttackNpc(Index, i, Damage)
            Else
                Call PlayerMsg(Index, "Your attack does nothing.", BrightRed)
            End If

            Exit Sub
        End If

```
Thats where it calculates the damage a player does.
Link to comment
Share on other sites

Oh wait….  Sorry.  Sec

Edit:
```
        ' Get the damage we can do
        Damage = GetPlayerDamage(Index)

        ' if the npc blocks, take away the block amount
        blockAmount = CanNpcBlock(mapNpcNum)
        Damage = Damage - blockAmount

        ' take away armour
        Damage = Damage - RAND(1, (Npc(npcNum).Stat(Stats.Agility) * 2))
        ' randomise from 1 to max hit
        Damage = RAND(1, Damage)
```

Theres where the engine gets the damage caused by the player.
Link to comment
Share on other sites

Thanks!

Isnt this code very strange?
```
Damage = RAND(1, Damage)
```
Like lets say we have a very strong character (end game) , high  level, best gear etc and his damage is about 300\. Then his damage would be 1-300.

Wouldnt it be better to have something like:
```
Damage = RAND((Damage / 1.5), Damage)
```
Then our characters damage would be 200-300.

Edit: Just tried it out and it worked way better.  :azn:
Link to comment
Share on other sites

@Kay-No:

> Thanks!
>
> Isnt this code very strange?
> ```
> Damage = RAND(1, Damage)
> ```
> Like lets say we have a very strong character (end game) , high  level, best gear etc and his damage is about 300\. Then his damage would be 1-300.
>
> Wouldnt it be better to have something like:
> ```
> Damage = RAND((Damage / 1.5), Damage)
> ```
> Then our characters damage would be 200-300.

Simply a design choice. I made it so that in melee combat you can hit anywhere between 1 and Max Damage.
Link to comment
Share on other sites

Heh. Robin just lays the basics down for you.
The formula is intended to be for show only and you should be revising alot of the code.

Be creative and add a mod variable.
exampled:
Damage 10 Mod 2
Damage = rand(damage-mod, damage+mod)

this will make damage be 8-12\. :)
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...