天行健 君子当自强而不息

Controlling Players and Characters(2)

 

Defining Characters in Your Game

Employing characters into your game is one of the most difficult jobs you’ll face.
Even at a basic level, the code needed to control gaming characters can be convoluting.
What’s a lowly programmer to do? Just take it slow, work from the begin-ning, and all will be well.

In this section, I introduce you to some basic concepts common to most roleplaying
games. These concepts include defining a character’s basic abilities (which
include strength, intelligence, agility, and so on), how characters navigate through
the game world, and how characters can interact with each other. Let’s start by
looking at how you can define a character's abilities.

 

Character Abilities

Characters need particular abilities in order to affect the outcome of certain
actions that take place within the game—combat for example. If a character swings
a sword, what is the chance it will hit its intended target, and for that matter how
much damage will the sword produce?


Typical role-playing games assign values to abilities—the higher the value, the better
the character in terms of a particular ability. Using numbers also makes calculations
easier. For example, a typical ability in a role-playing game is strength. Say
that strength is measured from 0 (total weakling) to 999 (super-hero). An average
human could then have strength of 100 to 150.


Now, go one step further and assume that a character must be a certain strength
in order to perform a specific feat. Pushing open a jammed door, for example,
requires a person to have strength of 100 or more. Lifting a boulder requires
strength of 500 or more. Beginning to get the idea?


What other types of abilities can a character possess? For your game, that is the big
question, so think about it carefully. Just what is going to happen in your game that
requires an ability to be assigned to a character? Generally speaking, you can get by
with the abilities shown in Table 16.1.

Each ability in your game is assigned a number, and each ability has a different use for the
numbers. Attack is the amount of damage characters deal out without weapons in their hands.
If this value is 100, the character can cause 100 points of damage per attack. At this point, let me
just say that a character can experience only so many points of damage before dying.

TIP
To keep things fair, whenever a weak character attacks a character with high defense
without the ability to do damage, you still want to apply some level of damage. Later, in
the section “Combat and Characters,” you see how to modify a weak character’s attack
ability in order to apply some sort of damage to a character with a high defense ability.

Defense, on the other hand, reduces the amount of damage points taken from an
attack. If a character has a defense value of 50, the damage from an attack is
reduced by 50 points, so the higher the defense, the lower the damage.

You also can modify attack and defense abilities by using items. Specific items, such
as weapons, have a value that can multiply the attack value of a character.

In terms of agility, characters have an innate chance of dodging attacks, which
increases as the characters grow stronger. Agility is measured from 0 to 999—the
higher the value, the greater the chance of dodging an attack. To determine
the chances of dodging an attack, a random number is figured and compared to the
agility value. If the random number is equal to or lower than the agility ability,
the attack is dodged.

The mental ability ranges anywhere from zero and up. The mental ability determines
the chances of a spell affecting its target. Spells normally have a chance for
success, but when you add mental ability, those chances increase. If a spell has a
mental value of 100, the spell has a 100 percent greater chance for working.

Resistance is the character’s ability to reduce damage from spells. This value can
range from 0 to 100 percent. The percentage is applied to the spell’s damage
amount and used as a final value to cause damage to a target character.

Finally, the to-hit ability can range from 0 to 999 as well. Again, a random value is
compared to the to-hit ability; a random number higher than the to-hit value
means that the attack missed its target.

In addition to character abilities, other types of information can define a character—
for example, the player’s health. A few extra details about each character are
needed at this point to determine just how healthy and powerful a character is.
Enter character attributes.


posted on 2007-11-11 13:59 lovedday 阅读(155) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


公告

导航

统计

常用链接

随笔分类(178)

3D游戏编程相关链接

搜索

最新评论