本文整理汇总了C++中dsp_cap函数的典型用法代码示例。如果您正苦于以下问题:C++ dsp_cap函数的具体用法?C++ dsp_cap怎么用?C++ dsp_cap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dsp_cap函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateEnmityBonus
void CEnmityContainer::UpdateEnmity(CBattleEntity* PEntity, int16 CE, int16 VE, bool withMaster)
{
// you're too far away so i'm ignoring you
if (!IsWithinEnmityRange(PEntity))
{
CE = 0;
VE = 0;
}
auto enmity_obj = m_EnmityList.find(PEntity->id);
if (enmity_obj != m_EnmityList.end())
{
float bonus = CalculateEnmityBonus(PEntity);
int newCE = enmity_obj->second.CE + ((CE > 0) ? CE * bonus : CE);
int newVE = enmity_obj->second.VE + ((VE > 0) ? VE * bonus : VE);
//Check for cap limit
enmity_obj->second.CE = dsp_cap(newCE, 0, 10000);
enmity_obj->second.VE = dsp_cap(newVE, 0, 10000);
enmity_obj->second.active = true;
if (CE + VE > 0 && PEntity->getMod(Mod::TREASURE_HUNTER) > enmity_obj->second.maxTH)
enmity_obj->second.maxTH = (uint8)(PEntity->getMod(Mod::TREASURE_HUNTER));
}
else if (CE >= 0 && VE >= 0)
{
bool initial = true;
for (auto&& enmityObject : m_EnmityList)
{
if (enmityObject.second.active)
{
initial = false;
break;
}
}
if (initial) CE += 200;
float bonus = CalculateEnmityBonus(PEntity);
CE = dsp_cap(CE * bonus, 0, 10000);
VE = dsp_cap(VE * bonus, 0, 10000);
auto maxTH = 0;
if (CE + VE > 0)
maxTH = (uint8)(PEntity->getMod(Mod::TREASURE_HUNTER));
m_EnmityList.emplace(PEntity->id, EnmityObject_t {PEntity, CE, VE, true, (uint8)maxTH});
if (withMaster && PEntity->PMaster != nullptr)
{
//add master to the enmity list
//add master to the enmity list (charmed mob)
if (PEntity->objtype == TYPE_PET || PEntity->objtype == TYPE_MOB && PEntity->PMaster != nullptr && PEntity->PMaster->objtype == TYPE_PC)
{
AddBaseEnmity(PEntity->PMaster);
}
}
}
}
示例2: UpdateEnmity
void CEnmityContainer::UpdateEnmityFromCure(CBattleEntity* PEntity, uint16 level, uint16 CureAmount, bool isCureV)
{
if (isCureV) {
UpdateEnmity(PEntity, 400, 700);
}
else {
CureAmount = (CureAmount < 1 ? 1 : CureAmount);
uint16 mod = battleutils::GetEnmityModCure(level);
uint16 CE = 40. / mod * CureAmount;
uint16 VE = 240. / mod * CureAmount;
// you're too far away so i'm ignoring you
if (!IsWithinEnmityRange(PEntity))
{
CE = 0;
VE = 0;
}
// Crash fix, PEntity was in ACTION_FALL
if (PEntity->PBattleAI->GetCurrentAction() == ACTION_FALL)
return;
EnmityList_t::iterator PEnmity = m_EnmityList.lower_bound(PEntity->id);
// current highest enmity before this update
CBattleEntity* OldEntity = GetHighestEnmity();
if (PEnmity != m_EnmityList.end() &&
!m_EnmityList.key_comp()(PEntity->id, PEnmity->first))
{
float bonus = CalculateEnmityBonus(PEntity);
float tranquilHeartReduction = 1.f - battleutils::HandleTranquilHeart(PEntity);
int newCE = PEnmity->second->CE + (CE * bonus * tranquilHeartReduction);
int newVE = PEnmity->second->VE + (VE * bonus * tranquilHeartReduction);
//Check for cap limit
PEnmity->second->CE = dsp_cap(newCE, 1, 10000);
PEnmity->second->VE = dsp_cap(newVE, 0, 10000);
}
else if (CE >= 0 && VE >= 0)
{
EnmityObject_t* PEnmityObject = new EnmityObject_t;
float bonus = CalculateEnmityBonus(PEntity);
float tranquilHeartReduction = 1.f - battleutils::HandleTranquilHeart(PEntity);
PEnmityObject->CE = dsp_cap(CE * bonus * tranquilHeartReduction, 1, 10000);
PEnmityObject->VE = dsp_cap(VE * bonus * tranquilHeartReduction, 0, 10000);
PEnmityObject->PEnmityOwner = PEntity;
PEnmityObject->maxTH = 0;
m_EnmityList.insert(PEnmity, EnmityList_t::value_type(PEntity->id, PEnmityObject));
}
}
}
示例3: AddAttackSwing
/************************************************************************
* *
* Creates up to many attacks for a particular hand. *
* *
************************************************************************/
void CAttackRound::CreateAttacks(CItemWeapon* PWeapon, PHYSICAL_ATTACK_DIRECTION direction)
{
uint8 num = 1;
// Checking the players weapon hit count
if (PWeapon->getReqLvl() <= m_attacker->GetMLevel())
{
num = PWeapon->getHitCount();
}
AddAttackSwing(ATTACK_NORMAL, direction, num);
// Checking the players triple, double and quadruple attack
int8 tripleAttack = m_attacker->getMod(MOD_TRIPLE_ATTACK);
int8 doubleAttack = m_attacker->getMod(MOD_DOUBLE_ATTACK);
int8 quadAttack = m_attacker->getMod(MOD_QUAD_ATTACK);
//check for merit upgrades
if (m_attacker->objtype == TYPE_PC)
{
CCharEntity* PChar = (CCharEntity*)m_attacker;
//merit chance only applies if player has the job trait
if (charutils::hasTrait(PChar, TRAIT_TRIPLE_ATTACK)) tripleAttack += PChar->PMeritPoints->GetMeritValue(MERIT_TRIPLE_ATTACK_RATE, PChar);
if (charutils::hasTrait(PChar, TRAIT_DOUBLE_ATTACK)) doubleAttack += PChar->PMeritPoints->GetMeritValue(MERIT_DOUBLE_ATTACK_RATE, PChar);
// TODO: Quadruple attack merits when SE release them.
}
quadAttack = dsp_cap(quadAttack,0,100);
doubleAttack = dsp_cap(doubleAttack,0,100);
tripleAttack = dsp_cap(tripleAttack,0,100);
if (num == 1 && rand()%100 < quadAttack)
{
AddAttackSwing(QUAD_ATTACK, direction, 3);
m_quadAttackOccured = true;
}
else if (num == 1 && rand()%100 < tripleAttack)
{
AddAttackSwing(TRIPLE_ATTACK, direction, 2);
m_tripleAttackOccured = true;
}
else if (num == 1 && rand()%100 < doubleAttack && num == 1)
{
AddAttackSwing(DOUBLE_ATTACK, direction, 1);
m_doubleAttackOccured = true;
}
// TODO: Possible Lua function for the nitty gritty stuff below.
// Iga mod: Extra attack chance whilst dual wield is on.
if (direction == LEFTATTACK && rand()%100 < m_attacker->getMod(MOD_EXTRA_DUAL_WIELD_ATTACK))
{
AddAttackSwing(ATTACK_NORMAL, RIGHTATTACK, 1);
}
}
示例4: dsp_cap
uint8 CGuild::addGuildPoints(CCharEntity* PChar, CItem* PItem, int16& pointsAdded)
{
uint8 rank = PChar->RealSkills.rank[m_id + 48];
rank = dsp_cap(rank, 3, 9);
if (PItem)
{
int32 curPoints = charutils::GetVar(PChar, "[GUILD]daily_points");
if (curPoints >= 0)
{
for (auto& GPItem : m_GPItems[rank - 3])
{
if (GPItem.item->getID() == PItem->getID())
{
uint8 quantity = dsp_min(((GPItem.maxpoints - curPoints) / GPItem.points) + 1, PItem->getQuantity());
uint16 points = GPItem.points * quantity;
if (points > GPItem.maxpoints - curPoints)
{
points = GPItem.maxpoints - curPoints;
}
charutils::AddPoints(PChar, pointsName.c_str(), points);
pointsAdded = points;
Sql_Query(SqlHandle, "REPLACE INTO char_vars VALUES (%d, '[GUILD]daily_points', %u);", PChar->id, curPoints + points);
return quantity;
}
}
}
}
return 0;
}
示例5: getMod
void CBattleEntity::UpdateHealth()
{
int32 dif = (getMod(MOD_CONVMPTOHP) - getMod(MOD_CONVHPTOMP));
health.modmp = ((health.maxmp + getMod(MOD_MP)) * (100 + getMod(MOD_MPP)) / 100) + dsp_min((health.maxmp * m_modStat[MOD_FOOD_MPP] / 100), m_modStat[MOD_FOOD_MP_CAP]);
health.modhp = ((health.maxhp + getMod(MOD_HP)) * (100 + getMod(MOD_HPP)) / 100) + dsp_min((health.maxhp * m_modStat[MOD_FOOD_HPP] / 100), m_modStat[MOD_FOOD_HP_CAP]);
dif = (health.modmp - 0) < dif ? (health.modmp - 0) : dif;
dif = (health.modhp - 1) < -dif ? -(health.modhp - 1) : dif;
health.modhp += dif;
health.modmp -= dif;
health.hp = dsp_cap(health.hp, 0, health.modhp);
health.mp = dsp_cap(health.mp, 0, health.modmp);
}
示例6: dsp_cap
int32 CBattleEntity::addHP(int32 hp)
{
if (status == STATUS_NORMAL) status = STATUS_UPDATE;
if (health.hp == 0 && hp < 0){
return 0; //if the entity is already dead, skip the rest to prevent killing it again
}
int32 cap = dsp_cap(health.hp + hp, 0, GetMaxHP());
hp = health.hp - cap;
health.hp = cap;
// если количество жизней достигает нуля, то сущность умирает
if(hp > 0)
{
battleutils::MakeEntityStandUp(this);
}
if (health.hp == 0)
{
if (animation == ANIMATION_CHOCOBO)
{
StatusEffectContainer->DelStatusEffectSilent(EFFECT_CHOCOBO);
}
PBattleAI->SetCurrentAction(ACTION_FALL);
}
return abs(hp);
}
示例7: dsp_cap
/************************************************************************
* *
* Creates kick attacks. *
* *
************************************************************************/
void CAttackRound::CreateKickAttacks()
{
if (m_attacker->objtype == TYPE_PC)
{
// kick attack mod (All jobs)
uint16 kickAttack = m_attacker->getMod(Mod::KICK_ATTACK);
if (m_attacker->GetMJob() == JOB_MNK) // MNK (Main job)
{
kickAttack += ((CCharEntity*)m_attacker)->PMeritPoints->GetMeritValue(MERIT_KICK_ATTACK_RATE, (CCharEntity*)m_attacker);
}
kickAttack = dsp_cap(kickAttack, 0, 100);
if (dsprand::GetRandomNumber(100) < kickAttack)
{
AddAttackSwing(PHYSICAL_ATTACK_TYPE::KICK, RIGHTATTACK, 1);
m_kickAttackOccured = true;
}
// TODO: Possible Lua function for the nitty gritty stuff below.
// Mantra set mod: Try an extra left kick attack.
if (m_kickAttackOccured && dsprand::GetRandomNumber(100) < m_attacker->getMod(Mod::EXTRA_KICK_ATTACK))
{
AddAttackSwing(PHYSICAL_ATTACK_TYPE::KICK, LEFTATTACK, 1);
}
}
}
示例8: ShowWarning
int16 CMagicState::CalculateMPCost(CSpell* PSpell)
{
if(PSpell == NULL)
{
ShowWarning("CMagicState::CalculateMPCost Spell is NULL\n");
return 0;
}
// ninja tools or bard song
if(!PSpell->hasMPCost())
{
return 0;
}
bool applyArts = true;
uint16 base = PSpell->getMPCost();
if (PSpell->getID() == 478 || PSpell->getID() == 502) //Embrava/Kaustra
{
base = m_PEntity->health.maxmp * 0.2;
}
int16 cost = base;
if (PSpell->getSpellGroup() == SPELLGROUP_BLACK)
{
if (PSpell->getAOE() == SPELLAOE_RADIAL_MANI && m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_MANIFESTATION))
{
cost *= 2;
applyArts = false;
}
if (m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_PARSIMONY))
{
cost /= 2;
applyArts = false;
}
else if (applyArts)
{
cost += base * (m_PEntity->getMod(MOD_BLACK_MAGIC_COST)/100.0f);
}
}
else if (PSpell->getSpellGroup() == SPELLGROUP_WHITE)
{
if (PSpell->getAOE() == SPELLAOE_RADIAL_ACCE && m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_ACCESSION))
{
cost *= 2;
applyArts = false;
}
if (m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_PENURY))
{
cost /= 2;
applyArts = false;
}
else if (applyArts)
{
cost += base * (m_PEntity->getMod(MOD_WHITE_MAGIC_COST)/100.0f);
}
}
return dsp_cap(cost, 0, 9999);
}
示例9: GetHighestEnmity
void CEnmityContainer::LowerEnmityByPercent(CBattleEntity* PEntity, uint8 percent, CBattleEntity* HateReceiver)
{
EnmityList_t::iterator PEnmity = m_EnmityList.lower_bound(PEntity->id);
// current highest enmity before this update
CBattleEntity* OldEntity = GetHighestEnmity();
if (PEnmity != m_EnmityList.end() &&
!m_EnmityList.key_comp()(PEntity->id, PEnmity->first))
{
float mod = ((float)(percent) / 100.0f);
int32 CEValue = (float)(PEnmity->second->CE * mod);
PEnmity->second->CE -= (CEValue < 0 ? 0 : CEValue);
int32 VEValue = (float)(PEnmity->second->VE * mod);
PEnmity->second->VE -= (VEValue < 0 ? 0 : VEValue);
// transfer hate if HateReceiver not nullptr
if (HateReceiver != nullptr)
{
UpdateEnmity(HateReceiver, 0, 0);
EnmityList_t::iterator PEnmityReceiver = m_EnmityList.lower_bound(HateReceiver->id);
PEnmityReceiver->second->CE = dsp_cap(PEnmityReceiver->second->CE + CEValue,1,10000);
PEnmityReceiver->second->VE = dsp_cap(PEnmityReceiver->second->VE + VEValue,0,10000);
}
}
// highest enmity holder after this update
CBattleEntity* NewEntity = GetHighestEnmity();
// PEntity is now the target, face the target
if (OldEntity != NewEntity && !m_EnmityHolder->isAsleep())
{
if ((m_EnmityHolder->objtype == TYPE_MOB && !(((CMobEntity*)m_EnmityHolder)->m_Behaviour & BEHAVIOUR_NO_TURN)) || m_EnmityHolder->objtype != TYPE_MOB)
{
uint8 angle = getangle(m_EnmityHolder->loc.p, NewEntity->loc.p);
m_EnmityHolder->loc.p.rotation = angle;
m_EnmityHolder->loc.zone->PushPacket(m_EnmityHolder, CHAR_INRANGE, new CEntityUpdatePacket(m_EnmityHolder, ENTITY_UPDATE, UPDATE_POS));
}
}
}
示例10: dsp_cap
float CEnmityContainer::CalculateEnmityBonus(CBattleEntity* PEntity){
int8 enmityBonus = 0;
if (PEntity->objtype & TYPE_PC)
{
enmityBonus = ((CCharEntity*)PEntity)->PMeritPoints->GetMeritValue(MERIT_ENMITY_INCREASE, (CCharEntity*)PEntity) -
((CCharEntity*)PEntity)->PMeritPoints->GetMeritValue(MERIT_ENMITY_DECREASE, (CCharEntity*)PEntity);
}
float bonus = (100.0f + dsp_cap(PEntity->getMod(Mod::ENMITY) + enmityBonus, -50, 100)) / 100.0f;
return bonus;
}
示例11: dsp_min
void CEnmityContainer::UpdateEnmityFromAttack(CBattleEntity* PEntity, uint16 Damage)
{
if (m_EnmityList.find(PEntity->id) == m_EnmityList.end())
{
return;
}
float reduction = (100.f - dsp_min(PEntity->getMod(Mod::ENMITY_LOSS_REDUCTION), 100)) / 100.0f;
int16 CE = -(1800 * Damage / PEntity->GetMaxHP()) * reduction;
auto enmity_obj = m_EnmityList.find(PEntity->id);
if (enmity_obj != m_EnmityList.end())
{
enmity_obj->second.CE = dsp_cap(enmity_obj->second.CE + CE, 0, 10000);
}
}
示例12: GetTotalSlots
uint8 GetTotalSlots(CCharEntity* PChar)
{
uint8 level = 0;
if (PChar->GetMJob() == JOB_BLU)
{
level = PChar->GetMLevel();
}
else if (PChar->GetSJob() == JOB_BLU)
{
level = PChar->GetSLevel();
}
if (level == 0)
return 0;
else
return dsp_cap(((level - 1)/10)*2 + 6, 6, 20);
}
示例13: WBUFL
CCharStatsPacket::CCharStatsPacket(CCharEntity * PChar)
{
this->type = 0x61;
this->size = 0x30;
WBUFL(data,(0x04)) = PChar->GetMaxHP();
WBUFL(data,(0x08)) = PChar->GetMaxMP();
WBUFB(data,(0x0C)) = PChar->GetMJob();
WBUFB(data,(0x0D)) = PChar->GetMLevel();
WBUFB(data,(0x0E)) = PChar->GetSJob();
WBUFB(data,(0x0F)) = PChar->GetSLevel();
WBUFW(data,(0x10)) = PChar->jobs.exp[PChar->GetMJob()];
WBUFW(data,(0x12)) = charutils::GetExpNEXTLevel(PChar->jobs.job[PChar->GetMJob()]);
memcpy(data+(0x14), &PChar->stats, 14); // TODO: с merits это не прокатит
WBUFW(data,(0x22)) = dsp_cap(PChar->getMod(MOD_STR), -999 + PChar->stats.STR, 999 - PChar->stats.STR);
WBUFW(data,(0x24)) = dsp_cap(PChar->getMod(MOD_DEX), -999 + PChar->stats.DEX, 999 - PChar->stats.DEX);
WBUFW(data,(0x26)) = dsp_cap(PChar->getMod(MOD_VIT), -999 + PChar->stats.VIT, 999 - PChar->stats.VIT);
WBUFW(data,(0x28)) = dsp_cap(PChar->getMod(MOD_AGI), -999 + PChar->stats.AGI, 999 - PChar->stats.AGI);
WBUFW(data,(0x2A)) = dsp_cap(PChar->getMod(MOD_INT), -999 + PChar->stats.INT, 999 - PChar->stats.INT);
WBUFW(data,(0x2C)) = dsp_cap(PChar->getMod(MOD_MND), -999 + PChar->stats.MND, 999 - PChar->stats.MND);
WBUFW(data,(0x2E)) = dsp_cap(PChar->getMod(MOD_CHR), -999 + PChar->stats.CHR, 999 - PChar->stats.CHR);
WBUFW(data,(0x30)) = PChar->ATT();
WBUFW(data,(0x32)) = PChar->DEF();
WBUFW(data,(0x34)) = PChar->getMod(MOD_FIRERES);
WBUFW(data,(0x36)) = PChar->getMod(MOD_ICERES);
WBUFW(data,(0x38)) = PChar->getMod(MOD_WINDRES);
WBUFW(data,(0x3A)) = PChar->getMod(MOD_EARTHRES);
WBUFW(data,(0x3C)) = PChar->getMod(MOD_THUNDERRES);
WBUFW(data,(0x3E)) = PChar->getMod(MOD_WATERRES);
WBUFW(data,(0x40)) = PChar->getMod(MOD_LIGHTRES);
WBUFW(data,(0x42)) = PChar->getMod(MOD_DARKRES);
WBUFW(data,(0x44)) = PChar->profile.title;
WBUFB(data,(0x46)) = PChar->profile.rank[PChar->profile.nation];
WBUFW(data,(0x48)) = PChar->profile.rankpoints;
WBUFW(data,(0x4A)) = PChar->profile.home_point.destination;
WBUFB(data,(0x50)) = PChar->profile.nation;
//0x52 = superior level (1 or 2)
//0x54 = maximum item level
//0x55 = itemlevel over 99
//0x56 = main weapon item level
}
示例14: if
uint16 CBattleEntity::addTP(float tp)
{
float TPMulti = 1.0;
if(objtype == TYPE_PC)
{
TPMulti = map_config.player_tp_multiplier;
}
else if(objtype == TYPE_MOB)
{
TPMulti = map_config.mob_tp_multiplier;
}
else if(objtype == TYPE_PET)
{
TPMulti = map_config.mob_tp_multiplier * 3;
}
float cap = dsp_cap(health.tp + (tp * TPMulti), 0, 300);
tp = health.tp - cap;
health.tp = cap;
return abs(tp);
}
示例15: while
uint32 CTaskMgr::DoTimer(uint32 tick)
{
int32 diff = 1000;
while( !m_TaskList.empty() )
{
CTask * PTask = m_TaskList.top();
diff = PTask->m_tick - tick;
if( diff > 0 ) break; // no more expired timers to process
m_TaskList.pop();
if( PTask->m_func )
{
PTask->m_func(( diff < -1000 ? tick : PTask->m_tick),PTask);
}
switch( PTask->m_type )
{
case TASK_INTERVAL:
{
PTask->m_tick = PTask->m_interval + (diff < - 1000 ? tick : PTask->m_tick);
m_TaskList.push(PTask);
}
break;
case TASK_ONCE:
case TASK_REMOVE:
default:
{
delete PTask; // suppose that all tasks were allocated by new
}
break;
}
diff = dsp_cap(diff, 50, 1000);
}
return diff;
}