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

天行健 君子當自強而不息

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>
            亚洲高清不卡在线| 亚洲男人的天堂在线观看| 女人天堂亚洲aⅴ在线观看| 亚洲影院高清在线| 国产精品欧美久久| 性欧美办公室18xxxxhd| 亚洲国产精品视频一区| 欧美成人亚洲成人日韩成人| 亚洲精品资源美女情侣酒店| 亚洲午夜av电影| 国产欧美日韩| 欧美高清在线视频| 欧美日韩一区综合| 久久精品99国产精品日本| 久久国产精品99国产精| 欧美日韩亚洲视频一区| 亚洲欧美日韩另类精品一区二区三区| 欧美高清视频在线| 欧美视频在线观看免费| 久久精品99国产精品| 欧美成人精品一区二区| 亚洲综合99| 久久天天综合| 亚洲一区二区三区四区五区午夜| 欧美成人福利视频| 欧美日一区二区在线观看| 久久久精品一品道一区| 欧美精品www| 久久影音先锋| 国产精品久久久久国产a级| 麻豆精品在线视频| 国产精品久久久久aaaa樱花 | 亚洲午夜av在线| 激情文学综合丁香| 国产精品99久久久久久久久| 国产精品mm| 亚洲视频在线观看视频| 久久亚洲精品网站| 午夜精彩视频在线观看不卡 | 欧美一区二区久久久| 久久综合色婷婷| 欧美一级片一区| 欧美日韩国产高清视频| 免费黄网站欧美| 国产麻豆精品在线观看| 99视频精品全国免费| 伊人久久大香线蕉av超碰演员| 久久久蜜臀国产一区二区| 国产精品v日韩精品| 亚洲福利视频二区| 在线成人中文字幕| 欧美在线影院| 亚洲黄网站在线观看| 午夜日韩激情| 欧美亚洲自偷自偷| 久久精品夜夜夜夜久久| 午夜精品一区二区三区在线播放 | 亚洲国产高清aⅴ视频| 国产在线观看91精品一区| 久久久久久高潮国产精品视| 欧美日韩亚洲激情| 日韩亚洲欧美一区二区三区| 99精品99久久久久久宅男| 久久综合网hezyo| 欧美成人精品在线观看| 一区免费观看视频| 久久婷婷丁香| 欧美二区视频| 91久久精品国产| 欧美国产大片| 亚洲精品一区在线| 亚洲视频1区| 国产精品理论片| 午夜精品一区二区三区在线视 | 国产日韩欧美综合精品| 午夜精品福利在线| 久久免费精品视频| 欧美日韩一区二区三区| 一本大道久久a久久综合婷婷 | 免费在线日韩av| 欧美激情精品久久久久久| 国产精品一区二区三区观看| 午夜精品久久久久久久久久久久久 | 欧美一区精品| 久久久久九九九| 亚洲欧洲午夜| 欧美日韩国产一区精品一区 | 国内精品久久久久影院优| 久久人人九九| 亚洲精品孕妇| 亚洲精品少妇网址| 国产精品二区二区三区| 欧美一区二区大片| 亚洲欧美精品在线观看| 国产视频一区在线| 免费中文字幕日韩欧美| 久久精品亚洲乱码伦伦中文| 永久免费视频成人| 欧美日韩中文在线| 亚洲精品在线一区二区| 欧美一级久久久| 91久久在线观看| 国产精品美女久久久久av超清 | 久久综合中文| 一本一本久久a久久精品综合麻豆| 久久亚洲精选| 久久亚洲精品中文字幕冲田杏梨| 国产精品日韩精品欧美精品| 久久久亚洲国产美女国产盗摄| 欧美一区二区三区视频在线观看| 欧美日韩综合在线| 久久香蕉国产线看观看网| 99精品福利视频| 久久婷婷丁香| 香蕉av777xxx色综合一区| 亚洲国产综合91精品麻豆| 国产精品手机视频| 欧美电影在线播放| 亚洲日本乱码在线观看| 久久先锋影音| 午夜亚洲激情| 99精品视频免费在线观看| 好看不卡的中文字幕| 久久婷婷综合激情| 午夜欧美大片免费观看| 9色国产精品| 亚洲国产视频a| 久久亚洲精品中文字幕冲田杏梨| 在线国产日韩| 国产一区二区0| 国产精品一区二区三区久久| 欧美日本一区| 欧美精品亚洲一区二区在线播放| 亚洲私人黄色宅男| 一本色道久久精品| 日韩视频一区二区三区在线播放免费观看 | 99re热这里只有精品视频| 国内精品福利| 国产一区二区三区四区在线观看 | 久久这里只有| 久久精品99国产精品| 午夜视频一区在线观看| 久久综合九色综合欧美就去吻| 亚洲电影视频在线| 在线观看久久av| 极品av少妇一区二区| 欧美日韩高清在线一区| 欧美巨乳在线观看| 欧美日韩国产一中文字不卡 | 久久精品日韩一区二区三区| 午夜视频在线观看一区| 小处雏高清一区二区三区| 午夜亚洲福利| 久久亚洲春色中文字幕| 免费视频一区| 欧美亚洲一区二区在线| 欧美在线在线| 久久综合九色九九| 欧美黄网免费在线观看| 亚洲区第一页| 亚洲自拍电影| 久久精品国产96久久久香蕉| 久久蜜臀精品av| 欧美乱妇高清无乱码| 欧美午夜女人视频在线| 国产视频精品网| 亚洲国产另类久久久精品极度| 国产欧美日韩在线观看| 欧美激情一区二区三区在线视频 | 亚洲国产精品va在线观看黑人| 欧美一区二区三区日韩| 久久综合激情| 欧美一区2区三区4区公司二百| 亚洲免费观看| 亚洲成色www久久网站| 99精品福利视频| 欧美在线日韩精品| 亚洲黑丝一区二区| 亚洲性色视频| 欧美成人中文| 国产丝袜一区二区| 一本色道精品久久一区二区三区| 亚洲精品日本| 久久国产精品99精品国产| 欧美国产精品日韩| 亚洲欧美影音先锋| 欧美极品在线视频| 国产亚洲精品资源在线26u| 亚洲伦理精品| 久久久久久久网站| 日韩性生活视频| 米奇777在线欧美播放| 久久蜜桃精品| 国产欧美在线看| 亚洲视频自拍偷拍| 欧美成人精品三级在线观看| 亚洲一区二区三区高清| 欧美激情视频一区二区三区不卡| 欧美精品一区二区三区很污很色的 | 先锋影音久久久|