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

天行健 君子當自強而不息

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 閱讀(214) 評論(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>
            aa国产精品| 亚洲免费一区二区| 久久久亚洲国产美女国产盗摄| 国产精品久久午夜夜伦鲁鲁| 亚洲一区二区黄色| 亚洲制服少妇| 国产主播一区二区| 免费欧美网站| 欧美激情精品久久久久久久变态| 99re6热只有精品免费观看| 亚洲精品久久视频| 欧美日本韩国一区| 亚洲欧美在线免费观看| 亚洲欧美日韩国产中文在线| 韩国成人福利片在线播放| 欧美1区2区视频| 欧美另类人妖| 欧美一级在线播放| 欧美在线短视频| 亚洲美女黄网| 亚洲一区二区三区免费在线观看 | 亚洲美女电影在线| 欧美黄网免费在线观看| 亚洲综合导航| 久久精品综合网| 亚洲午夜国产一区99re久久 | 久久久一区二区| 女主播福利一区| 亚洲一区二区视频在线| 欧美在线一区二区三区| 亚洲精品在线视频观看| 性色av一区二区怡红| 亚洲国产一区二区三区高清| 日韩一本二本av| 韩国欧美国产1区| 一区二区三区四区国产| 亚洲高清不卡在线观看| 亚洲一区999| 亚洲精品欧美| 久久精品123| 亚洲免费中文| 欧美另类变人与禽xxxxx| 久久精品1区| 国产精品国色综合久久| 欧美大片免费看| 国内精品久久久久久 | 免费在线国产精品| 国产精品美女www爽爽爽视频 | 亚洲视屏在线播放| 狼狼综合久久久久综合网 | 亚洲精品免费观看| 欧美在线免费观看亚洲| 亚洲女人av| 欧美日韩精品在线视频| 欧美99在线视频观看| 国产一区二区三区高清 | 久久久久久亚洲精品杨幂换脸| 欧美喷水视频| 亚洲国产精品一区在线观看不卡| 国产自产高清不卡| 午夜精品久久久久99热蜜桃导演| 在线中文字幕日韩| 欧美日韩国产综合视频在线| 欧美96在线丨欧| 亚洲成在人线av| 久久免费偷拍视频| 美女黄毛**国产精品啪啪| 狠狠色狠狠色综合| 久久国产精品网站| 免费欧美高清视频| 亚洲成色999久久网站| 麻豆精品视频在线观看| 欧美成人官网二区| 亚洲精品资源| 欧美日韩国产色综合一二三四 | 老司机久久99久久精品播放免费| 国产一区二区精品久久91| 欧美一区二区日韩| 免费观看国产成人| 亚洲精品国产拍免费91在线| 欧美精品久久天天躁| 日韩视频在线一区| 性色一区二区三区| 狠狠色丁香久久婷婷综合_中| 久久久久九九九九| 亚洲国产毛片完整版| 中文在线资源观看网站视频免费不卡| 欧美日韩国产美| 亚洲欧美激情视频| 可以免费看不卡的av网站| 最新亚洲激情| 国产精品丝袜久久久久久app | 欧美激情无毛| 一区二区日韩免费看| 国产欧美日韩免费看aⅴ视频| 欧美在线精品免播放器视频| 欧美成人情趣视频| 亚洲一区二区三区欧美| 韩日欧美一区二区三区| 欧美激情视频在线播放| 亚洲欧美精品| 亚洲国产精品一区二区尤物区 | 亚洲精品一区二区三区在线观看 | 欧美一区2区三区4区公司二百| 久久综合伊人| 亚洲天堂第二页| 伊人精品久久久久7777| 欧美日韩一区在线观看| 久久久久国产成人精品亚洲午夜| 亚洲精品欧美在线| 久久人体大胆视频| 亚洲免费在线精品一区| 在线免费不卡视频| 国产精品一区二区三区成人| 欧美粗暴jizz性欧美20| 香蕉久久久久久久av网站| 亚洲精选国产| 欧美v日韩v国产v| 亚洲自拍偷拍视频| 亚洲精品四区| 黄网动漫久久久| 欧美视频一二三区| 欧美aa在线视频| 久久免费视频在线| 亚洲欧美在线免费| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 久久免费少妇高潮久久精品99| 一本一本久久| 亚洲精品欧美精品| 尤物九九久久国产精品的特点| 国产精品美女xx| 欧美日韩不卡| 欧美国产乱视频| 蜜桃av久久久亚洲精品| 久久超碰97人人做人人爱| 亚洲欧美久久久| 亚洲一区二区精品| 一区二区日韩伦理片| 亚洲精品中文字幕有码专区| 亚洲高清一区二| 亚洲国产1区| 亚洲黄网站黄| 亚洲黄页一区| 亚洲精品免费一区二区三区| 亚洲第一主播视频| 亚洲国产精品久久久久婷婷884| 免费一级欧美片在线观看| 免费日韩成人| 免费在线观看成人av| 麻豆91精品| 欧美激情精品久久久久| 欧美激情一二三区| 亚洲人成在线影院| 亚洲欧洲精品一区| 日韩网站在线| 亚洲自拍电影| 久久精品综合| 免费成人黄色av| 欧美精品一区三区在线观看| 欧美日韩国产一区精品一区 | 久久天天躁夜夜躁狠狠躁2022| 久久久久久精| 欧美v日韩v国产v| 欧美日韩久久精品| 国产精品稀缺呦系列在线| 国产日韩精品一区二区三区在线| 国产在线观看91精品一区| 欲色影视综合吧| 亚洲精品一区二区三区福利| 亚洲视屏一区| 久久精品观看| 最新成人av网站| 亚洲在线1234| 久久婷婷人人澡人人喊人人爽| 欧美激情第4页| 国产精品午夜av在线| 精品成人一区| 中文日韩在线| 久久一区欧美| 在线性视频日韩欧美| 欧美在线不卡| 欧美三级不卡| 在线日韩一区二区| 亚洲免费在线观看| 免费在线欧美黄色| 亚洲一区二区三区成人在线视频精品| 欧美制服丝袜第一页| 欧美日韩精选| 一区二区三区中文在线观看 | 怡红院精品视频| 亚洲天堂网站在线观看视频| 久久亚洲一区二区| 日韩亚洲成人av在线| 久久久亚洲国产天美传媒修理工| 欧美日韩一区二区三区| 在线播放中文字幕一区| 午夜精品亚洲| 日韩一区二区精品在线观看| 久久亚洲电影| 国产综合色在线|