newsgroups-index (beta)

Current group: aus.mathematics

Formula help with my adventure game, please.

Formula help with my adventure game, please.  
alexportilla at pobros.com
From:alexportilla at pobros.com
Subject:Formula help with my adventure game, please.
Date:Fri, 07 Jan 2005 17:26:54 -0500
Larry Lard wrote:

> Alex Hotmail wrote:
>
>> Hello,
>>
>> Maybe someone can help me out here, my math skills aren't that great.
>
>
>
>> I'm creating a small adventure game and I need to hash out some
>
>
> formulas
>
>> such as the hero hitting a monster. My next step is to find the
>
>
> linear
>
>> formula solution, fit a plane to the four points.
>>
>> These are the variables I'm using:
>>
>> ·PlayerDexterity = ranges from 1 to 100.
>> ·PlayerMinDexterity = minimum dexterity of a player
>> ·PlayerMaxDexterity = maximum dexterity of a player
>> ·NPCLevel = the current level of a monster
>> ·NPCMinLevel = the lowest level a monster can be
>> ·NPCMaxLevel = the highest level a monster can be
>> ·ToHitNpc = the chance off hitting a monster based on percentage
>
>
> between
>
>> 1 and 100
>>
>> I've defined these rules for the player to hit a monster:
>>
>> If PlayerDexterity is equal to PlayerMinDexterity, and NPCLevel is
>
>
> equal
>
>> to NPCMinLevel, then ToHitNPC is equal to 50%
>>
>> If PlayerDexterity is equal to PlayerMaxDexterity, and NPCLevel is
>
>
> equal
>
>> to NPCMinLevel, then ToHitNPC is equal to 100%
>>
>> If PlayerDexterity is equal to PlayerMinDexterity, and NPCLevel is
>
>
> equal
>
>> to NPCMaxLevel, then ToHitNPC is equal to 0%
>>
>> If PlayerDexterity is equal to PlayerMaxDexterity, and NPCLevel is
>
>
> equal
>
>> to NPCMaxLevel, then ToHitNPC is equal to 50%
>>
>> Step 1, linear formula solution, fit a plane to the four points:
>> ( x, y, z ) = ( PlayerDextery, NPCLevel, ToHitNPC ) =
>> ( PlayerMinDexterity, NPCMinLevel, 50 ),
>> ( PlayerMaxDexterity, NPCMinLevel, 100 ),
>> ( PlayerMinDexterity, NPCMaxLevel, 0 ),
>> ( PlayerMaxDexterity, NPCMaxLevel, 50 )
>>
>> I'm not sure how to proceed, I need the formula to calculate the
>> ToHitNPC percentage.
>
>
>
> How about this: scale NPC level linearly thus:
>
> minlevel ---- level --- maxlevel
> 0 --- L ---- 50
>
> ie L = (level-minlevel) / (maxlevel-minlevel)
>
> also scale dex linearly to between 0 and 50
>
> D = (dex-mindex) / (maxdex-mindex)
>
> then say
>
> Tohit = L + D
>
> That fits your four points.
>
> btw when you say
>
>
>> ·PlayerDexterity = ranges from 1 to 100.
>> ·PlayerMinDexterity = minimum dexterity of a player
>> ·PlayerMaxDexterity = maximum dexterity of a player
>
>
>
> Do you just mean that mindex=1 and maxdex=100?
>
>
>
>
>> Thanks for your help!!!
>> Alex
>
>
>

Thanks for the quick response! I think I undertand what you are saying.
Some of the variables I've used will be actually constants once the game
is running but I want to be able to change them if need be. Here are the
values I'm currently using:

•There are 29 unique NPC monster types in the game that range from
indexes 1 to 29. Each NPC monster index is directly tied to the level,
ex: NPC monster index 16 is a level 16 NPC monster.

•The monsters grow stronger linearly with the weakest being 1 and the
strongest 29.

•PlayerMinDexterity = 10

•PlayerMaxDexterity = 100

•PlayerDexterity: mindex = PlayerMinDexterity, maxdex = PlayerMaxDexterity

•NPCMinLevel = 1

•NPCMaxLevel = 29

•NPCLevel: mindex = NPCMinLevel, maxdex = NPCMaxLevel

•ToHitNpc: mindex = 0, maxdex = 100

If I were to use these numbers then I would get something like this:

Linear formula solution, fit a plane to the four points:
( x, y, z ) = ( PlayerDextery, NPCLevel, ToHitNPC ) = (10,1,50),
(100,1,100), (10,29,0), (100,29,50)

Choosing the first three points we find analytically that they share the
plane defined by:
z = (ax+by+d)/c = (1400x - 4500y + 116500)/ 2520

Then plugging back in all four values for x and y we get these values for
z:

x y z
--- --- ---
100 29 50
100 1 100
10 29 0
10 1 50

So those values lie in the same plane. Thus the formula is:
ToHitNPC = (1400 * PlayerDexterity - 4500 * NPCLevel + 116500)/ 2520


My issue is that I don't want to hardcode the "1400, 4500, 116500, and
2520" numbers in the formula above so that I can easily come later and
adjust these numbers.

Thanks!!
Alex
   

Copyright © 2006 newsgroups-index   -   All rights reserved   -   Impressum