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

天行健 君子當自強而不息

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>
            影音先锋中文字幕一区| 欧美在线你懂的| 欧美激情一区二区在线 | 校园春色综合网| 亚洲女同精品视频| 激情综合亚洲| 亚洲国产一成人久久精品| 欧美精品电影| 欧美亚洲一区二区在线| 久久一区亚洲| 亚洲午夜极品| 久久成人免费日本黄色| 亚洲国内高清视频| 一区二区三区 在线观看视频| 国产精品狠色婷| 欧美一区二区日韩一区二区| 欧美一级视频一区二区| 亚洲欧洲日韩综合二区| 亚洲视频视频在线| 亚洲国产精品第一区二区三区| 日韩一区二区电影网| 国产一区二区三区在线观看免费视频 | 久久精品色图| 亚洲国产精品电影| 亚洲欧美日产图| 亚洲青涩在线| 性欧美videos另类喷潮| 一本色道久久综合亚洲二区三区| 性伦欧美刺激片在线观看| 99在线观看免费视频精品观看| 欧美一区二区精美| 亚洲视屏一区| 毛片一区二区| 久久精品主播| 国产精品www994| 亚洲成人在线免费| 亚洲激情社区| 久久成人一区二区| 亚洲午夜一区| 欧美福利电影在线观看| 久久综合精品一区| 国产精品午夜电影| 亚洲精品久久在线| 亚洲国产黄色片| 欧美在线在线| 欧美在线中文字幕| 国产精品久久久久9999| 亚洲精品综合久久中文字幕| 亚洲高清久久| 久久九九免费视频| 久久精品亚洲一区二区三区浴池| 欧美色道久久88综合亚洲精品| 亚洲国产成人91精品| 在线观看亚洲精品视频| 久久xxxx精品视频| 久久九九久精品国产免费直播| 国产精品乱码久久久久久| 99精品视频免费全部在线| 亚洲伦理久久| 欧美激情视频给我| 亚洲国产精品悠悠久久琪琪| 亚洲韩国日本中文字幕| 美国成人直播| 亚洲国产综合在线| 亚洲精品专区| 欧美日韩国产精品自在自线| 亚洲伦伦在线| 亚洲欧美国产制服动漫| 国产精品一级二级三级| 亚洲免费影院| 久久阴道视频| 亚洲国产一区二区精品专区| 欧美国产日本在线| 99精品久久久| 久久精品日韩| 亚洲激情一区二区三区| 欧美精品一区二区三区在线播放 | 亚洲无限乱码一二三四麻| 亚洲欧美视频| 国内成+人亚洲| 欧美a级片网站| 夜夜嗨av一区二区三区四区| 欧美一区二区视频在线观看| 国内精品国产成人| 欧美激情视频网站| 在线亚洲一区| 久久久水蜜桃| 亚洲毛片一区| 久久久蜜桃精品| 日韩一级欧洲| 国产欧美精品xxxx另类| 美女精品在线| 亚洲专区免费| 欧美国产亚洲另类动漫| 亚洲一区二区三区免费在线观看 | 国产亚洲精品aa午夜观看| 久久综合激情| 中文国产成人精品| 欧美成人午夜77777| 亚洲自拍高清| 亚洲国产精品高清久久久| 欧美四级在线观看| 久久看片网站| 亚洲视频一区| 亚洲第一视频| 久久久久国产精品人| 日韩午夜三级在线| 国产一区二区日韩精品欧美精品| 欧美激情导航| 久久精品女人的天堂av| 一区二区三区四区五区精品视频 | 一区二区不卡在线视频 午夜欧美不卡在 | 久久综合久色欧美综合狠狠 | 久久久另类综合| 亚洲一级网站| 亚洲精品久久久久中文字幕欢迎你 | 欧美视频在线观看视频极品| 欧美在线视频a| 亚洲视频播放| 亚洲免费观看在线观看| 欧美11—12娇小xxxx| 欧美一区=区| 亚洲视频在线视频| 日韩视频在线免费观看| 亚洲大片在线观看| 国产一区二区三区日韩| 国产精品狠色婷| 欧美日韩精品在线播放| 欧美福利精品| 免费成人av在线| 久久综合电影一区| 久久久天天操| 久久综合一区| 久久全国免费视频| 久久精品亚洲精品国产欧美kt∨| 欧美亚洲日本国产| 欧美亚洲免费| 欧美中文字幕视频在线观看| 亚洲欧美综合网| 欧美亚洲视频在线观看| 欧美在线免费播放| 欧美主播一区二区三区美女 久久精品人 | 免费高清在线视频一区·| 久久精品日韩一区二区三区| 久久岛国电影| 麻豆精品传媒视频| 欧美刺激午夜性久久久久久久| 蜜桃久久精品一区二区| 欧美成人国产一区二区| 亚洲电影免费观看高清完整版在线| 欧美大胆人体视频| 亚洲黄色影片| 99riav久久精品riav| 亚洲色在线视频| 先锋影音网一区二区| 久久久久综合| 欧美成人a视频| 欧美性开放视频| 国产一区二区三区在线观看精品| 国内视频一区| 亚洲精品一二| 午夜精品免费在线| 老司机午夜免费精品视频| 欧美freesex交免费视频| 亚洲国产精品电影| 亚洲午夜精品一区二区三区他趣| 午夜在线不卡| 欧美成人精品影院| 国产精品欧美日韩一区二区| 国语自产精品视频在线看一大j8 | 国产无一区二区| 亚洲黄色尤物视频| 亚洲综合久久久久| 美女尤物久久精品| 一区二区久久| 久久午夜国产精品| 国产精品豆花视频| 亚洲国产精品成人综合| 亚洲专区国产精品| 欧美成人tv| 亚洲一级一区| 欧美成人a∨高清免费观看| 国产精品影视天天线| 亚洲精品字幕| 久久日韩粉嫩一区二区三区| 99精品视频网| 男女激情久久| 国产一区二区按摩在线观看| 国产精品99久久久久久久久久久久 | 国产精品一区二区久久精品| 亚洲激情精品| 久久综合激情| 亚洲欧美日韩精品久久亚洲区| 欧美护士18xxxxhd| 精品99视频| 久久成人免费视频| 一区二区三区高清不卡| 欧美成人精品在线视频| 黄色日韩在线| 久久国产精品99国产|