本文整理汇总了C++中cap_value函数的典型用法代码示例。如果您正苦于以下问题:C++ cap_value函数的具体用法?C++ cap_value怎么用?C++ cap_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cap_value函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: inter_pet_tosql
//---------------------------------------------------------
int inter_pet_tosql (int pet_id, struct s_pet *p)
{
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`)
char esc_name[NAME_LENGTH * 2 + 1]; // escaped pet name
Sql_EscapeStringLen (sql_handle, esc_name, p->name, strnlen (p->name, NAME_LENGTH));
p->hungry = cap_value (p->hungry, 0, 100);
p->intimate = cap_value (p->intimate, 0, 1000);
if (pet_id == -1) {
// New pet.
if (SQL_ERROR == Sql_Query (sql_handle, "INSERT INTO `%s` "
"(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) "
"VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate)) {
Sql_ShowDebug (sql_handle);
return 0;
}
p->pet_id = (int) Sql_LastInsertId (sql_handle);
} else {
// Update pet.
if (SQL_ERROR == Sql_Query (sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'",
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id)) {
Sql_ShowDebug (sql_handle);
return 0;
}
}
if (save_log)
ShowInfo ("Pet salvo %d - %s.\n", pet_id, p->name);
return 1;
}
开发者ID:Celso1415,项目名称:Fusion,代码行数:36,代码来源:int_pet.c
示例2: party_exp_share
//Exp share and added zeny share [Valaris]
int party_exp_share(struct party_data *p, struct block_list *src, unsigned int base_exp, unsigned int job_exp, int zeny)
{
struct map_session_data *sd[MAX_PARTY];
unsigned int i, c;
#ifdef RENEWAL_EXP
uint32 base_exp_bonus, job_exp_bonus;
#endif
nullpo_ret(p);
//Count the number of players eligible for exp sharing
for (i = c = 0; i < MAX_PARTY; i++) {
if ((sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle(sd[c])))
continue;
c++;
}
if (c < 1)
return 0;
base_exp /= c;
job_exp /= c;
zeny /= c;
if (battle_config.party_even_share_bonus && c > 1) {
double bonus = 100 + battle_config.party_even_share_bonus * (c - 1);
if (base_exp)
base_exp = (unsigned int)cap_value(base_exp * bonus / 100, 0, UINT_MAX);
if (job_exp)
job_exp = (unsigned int)cap_value(job_exp * bonus / 100, 0, UINT_MAX);
if (zeny)
zeny = (unsigned int)cap_value(zeny * bonus / 100, INT_MIN, INT_MAX);
}
#ifdef RENEWAL_EXP
base_exp_bonus = base_exp;
job_exp_bonus = job_exp;
#endif
for (i = 0; i < c; i++) {
#ifdef RENEWAL_EXP
if (!(src && src->type == BL_MOB && ((TBL_MOB *)src)->db->mexp)) {
TBL_MOB *md = BL_CAST(BL_MOB, src);
int rate = 0;
if (!md)
return 0;
rate = pc_level_penalty_mod(sd[i], md->db->lv, md->db->status.class_, 1);
base_exp = (unsigned int)cap_value(base_exp_bonus * rate / 100, 1, UINT_MAX);
job_exp = (unsigned int)cap_value(job_exp_bonus * rate / 100, 1, UINT_MAX);
}
#endif
pc_gainexp(sd[i], src, base_exp, job_exp, false);
if (zeny) //Zeny from mobs [Valaris]
pc_getzeny(sd[i],zeny,LOG_TYPE_PICKDROP_MONSTER,NULL);
}
return 0;
}
开发者ID:SamuelHercules,项目名称:idathena,代码行数:60,代码来源:party.c
示例3: party_exp_share
/** Party EXP and Zeny sharing
* @param p Party data
* @param src EXP source (for renewal level penalty)
* @param base_exp Base EXP gained from killed mob
* @param job_exp Job EXP gained from killed mob
* @param zeny Zeny gained from killed mob
* @author Valaris
**/
void party_exp_share(struct party_data* p, struct block_list* src, unsigned int base_exp, unsigned int job_exp, int zeny)
{
struct map_session_data* sd[MAX_PARTY];
unsigned int i, c;
#ifdef RENEWAL_EXP
TBL_MOB *md = BL_CAST(BL_MOB, src);
if (!md)
return;
#endif
nullpo_retv(p);
// count the number of players eligible for exp sharing
for (i = c = 0; i < MAX_PARTY; i++) {
if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle(sd[c])) )
continue;
c++;
}
if (c < 1)
return;
base_exp/=c;
job_exp/=c;
zeny/=c;
if (battle_config.party_even_share_bonus && c > 1) {
double bonus = 100 + battle_config.party_even_share_bonus*(c-1);
if (base_exp)
base_exp = (unsigned int) cap_value(base_exp * bonus/100, 0, UINT_MAX);
if (job_exp)
job_exp = (unsigned int) cap_value(job_exp * bonus/100, 0, UINT_MAX);
if (zeny)
zeny = (unsigned int) cap_value(zeny * bonus/100, INT_MIN, INT_MAX);
}
for (i = 0; i < c; i++) {
#ifdef RENEWAL_EXP
uint32 base_gained = base_exp, job_gained = job_exp;
if (base_exp || job_exp) {
int rate = pc_level_penalty_mod(md->level - sd[i]->status.base_level, md->db->status.class_, md->db->status.mode, 1);
if (rate != 100) {
if (base_exp)
base_gained = (unsigned int)cap_value(apply_rate(base_exp, rate), 1, UINT_MAX);
if (job_exp)
job_gained = (unsigned int)cap_value(apply_rate(job_exp, rate), 1, UINT_MAX);
}
}
pc_gainexp(sd[i], src, base_gained, job_gained, 0);
#else
pc_gainexp(sd[i], src, base_exp, job_exp, 0);
#endif
if (zeny) // zeny from mobs [Valaris]
pc_getzeny(sd[i],zeny,LOG_TYPE_PICKDROP_MONSTER,NULL);
}
}
开发者ID:julius5,项目名称:rathena,代码行数:66,代码来源:party.c
示例4: inter_pet_fromsql
int inter_pet_fromsql(int pet_id, struct s_pet* p)
{
char* data;
size_t len;
#ifdef NOISY
ShowInfo("Loading pet (%d)...\n",pet_id);
#endif
memset(p, 0, sizeof(struct s_pet));
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`)
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
{
Sql_ShowDebug(sql_handle);
return 0;
}
if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
{
p->pet_id = pet_id;
Sql_GetData(sql_handle, 1, &data, NULL);
p->class_ = atoi(data);
Sql_GetData(sql_handle, 2, &data, &len);
memcpy(p->name, data, min(len, NAME_LENGTH));
Sql_GetData(sql_handle, 3, &data, NULL);
p->account_id = atoi(data);
Sql_GetData(sql_handle, 4, &data, NULL);
p->char_id = atoi(data);
Sql_GetData(sql_handle, 5, &data, NULL);
p->level = atoi(data);
Sql_GetData(sql_handle, 6, &data, NULL);
p->egg_id = atoi(data);
Sql_GetData(sql_handle, 7, &data, NULL);
p->equip = atoi(data);
Sql_GetData(sql_handle, 8, &data, NULL);
p->intimate = atoi(data);
Sql_GetData(sql_handle, 9, &data, NULL);
p->hungry = atoi(data);
Sql_GetData(sql_handle, 10, &data, NULL);
p->rename_flag = atoi(data);
Sql_GetData(sql_handle, 11, &data, NULL);
p->incuvate = atoi(data);
Sql_FreeResult(sql_handle);
p->hungry = cap_value(p->hungry, 0, 100);
p->intimate = cap_value(p->intimate, 0, 1000);
if( save_log )
ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name);
}
return 0;
}
开发者ID:dbrocom,项目名称:syncragnarok,代码行数:54,代码来源:int_pet.c
示例5: party_exp_share
// exp share and added zeny share [Valaris]
int party_exp_share(struct party_data* p, struct block_list* src, unsigned int base_exp, unsigned int job_exp, int zeny)
{
struct map_session_data* sd[MAX_PARTY];
unsigned int i, c;
nullpo_retr(0, p);
// count the number of players eligible for exp sharing
for( i = c = 0; i < MAX_PARTY; i++ )
{
if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle(sd[c])) )
continue;
c++;
}
if( c < 1 )
return 0;
base_exp /= c;
job_exp /= c;
zeny /= c;
if( battle_config.renewal_system_enable && c > 2 )
{
int rbonus = 100 + (10 * (c - 2)); // 10% ~ 100%
if( base_exp )
base_exp = (unsigned int) cap_value(base_exp * rbonus/100, 0, UINT_MAX);
if( job_exp )
job_exp = (unsigned int) cap_value(job_exp * rbonus/100, 0, UINT_MAX);
}
if( battle_config.party_even_share_bonus && c > 1 )
{
double bonus = 100 + battle_config.party_even_share_bonus*(c-1);
if (base_exp)
base_exp = (unsigned int) cap_value(base_exp * bonus/100, 0, UINT_MAX);
if (job_exp)
job_exp = (unsigned int) cap_value(job_exp * bonus/100, 0, UINT_MAX);
if (zeny)
zeny = (unsigned int) cap_value(zeny * bonus/100, INT_MIN, INT_MAX);
}
for( i = 0; i < c; i++ )
{
pc_gainexp(sd[i],src,base_exp,job_exp,false);
if( zeny ) // zeny from mobs [Valaris]
pc_getzeny(sd[i],zeny);
}
return 0;
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:51,代码来源:party.c
示例6: mercenary_set_faith
int mercenary_set_faith(struct mercenary_data *md, int value)
{
struct map_session_data *sd;
int class_, *faith;
if( md == NULL || md->db == NULL || (sd = md->master) == NULL )
return 0;
class_ = md->db->class_;
if( class_ >= 6017 && class_ <= 6026 )
faith = &sd->status.arch_faith;
else if( class_ >= 6027 && class_ <= 6036 )
faith = &sd->status.spear_faith;
else if( class_ >= 6037 && class_ <= 6046 )
faith = &sd->status.sword_faith;
else
return 0;
*faith += value;
*faith = cap_value(*faith, 0, SHRT_MAX);
clif->mercenary_updatestatus(sd, SP_MERCFAITH);
return 0;
}
开发者ID:Alvero,项目名称:Hercules,代码行数:25,代码来源:mercenary.c
示例7: WBUFL
CBazaarItemPacket::CBazaarItemPacket(CItem* PItem, uint8 slotID, uint8 tax)
{
this->type = 0x05; // 0x105
this->size = 0x17;
WBUFL(data,(0x04)-4) = PItem->getCharPrice();
WBUFL(data,(0x08)-4) = PItem->getQuantity();
WBUFW(data,(0x0C)-4) = tax;
WBUFW(data,(0x0E)-4) = PItem->getID();
WBUFB(data,(0x10)-4) = slotID;
if (PItem->getSubType() & ITEM_CHARGED)
{
uint32 currentTime = CVanaTime::getInstance()->getSysTime() - 1009810800;
uint32 nextUseTime = ((CItemUsable*)PItem)->getLastUseTime() + ((CItemUsable*)PItem)->getReuseDelay();
WBUFB(data,(0x11)-4) = 0x01; // флаг ITEM_CHARGED
WBUFB(data,(0x12)-4) = ((CItemUsable*)PItem)->getCurrentCharges();
WBUFB(data,(0x14)-4) = (nextUseTime > currentTime ? 0x90 : 0xD0);
WBUFL(data,(0x15)-4) = nextUseTime; // таймер следующего использования
WBUFL(data,(0x19)-4) = ((CItemUsable*)PItem)->getUseDelay() + currentTime; // таймер задержки использования
}
memcpy(data+(0x1D)-4, PItem->getSignature(), cap_value(strlen(PItem->getSignature()), 0, 12));
}
开发者ID:Laterus,项目名称:Darkstar-Linux-Fork,代码行数:27,代码来源:bazaar_item.cpp
示例8: channel_create
bool channel_create(struct map_session_data *sd, const char* name, const char* pass, short type, short color, int op)
{
struct channel_data *cd;
int i = 0;
if( !name || strlen(name) < 2 || strlen(name) >= NAME_LENGTH || name[0] != '#' )
{
if( sd ) clif_displaymessage(sd->fd, msg_txt(801));
return false;
}
if( type == CHN_USER && !sd )
return false; // Operator required for user channels
if( sd && type == CHN_USER && (i = channel_slot_free(sd)) < 0 )
{
clif_displaymessage(sd->fd, msg_txt(800));
return false;
}
if( (cd = (struct channel_data *)strdb_get(channel_db, name)) != NULL )
{
if( sd ) clif_displaymessage(sd->fd, msg_txt(802));
return false; // Already exists
}
CREATE(cd, struct channel_data, 1);
cd->channel_id = ++channel_counter;
safestrncpy(cd->name, name, sizeof(cd->name));
safestrncpy(cd->pass, pass, sizeof(cd->pass));
cd->type = type;
cd->color = channel_color[cap_value(color,0,38)];
cd->users = 0;
cd->op = 0;
cd->users_db = idb_alloc(DB_OPT_BASE);
if( type == CHN_USER )
{
char output[128];
sprintf(output, msg_txt(803), cd->name, sd->status.name);
sd->cd[i] = cd;
cd->op = sd->bl.id;
idb_put(cd->users_db, sd->bl.id, sd);
cd->users++;
clif_channel_message(cd, output, -1);
}
else if( type < CHN_USER )
{
server_channel[type] = cd; // Quick access to main channels
ShowInfo("Channel System : New channel %s created.\n", cd->name);
}
else
cd->op = op; // Server Channel
strdb_put(channel_db, cd->name, cd);
return true;
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:55,代码来源:channel.c
示例9: cap_value
void vsx_widget_controller_slider::command_process_back_queue(vsx_command_s *t)
{
if (owned && t->cmd == "si") { vsx_widget::command_process_back_queue(t); }
else
if (t->cmd == "u") {
target_value = vsx_string_helper::s2f(t->cmd_data);
cap_value();
send_to_server();
k_focus = this;
} else vsx_widget_controller_base::command_process_back_queue(t);
}
开发者ID:CJFocke,项目名称:vsxu,代码行数:11,代码来源:vsx_widget_controller_slider.cpp
示例10: VSX_UNUSED
void vsx_widget_controller_slider::event_mouse_move(vsx_widget_distance distance,vsx_widget_coords coords)
{
VSX_UNUSED(coords);
if (controlling)
{
target_value = (-(((distance.corner.y-handlesize/2)/(size.y-handlesize))-1) * (amp))+ofs; //amp-ofs
cap_value();
}
send_to_server();
++mouse_moves;
}
开发者ID:CJFocke,项目名称:vsxu,代码行数:12,代码来源:vsx_widget_controller_slider.cpp
示例11: guild_change_position
// ギルド役職変更
int guild_change_position(int guild_id,int idx,
int mode,int exp_mode,const char *name)
{
struct guild_position p;
exp_mode = cap_value(exp_mode, 0, battle_config.guild_exp_limit);
//Mode 0x01 <- Invite
//Mode 0x10 <- Expel.
p.mode=mode&0x11;
p.exp_mode=exp_mode;
safestrncpy(p.name,name,NAME_LENGTH);
return intif_guild_position(guild_id,idx,&p);
}
开发者ID:casioza,项目名称:server000,代码行数:14,代码来源:guild.c
示例12: guild_change_position
// ギルド役職変更
int guild_change_position(int guild_id,int idx,
int mode,int exp_mode,const char *name)
{
struct guild_position p;
exp_mode = cap_value(exp_mode, 0, battle_config.guild_exp_limit);
//Mode 0x01 <- Invite
//Mode 0x10 <- Expel.
p.mode=mode&0x11;
p.exp_mode=exp_mode;
memcpy(p.name,name,NAME_LENGTH-1);
p.name[NAME_LENGTH-1] = '\0'; //Security check... [Skotlex]
return intif_guild_position(guild_id,idx,&p);
}
开发者ID:AxlSckay,项目名称:Ragnarok-OldTimes,代码行数:15,代码来源:guild.c
示例13: mercenary_kills
int mercenary_kills(struct mercenary_data *md)
{
md->mercenary.kill_count++;
md->mercenary.kill_count = cap_value(md->mercenary.kill_count, 0, INT_MAX);
if((md->mercenary.kill_count % 50) == 0) {
mercenary_set_faith(md, 1);
mercenary_killbonus(md);
}
if(md->master)
clif_mercenary_updatestatus(md->master, SP_MERCKILLS);
return 0;
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:15,代码来源:mercenary.c
示例14: elemental_skill_get_requirements
struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 skill_lv){
struct skill_condition req;
uint16 idx = skill_get_index(skill_id);
memset(&req,0,sizeof(req));
if( idx == 0 ) // invalid skill id
return req;
skill_lv = cap_value(skill_lv, 1, MAX_SKILL_LEVEL);
req.hp = skill_db[idx]->require.hp[skill_lv-1];
req.sp = skill_db[idx]->require.sp[skill_lv-1];
return req;
}
开发者ID:newmessage,项目名称:rathena,代码行数:16,代码来源:elemental.c
示例15: mercenary_set_calls
/**
* Set Mercenary's calls
* @param md Mercenary
* @param value
**/
void mercenary_set_calls(struct mercenary_data *md, int value) {
struct map_session_data *sd;
uint16 class_;
int *calls;
if( md == NULL || md->db == NULL || (sd = md->master) == NULL )
return;
class_ = md->db->class_;
if( class_ >= 6017 && class_ <= 6026 )
calls = &sd->status.arch_calls;
else if( class_ >= 6027 && class_ <= 6036 )
calls = &sd->status.spear_calls;
else if( class_ >= 6037 && class_ <= 6046 )
calls = &sd->status.sword_calls;
else
return;
*calls += value;
*calls = cap_value(*calls, 0, INT_MAX);
}
开发者ID:AlScarface,项目名称:rathena,代码行数:27,代码来源:mercenary.c
示例16: vending_openvending
/*==========================================
* Open shop
* data := {<index>.w <amount>.w <value>.l}[count]
*------------------------------------------*/
void vending_openvending(struct map_session_data* sd, const char* message, const uint8* data, int count) {
int i, j;
int vending_skill_lvl;
nullpo_retv(sd);
if ( pc_isdead(sd) || !sd->state.prevend || pc_istrading(sd))
return; // can't open vendings lying dead || didn't use via the skill (wpe/hack) || can't have 2 shops at once
vending_skill_lvl = pc->checkskill(sd, MC_VENDING);
// skill level and cart check
if( !vending_skill_lvl || !pc_iscarton(sd) ) {
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// check number of items in shop
if( count < 1 || count > MAX_VENDING || count > 2 + vending_skill_lvl ) {
// invalid item count
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// filter out invalid items
i = 0;
for( j = 0; j < count; j++ ) {
short index = *(uint16*)(data + 8*j + 0);
short amount = *(uint16*)(data + 8*j + 2);
unsigned int value = *(uint32*)(data + 8*j + 4);
index -= 2; // offset adjustment (client says that the first cart position is 2)
if( index < 0 || index >= MAX_CART // invalid position
|| pc->cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity
//NOTE: official server does not do any of the following checks!
|| !sd->status.cart[index].identify // unidentified item
|| sd->status.cart[index].attribute == 1 // broken item
|| sd->status.cart[index].expire_time // It should not be in the cart but just in case
|| !itemdb_cantrade(&sd->status.cart[index], pc->get_group_level(sd), pc->get_group_level(sd)) ) // untradeable item
continue;
sd->vending[i].index = index;
sd->vending[i].amount = amount;
sd->vending[i].value = cap_value(value, 0, (unsigned int)battle_config.vending_max_value);
i++; // item successfully added
}
if( i != j )
clif->message (sd->fd, msg_txt(266)); //"Some of your items cannot be vended and were removed from the shop."
if( i == 0 ) { // no valid item found
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0); // custom reply packet
return;
}
sd->state.prevend = sd->state.workinprogress = 0;
sd->state.vending = true;
sd->vender_id = getid();
sd->vend_num = i;
safestrncpy(sd->message, message, MESSAGE_SIZE);
clif->openvending(sd,sd->bl.id,sd->vending);
clif->showvendingboard(&sd->bl,message,0);
idb_put(vending->db, sd->status.char_id, sd);
}
开发者ID:Schwierig,项目名称:Hercules,代码行数:69,代码来源:vending.c
示例17: bg_arena
/* ==============================================================
bg_arena (0 EoS | 1 Boss | 2 TI | 3 CTF | 4 TD | 5 SC | 6 CON | 7 RUSH | 8 DOM)
bg_result (0 Won | 1 Tie | 2 Lost)
============================================================== */
void bg_team_rewards(int bg_id, int nameid, int amount, int kafrapoints, int quest_id, const char *var, int add_value, int bg_arena, int bg_result)
{
struct battleground_data *bg;
struct map_session_data *sd;
struct item_data *id;
struct item it;
int i, j, flag, fame, get_amount, rank = 0, type;
if( amount < 1 || (bg = bg_team_search(bg_id)) == NULL || (id = itemdb_exists(nameid)) == NULL )
return;
if( battle_config.bg_reward_rates != 100 )
{ // BG Reward Rates
amount = amount * battle_config.bg_reward_rates / 100;
kafrapoints = kafrapoints * battle_config.bg_reward_rates / 100;
}
bg_result = cap_value(bg_result,0,2);
memset(&it,0,sizeof(it));
if( nameid == 7828 || nameid == 7829 || nameid == 7773 )
{
it.nameid = nameid;
it.identify = 1;
}
else nameid = 0;
for( j = 0; j < MAX_BG_MEMBERS; j++ )
{
if( (sd = bg->members[j].sd) == NULL )
continue;
if( battle_config.bg_ranking_bonus )
{
rank = 0;
ARR_FIND(0,MAX_FAME_LIST,i,bgrank_fame_list[i].id == sd->status.char_id);
if( i < MAX_FAME_LIST )
rank = 1;
else
{
ARR_FIND(0,MAX_FAME_LIST,i,bg_fame_list[i].id == sd->status.char_id);
if( i < MAX_FAME_LIST )
rank = 1;
}
}
if( quest_id ) quest_add(sd,quest_id);
pc_setglobalreg(sd,var,pc_readglobalreg(sd,var) + add_value);
if( kafrapoints > 0 )
{
get_amount = kafrapoints;
if( rank ) get_amount += battle_config.bg_ranking_bonus * get_amount / 100;
pc_getcash(sd,0,get_amount);
}
if( nameid && amount > 0 )
{
get_amount = amount;
if( rank ) get_amount += battle_config.bg_ranking_bonus * get_amount / 100;
if( (flag = pc_additem(sd,&it,get_amount,LOG_TYPE_SCRIPT)) )
clif_additem(sd,0,0,flag);
}
type = bg->members[j].ranked ? 2 : 3; // Where to Add Fame
switch( bg_result )
{
case 0: // Won
add2limit(sd->status.bgstats.win,1,USHRT_MAX);
achievement_validate_bg(sd,ATB_VICTORY,1);
fame = 100;
if( sd->bmaster_flag )
{
add2limit(sd->status.bgstats.leader_win,1,USHRT_MAX);
achievement_validate_bg(sd,ATB_LEADER_VICTORY,1);
fame += 25;
}
pc_addfame(sd,fame,type);
switch( bg_arena )
{
case 0:
add2limit(sd->status.bgstats.eos_wins,1,USHRT_MAX);
achievement_validate_bg(sd,ATB_EOS_VICTORY,1);
break;
case 1:
add2limit(sd->status.bgstats.boss_wins,1,USHRT_MAX);
achievement_validate_bg(sd,ATB_BOSS_VICTORY,1);
break;
case 2:
add2limit(sd->status.bgstats.ti_wins,1,USHRT_MAX);
achievement_validate_bg(sd,ATB_TI_VICTORY,1);
break;
case 3:
add2limit(sd->status.bgstats.ctf_wins,1,USHRT_MAX);
achievement_validate_bg(sd,ATB_CTF_VICTORY,1);
//.........这里部分代码省略.........
开发者ID:Chocolate31,项目名称:eamod,代码行数:101,代码来源:battleground.c
示例18: vending_openvending
/*==========================================
* Abrir loja
* data := {<index>.w <amount>.w <value>.l}[count]
*------------------------------------------*/
void vending_openvending(struct map_session_data* sd, const char* message, const uint8* data, int count) {
int i, j;
int vending_skill_lvl;
nullpo_retv(sd);
if ( pc_isdead(sd) || !sd->state.prevend || pc_istrading(sd))
return; // nao pode abrir vendas deitado morto || não usou via habilidade (wpe/hack) || não pode ter 2 lojas ao mesmo tempo
vending_skill_lvl = pc->checkskill(sd, MC_VENDING);
// check de nivel de habilidade e carrinho
if( !vending_skill_lvl || !pc_iscarton(sd) ) {
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// checka numero de itens na loja
if( count < 1 || count > MAX_VENDING || count > 2 + vending_skill_lvl ) {
// contagem de item invalida
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// filtrar itens invalidos
i = 0;
for( j = 0; j < count; j++ ) {
short index = *(uint16*)(data + 8*j + 0);
short amount = *(uint16*)(data + 8*j + 2);
unsigned int value = *(uint32*)(data + 8*j + 4);
index -= 2; // ajuste de equilibrio (cliente diz que a posição do primeiro carrinho é 2)
if( index < 0 || index >= MAX_CART // posição inválida
|| pc->cartitem_amount(sd, index, amount) < 0 // item invalido ou quantidade insuficiente
//NOT: servidores oficiais não fazem nenhum dos checks abaixo!
|| !sd->status.cart[index].identify // item não-identficado
|| sd->status.cart[index].attribute == 1 // item quebrado
|| sd->status.cart[index].expire_time // Isso não deveria estar no carrinho mas apenas no caso de estar
|| (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // não pode trocar itens de recompensa, permissão w/o
|| !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // Itens não-trocaveis
continue;
sd->vending[i].index = index;
sd->vending[i].amount = amount;
sd->vending[i].value = cap_value(value, 0, (unsigned int)battle_config.vending_max_value);
i++; // item adicionado com sucesso
}
if( i != j )
clif->message (sd->fd, msg_txt(266)); //"Alguns dos seus itens não pode ser vendido e foram removidos da loja."
if( i == 0 ) { // nenhum item válido encontrado
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0); // packet de resposta personalizada
return;
}
sd->state.prevend = sd->state.workinprogress = 0;
sd->state.vending = true;
sd->vender_id = getid();
sd->vend_num = i;
safestrncpy(sd->message, message, MESSAGE_SIZE);
clif->openvending(sd,sd->bl.id,sd->vending);
clif->showvendingboard(&sd->bl,message,0);
idb_put(vending->db, sd->status.char_id, sd);
}
开发者ID:Cronus-Emulator,项目名称:Cronus,代码行数:70,代码来源:vending.c
示例19: vending_openvending
/*==========================================
* Open shop
* data := {<index>.w <amount>.w <value>.l}[count]
*------------------------------------------*/
void vending_openvending(struct map_session_data* sd, const char* message, bool flag, const uint8* data, int count)
{
int i, j, char_id;
int vending_skill_lvl;
nullpo_retv(sd);
if( !flag ) // cancelled
return; // nothing to do
if (pc_istrading(sd))
return; // can't have 2 shops at once
vending_skill_lvl = pc_checkskill(sd, MC_VENDING);
// skill level and cart check
if( !vending_skill_lvl || !pc_iscarton(sd) )
{
clif_skill_fail(sd, MC_VENDING, 0, 0);
return;
}
// check number of items in shop
if( count < 1 || count > MAX_VENDING || count > 2 + vending_skill_lvl )
{ // invalid item count
clif_skill_fail(sd, MC_VENDING, 0, 0);
return;
}
if((sd->bl.m == map_mapname2mapid("mercadores")
&& (
((sd->bl.x != 65) && (sd->bl.x != 74) && (sd->bl.x != 85) && (sd->bl.x != 94)
&& (sd->bl.x != 34) && (sd->bl.x != 25) && (sd->bl.x != 14) && (sd->bl.x != 5)
&& (sd->bl.x != 44) && (sd->bl.x != 55))
))) {
clif_displaymessage(sd->fd,"Você não pode abrir lojas no meio da Sala.");
return;
}
// filter out invalid items
i = 0;
for( j = 0; j < count; j++ )
{
short index = *(uint16*)(data + 8*j + 0);
short amount = *(uint16*)(data + 8*j + 2);
unsigned int value = *(uint32*)(data + 8*j + 4);
index -= 2; // offset adjustment (client says that the first cart position is 2)
if( index < 0 || index >= MAX_CART // invalid position
|| pc_cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity
//NOTE: official server does not do any of the following checks!
|| !sd->status.cart[index].identify // unidentified item
|| sd->status.cart[index].attribute == 1 // broken item
|| sd->status.cart[index].expire_time // It should not be in the cart but just in case
|| sd->status.cart[index].bound // Can't Trade Account bound items
|| ( sd->status.cart[index].card[0] == CARD0_CREATE && (char_id = MakeDWord(sd->status.cart[index].card[2],sd->status.cart[index].card[3])) > 0 && ((battle_config.bg_reserved_char_id && char_id == battle_config.bg_reserved_char_id) || (battle_config.ancient_reserved_char_id && char_id == battle_config.ancient_reserved_char_id)) )
|| !itemdb_cantrade(&sd->status.cart[index], pc_isGM(sd), pc_isGM(sd)) ) // untradeable item
continue;
sd->vending[i].index = index;
sd->vending[i].amount = amount;
sd->vending[i].value = cap_value(value, 0, (unsigned int)battle_config.vending_max_value);
i++; // item successfully added
}
if( i != j )
clif_displaymessage (sd->fd, msg_txt(266)); //"Some of your items cannot be vended and were removed from the shop."
if( i == 0 )
{ // no valid item found
clif_skill_fail(sd, MC_VENDING, 0, 0); // custom reply packet
return;
}
sd->state.vending = true;
sd->vender_id = vending_getuid();
sd->vend_num = i;
safestrncpy(sd->message, message, MESSAGE_SIZE);
pc_stop_walking(sd,1);
clif_openvending(sd,sd->bl.id,sd->vending);
clif_showvendingboard(&sd->bl,message,0);
if( battle_config.channel_announces&0x10 )
{
char chat_message[256];
sprintf(chat_message, msg_txt(820), vending_chat_nick, sd->status.name, sd->message, map[sd->bl.m].name, sd->bl.x, sd->bl.y);
clif_channel_message(server_channel[CHN_VENDING], chat_message, 27);
}
if( map[sd->bl.m].flag.vending_cell )
map_setcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_NOBOARDS, false);
}
开发者ID:ranfs,项目名称:fa6d4ae1781f9a68f1a4d5,代码行数:97,代码来源:vending.c
示例20: party_exp_share
// exp share and added zeny share [Valaris]
int party_exp_share(struct party_data* p, struct block_list* src, unsigned int base_exp, unsigned int job_exp, int zeny)
{
struct map_session_data* sd[MAX_PARTY];
unsigned int i, c;
nullpo_ret(p);
// count the number of players eligible for exp sharing
for( i = c = 0; i < MAX_PARTY; i++ )
{
if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle(sd[c])) )
continue;
c++;
}
if(c < 1)
return 0;
if (battle_config.renewal_party_exp_nerf)
{
int nerf;
if (c == 2)
{
nerf = 50;
}
else if (c == 3)
{
nerf = 37;
}
else if (c == 4)
{
nerf = 30;
}
else if (c == 5)
{
nerf = 26;
}
else if (c == 6)
{
nerf = 23;
}
else if (c == 7)
{
nerf = 21;
}
else if (c == 8)
{
nerf = 20;
}
else if (c == 9)
{
nerf = 19;
}
else if (c == 10)
{
nerf = 18;
}
else if (c == 11)
{
nerf = 17;
}
else if (c == 12)
{
nerf = 17;
}
else
{
nerf = 0;
}
if (nerf)
{
base_exp = base_exp * nerf / 100;
job_exp = job_exp * nerf / 100;
zeny = zeny * nerf / 100;
}
}
else
{
base_exp /= c;
job_exp /= c;
zeny /= c;
}
if( battle_config.party_even_share_bonus && c > 1 )
{
double bonus = 100 + battle_config.party_even_share_bonus*(c-1);
if (base_exp)
base_exp = (unsigned int) cap_value(base_exp * bonus/100, 0, UINT_MAX);
if (job_exp)
job_exp = (unsigned int) cap_value(job_exp * bonus/100, 0, UINT_MAX);
if (zeny)
zeny = (unsigned int) cap_value(zeny * bonus/100, INT_MIN, INT_MAX);
}
for( i = 0; i < c; i++ )
{
pc_gainexp(sd[i], src, base_exp, job_exp, false);
//.........这里部分代码省略.........
开发者ID:DanielSchiavini,项目名称:cortezonline,代码行数:101,代码来源:party.c
注:本文中的cap_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论