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

天行健 君子當自強而不息

Controlling Players and Characters(40)

Things are winding down with the controller at this point. You use the following
functions to equip, use, and drop an item:

bool cCharController::equip(sCharacter* character, long item_index, long equip_type, bool equip_now)
{
    
if(m_mil == NULL || character == NULL)
        
return false;

    
// make sure allow equiping of item
    if(! check_bit(m_mil[item_index].usage, character->char_def.class_index))
        
return false;

    
// remove current item first and equip new one
    switch(equip_type)
    {
    
case WEAPON:
        character->char_def.weapon = -1;
        character->weapon_mesh.free();

        
if(equip_now && m_mil[item_index].category == WEAPON)
        {
            character->char_def.weapon = item_index;

            
if(m_mil[item_index].mesh_filename)
            {
                
char path[MAX_PATH];
                sprintf(path, "%s%s", m_weapon_mesh_path, m_mil[item_index].mesh_filename);

                character->weapon_mesh.load(path, m_texture_path);
                character->weapon_object.create(&character->weapon_mesh);
                character->weapon_object.attach_to_object(&character->
object, "WeaponHand");
            }
        }

        
break;

    
case ARMOR:
        character->char_def.armor = -1;

        
if(equip_now && m_mil[item_index].category == ARMOR)
            character->char_def.armor = item_index;

        
break;

    
case SHIELD:
        character->char_def.shield = -1;

        
if(equip_now && m_mil[item_index].category == SHIELD)
            character->char_def.shield = item_index;

        
break;

    
case ACCESSORY:
        character->char_def.accessory = -1;

        
if(equip_now && m_mil[item_index].category == ACCESSORY)
            character->char_def.accessory = item_index;

        
break;

    
default:
        
return false;
    }

    
return true;
}

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

void cCharController::use_item(sCharacter* owner, sCharacter* target, 
                               
long item_index, sCharItem* char_item)
{
    
if(owner == NULL || target == NULL || m_mil == NULL)
        
return;

    sItem* item = &m_mil[item_index];

    
// make sure allow to use of item
    if(! check_bit(item->usage, target->char_def.class_index))
        
return;

    
// use specified item
    switch(item->category)
    {
    
case EDIBLE:
    
case HEALING:   // alter health
        target->health_points += item->value;
        
break;
    }

    
// decrease quantity and remove object if needed
    if(check_bit(item->flags, USEONCE) && char_item)
    {
        char_item->quantity--;

        
if(char_item->quantity <= 0 && owner->char_ics)
            owner->char_ics->remove(char_item);
    }
}

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

bool cCharController::drop(sCharacter* character, sCharItem* char_item, long quantity)
{
    
if(char_item == NULL || m_mil == NULL || character == NULL)
        
return false;

    
// make sure item can be dropped
    if(! check_bit(m_mil[char_item->item_index].flags, CANDROP))
        
return false;

    char_item->quantity -= quantity;

    
// remove item from ics if no more left
    if(char_item->quantity <= 0 && character->char_ics)
        character->char_ics->remove(char_item);

    
return true;
}

With equip, you must specify the character to modify and the item number (from
the MIL) of the item being equipped. You use the equip_type argument to specify which
item type to equip (WEAPON, ARMOR, SHIELD, or ACCESSORY) and the equip_now flag to tell the
controller to equip the specified item (set equip_now to true) or just to unequip the currently
used item (by setting equip_now to false).

As for the use item function (use_item), two characters are required: the owner of the
item and the character on which the item is being used. In that way, one character
can use a healing potion on another character. Specify the MIL item number being
used, as well as a pointer to the owner’s ICS char_item structure so that the quantity
of the item can be decreased.

The next function is required to process the teleport spell effect on PCs. Whenever a
teleport spell is used on a PC, the character controller calls the following function to
handle the effects. Both the pointer to the target character and spell structure are
passed:

virtual bool pc_teleport(sCharacter* character, const sSpell* spell)
{
  return true;
}

Finishing up the character controller class functions is the one that is responsible
for preparing a character to perform an action. You use this function mostly when
controlling your PC via the pc_update function:

    void set_char_action(sCharacter* character, long action, long action_timer)
    {
        
if(character == NULL)
            
return;

        
// make sure attack, spell, and item supporting charge.
        if(action == CHAR_ATTACK || action == CHAR_SPELL || action == CHAR_ITEM)
        {
            
if(character->charge < 100.0f)
                
return;
        }

        character->action = action;
        play_action_sound(character);

        
long mesh_index = character->char_def.mesh_index;

        
// set action timer
        if(action_timer == -1)
            character->action_timer = 1;
        
else
        {
            
ulong anim_length = m_mesh_anim[mesh_index].anim.get_time_length(m_char_anim[action].name);
            character->action_timer = action_timer + anim_length * 30;
        }
    }

When a PC (or any character for that matter) does something, a matching action is
performed. Walking is an action, attacking is an action, and so on. Previously, actions
were defined as CHAR_IDLE, CHAR_MOVE, CHAR_ATTACK, and so on, for example. You need to
set the action argument to one of those values in order to initiate a character action.

For each action that a character can perform, there is a matching animation in the
sCharAnimInfo structure array used to initialize the controller. When a character
performs an action, the appropriate animation is set, as well as the action timer
used to count down the time until the animation is complete. Remember that no
further actions can be performed until the current action is complete.

The last argument in the list, add_timer, is used to add additional milliseconds to the
action timer. Specifying a value of -1 for add_timer, forces set_char_action to not use the
action timer, which means that the action clears on the next update.

posted on 2007-12-04 20:13 lovedday 閱讀(231) 評論(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>
            亚洲精品久久久久久一区二区| 亚洲成人在线| 午夜精品一区二区三区在线视| 日韩视频免费观看| 欧美视频免费看| 欧美在线视频观看| 久久精品视频免费播放| 亚洲国产精品久久精品怡红院| 亚洲成人自拍视频| 欧美日韩一区二区视频在线观看 | 亚洲一二三区精品| 国产精品一香蕉国产线看观看| 久久久精品日韩欧美| 欧美.com| 亚洲欧美另类国产| 久久精品国产亚洲精品| 亚洲精品欧洲精品| 亚洲亚洲精品在线观看| 影音先锋国产精品| 99re6热在线精品视频播放速度| 国产精品一区免费视频| 久久夜色撩人精品| 欧美日韩蜜桃| 久久久久久久久岛国免费| 欧美h视频在线| 欧美一区二区高清在线观看| 久久综合五月| 欧美一区二区国产| 嫩草成人www欧美| 午夜激情一区| 欧美成人在线免费观看| 久久激情视频| 欧美日韩精品一本二本三本| 久久尤物视频| 国产精品卡一卡二卡三| 亚洲国产日韩在线| 国内成+人亚洲| 在线综合亚洲欧美在线视频| 亚洲国产片色| 久久激情综合网| 亚洲午夜精品网| 蜜臀av国产精品久久久久| 欧美一区二区视频97| 欧美激情精品久久久久久| 久久久水蜜桃av免费网站| 欧美三级小说| 亚洲精品国精品久久99热一| 在线观看三级视频欧美| 午夜精品理论片| 亚洲欧美日韩视频一区| 欧美精品日韩| 亚洲福利专区| 亚洲黄页一区| 久久综合久久综合久久| 久久亚洲欧美| 国产一区在线视频| 午夜精品久久久久久久99热浪潮 | 久久狠狠亚洲综合| 国产精品成人一区| 一区二区三区高清在线| 在线亚洲伦理| 欧美日韩一区在线视频| 亚洲精品在线视频| 一本色道久久88综合亚洲精品ⅰ| 另类专区欧美制服同性| 欧美大片在线观看| 91久久中文| 欧美另类在线播放| 亚洲精品日韩一| 国产精品99久久久久久久女警| 欧美a级一区| 亚洲国产精品黑人久久久| 亚洲精品一区二区在线观看| 模特精品在线| 亚洲精品一区二区三区福利| 在线亚洲国产精品网站| 欧美丝袜第一区| 亚洲一区二区三区在线视频| 小黄鸭精品aⅴ导航网站入口 | 久久综合伊人77777蜜臀| 免费观看成人www动漫视频| 在线观看视频一区二区欧美日韩| 久久久久久久久蜜桃| 蜜臀va亚洲va欧美va天堂| 亚洲国产精品久久久久久女王| 免费欧美日韩| 亚洲伦伦在线| 欧美在线日韩在线| 悠悠资源网久久精品| 欧美精品国产一区| 亚洲视频第一页| 久久字幕精品一区| 日韩写真在线| 国产精品视频久久一区| 久久一区免费| aa级大片欧美三级| 久久艳片www.17c.com| 日韩一级在线观看| 国产三区二区一区久久| 久久综合五月| 亚洲午夜久久久久久久久电影院| 久久视频国产精品免费视频在线| 亚洲国产日韩欧美综合久久 | 久久精品一本| 夜夜嗨av色综合久久久综合网| 欧美中文字幕| 亚洲最黄网站| 激情伊人五月天久久综合| 欧美日韩的一区二区| 欧美亚洲视频一区二区| 亚洲人成人99网站| 久久视频这里只有精品| 宅男精品导航| 最新日韩欧美| 国产一区欧美日韩| 国产精品高潮呻吟| 美女日韩在线中文字幕| 亚洲欧美另类国产| 亚洲精品社区| 亚洲高清二区| 久久综合色婷婷| 欧美一区深夜视频| 中文久久精品| 亚洲国产精品va在线看黑人动漫| 国产欧美日韩在线视频| 欧美另类99xxxxx| 另类图片综合电影| 久久久91精品国产一区二区三区| 亚洲视频中文| 夜色激情一区二区| 亚洲人成在线影院| 亚洲黄色性网站| 欧美激情麻豆| 噜噜噜在线观看免费视频日韩| 欧美一区二区观看视频| 亚洲一区三区视频在线观看| 亚洲免费电影在线观看| 亚洲精品免费在线| 亚洲国产日韩欧美综合久久| 尤物yw午夜国产精品视频明星| 国产午夜精品久久久| 国产精品三区www17con| 国产精品久久久久免费a∨ | 久久av二区| 欧美一区二区三区久久精品茉莉花| 亚洲影院在线| 欧美亚洲视频| 久久国产精彩视频| 久久不射中文字幕| 久久精品国产69国产精品亚洲| 在线观看日产精品| 黄色免费成人| 在线日韩中文字幕| 亚洲激情网站免费观看| 亚洲精品国产日韩| 99精品视频免费观看| 一区二区成人精品| 欧美亚洲一区在线| 久久久久久精| 亚洲第一在线视频| 亚洲国产影院| 一区二区久久久久久| 一本色道久久综合亚洲精品高清| 一区二区激情| 欧美一区二区三区免费大片| 久久精品99久久香蕉国产色戒| 久久久久国产一区二区三区四区 | 久久激情视频| 欧美成人精品一区二区| 欧美日韩久久久久久| 国产伦精品一区二区三区在线观看| 国产一区二区视频在线观看| 亚洲福利视频一区二区| 夜夜嗨av一区二区三区| 香蕉乱码成人久久天堂爱免费| 久久综合亚州| 亚洲精品日韩在线观看| 香蕉久久一区二区不卡无毒影院| 久久精品国产久精国产一老狼| 欧美激情亚洲另类| 国产一区二区三区高清| 亚洲乱码国产乱码精品精可以看| 亚洲欧美久久久| 欧美α欧美αv大片| 在线综合+亚洲+欧美中文字幕| 久久国产精彩视频| 欧美四级在线观看| 亚洲成色999久久网站| 午夜精品久久久久久99热软件| 免费观看久久久4p| 亚洲最新在线视频| 免费av成人在线| 国产伦精品一区| 一区二区成人精品| 久久亚洲精品视频| 亚洲免费视频中文字幕| 欧美精品亚洲二区| 亚洲国产成人久久| 久久国产手机看片| 亚洲午夜视频|