Cause damage to players?

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Cause damage to players?

Post by stranf »

I can't seem to find a function that damages players.

What I'm looking for is a way to hurt a player who puts something on:

IE:

Code: Select all

 OnEquip()

{
  Damage(mChar, damageAmount)  


}
Also, is there a way to specify random numbers through the JS engine? It would be fun to do:

Code: Select all

Damage(mChar, 3d20)
or something to the effect, to get some randomness in the game.

Thanks!
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Short answer, yes, long answer, yes with a but :)

You didn't need any way (and for your purposes, still don't) till now to do damage to a person. You could have used code looking like:

Code: Select all

mChar.health -= 23;
That would reduce 23 health from a player. However, something I am committing shortly will adjust that. You can still use that method (and for your purposes, it being an item, that's fine) but there will be a better way for other characters to do damage, and that will be.

Code: Select all

mChar.Damage( 23, [attacker] );
The [attacker] part is entirely optional, so if no character does the damage, you don't have to pass it. But if you do, it gets tracked that that player did the damage. There's also a Heal() varient that will be added too (healing is +=, not -=, btw).

And as for randomness, yes, dice exist. For your example there, it would be

Code: Select all

mChar.health -= RollDice( 3, 20, 0 );
RollDice takes 3 parameters (eg RollDice( a, b, c ) )
1) The number of die
2) The number of faces on each die
3) The number to add.

As a dice, the formula would be

aDb + c

Hope that helps.
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Sweet! nice explaination. That's exactly what I wanted.

I already released my cursed items, so I guess I'll add some damage-causing cursed items with the release of my magic items 3. :)
Post Reply