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

天行健 君子當自強而不息

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 閱讀(208) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(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>
            亚洲亚洲精品三区日韩精品在线视频| 亚洲欧洲视频| 欧美呦呦网站| 欧美一区二区三区视频在线观看| 国产婷婷色一区二区三区| 久久精品国产99| 久久青青草综合| 亚洲精品欧美在线| 亚洲精品少妇网址| 国产精品普通话对白| 久久精品日韩| 欧美激情精品久久久久久变态| 亚洲午夜电影网| 欧美综合国产精品久久丁香| 在线看国产一区| 日韩亚洲欧美在线观看| 国产免费一区二区三区香蕉精| 麻豆精品精华液| 欧美日本亚洲| 久久夜色精品国产| 欧美午夜激情在线| 久久久久久一区二区三区| 欧美精品色综合| 久久理论片午夜琪琪电影网| 欧美激情一区二区| 久久精品电影| 欧美日韩精品系列| 你懂的视频一区二区| 国产精品久久久久久亚洲调教| 欧美gay视频| 国产精品视频一| 亚洲激情欧美激情| 国产精品一区免费观看| 91久久国产精品91久久性色| 国产一本一道久久香蕉| 一本色道久久综合亚洲二区三区 | 亚洲精品中文字幕有码专区| 国产一级精品aaaaa看| 亚洲伦伦在线| 亚洲精品久久久久久久久久久久久| 午夜久久福利| 99视频国产精品免费观看| 久久人人看视频| 久久精品一二三区| 国产精品视频九色porn| 亚洲精品综合| 亚洲精品一区二区三区婷婷月| 欧美一区二区三区四区视频 | 亚洲电影在线播放| 亚洲欧美三级在线| 亚洲一区网站| 欧美视频在线免费看| 亚洲激情视频在线播放| 亚洲第一免费播放区| 久久国产日韩| 久久青青草综合| 国产偷国产偷亚洲高清97cao| 一区二区三区国产| 亚洲自拍偷拍福利| 欧美日韩国产综合在线| 91久久精品一区| 夜夜嗨av一区二区三区| 欧美日韩国产精品自在自线| 亚洲区一区二| 亚洲视频第一页| 国产精品videosex极品| 在线天堂一区av电影| 亚洲影院在线观看| 国产精品一区亚洲| 欧美亚洲网站| 欧美1区2区| 亚洲人成7777| 欧美日韩在线免费视频| 亚洲婷婷综合色高清在线| 亚洲一区美女视频在线观看免费| 国产精品久久波多野结衣| 中文在线不卡视频| 久久黄色小说| 亚洲国产日本| 欧美日韩综合视频网址| 亚洲午夜精品视频| 久久免费视频在线观看| 亚洲精品国精品久久99热一| 欧美伦理视频网站| 亚洲一区二区在线视频| 美女尤物久久精品| 日韩亚洲视频| 国产九九精品视频| 久久这里只有| 中文久久精品| 免费成人av在线| 一本一本a久久| 国产一区二区精品| 欧美激情精品久久久久久大尺度 | 日韩一二在线观看| 久久成人免费网| 亚洲经典在线| 国产伦精品一区二区| 久久深夜福利| 国产精品99久久久久久宅男| 久久亚洲午夜电影| 亚洲午夜精品久久久久久app| 国产亚洲亚洲| 欧美巨乳波霸| 久久久久欧美精品| 亚洲午夜精品一区二区| 欧美gay视频激情| 性色av一区二区三区红粉影视| 亚洲国产精品美女| 国产精品永久免费观看| 欧美精品久久久久a| 久久国产精品久久国产精品 | 农夫在线精品视频免费观看| 亚洲影视九九影院在线观看| 亚洲激情影视| 黄色一区二区三区| 国产精品视频一区二区高潮| 欧美xxx在线观看| 欧美在线视频一区二区| 一本在线高清不卡dvd| 亚洲福利视频专区| 久久国产一二区| 午夜久久久久久| 日韩亚洲不卡在线| 亚洲黄色一区二区三区| 狠狠操狠狠色综合网| 国产精品一区二区三区免费观看 | 亚洲电影在线播放| 国产亚洲激情| 国产麻豆91精品| 欧美午夜不卡视频| 欧美日韩精品综合| 欧美精品亚洲| 欧美日本一区二区三区| 欧美丰满高潮xxxx喷水动漫| 久久免费高清| 久久艳片www.17c.com| 久久精品色图| 久久精品男女| 久久―日本道色综合久久| 久久不射中文字幕| 久久精品国产久精国产一老狼| 欧美一区二区三区精品电影| 午夜激情一区| 久久电影一区| 久久偷看各类wc女厕嘘嘘偷窃| 久久久久久久久久看片| 久久亚洲精品中文字幕冲田杏梨 | 亚洲免费视频在线观看| 亚洲综合色婷婷| 欧美亚洲网站| 久久躁狠狠躁夜夜爽| 母乳一区在线观看| 欧美日韩hd| 国产精品成人在线观看| 国产精品夜色7777狼人 | 欧美日本在线观看| 欧美视频日韩视频在线观看| 欧美性一区二区| 国产亚洲福利| 亚洲日本成人女熟在线观看| 99视频在线精品国自产拍免费观看| 一区二区三区高清视频在线观看| 亚洲一区二区av电影| 久久aⅴ国产紧身牛仔裤| 久久久久久婷| 亚洲精品国产精品国自产观看| 中文国产一区| 久久手机精品视频| 欧美精品在线观看一区二区| 国产精品乱子乱xxxx| 国内精品伊人久久久久av影院| 亚洲第一免费播放区| 亚洲天堂av高清| 久久综合国产精品台湾中文娱乐网| 亚洲第一福利在线观看| 亚洲小说春色综合另类电影| 久久久精品性| 国产精品二区在线观看| 精品成人在线观看| 亚洲永久视频| 欧美高清视频一区二区| 亚洲欧美日韩精品综合在线观看 | 欧美在线观看一区| 欧美精品自拍| 激情文学一区| 午夜一区二区三区不卡视频| 女人天堂亚洲aⅴ在线观看| 亚洲色诱最新| 欧美日韩99| 亚洲高清成人| 久久久精彩视频| 亚洲社区在线观看| 欧美理论在线| 亚洲国产黄色片| 久久久午夜视频| 亚洲一区二区三区四区五区午夜| 欧美激情一区二区久久久| 精品成人在线观看| 久久久五月婷婷|