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

天行健 君子當自強而不息

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 閱讀(223) 評論(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>
            男女精品网站| 亚洲最黄网站| 久久九九精品| 亚洲影视九九影院在线观看| 国产精品中文字幕在线观看| 久久九九国产精品| 久久美女性网| 亚洲作爱视频| 亚洲在线1234| 亚洲电影av| 亚洲激情一区| 国产精品久久久久9999高清| 欧美在线视频观看| 老巨人导航500精品| 亚洲毛片网站| 亚洲免费视频一区二区| 在线观看日韩一区| 日韩视频免费观看高清在线视频| 欧美区日韩区| 欧美一区二区三区四区高清| 久久亚洲捆绑美女| 亚洲午夜av| 久久精品视频播放| 日韩午夜免费视频| 性欧美大战久久久久久久久| 亚洲精品123区| 亚洲欧美在线磁力| 亚洲人成啪啪网站| 欧美尤物巨大精品爽| 亚洲精品一二三区| 欧美在线高清视频| 夜夜嗨av一区二区三区中文字幕| 午夜精品999| 中文精品视频| 久久久久国内| 午夜精品久久| 欧美日韩成人在线| 免费黄网站欧美| 国产美女精品免费电影| 亚洲欧洲日韩综合二区| 精品1区2区| 亚洲一区日韩| 在线亚洲欧美专区二区| 久久夜色精品亚洲噜噜国产mv | 欧美激情乱人伦| 欧美一区二区在线看| 欧美精品久久久久久久久老牛影院| 欧美自拍偷拍午夜视频| 欧美日韩一二三区| 亚洲精华国产欧美| 亚洲欧洲在线一区| 久久久免费精品视频| 久久精品一区中文字幕| 欧美三日本三级少妇三99| 亚洲国产成人av在线| 激情丁香综合| 久久久精品日韩| 久久久99爱| 国产日韩欧美在线视频观看| 一区二区三区四区蜜桃| 亚洲视频在线观看三级| 欧美片在线观看| 亚洲精品乱码久久久久久黑人| 亚洲激情二区| 欧美极品一区二区三区| 亚洲国产一二三| 亚洲人精品午夜| 免费欧美在线视频| 亚洲激情不卡| 亚洲视频精选在线| 欧美视频在线一区| 亚洲视频免费在线| 久久精彩视频| 精品成人一区二区| 免费成人网www| 亚洲国产综合在线| 亚洲香蕉网站| 国产精品视频免费观看| 欧美一区二区三区视频在线| 久久精品国产2020观看福利| 韩国欧美一区| 免费视频一区| 中日韩在线视频| 久久精品国产99国产精品澳门 | 欧美精品xxxxbbbb| 亚洲素人在线| 久久婷婷蜜乳一本欲蜜臀| 136国产福利精品导航| 欧美激情在线观看| 亚洲视频www| 麻豆精品在线播放| 一区二区三区久久精品| 国产日本欧美视频| 久久躁狠狠躁夜夜爽| 日韩一区二区电影网| 久久aⅴ乱码一区二区三区| 激情综合在线| 欧美三级日韩三级国产三级| 欧美一区二区三区在线免费观看 | 欧美激情一级片一区二区| 亚洲网站视频| 韩日精品中文字幕| 欧美日韩国产精品一卡| 欧美一区二区三区在线| 亚洲精品一区二区三区99| 久久国产欧美日韩精品| 日韩一级大片| 黄色成人在线| 欧美午夜不卡视频| 免费日韩av片| 午夜精品视频一区| 亚洲精品社区| 蜜桃精品一区二区三区| 午夜视频在线观看一区| 亚洲精品乱码久久久久久久久| 国产拍揄自揄精品视频麻豆| 欧美精品一区二区三区高清aⅴ| 欧美在线免费观看| 在线一区观看| 亚洲精品欧美日韩专区| 欧美粗暴jizz性欧美20| 久久大逼视频| 亚洲欧美成人一区二区在线电影| 91久久夜色精品国产网站| 国模吧视频一区| 国产精品日韩欧美一区二区三区 | 午夜精品区一区二区三| 一区二区日韩伦理片| 亚洲国产aⅴ天堂久久| 美女日韩在线中文字幕| 久久精视频免费在线久久完整在线看| 亚洲一区二区三区激情| 日韩五码在线| 亚洲精品日产精品乱码不卡| 亚洲国产成人久久综合| 伊人狠狠色j香婷婷综合| 国产亚洲精品激情久久| 国产一区91| 国产亚洲一区精品| 国产在线欧美日韩| 国内久久婷婷综合| 国内精品久久久久久久97牛牛| 国产毛片一区| 国产视频精品va久久久久久| 国产欧美日韩91| 国产一区二区精品久久91| 国产偷自视频区视频一区二区| 国产精品一区二区久久精品| 国产欧美一区二区精品秋霞影院 | 免费亚洲视频| 欧美二区乱c少妇| 欧美黑人在线播放| 欧美破处大片在线视频| 欧美色欧美亚洲另类二区| 国产精品v日韩精品| 欧美吻胸吃奶大尺度电影| 国产精品国产一区二区| 国产精品一区二区欧美| 国产亚洲综合在线| 亚洲国产高清在线| 亚洲精品综合| 亚洲字幕一区二区| 久久9热精品视频| 免费欧美电影| 亚洲美女黄网| 欧美亚洲综合网| 乱码第一页成人| 欧美三级午夜理伦三级中视频| 国产精品日韩久久久久| 一区二区在线视频观看| 亚洲精品综合在线| 午夜视黄欧洲亚洲| 欧美成人一区二区三区在线观看 | 亚洲全黄一级网站| 亚洲一级影院| 美女视频黄 久久| 欧美调教vk| 在线观看欧美日韩国产| 一区二区日韩伦理片| 欧美在线观看天堂一区二区三区| 久久亚洲国产精品日日av夜夜| 亚洲国产精品久久久| 亚洲一区二区av电影| 噜噜噜91成人网| 国产精品夫妻自拍| 亚洲国产一区二区三区高清| 亚洲免费在线看| 欧美激情一区二区三区| 亚洲欧美日本日韩| 欧美日本二区| 精品成人一区| 久久aⅴ国产紧身牛仔裤| 亚洲国产毛片完整版| 欧美一级免费视频| 欧美国产乱视频| 一区在线播放视频| 欧美一区二区三区免费视| 亚洲国产精品ⅴa在线观看| 欧美一区二区三区在| 国产精品区一区二区三区|