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

天行健 君子當自強而不息

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>
            1000部国产精品成人观看| 亚洲国产一区二区三区青草影视| 亚洲久久视频| 亚洲人成亚洲人成在线观看图片| 久久久久久久尹人综合网亚洲| 好吊色欧美一区二区三区四区| 久久午夜电影网| 久久综合九色欧美综合狠狠| 亚洲电影成人| 亚洲理论在线| 国产精品视频免费| 久久久国产精品一区二区中文| 久久不见久久见免费视频1| 极品日韩久久| 亚洲精品乱码| 国产精品手机在线| 欧美成人精品| 欧美视频精品在线| 久久精品99国产精品| 久久青草久久| 亚洲午夜精品一区二区| 亚洲欧美国产va在线影院| 在线成人国产| 99精品视频免费观看视频| 国产日韩欧美一区二区三区四区| 另类图片综合电影| 欧美日韩国产成人精品| 欧美日韩mv| 欧美在线观看www| 久久免费国产精品| 亚洲综合日韩| 免费成人在线观看视频| 亚洲免费在线视频一区 二区| 久久高清一区| 亚洲影视在线播放| 久久久蜜臀国产一区二区| 亚洲一区二区三区午夜| 久久久久国产一区二区三区四区 | 欧美日韩国产bt| 久久国产精品99精品国产| 美女任你摸久久| 久久国产精品久久久久久| 欧美激情第六页| 久久精品一区二区三区四区| 欧美日韩在线视频一区| 欧美国产欧美亚洲国产日韩mv天天看完整| 欧美日韩亚洲系列| 欧美激情第五页| 国产一本一道久久香蕉| 99精品视频免费| 亚洲美女尤物影院| 免费成人高清在线视频| 久久麻豆一区二区| 国产欧美一二三区| 99视频有精品| 在线亚洲成人| 欧美黑人在线观看| 欧美国产三级| 亚洲成人中文| 久久全球大尺度高清视频| 久久久伊人欧美| 国产欧美日韩91| 亚洲欧美成人| 久久激情五月丁香伊人| 国产欧美日韩精品a在线观看| 夜夜嗨av一区二区三区中文字幕| 日韩网站在线| 欧美精品 日韩| 日韩视频永久免费| 在线亚洲美日韩| 欧美无乱码久久久免费午夜一区| 亚洲欧洲一区二区在线播放| 亚洲精品一区二区在线| 亚洲美女黄色片| 日韩一级成人av| 欧美日本不卡高清| 在线亚洲欧美专区二区| 午夜精品久久久久久久久久久久久| 欧美日韩在线观看一区二区三区| 亚洲麻豆视频| 欧美一区二区三区在线看| 国产精品视频大全| 欧美在线观看一区| 亚洲大片免费看| 一本色道久久88综合日韩精品 | 欧美在线视频网站| 免费国产一区二区| 亚洲三级免费| 国产精品高清一区二区三区| 亚洲一区日韩| 欧美chengren| 一区二区三区高清在线| 国产精品久久久久久久午夜片| 亚洲欧美中文日韩在线| 久久久www成人免费无遮挡大片| 国产一区美女| 欧美精品午夜| 久久gogo国模裸体人体| 亚洲电影在线| 亚洲欧美日韩精品综合在线观看| 国产一区二区三区久久精品| 欧美国内亚洲| 午夜精品av| 亚洲夫妻自拍| 欧美在线视频a| 亚洲日韩第九十九页| 国产精品久久久久久久浪潮网站| 久久国产88| 亚洲伦理久久| 欧美电影免费观看高清| 亚洲一区不卡| 亚洲国产精品一区二区第一页| 欧美日韩国产三区| 久久久久久久网| 亚洲欧美国产高清| 亚洲欧洲精品成人久久奇米网 | 1024国产精品| 国产精品免费aⅴ片在线观看| 免费成人在线观看视频| 亚洲字幕一区二区| 亚洲区一区二| 美国成人毛片| 欧美一区二区视频网站| 日韩视频免费在线观看| 国外成人性视频| 国产精品视频一区二区三区| 欧美精品七区| 欧美成年人视频网站| 欧美在线啊v| 亚洲影音一区| 一区二区三区久久| 日韩一级免费观看| 亚洲人久久久| 亚洲欧洲一区二区三区在线观看| 久久综合久久美利坚合众国| 午夜免费日韩视频| 亚洲在线播放电影| 亚洲午夜一区二区三区| 99精品免费| 亚洲日本免费电影| 在线精品福利| 一区二区在线视频播放| 经典三级久久| 在线观看日韩av先锋影音电影院| 国产一区二区三区在线观看免费视频| 国产精品成人v| 国产精品成人午夜| 国产精品女人网站| 国产麻豆午夜三级精品| 国产精品久久一卡二卡| 国产精品久久久久久久久借妻| 欧美日韩国产不卡| 欧美四级在线| 国产精品影片在线观看| 国产精品一区二区久激情瑜伽| 国产欧美日韩激情| 国语自产精品视频在线看一大j8 | 久久久久久久久一区二区| 欧美在线首页| 久久频这里精品99香蕉| 免播放器亚洲| 亚洲国产精品高清久久久| 亚洲黄色性网站| 日韩视频在线免费观看| 亚洲一区二区三区免费观看| 亚洲一区影音先锋| 欧美一区二区黄色| 日韩视频精品在线| 这里只有精品视频| 午夜久久黄色| 免费av成人在线| 欧美日韩视频一区二区| 国产美女精品在线| 在线播放日韩| 99国产精品一区| 欧美一区二区三区视频免费播放| 久久久久久亚洲精品中文字幕| 欧美成人午夜免费视在线看片| 亚洲三级免费观看| 亚洲综合色在线| 农村妇女精品| 国产精品成人午夜| 激情国产一区| 亚洲午夜精品久久久久久浪潮 | 亚洲一品av免费观看| 久久精品欧美日韩| 91久久精品视频| 欧美一区二区三区视频在线 | 欧美日韩国产一区精品一区| 国产日韩精品一区二区三区| 亚洲激情一区二区三区| 午夜久久久久久久久久一区二区| 免费欧美日韩| 亚洲字幕一区二区| 欧美巨乳波霸| 亚洲高清不卡一区| 欧美在线地址| 亚洲视频视频在线| 欧美激情在线免费观看| 狠狠综合久久av一区二区老牛|