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

天行健 君子當自強而不息

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在线| 亚洲国内自拍| 亚洲淫片在线视频| 亚洲午夜久久久| 国产精品一二三四区| 欧美一区二区在线看| 亚洲欧美日韩成人高清在线一区| 美女视频一区免费观看| 欧美一区成人| 亚洲国产电影| 99视频精品全国免费| 国产精品免费在线| 久久亚洲精品中文字幕冲田杏梨 | 欧美三级乱码| 亚洲综合大片69999| 久久狠狠久久综合桃花| 亚洲美女中文字幕| 亚洲欧美日韩国产中文| 亚洲韩国青草视频| 一区二区欧美在线观看| 一色屋精品视频在线观看网站| 亚洲靠逼com| 一本在线高清不卡dvd| 国内自拍一区| 夜夜爽夜夜爽精品视频| 黑人巨大精品欧美黑白配亚洲| 亚洲欧美日韩国产一区二区三区| 老司机免费视频一区二区三区| 一区二区三区欧美在线观看| 国产一区二区精品久久91| 亚洲欧洲日韩女同| 国产午夜精品美女毛片视频| 亚洲精品123区| 国产主播喷水一区二区| 日韩视频在线观看一区二区| 韩国三级在线一区| 亚洲天堂偷拍| 亚洲欧洲精品一区二区三区 | 亚洲国产精品va在看黑人| 99国产精品| 亚洲成人中文| 亚洲欧美国产日韩天堂区| 一区二区高清视频| 免费不卡亚洲欧美| 久久综合色综合88| 国产日韩综合| 亚洲欧美日韩国产一区| 中文一区字幕| 欧美女主播在线| 欧美激情第9页| 在线观看亚洲a| 久久国产精品99国产精| 欧美一区二区播放| 国产精品久久久久久模特| 亚洲精品国产欧美| 亚洲最新在线视频| 欧美激情aⅴ一区二区三区| 欧美成人高清| 亚洲国产精品ⅴa在线观看| 久久久亚洲精品一区二区三区| 在线日韩电影| 欧美一区二区三区四区夜夜大片 | 国产精品久久久久毛片软件| 亚洲精品国产日韩| 亚洲精品女人| 欧美精品久久99久久在免费线| 一本久久综合| 欧美日韩一级大片网址| 日韩一区二区精品葵司在线| 亚洲色图在线视频| 国产精品激情av在线播放| 日韩视频专区| 亚洲欧美日韩精品一区二区| 国产精品高潮久久| 午夜欧美视频| 欧美va亚洲va日韩∨a综合色| 欧美精品一区二区三区一线天视频| 亚洲视频在线观看三级| 欧美日韩国产小视频| 一区二区不卡在线视频 午夜欧美不卡在| 欧美视频在线观看视频极品| 在线亚洲一区观看| 久久精品首页| 在线成人h网| 欧美理论大片| 这里只有视频精品| 久久精品人人做人人综合| **欧美日韩vr在线| 欧美日韩美女在线| 欧美一区二区在线播放| 欧美大片免费久久精品三p| 一本一本久久a久久精品综合麻豆| 欧美一区二区三区免费视频| 欧美国产激情| 午夜精品久久久久99热蜜桃导演| 老司机亚洲精品| 99视频在线观看一区三区| 久久国产精品亚洲va麻豆| 亚洲美女福利视频网站| 国产精品一国产精品k频道56| 亚洲黄色成人| 久久av二区| 亚洲最快最全在线视频| 国产区日韩欧美| 欧美日韩1区2区3区| 欧美在线视频免费| 亚洲欧洲日本mm| 久久亚洲精品视频| 亚洲免费中文| 亚洲美女视频网| 国语自产精品视频在线看一大j8| 亚洲免费视频一区二区| 亚洲国产精品国自产拍av秋霞| 悠悠资源网亚洲青| 国产精品美女视频网站| 麻豆国产精品777777在线| 亚洲午夜免费视频| 亚洲精品美女| 你懂的视频一区二区| 欧美一区二区在线看| 亚洲午夜在线观看| 亚洲精一区二区三区| 黄色成人av在线| 国产女主播一区二区| 欧美日韩一二区| 欧美精品国产精品| 欧美大尺度在线观看| 久久精品一区二区| 久久精品国产精品亚洲综合| 亚洲一区欧美激情| 亚洲视频视频在线| 99精品国产在热久久婷婷| 亚洲大片一区二区三区| 欧美成人午夜77777| 久久午夜国产精品| 久久天天躁夜夜躁狠狠躁2022| 在线观看欧美黄色| 激情综合色丁香一区二区| 国产亚洲一区在线| 国产欧美一区二区精品秋霞影院| 久久久国产一区二区三区| 香蕉久久夜色精品| 亚洲欧美国产77777| 亚洲欧美日韩中文在线制服| 亚洲自拍偷拍福利| 性色av一区二区三区在线观看 | 亚洲精品极品| 亚洲日本中文字幕| 亚洲精品在线二区| 日韩天堂在线视频| 亚洲一区欧美激情| 羞羞色国产精品| 久久精品网址| 欧美激情1区2区3区| 亚洲激情偷拍| 亚洲视频欧洲视频| 欧美一区二区视频观看视频| 久久久中精品2020中文| 蜜臀av性久久久久蜜臀aⅴ| 葵司免费一区二区三区四区五区| 日韩一级网站| 亚洲欧美视频| 久久久福利视频| 老鸭窝毛片一区二区三区 | 免费观看成人www动漫视频| 欧美1区免费| 日韩一二三在线视频播| 亚洲欧美激情精品一区二区| 久久色在线播放| 欧美天堂亚洲电影院在线观看| 久久久国产精品一区| 欧美成人精品| 国产精品久久久一区二区三区| 久久综合伊人77777麻豆| 欧美成人免费全部| 国产精品国产自产拍高清av王其| 欧美国内亚洲| 国产精品日韩电影| 亚洲国产专区校园欧美| 亚洲免费在线电影| 欧美成人免费视频| 亚洲专区国产精品| 欧美美女福利视频| 精品1区2区3区4区| 一区二区日韩免费看| 看欧美日韩国产| 亚洲一区二区三区精品动漫| 久久亚洲私人国产精品va| 国产精品高清在线观看| 亚洲国产精品热久久| 欧美一区二区在线免费观看| 欧美黑人在线观看| 欧美亚洲自偷自偷| 欧美日韩妖精视频| 亚洲国产精品一区二区第一页 | 亚洲欧洲另类| 久久久久久久久岛国免费| 亚洲精品一区在线观看香蕉| 久久男人资源视频| 国产日韩综合|