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

天行健 君子當自強而不息

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 閱讀(228) 評論(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>
            久久久亚洲一区| 麻豆久久久9性大片| 亚洲精品综合精品自拍| 亚洲免费电影在线| 亚洲性视频h| 欧美影院成人| 欧美高清成人| 99国产精品久久久久久久成人热| 在线中文字幕不卡| 久久九九国产精品| 欧美日本不卡| 国产手机视频一区二区| 亚洲福利视频在线| 亚洲午夜一区| 麻豆freexxxx性91精品| 日韩一级欧洲| 久久九九99| 欧美视频网站| 激情一区二区| 亚洲一区区二区| 久久先锋影音av| 亚洲精品一区二区三区蜜桃久| 亚洲一区二区久久| 模特精品裸拍一区| 国产欧美亚洲视频| 日韩一级黄色av| 久久久久九九视频| 夜夜爽www精品| 免费成人av在线看| 国产综合av| 亚洲免费在线播放| 亚洲国产成人午夜在线一区 | 99热这里只有精品8| 欧美亚洲专区| 99精品国产在热久久下载| 久久久亚洲综合| 国产视频一区二区三区在线观看| 亚洲精品一区二| 免费成人美女女| 欧美一级黄色网| 国产精品视频免费一区| 亚洲素人一区二区| 亚洲经典自拍| 欧美国产91| 亚洲茄子视频| 欧美激情精品久久久久久蜜臀 | 美女日韩在线中文字幕| 午夜精品久久久久久久99水蜜桃 | 欧美日韩精品伦理作品在线免费观看 | 9久re热视频在线精品| 麻豆成人综合网| **欧美日韩vr在线| 免费中文日韩| 久久影院午夜论| 亚洲丰满少妇videoshd| 久久综合国产精品台湾中文娱乐网| 亚洲男女自偷自拍图片另类| 欧美日韩在线看| 亚洲一区美女视频在线观看免费| 亚洲人成毛片在线播放| 欧美高清不卡| 在线视频一区二区| 宅男66日本亚洲欧美视频| 欧美日韩在线视频观看| 亚洲永久免费精品| 午夜精品婷婷| 悠悠资源网久久精品| 蜜桃av久久久亚洲精品| 麻豆成人精品| 一区二区三区日韩在线观看| 亚洲精品一区二区在线| 欧美午夜精品理论片a级大开眼界 欧美午夜精品理论片a级按摩 | 免费短视频成人日韩| 亚洲激情在线视频| 亚洲精品免费电影| 欧美午夜欧美| 久久高清一区| 乱码第一页成人| 一本色道婷婷久久欧美| 亚洲一区影音先锋| 精品电影一区| 亚洲精品乱码久久久久久蜜桃麻豆| 欧美日韩一区二区三区视频| 午夜天堂精品久久久久| 欧美在线网址| 中文精品视频| 久久精品中文字幕免费mv| 日韩一级黄色片| 亚洲欧美日韩一区二区三区在线| 激情伊人五月天久久综合| 91久久精品国产91性色tv| 国产精品成人aaaaa网站| 久久美女性网| 欧美肉体xxxx裸体137大胆| 久久精品国产亚洲高清剧情介绍| 欧美成人自拍| 久久国产视频网站| 欧美激情导航| 老鸭窝毛片一区二区三区| 欧美日韩成人综合在线一区二区 | 亚洲国产免费| 亚洲女性裸体视频| 亚洲精品欧美一区二区三区| 午夜精品亚洲一区二区三区嫩草| 亚洲国产女人aaa毛片在线| 亚洲自拍偷拍一区| 日韩图片一区| 美女日韩在线中文字幕| 久久不射网站| 国产精品久久久久久久久果冻传媒| 免费视频一区| 国产一区二区三区网站| 亚洲视频电影图片偷拍一区| 亚洲人在线视频| 久久亚洲综合色| 久久一本综合频道| 国产亚洲视频在线观看| 一区二区三区成人| 在线性视频日韩欧美| 欧美v国产在线一区二区三区| 久久亚洲影院| 国产综合香蕉五月婷在线| 亚洲视频导航| 午夜一区不卡| 国产精品美女久久久久久免费| 亚洲日韩第九十九页| 亚洲国产日日夜夜| 久热综合在线亚洲精品| 另类专区欧美制服同性| 狠狠色狠狠色综合日日tαg | 嫩草国产精品入口| 激情成人av| 久久亚洲不卡| 欧美黄色网络| 日韩亚洲在线观看| 欧美日韩国产一区二区三区| 亚洲美女性视频| 亚洲一区二区三区视频播放| 欧美日韩你懂的| 亚洲午夜激情免费视频| 亚洲欧美日韩视频二区| 国产精品永久免费视频| 亚洲女爱视频在线| 久久久久国产一区二区三区四区| 国产欧美日韩视频在线观看| 性欧美激情精品| 久久亚洲私人国产精品va| 极品少妇一区二区三区精品视频 | 99国产精品久久久久久久| 亚洲视频免费| 国产精品久线观看视频| 亚洲欧美国产三级| 久久精品国产91精品亚洲| 精品51国产黑色丝袜高跟鞋| 久久免费视频在线| 亚洲激情成人在线| 午夜免费电影一区在线观看| 国产日韩在线亚洲字幕中文| 久久精品一二三区| 亚洲精品一区二区三| 欧美伊人久久| 亚洲欧洲精品一区二区三区 | 久久人人爽人人| 亚洲国产精品久久久| 午夜精品一区二区三区在线播放| 国产夜色精品一区二区av| 老司机67194精品线观看| 亚洲精品久久久久| 久久国产精品久久国产精品| 亚洲国产成人精品女人久久久 | 欧美日韩国产精品一卡| 性欧美xxxx视频在线观看| 亚洲高清在线观看| 欧美在线观看网站| 亚洲裸体在线观看| 国产精品一区在线观看你懂的| 久久影院午夜片一区| 亚洲一区二区在线免费观看| 欧美成人精品在线视频| 亚洲免费在线| 亚洲免费成人av| 国内外成人免费激情在线视频网站| 欧美成人精品激情在线观看| 午夜精品久久久久99热蜜桃导演| 亚洲国产精品激情在线观看| 久久久.com| 亚洲女女女同性video| 亚洲伦理精品| 影音先锋国产精品| 国产日韩欧美视频| 国产精品s色| 欧美精品一区在线| 久久综合999| 久久久久久高潮国产精品视| 亚洲在线日韩| 在线视频日本亚洲性| 亚洲高清在线精品| 欧美高清免费| 欧美成人午夜免费视在线看片| 久久精品国产亚洲aⅴ|