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

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

Controlling Players and Characters(38)

Coming up is a huge collection of functions you use to retrieve and set the specific
information about a character (related to the artificial intelligence functionality or
actions):

    cCharIcs* get_char_ics(long id)
    {
        sCharacter* character;

        
if((character = get_char(id)) == NULL)
            
return NULL;

        
return character->char_ics;
    }

    
void set_char_lock(long id, bool is_lock)
    {
        sCharacter* character;

        
if((character = get_char(id)) != NULL)
            character->is_lock = is_lock;
    }

    
void set_char_lock_timer(long id, long action_timer)
    {
        sCharacter* character;

        
if((character = get_char(id)) != NULL)            
            character->action_timer = action_timer;
    }

    
void set_char_type(long id, long type)
    {
        sCharacter* character;

        
if((character = get_char(id)) != NULL)
            character->type = type;
    }

    
long get_char_type(long id)
    {
        sCharacter* character;

        
if((character = get_char(id)) == NULL)
            
return 0;

        
return character->type;
    }

    
void set_char_ai(long id, long ai)
    {
        sCharacter* character;

        
if((character = get_char(id)) != NULL)
            character->ai = ai;
    }

    
long get_char_ai(long id)
    {
        sCharacter* character;

        
if((character = get_char(id)) == NULL)
            
return 0;

        
return character->ai;
    }

    
void set_char_distance(long id, float dist)
    {
        
// set evade/follow distance

        sCharacter* character;

        
if((character = get_char(id)) != NULL)
            character->distance = dist;
    }

    
float get_char_distance(long id)
    {
        
// get evade/follow distance

        sCharacter* character;

        
if((character = get_char(id)) == NULL)
            
return 0.0f;

        
return character->distance;
    }

    
void set_char_route(long id, long num_points, const sRoutePoint* route)
    {
        sCharacter* character;
        
if((character = get_char(id)) == NULL)
            
return;

        
// free old route
        delete[] character->route;
        character->route = NULL;

        
// set new route
        if((character->num_points = num_points) != 0)
        {
            character->route = 
new sRoutePoint[num_points];
            memcpy(character->route, route, num_points * 
sizeof(sRoutePoint));

            character->cur_point = 0;
        }
    }

    
void set_char_script(long id, const char* script_filename)
    {
        sCharacter* character;
        
        
if((character = get_char(id)) != NULL)
            strcpy(character->script_filename, script_filename);
    }

    
char* get_char_script(long id)
    {
        sCharacter* character;
        
if((character = get_char(id)) == NULL)
            
return NULL;

        
return character->script_filename;
    }

    
void set_update_enable(long id, bool update_enable)
    {
        sCharacter* character;

        
if((character = get_char(id)) != NULL)
            character->update_enable = update_enable;
    }

    
bool get_update_enable(long id)
    {
        sCharacter* character;

        
if((character = get_char(id)) == NULL)
            
return false;

        
return character->update_enable;
    }

    
void move_char(long id, float pos_x, float pos_y, float pos_z)
    {
        sCharacter* character;

        
if((character = get_char(id)) != NULL)
        {
            character->pos_x = pos_x;
            character->pos_y = pos_y;
            character->pos_z = pos_z;
        }
    }

    
void get_char_position(long id, float* pos_x, float* pos_y, float* pos_z)
    {
        sCharacter* character;

        
if((character = get_char(id)) != NULL)
        {
            
if(pos_x)   *pos_x = character->pos_x;
            
if(pos_y)   *pos_y = character->pos_y;
            
if(pos_z)   *pos_z = character->pos_z;
        }
    }

    
void set_char_bound(long id,
                        
float min_x, float min_y, float min_z,
                        
float max_x, float max_y, float max_z)
    {
        sCharacter* character;

        
if((character = get_char(id)) != NULL)
        {
            character->min_x = min(min_x, max_x);
            character->min_y = min(min_y, max_y);
            character->min_z = min(min_z, max_z);
            character->max_x = max(min_x, max_x);
            character->max_y = max(min_y, max_y);
            character->max_z = max(min_z, max_z);
        }
    }

    
void get_char_bound(long id,
                        
float* min_x, float* min_y, float* min_z,
                        
float* max_x, float* max_y, float* max_z)
    {
        sCharacter* character;

        
if((character = get_char(id)) != NULL)
        {
            
if(min_x)   *min_x = character->min_x;
            
if(min_y)   *min_y = character->min_y;
            
if(min_z)   *min_z = character->min_z;
            
if(max_x)   *max_x = character->max_x;
            
if(max_y)   *max_y = character->max_y;
            
if(max_z)   *max_z = character->max_z;
        }
    }

    
void set_target_char(long id, long target_id)
    {
        sCharacter* character;
        
if((character = get_char(id)) == NULL)
            
return;

        
if(target_id == -1)
            character->target_char = NULL;
        
else
        {
            sCharacter* target_char;

            
for(target_char = m_root_char; target_char != NULL; target_char = target_char->next)
            {
                
if(target_char->id == target_id)
                {
                    character->target_char = target_char;
                    
break;
                }
            }

            
// clear target if not found in list
            if(target_char == NULL)
                character->target_char = NULL;
        }
    }

    
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;
        }
    }

Skipping the details on the preceding functions, you now encounter the function
used to set up the data that displays a message over a character:


    void set_char_msg(sCharacter* character, const char* msg, long msg_timer, D3DCOLOR msg_color)
    {
        
// set text messages to float up from character

        strcpy(character->msg, msg);

        character->msg_timer = msg_timer;
        character->msg_color = msg_color;
    }

set_char_msg allows you to temporarily overlay a string of text for Timer milliseconds, drawing
the text in the color specified. You set a character message to inform the player of
an event, such as how many health points were reduced because of an attack.

Coming next is the function that processes the damage taken from an attack,
whether it’s physical or magical (as denoted by the
is_physical_attack flag, set to true for
physical attacks or false for magical):

void cCharController::damage(sCharacter* victim,
                             
bool is_physical_attack, long attack_amount,
                             
long damage_class, long cure_class)
{
    
// can not attack if already dead or being hurt or not update enabled
    if(victim == NULL || !victim->update_enable || victim->action == CHAR_DIE || victim->action == CHAR_HURT)
        
return;

    
float   range;
    
long    damage_amount;
    
    
if(is_physical_attack)  // adjust for defense if physical attack
    {
        
// random value for less/more damage (-+10%)
        range = (rand()%20 + 90.0f) / 100.0f;
        damage_amount = attack_amount * range;

        
// subtract for defencse to victim (allow -20% difference)
        range = (rand()%20 + 80.0f) / 100.0f;
        damage_amount -= (get_defense(victim) * range);
    }
    
else    // adjust for magical attack            
        damage_amount = attack_amount * (1.0f - get_resistance(victim)/100.0f);    

    
if(damage_amount < 0)   // bounds check
        damage_amount = 0;

    
// check for double damage
    if(victim->char_def.class_index == damage_class)
        damage_amount *= 2;

    
// check for cure damage
    if(victim->char_def.class_index == cure_class)
        damage_amount = -labs(damage_amount) / 2;

    
// if no physical damage is dealt then randomly deal 10-20% of damage from the original amount.
    if(damage_amount == 0 && is_physical_attack)
    {
        range = (rand()%10 + 10) / 100.0f;
        damage_amount = attack_amount * range;
    }
    
    victim->health_points -= damage_amount;

    
char text[128];

    
if(damage_amount > 0)       // set hurt status and display message
    {
        sprintf(text, "-%lu HP", damage_amount);
        set_char_msg(victim, text, 500, D3DCOLOR_RGBA(255, 64, 0, 255));

        
// only set hurt if idle or moving
        if(victim->action == CHAR_MOVE || victim->action == CHAR_IDLE)
            set_char_action(victim, CHAR_HURT, 0);
    }
    
else if(damage_amount < 0)  // display cure amount
    {
        sprintf(text, "+%lu HP", -damage_amount);
        set_char_msg(victim, text, 500, D3DCOLOR_RGBA(0, 64, 255, 255));
    }    
}

Damage takes a pointer to the character taking damage, the type of damage (physical
or magical), the amount of damage to apply, and the double damage and cure
classes of the attack. You adjust the damage amount based on the defense and resistance
abilities of the victim.

posted on 2007-12-04 19:19 lovedday 閱讀(280) 評論(0)  編輯 收藏 引用


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


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

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

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            黄色日韩在线| 亚洲精品乱码久久久久久日本蜜臀 | 欧美激情麻豆| 欧美一级免费视频| 亚洲精品网址在线观看| 亚洲国产日本| 亚洲尤物影院| 麻豆精品网站| 亚洲裸体视频| 久久国产精品99久久久久久老狼 | 亚洲国产成人一区| 亚洲一区二区成人在线观看| 欧美诱惑福利视频| 欧美日韩一区二区三区视频| 黑人操亚洲美女惩罚| 噜噜噜噜噜久久久久久91| 久久久久久久久久久一区| 欧美色综合天天久久综合精品| 精品不卡视频| 香蕉乱码成人久久天堂爱免费| 欧美成人精品一区二区| 亚洲欧美综合v| 欧美视频二区36p| 久久久久99| 亚洲专区免费| 国产精品实拍| 亚洲一区二区三区影院| 欧美大尺度在线观看| 亚洲欧美怡红院| 亚洲黄网站黄| 性欧美8khd高清极品| 欧美午夜国产| 亚洲一区二区三区高清不卡| 欧美一区二视频在线免费观看| 在线观看欧美日韩| 美乳少妇欧美精品| 久久久五月婷婷| 亚洲欧美日韩区| 亚洲一区二区三区乱码aⅴ蜜桃女 亚洲一区二区三区乱码aⅴ | 一区二区三区久久网| 久久综合伊人| 亚洲成人资源| 亚洲二区视频| 激情综合视频| 亚洲一区三区视频在线观看 | 国产精品看片你懂得| 亚洲男人影院| 欧美精品一区二区三区高清aⅴ| 亚洲人久久久| 日韩午夜在线播放| 国产精品激情| 久久久亚洲高清| 久久综合五月| 久久深夜福利| 国模吧视频一区| 欧美 日韩 国产 一区| 国产精品羞羞答答| 夜夜嗨av一区二区三区四区| 国产欧美日韩中文字幕在线| 久久精品国产96久久久香蕉| 久久久亚洲成人| 久久久久国产精品厨房| 国产欧美日韩一区二区三区在线观看| av成人手机在线| 中文欧美字幕免费| 午夜影视日本亚洲欧洲精品| 午夜精品久久久久久久99热浪潮| 性欧美超级视频| 香蕉成人久久| 国产欧美精品一区二区色综合| 99精品国产福利在线观看免费| 99riav国产精品| 午夜精品久久久久久久99水蜜桃| 亚洲女性裸体视频| 国产精品久久久一区麻豆最新章节| 99re国产精品| 午夜精品久久久久| 国产精品一区视频| 亚洲国产综合在线| 国产亚洲综合在线| 亚洲美女淫视频| 亚洲在线中文字幕| 国产欧美精品日韩区二区麻豆天美| 亚洲欧美在线网| 久久综合久久综合这里只有精品| 欧美日韩国产一中文字不卡| 美女精品网站| 亚洲人精品午夜| 国产精品美女xx| 久久久中精品2020中文| 亚洲国产1区| 午夜国产欧美理论在线播放 | 欧美在线视屏| 欧美激情一区在线| 国产农村妇女精品一区二区| 欧美在线观看视频一区二区| 欧美sm视频| 亚洲性图久久| 国内精品视频久久| 欧美另类videos死尸| 亚洲影视九九影院在线观看| 麻豆精品视频在线观看| 夜夜嗨av色一区二区不卡| 久久精品人人做人人综合| 亚洲伊人伊色伊影伊综合网| 国产区精品视频| 免费亚洲视频| 狂野欧美性猛交xxxx巴西| 一本色道久久88综合日韩精品 | 国产精品久久亚洲7777| 久久久噜噜噜久久中文字免| 日韩亚洲欧美高清| 免费黄网站欧美| 亚洲欧美资源在线| 亚洲高清视频中文字幕| 久久都是精品| 野花国产精品入口| 欧美电影美腿模特1979在线看| 性欧美大战久久久久久久久| 亚洲人成人一区二区三区| 国产拍揄自揄精品视频麻豆| 欧美日韩精品一区二区三区四区| 久久国产精品毛片| 亚洲香蕉网站| 久久国产精品电影| 黑人中文字幕一区二区三区| 欧美四级在线| 欧美风情在线观看| 久久综合中文色婷婷| 欧美一区二区三区日韩视频| 亚洲午夜一区二区三区| 99视频精品| 91久久国产综合久久| 亚洲一级片在线观看| 亚洲日本欧美在线| 亚洲第一福利社区| 一区二区三区在线观看欧美| 国产视频丨精品|在线观看| 久久国产婷婷国产香蕉| 午夜久久黄色| 亚洲综合色网站| 午夜精品久久久久| 亚洲欧美日韩成人高清在线一区| 亚洲婷婷在线| 亚洲欧美日韩直播| 亚洲欧美国产日韩天堂区| 亚洲一二三区在线观看| 一区二区三区欧美视频| 亚洲深夜福利网站| 老司机精品视频网站| 久久亚洲视频| 免播放器亚洲一区| 蜜臀av性久久久久蜜臀aⅴ| 麻豆精品视频在线| 欧美激情亚洲一区| 亚洲欧洲另类| 一本色道久久加勒比精品| 一区二区三区高清| 亚洲自拍另类| 久久久高清一区二区三区| 久久综合久久综合九色| 欧美大片在线影院| 校园激情久久| 欧美伊人久久| 麻豆精品国产91久久久久久| 午夜在线观看欧美| 久久日韩粉嫩一区二区三区| 亚洲一区二三| 久久国产精品网站| 欧美精品1区2区| 国产麻豆精品视频| 亚洲国产欧美日韩精品| 亚洲素人一区二区| 久久国产综合精品| 欧美激情免费在线| 亚洲视频第一页| 久久女同精品一区二区| 欧美日韩一二三四五区| 国产一区二区欧美| 99视频有精品| 久久久噜噜噜久噜久久 | 欧美一级专区| 亚洲自拍三区| 另类av一区二区| 一本大道久久a久久综合婷婷| 欧美一区二区三区在线免费观看| 久久综合狠狠综合久久综合88| 国产精品yjizz| 在线成人av| 久久se精品一区二区| 亚洲日本在线观看| 欧美综合二区| 国产精品乱码人人做人人爱| 亚洲黄色免费网站| 久久精品中文字幕免费mv| 亚洲精品乱码久久久久久日本蜜臀| 午夜伦欧美伦电影理论片| 欧美日本高清| 亚洲欧洲日韩女同| 老司机精品导航|