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

天行健 君子當(dāng)自強(qiáng)而不息

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) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(lèi)(178)

3D游戲編程相關(guān)鏈接

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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一区二区三区| 亚洲欧美国产精品专区久久| 一区二区三区四区蜜桃| 牛牛影视久久网| 麻豆精品在线观看| 韩国女主播一区| 亚洲一区精品电影| 亚洲一区免费| 欧美日韩免费高清| 亚洲裸体视频| 日韩视频在线观看国产| 欧美大片在线观看| 麻豆成人在线| 国产在线精品成人一区二区三区| 亚洲日韩视频| 尤物精品国产第一福利三区| av成人免费在线| 亚洲巨乳在线| 久久精品国产久精国产思思| 亚洲黄一区二区三区| 亚洲婷婷在线| 亚洲人成亚洲人成在线观看| 久久精品99久久香蕉国产色戒 | 亚洲无线一线二线三线区别av| 欧美一区二区在线视频| 亚洲午夜一区二区三区| 欧美精品色综合| 欧美激情二区三区| 在线电影欧美日韩一区二区私密| 亚洲欧美在线免费| 亚洲视频欧洲视频| 欧美人与禽猛交乱配| 欧美激情91| 亚洲精品久久| 欧美成人精品不卡视频在线观看 | 亚洲国产mv| 亚洲第一精品影视| 久久人人97超碰精品888| 久久久久久九九九九| 国产亚洲一级| 欧美在线观看视频在线| 久久精品国产久精国产爱| 欧美韩日视频| 亚洲黄色一区二区三区| 久久伊人一区二区| 欧美大胆a视频| 国产专区一区| 久久精品二区三区| 欧美大片在线看免费观看| 国产精品天天摸av网| 亚洲综合电影一区二区三区| 久久成人免费电影| 红桃视频一区| 嫩草影视亚洲| 亚洲最新视频在线| 羞羞色国产精品| 国产视频欧美视频| 久久蜜桃资源一区二区老牛| 欧美/亚洲一区| 亚洲精品在线观看免费| 欧美性开放视频| 羞羞漫画18久久大片| 蜜桃精品一区二区三区| 99国产精品99久久久久久| 欧美性色aⅴ视频一区日韩精品| 亚洲特级毛片| 久久在线91| 一本色道久久综合亚洲精品不| 国产精品嫩草久久久久| 久久国产免费| 亚洲美洲欧洲综合国产一区| 久久精品系列| 亚洲高清精品中出| 欧美视频在线观看 亚洲欧| 亚洲精品永久免费精品| 性久久久久久| 极品尤物av久久免费看| 国产精品进线69影院| 久久亚洲精品一区| 在线一区二区三区四区| 欧美国产国产综合| 午夜视频一区在线观看| 亚洲电影第1页| 国产精品久久久久久久久久ktv | 国产精品视区| 性欧美video另类hd性玩具| 激情久久久久| 国产精品男女猛烈高潮激情| 你懂的视频一区二区| 亚洲在线观看免费| 91久久精品国产| 久久午夜国产精品| 亚洲一区二区成人| 在线日本高清免费不卡| 国产麻豆午夜三级精品| 欧美—级a级欧美特级ar全黄| 欧美在线一区二区| 一区二区三区精品国产| 欧美91精品| 久久久久久午夜| 午夜精品理论片| 中文亚洲视频在线| 亚洲精品美女在线观看| 狠狠色狠狠色综合日日tαg| 国产精品日韩在线一区| 欧美日韩亚洲高清一区二区| 快播亚洲色图| 久久久噜久噜久久综合| 午夜在线a亚洲v天堂网2018| 亚洲视频在线一区| 日韩视频永久免费| 麻豆免费精品视频| 久久精品国产亚洲高清剧情介绍| 亚洲人成网站色ww在线| 尤物九九久久国产精品的特点 | 国产一区二区三区日韩| 国产精品久久久一区二区| 欧美日韩国产在线一区| 欧美黄色视屏| 欧美国产日本在线| 欧美大胆成人| 欧美1级日本1级| 免费永久网站黄欧美| 久久综合久久88| 久久综合伊人77777蜜臀| 久久午夜电影网| 欧美亚洲尤物久久| 午夜精品久久久| 亚洲男人av电影| 欧美专区在线播放| 狼人天天伊人久久| 欧美激情视频一区二区三区在线播放| 蜜臀av国产精品久久久久| 免费在线日韩av| 欧美日韩精品一本二本三本| 欧美日韩精品免费| 国产精品免费视频观看| 国产色产综合产在线视频| 欧美日韩亚洲高清| 国产精品一区二区欧美| 国语自产精品视频在线看抢先版结局| 国产综合久久久久影院| 国内成人精品2018免费看| 永久免费毛片在线播放不卡| 亚洲精品黄网在线观看| 在线综合+亚洲+欧美中文字幕| 亚洲天堂av在线免费观看| 性色av一区二区三区| 校园春色综合网| 国产精品va在线| 国产精品一区免费在线观看| 激情久久综艺| 99re亚洲国产精品| 欧美一区二区在线看| 美女国产一区| 亚洲电影在线免费观看| 亚洲你懂的在线视频| 另类av一区二区| 国产精品av免费在线观看| 国产一区二区三区久久久| 亚洲免费黄色| 久久久激情视频| 亚洲精品美女在线观看| 欧美一级在线播放| 欧美激情一区二区三级高清视频| 国产精品国产三级国产a| 在线电影一区| 午夜精品久久久久久久蜜桃app | 久久超碰97人人做人人爱| 美女爽到呻吟久久久久| 国产精品国产三级国产aⅴ浪潮| 一区二区三区在线观看欧美| 一区二区三区www| 免费观看亚洲视频大全| 亚洲一级黄色片| 欧美成人一品| 国产一区再线| 在线亚洲精品福利网址导航| 欧美成年视频| 欧美在线一二三| 国产精品久久国产精麻豆99网站| 亚洲激情欧美激情| 久久久精品国产99久久精品芒果| 亚洲夫妻自拍| 欧美一区二区三区免费大片| 欧美大片在线观看一区| 欧美色图五月天| 一区二区三区三区在线| 欧美电影免费观看| 久久久久久91香蕉国产| 国产欧美视频在线观看| 在线亚洲精品福利网址导航| 欧美.日韩.国产.一区.二区| 久久精品国产在热久久| 国产麻豆日韩欧美久久|