青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Controlling Players and Characters(23)

 

Creating a Spell Controller

Controlling spells is a matter of tracking the meshes and animations that represent
the spell and then processing the spell’s effects on their intended targets. Because
the spell’s effects are really related to the characters, it’s best to let the engine that
controls the characters handle the spell effects and leave the spell animation up to
a spell controller class object.

You want to create a spell controller class that maintains a list of currently cast spells
and displays them onscreen. When a spell is complete, this controller class calls an outside
function to process the spell’s effects. This spell controller class, cSpellController,
uses supportive structures that make tracking the spell meshes and animation
easier. These structures are sMeshAnim and sSpellTracker.

 

Meshes with sMeshAnim

Reviewing the sSpell spell structure, you can see that meshes are referenced by
number rather than by name. That mesh reference number is actually the index to
an array of meshes. You store this array of meshes in a collection of sMeshAnim
structures:

typedef struct sMeshAnim
{
    
char        filename[MAX_PATH];     // filename of mesh/anim
    long        count;                  // number of characters using mesh
    cMesh       mesh;
    cAnimation  anim;    

    sMeshAnim() { count = 0; }
} *sCharMeshListPtr;

For each mesh in use in your engine, you have a matching sMeshAnim structure.
Each structure instance stores the filename of the mesh to use, a cMesh and a
cAnimation object for the mesh, and a variable (Count) that keeps count of how many
instances of the mesh are currently in use.

For each spell that needs a mesh, the appropriate .X file is loaded into the mesh
and animation objects (both using the same filename and the animation using a
single animation set called anim).

Meshes are only loaded from disk whenever the spell controller requires them, and
because the structure maintains a count of the times the mesh is in use, the spell
controller can quickly determine whether the mesh is loaded.

As spells complete their animation cycle, the appropriate mesh count is reduced,
and when the number of spells that use the mesh is reduced to zero, the mesh and
animation objects are released (to save memory).

 

Tracking Spells Using sSpellTracker

Whereas the sMeshAnim structure maintains the meshes used by spells, the actual
list of active spells is maintained by the sSpellTracker structure. The sSpellTracker
structure is allocated and inserted into a linked list of the same structures any time
a spell is cast:

#define NUM_SPELL_DEF   64

enum SpellEfects
{
    ALTER_HEALTH = 0, ALTER_MANA, CURE_AILMENT, CAUSE_AILMENT, RAISE_DEAD, INSTANT_KILL, DISPEL_MAGIC, TELEPORT
};

enum SpellTargets
{
    TARGET_SINGLE = 0, TARGET_SELF, TARGET_AREA
};

enum AnimPositions
{
    POSITION_NONE = 0, POSITION_CASTER, POSITION_TOTARGET, POSITION_TOCASTER, POSITION_TARGET, POSITION_SCALE
};

/************************************************************************************************/

typedef 
struct sSpellTracker
{
    
long        spell_index;

    sCharacter* caster;
    
long        affect_type;

    
long cur_anim;              // animation: 0-2
    float source_x, source_y, source_z;
    
float target_x, target_y, target_z;

    
float x_pos, y_pos, z_pos;  // current coordinate
    float x_add, y_add, z_add;  // movement values
    float dist_to_target;       

    union
    {
        
float   speed;          
        
long    holding_time;   
    };

    cObject 
object;             // graphics object

    sSpellTracker*  prev;
    sSpellTracker*  next;

    
/////////////////////////////////////////////////////////////////////////////

    sSpellTracker()
    {
        caster = NULL;
        prev = next = NULL;
    }

    ~sSpellTracker()
    {
        delete next;
    }
} *sSpellTrackerPtr;

For each spell cast, a sSpellTracker structure is used to contain the information to track
the mesh, animation, movement, timing, and which character cast the spell. The
structure starts off with the spell number (spell_index), which relates directly to the MSL.

To later help determine the effects of a spell, a pointer to a character (caster) is
maintained as well as the type of characters the spell can affect (PCs, NPCs, or
MCs). You can define each type of character as follows:

#define CHAR_PC 0
#define CHAR_NPC 1
#define CHAR_MONSTER 2

Notice that a spell has no target character defined, but a trio of target coordinates.
In fact, a spell has a trio of source coordinates. Remember that a spell mesh can
stay in place over the caster or victim, move between the two, or stretch between
them. Setting the source and target coordinates ensures that the tracker knows how
to position the mesh in use.

Speaking of the mesh in use, curr_anim is used to track which of the three
meshes to use. As you may recall, a mesh movement takes place in three steps, and
once the current animation passes the third step, the spell takes effect.

To track the motion of the spell meshes (if they are indeed moving), you use a set of
values (x_add, y_add, and z_add) that tells the spell controller which direction to move the
mesh at each update. As for the current position of the mesh in use, the variables
x_pos, x_pos, and z_pos contain the current coordinates at which to render the mesh.

The speed in which a mesh moves is contained in speed, and the total distance the
mesh can move is contained in dist_to_target. If a mesh stays in place, the holding_time variable
does a countdown of the number of milliseconds until the cycle is complete.

Rounding off sSpellTracker, object is the graphics object you use to render the
meshes, and prev and next maintain the linked list of structures.


posted on 2007-12-03 19:11 lovedday 閱讀(216) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲国产日韩欧美在线图片| 亚洲精品视频在线| 亚洲欧美中文字幕| 国产亚洲成精品久久| 久久成人精品无人区| 午夜精品福利在线| 韩日成人在线| 亚洲第一久久影院| 欧美日韩在线播放| 欧美在线视频a| 久久免费的精品国产v∧| 亚洲精品1区2区| 99综合视频| 国产一区二区观看| 亚洲第一精品福利| 国产精品国产三级国产aⅴ9色| 久久综合久久久久88| 亚洲国内自拍| 亚洲小说欧美另类婷婷| 国产一区二区三区在线观看免费视频| 国产亚洲欧洲| 亚洲第一成人在线| 国产精品精品视频| 蜜桃久久精品乱码一区二区| 欧美另类视频在线| 欧美在线视频一区二区| 免费一区视频| 久久成人精品一区二区三区| 美女视频黄 久久| av成人免费在线| 欧美在线一级va免费观看| 日韩一级片网址| 午夜精品福利一区二区蜜股av| 欧美日本高清| 久久一本综合频道| 欧美日韩一区二区精品| 开元免费观看欧美电视剧网站| 亚洲一区二区视频在线观看| 国内外成人在线| 日韩小视频在线观看专区| 国产有码在线一区二区视频| 亚洲国产精品毛片| 好吊色欧美一区二区三区四区| 久久精品一区二区三区不卡牛牛| 一本到12不卡视频在线dvd| 一区二区三区在线不卡| 一区二区三欧美| 亚洲激情另类| 久久亚洲午夜电影| 久久久久久亚洲精品中文字幕| 亚洲视频免费看| 99精品久久久| 久久这里有精品15一区二区三区| 亚洲激情电影在线| 欧美一级视频| 欧美亚洲一区二区在线观看| 欧美精品一区二区久久婷婷 | 亚洲一区二区三区在线观看视频| 欧美日本中文| 亚洲国产另类精品专区| 黄色成人在线| 欧美在线视频一区二区| 欧美在线视频a| 国产日韩在线播放| 午夜在线精品偷拍| 久久精品官网| 韩国一区电影| 久久综合色88| 欧美激情亚洲综合一区| 亚洲国产欧美一区二区三区同亚洲| 亚洲国产精品一区二区www| 永久免费精品影视网站| 久久久久久久久久久一区| 欧美在线免费一级片| 国产日韩欧美三区| 久久精品日韩欧美| 亚洲日本在线视频观看| 另类av一区二区| 亚洲日本在线观看| 亚洲一区二区视频| 国产嫩草一区二区三区在线观看| 牛牛国产精品| 日韩一区二区高清| 国产精品久久久久久亚洲调教| 久久久午夜精品| 亚洲国产天堂久久综合| 欧美精品v国产精品v日韩精品 | 在线不卡中文字幕| 老司机67194精品线观看| 欧美大片在线观看一区| 夜夜嗨av一区二区三区四季av| 欧美中文字幕在线播放| 欧美成人国产va精品日本一级| 欧美天堂亚洲电影院在线播放| 久久久久久香蕉网| 亚洲人成人一区二区三区| 欧美精品一区在线播放| 亚洲午夜久久久久久久久电影网| 亚洲黄色免费电影| 欧美亚洲成人免费| 久久久久久噜噜噜久久久精品| 午夜精品福利一区二区蜜股av| 久热爱精品视频线路一| 99re6热只有精品免费观看| 久久激情视频免费观看| 亚洲三级影院| 国产精品日韩一区二区| 久久一区国产| 亚洲一区二区日本| 亚洲国产精品免费| 久久久青草婷婷精品综合日韩| 国产精品一区二区久久精品| 久久久久99| 亚洲婷婷在线| 亚洲欧洲一区二区三区在线观看| 在线精品国产成人综合| 国产精品狠色婷| 女人色偷偷aa久久天堂| 午夜精彩视频在线观看不卡| 亚洲精品一区二区三区av| 久久人人九九| 午夜亚洲一区| 亚洲一区二区三区高清| 亚洲国产精品成人综合色在线婷婷 | 亚洲大胆在线| 国产模特精品视频久久久久| 欧美日韩美女一区二区| 免费日韩av片| 久久精品国产一区二区三区| 夜夜嗨网站十八久久| 最近看过的日韩成人| 美女国产精品| 久久综合精品一区| 久久久久久久综合色一本| 亚洲欧美日韩综合| 亚洲无线一线二线三线区别av| 国产精品羞羞答答| 国产精品国产一区二区 | 欧美激情久久久久| 久久久美女艺术照精彩视频福利播放| 国产在线高清精品| 国产日产欧产精品推荐色| 欧美丝袜一区二区三区| 欧美日韩国产999| 欧美精品一区二区在线观看| 欧美成人精品h版在线观看| 久久久国产视频91| 久久亚洲欧美| 欧美电影资源| 欧美日韩18| 国产精品国产三级国产专播品爱网| 性欧美1819性猛交| 亚洲天堂免费在线观看视频| 一区二区三区成人| 一本色道久久99精品综合| 亚洲一区二区三区国产| 午夜亚洲视频| 久久久久久久999| 欧美二区乱c少妇| 欧美日韩精品免费 | 亚洲精品一区二区网址| 99国产精品自拍| 亚洲欧美一区二区三区在线| 性一交一乱一区二区洋洋av| 久久久久国产一区二区三区四区 | 亚洲每日更新| 宅男噜噜噜66一区二区66| 亚洲一区精彩视频| 久久成人久久爱| 欧美多人爱爱视频网站| 国产精品九九| 精品999网站| 亚洲色诱最新| 久久久噜噜噜久噜久久| 亚洲国产精品黑人久久久| av成人免费在线观看| 欧美一区二区三区成人| 牛夜精品久久久久久久99黑人 | 欧美激情中文字幕一区二区| 亚洲国产日韩欧美一区二区三区| 久久精品国产2020观看福利| 欧美黄色影院| 亚洲免费影视| 欧美超级免费视 在线| 国产精品免费小视频| 亚洲国产欧美不卡在线观看| 亚洲综合日韩在线| 欧美高清日韩| 欧美一级艳片视频免费观看| 欧美二区在线看| 国产在线成人| 午夜精品久久久久久| 欧美激情第9页| 欧美一区不卡| 国产精品高清在线观看| 亚洲国产日韩在线| 久久久亚洲高清| 一区二区三区四区国产精品| 久久综合伊人77777尤物| 国产欧美日韩综合|