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

天行健 君子當自強而不息

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>
            亚洲免费成人av电影| 最新中文字幕一区二区三区| 亚洲一区欧美| 国产精品你懂的在线欣赏| 亚洲综合久久久久| 香蕉视频成人在线观看 | 欧美一区免费视频| 精品动漫3d一区二区三区免费| 久久亚洲私人国产精品va媚药| 老司机凹凸av亚洲导航| 亚洲伦理在线免费看| 亚洲视频综合在线| 国内伊人久久久久久网站视频| 欧美电影免费观看| 国产精品v欧美精品v日本精品动漫| 久久se精品一区精品二区| 久久成人免费网| 夜色激情一区二区| 欧美一区二区视频免费观看| 亚洲国产精品成人一区二区| 一区二区日韩欧美| 尤物精品国产第一福利三区 | 老司机精品导航| 欧美日韩国产色视频| 久久久精品999| 欧美区一区二| 久久综合激情| 国产精品qvod| 亚洲国产成人精品久久久国产成人一区| 欧美另类综合| 猛男gaygay欧美视频| 欧美日韩国产三区| 免费日韩精品中文字幕视频在线| 欧美另类videos死尸| 久久这里有精品15一区二区三区| 欧美日本亚洲| 欧美激情一区三区| 国产精品久久影院| 亚洲欧洲精品一区二区精品久久久| 国产精品日韩精品欧美在线| 亚洲区中文字幕| 国产一区二区高清不卡| 99国产精品久久| 亚洲精品婷婷| 久热精品在线视频| 久久久综合精品| 欧美三区不卡| 亚洲精品乱码久久久久久久久 | 欧美日韩成人一区二区| 欧美va天堂在线| 国产亚洲精品一区二555| 一区二区免费在线播放| 亚洲国产精品久久人人爱蜜臀| 亚洲欧美日本国产专区一区| aa级大片欧美| 欧美精品www| 亚洲高清资源| 亚洲高清资源| 久久三级视频| 免费日韩av片| 亚洲国产岛国毛片在线| 久久免费99精品久久久久久| 久久米奇亚洲| 国产一区二区三区高清| 欧美一级网站| 久久免费国产精品1| 国产在线精品成人一区二区三区| 午夜日韩视频| 久久久久国产精品一区| 国产一区二区三区久久| 久久精品国产在热久久| 久久国产精品网站| 今天的高清视频免费播放成人| 欧美一级片久久久久久久| 久久精品日韩欧美| 亚洲第一级黄色片| 欧美a一区二区| 亚洲美女区一区| 亚洲欧美三级伦理| 国产亚洲女人久久久久毛片| 久久精品视频在线播放| 亚洲第一中文字幕| 一本久久综合亚洲鲁鲁| 国产精品你懂得| 久久精彩视频| 亚洲国产精品欧美一二99| 国产精品99久久久久久有的能看| 国产精品美女诱惑| 欧美专区18| 欧美第一黄网免费网站| 亚洲深夜福利网站| 国产一区在线视频| 欧美成人国产va精品日本一级| 亚洲精品一区二区三| 欧美一区在线视频| 亚洲国产精品久久久久婷婷老年 | 亚洲在线成人| 在线免费观看日韩欧美| 欧美日韩二区三区| 欧美一区二区精品在线| 亚洲国产成人91精品| 亚洲制服少妇| 亚洲欧洲在线视频| 国产欧美日韩中文字幕在线| 欧美精品18| 欧美中文字幕在线视频| 日韩视频三区| 麻豆av一区二区三区| 亚洲午夜视频在线| 在线观看亚洲精品| 国产精品裸体一区二区三区| 美女脱光内衣内裤视频久久影院| 一本大道久久精品懂色aⅴ| 久久久亚洲国产天美传媒修理工 | 亚洲国产视频一区| 久久精品免费| 亚洲视频专区在线| 亚洲人体1000| 黄色亚洲免费| 国产精品免费观看视频| 欧美黄色影院| 久久久久久网| 性欧美办公室18xxxxhd| 99视频精品在线| 亚洲大胆在线| 久久亚洲精选| 欧美一区二区三区在线视频| 这里只有精品在线播放| 亚洲国产成人tv| 国内精品久久久久久影视8| 欧美日韩中文另类| 欧美日韩在线播放一区二区| 欧美高清在线视频| 美日韩免费视频| 久久久夜精品| 久久九九精品| 久久久国产精品一区二区中文| 亚洲欧美成aⅴ人在线观看| 在线亚洲+欧美+日本专区| 99re6热只有精品免费观看| 亚洲黄色性网站| 亚洲第一精品福利| 欧美福利小视频| 欧美激情一区二区三区蜜桃视频| 女人香蕉久久**毛片精品| 久久影院亚洲| 欧美成人免费全部观看天天性色| 免费欧美在线视频| 欧美激情视频网站| 亚洲高清不卡在线| 亚洲激情av| 一区二区电影免费观看| 在线性视频日韩欧美| 亚洲欧美激情视频| 欧美自拍偷拍午夜视频| 久久国产视频网站| 久久一区国产| 欧美日韩视频第一区| 国产精品久久久一区麻豆最新章节 | 久久国产精品亚洲va麻豆| 久久久精品国产免大香伊| 久久综合图片| 亚洲国产精品一区在线观看不卡| 亚洲精品欧美| 日韩视频永久免费| 亚洲欧美另类国产| 久久久99免费视频| 欧美日韩国产精品一卡| 国产乱子伦一区二区三区国色天香| 国内成+人亚洲| 日韩亚洲精品视频| 欧美在线综合视频| 亚洲大片一区二区三区| 在线综合亚洲| 久久美女艺术照精彩视频福利播放| 欧美极品一区二区三区| 国产精品久久久久免费a∨大胸| 国产在线拍偷自揄拍精品| 亚洲国产美女| 欧美一区二区三区精品电影| 欧美搞黄网站| 亚洲影院色无极综合| 老司机午夜精品视频| 国产精品久久久久一区二区三区| 一区二区三区在线高清| 亚洲精品一区在线| 久久免费视频网| 一本色道久久综合| 老司机免费视频一区二区| 国产精品女主播| 亚洲美女av网站| 久久中文字幕一区二区三区| 亚洲日本va在线观看| 老司机一区二区三区| 国产美女精品视频免费观看| 亚洲伦理在线观看| 欧美成人激情视频免费观看| 亚洲欧美日韩成人高清在线一区| 欧美久久综合| 亚洲精品午夜|