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

天行健 君子當(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) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶登錄后才能發(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>
            男男成人高潮片免费网站| 亚洲午夜精品| 久久xxxx精品视频| 国产精品无码专区在线观看| 一区二区三区久久久| 亚洲国产99| 久久久久国色av免费看影院 | 激情成人综合网| 欧美在线亚洲一区| 午夜精品久久久久久久男人的天堂 | 国产一区二区三区四区五区美女| 亚洲午夜精品福利| 亚洲免费av电影| 欧美日韩亚洲国产一区| 亚洲一二三区在线观看| 中文国产成人精品| 欧美性猛交一区二区三区精品| 一区二区电影免费观看| 99re6热只有精品免费观看| 欧美日韩一区二区在线观看 | 裸体丰满少妇做受久久99精品| 精品1区2区| 亚洲国产精品黑人久久久| 免费久久99精品国产自在现线| 亚洲人午夜精品| 9i看片成人免费高清| 国产精品女主播| 欧美中文日韩| 麻豆精品在线视频| 这里只有精品电影| 亚洲欧美综合国产精品一区| 激情一区二区三区| 亚洲国产另类久久久精品极度| 欧美成人免费网站| 亚洲欧美在线免费观看| 欧美一区2区三区4区公司二百| 激情成人中文字幕| 亚洲精品久久久久久一区二区| 国产精品国产三级国产专播品爱网| 午夜亚洲伦理| 免费亚洲电影在线观看| 香蕉久久久久久久av网站| 久久九九免费| 亚洲一二三区在线| 久久人人97超碰国产公开结果| 夜夜嗨av一区二区三区免费区| 亚洲乱码国产乱码精品精98午夜| 国产欧美亚洲日本| 亚洲日本欧美天堂| 国产性天天综合网| 亚洲精品欧美激情| 极品尤物一区二区三区| 日韩视频在线免费| 尤物yw午夜国产精品视频明星| 一本色道久久综合亚洲91| 狠狠入ady亚洲精品经典电影| 亚洲人精品午夜| 一区在线电影| 亚洲欧美在线磁力| 亚洲国产精品一区二区第一页| 亚洲美女在线视频| 亚洲激情社区| 久久精品国产亚洲精品| 99视频有精品| 欧美成人免费在线视频| 久久嫩草精品久久久久| 国产精品美女www爽爽爽| 亚洲高清不卡av| 激情婷婷欧美| 欧美一区成人| 久久精品首页| 欧美日韩国产区| 亚洲国产精品va在线看黑人| 在线欧美三区| 欧美亚洲日本网站| 亚洲欧美日韩国产| 欧美日韩一区自拍| 亚洲人成网站在线观看播放| 亚洲国产精品尤物yw在线观看| 久久久国产视频91| 久久先锋影音| 亚洲第一福利社区| 免费成人高清视频| 欧美成人精品福利| 亚洲电影免费观看高清完整版| 欧美一区视频在线| 久久久久久综合| 激情五月综合色婷婷一区二区| 欧美一区二区三区在线观看视频| 欧美一区二区三区另类| 国产精品免费小视频| 亚洲影视九九影院在线观看| 亚洲女人av| 国产精品夜夜夜| 一区二区三区三区在线| 一本在线高清不卡dvd| 欧美日韩在线观看视频| 一区二区三区欧美在线| 欧美一级久久久久久久大片| 国产亚洲欧美一区二区三区| 久久爱www久久做| 欧美成人激情视频| 宅男噜噜噜66一区二区| 国产精品私拍pans大尺度在线| 午夜精品福利一区二区三区av | 国产亚洲欧美色| 久久精品国产亚洲精品| 欧美伊人久久久久久久久影院| 国产一区二区三区在线观看视频| 久久久综合精品| 亚洲日本中文字幕免费在线不卡| 亚洲一区中文字幕在线观看| 国产一区二区中文字幕免费看| 亚洲永久免费| 欧美电影在线免费观看网站| 亚洲视频在线观看视频| 欧美日韩黄色一区二区| 欧美在线|欧美| 亚洲电影自拍| 欧美一区二区三区在线视频| 在线国产亚洲欧美| 欧美日韩成人激情| 久久爱www.| 一区二区三区产品免费精品久久75| 一区二区三区日韩欧美精品| 国产精品久久久久毛片软件 | 亚洲精品视频在线观看网站| 欧美亚洲专区| 999在线观看精品免费不卡网站| 国产乱码精品| 欧美精品尤物在线| 久久精品人人| 亚洲视频电影图片偷拍一区| 美女尤物久久精品| 99视频精品在线| 国产一区二区三区黄视频| 欧美日韩国产色综合一二三四| 久久黄色影院| 亚洲午夜久久久久久尤物| 亚洲第一在线视频| 久久婷婷久久| 欧美一区久久| 亚洲欧美日韩国产综合| 日韩一区二区电影网| 一区二区视频免费完整版观看| 国产精品狼人久久影院观看方式| 欧美成人一区二区三区在线观看| 欧美影院成年免费版| 日韩午夜在线观看视频| 久久久国产一区二区| 香蕉久久精品日日躁夜夜躁| 亚洲午夜国产一区99re久久 | 久久精品国产v日韩v亚洲 | 欧美一区二区三区在| 亚洲一区在线播放| 亚洲精品一区在线观看| 一区二区三区精品在线| 亚洲免费在线观看| 欧美自拍偷拍| 另类欧美日韩国产在线| 欧美激情亚洲激情| 亚洲精品久久久久中文字幕欢迎你| 亚洲人成人77777线观看| 亚洲精品一区二区在线| 亚洲一区二区在线看| 欧美中文字幕在线视频| 老司机亚洲精品| 欧美日韩精品二区第二页| 国产精品萝li| 亚洲国产精品va在线观看黑人| avtt综合网| 欧美专区亚洲专区| 亚洲成人在线网| 国产亚洲精品福利| 黄色成人在线观看| av成人免费在线| 欧美在线观看网址综合| 欧美激情一区二区三区在线| 一区二区精品在线| 久久人体大胆视频| 欧美三级电影精品| 一区视频在线| 亚洲丝袜av一区| 老司机精品久久| 99re6这里只有精品视频在线观看| 亚洲欧美日韩一区二区| 女仆av观看一区| 国产欧美日韩不卡| 日韩一级大片在线| 另类专区欧美制服同性| 一本久久a久久免费精品不卡| 欧美制服丝袜第一页| 欧美视频在线播放| 亚洲国产精彩中文乱码av在线播放| 亚洲天堂免费在线观看视频| 你懂的网址国产 欧美| 亚洲欧美日韩在线观看a三区| 欧美久久精品午夜青青大伊人| 黑人一区二区三区四区五区| 亚洲免费一级电影|