本文整理汇总了C++中CCharacter::IncreaseHealth方法的典型用法代码示例。如果您正苦于以下问题:C++ CCharacter::IncreaseHealth方法的具体用法?C++ CCharacter::IncreaseHealth怎么用?C++ CCharacter::IncreaseHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCharacter
的用法示例。
在下文中一共展示了CCharacter::IncreaseHealth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Tick
void CPickup::Tick()
{
// wait for respawn
if(m_SpawnTick > 0)
{
if(Server()->Tick() > m_SpawnTick)
{
// respawn
m_SpawnTick = -1;
if(m_Type == POWERUP_WEAPON)
GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SPAWN);
}
else
return;
}
// Check if a player intersected us
CCharacter *pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
if(pChr && pChr->IsAlive())
{
// player picked us up, is someone was hooking us, let them go
int RespawnTime = -1;
switch (m_Type)
{
case POWERUP_HEALTH:
if(pChr->IncreaseHealth(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
}
break;
case POWERUP_ARMOR:
if(pChr->IncreaseArmor(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
}
break;
case POWERUP_WEAPON:
if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS)
{
if(pChr->GiveWeapon(m_Subtype, 10))
{
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
else if(m_Subtype == WEAPON_SHOTGUN)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
else if(m_Subtype == WEAPON_RIFLE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
if(pChr->GetPlayer())
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
}
}
break;
case POWERUP_NINJA:
{
// activate ninja on target player
pChr->GiveNinja();
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
// loop through all players, setting their emotes
CCharacter *pC = static_cast<CCharacter *>(GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER));
for(; pC; pC = (CCharacter *)pC->TypeNext())
{
if (pC != pChr)
pC->SetEmote(EMOTE_SURPRISE, Server()->Tick() + Server()->TickSpeed());
}
pChr->SetEmote(EMOTE_ANGRY, Server()->Tick() + 1200 * Server()->TickSpeed() / 1000);
break;
}
default:
break;
};
if(RespawnTime >= 0)
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "pickup player='%d:%s' item=%d/%d",
pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime;
}
}
}
示例2: Tick
//.........这里部分代码省略.........
GameWorld()->DestroyEntity(this);
return;
}
}
else
{
if(pChr->GiveWeapon(m_Subtype, m_Amount))
{
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
else if(m_Subtype == WEAPON_SHOTGUN)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
else if(m_Subtype == WEAPON_RIFLE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
if(pChr->GetPlayer())
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
}
}
break;
case POWERUP_BLOCK:
if (pChr->GiveBlock(m_Subtype, 1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_BLOCK);
GameWorld()->DestroyEntity(this);
return;
}
break;
case POWERUP_FOOD:
if (m_Subtype == FOOD_COW)
{
if (pChr->IncreaseHealth(2) || pChr->IncreaseArmor(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
GameWorld()->DestroyEntity(this);
return;
}
}
else if (m_Subtype == FOOD_PIG)
{
if (pChr->IncreaseHealth(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
GameWorld()->DestroyEntity(this);
return;
}
}
break;
//
case POWERUP_HEALTH:
if(pChr->IncreaseHealth(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
}
break;
case POWERUP_ARMOR:
if(pChr->IncreaseArmor(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
}
示例3: Tick
//.........这里部分代码省略.........
bool Grounded = false;
if(GameServer()->Collision()->CheckPoint(m_Pos.x+12, m_Pos.y+12+5))
Grounded = true;
if(GameServer()->Collision()->CheckPoint(m_Pos.x-12, m_Pos.y+12+5))
Grounded = true;
int OnForceTile = GameServer()->Collision()->IsForceTile(m_Pos.x-12, m_Pos.y+12+5);
if (OnForceTile == 0)
OnForceTile = GameServer()->Collision()->IsForceTile(m_Pos.x+12, m_Pos.y+12+5);
if (Grounded)
m_Vel.x = (m_Vel.x + OnForceTile) * 0.8f;
//m_Vel.x *= 0.8f;
else
m_Vel.x *= 0.99f;
//if (OnForceTile == -1)
// m_Vel.x -= 0.3f;
GameServer()->Collision()->MoveBox(&m_Pos, &m_Vel, vec2(24.0f, 24.0f), 0.4f);
}
// Check if a player intersected us
CCharacter *pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
if(pChr && pChr->IsAlive() && pChr->m_SkipPickups <= 0 && (!g_Config.m_SvBotsSkipPickups || !pChr->GetPlayer()->m_IsBot)) // && !pChr->GetPlayer()->m_pAI)
{
// player picked us up, is someone was hooking us, let them go
int RespawnTime = -1;
switch (m_Type)
{
case POWERUP_HEALTH:
if(pChr->IncreaseHealth(10))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
break;
case POWERUP_ARMOR:
if(pChr->IncreaseArmor(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
break;
case POWERUP_MINE:
if(pChr->AddMine())
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
break;
case POWERUP_KIT:
if(pChr->AddKit())
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
示例4: Tick
//.........这里部分代码省略.........
CCharacter *pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
if(pChr && pChr->IsAlive()) // && !pChr->GetPlayer()->m_pAI)
{
// player picked us up, is someone was hooking us, let them go
int RespawnTime = -1;
switch (m_Type)
{
case POWERUP_HEALTH:
if (m_Subtype > 0 && m_Owner >= 0 && m_Owner < MAX_CLIENTS && GameServer()->m_apPlayers[m_Owner])
{
int Team = GameServer()->m_apPlayers[m_Owner]->GetTeam();
if (Team != pChr->GetPlayer()->GetTeam())
{
if (m_Subtype == 1)
GameServer()->CreateExplosion(m_Pos, m_Owner, WEAPON_HAMMER, false, false);
if (m_Subtype == 2)
{
CSuperexplosion *S = new CSuperexplosion(&GameServer()->m_World, m_Pos, m_Owner, WEAPON_HAMMER, 1);
GameServer()->m_World.InsertEntity(S);
}
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
m_Subtype = 0;
break;
}
}
if(pChr->IncreaseHealth(10))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
else
if (pChr->GetPlayer()->GotAbility(STORE_HEALTH) && pChr->StoreHealth())
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
break;
case POWERUP_ARMOR:
if(pChr->IncreaseArmor(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
break;
case POWERUP_WEAPON:
if(m_Subtype >= 0 && m_Subtype < NUM_CUSTOMWEAPONS)
{
int Parent = aCustomWeapon[m_Subtype].m_ParentWeapon;
if (Parent < 0 || Parent >= NUM_WEAPONS)
示例5: Tick
void CPickup::Tick()
{
// wait for respawn
if(m_SpawnTick > 0)
{
if(Server()->Tick() > m_SpawnTick)
{
// respawn
m_SpawnTick = -1;
if(m_Type == POWERUP_WEAPON)
GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SPAWN);
}
else
return;
}
// Check if a player intersected us
CCharacter *pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
if(pChr && pChr->IsAlive())
{
// player picked us up, is someone was hooking us, let them go
int RespawnTime = -1;
switch (m_Type)
{
case POWERUP_HEALTH:
if(pChr->IncreaseHealth(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
}
break;
case POWERUP_ARMOR:
if(pChr->IncreaseArmor(1))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
}
break;
case POWERUP_WEAPON:
if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS)
{
if(pChr->GiveWeapon(m_Subtype, 10))
{
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
else if(m_Subtype == WEAPON_SHOTGUN)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
else if(m_Subtype == WEAPON_RIFLE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
if(pChr->GetPlayer())
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
}
}
break;
case POWERUP_NINJA:
{
// activate ninja on target player
pChr->GiveNinja();
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
// loop through all players, setting their emotes
CEntity *apEnts[64];
int Num = GameServer()->m_World.FindEntities(vec2(0, 0), 1000000, apEnts, 64, NETOBJTYPE_CHARACTER);
for (int i = 0; i < Num; ++i)
{
CCharacter *pC = static_cast<CCharacter *>(apEnts[i]);
if (pC != pChr)
pC->SetEmote(EMOTE_SURPRISE, Server()->Tick() + Server()->TickSpeed());
}
pChr->SetEmote(EMOTE_ANGRY, Server()->Tick() + 1200 * Server()->TickSpeed() / 1000);
break;
}
default:
break;
};
if(RespawnTime >= 0)
{
dbg_msg("game", "pickup player='%d:%s' item=%d/%d",
pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype);
m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime;
}
}
}
示例6: FireWeapon
//.........这里部分代码省略.........
{
/* INFECTION MODIFICATION END *****************************************/
// reset objects Hit
m_NumObjectsHit = 0;
GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE);
CCharacter *apEnts[MAX_CLIENTS];
int Hits = 0;
int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)apEnts,
MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
for (int i = 0; i < Num; ++i)
{
CCharacter *pTarget = apEnts[i];
if ((pTarget == this) || GameServer()->Collision()->IntersectLine(ProjStartPos, pTarget->m_Pos, NULL, NULL))
continue;
// set his velocity to fast upward (for now)
if(length(pTarget->m_Pos-ProjStartPos) > 0.0f)
GameServer()->CreateHammerHit(pTarget->m_Pos-normalize(pTarget->m_Pos-ProjStartPos)*m_ProximityRadius*0.5f);
else
GameServer()->CreateHammerHit(ProjStartPos);
vec2 Dir;
if (length(pTarget->m_Pos - m_Pos) > 0.0f)
Dir = normalize(pTarget->m_Pos - m_Pos);
else
Dir = vec2(0.f, -1.f);
/* INFECTION MODIFICATION START ***************************************/
if(IsInfected() && pTarget->IsInfected())
{
pTarget->IncreaseHealth(2);
pTarget->IncreaseArmor(2);
}
else
{
pTarget->TakeDamage(vec2(0.f, -1.f) + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage,
m_pPlayer->GetCID(), m_ActiveWeapon);
}
/* INFECTION MODIFICATION END *****************************************/
Hits++;
}
// if we Hit anything, we have to wait for the reload
if(Hits)
m_ReloadTimer = Server()->TickSpeed()/3;
/* INFECTION MODIFICATION START ***************************************/
}
/* INFECTION MODIFICATION END *****************************************/
} break;
case WEAPON_GUN:
{
CProjectile *pProj = new CProjectile(GameWorld(), WEAPON_GUN,
m_pPlayer->GetCID(),
ProjStartPos,
Direction,
(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime),
1, 0, 0, -1, WEAPON_GUN);
// pack the Projectile and send it to the client Directly
CNetObj_Projectile p;
示例7: Tick
//.........这里部分代码省略.........
m_Decay = 30;
int shotspread = 2;
for(int i = -shotspread; i <= shotspread; i++)
{
float spreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
float a = m_Angle;
a += spreading[i+2];
float v = 1-(abs(i)/(float)shotspread);
float speed = mix((float)tuning.shotgun_speeddiff, 1.0f, v);
CProjectile *pProj = new CProjectile(WEAPON_SHOTGUN,
-2,
realpos,
vec2(cosf(a), sinf(a))*speed,
(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_ShotgunLifetime),
1, 0, 0, -1, WEAPON_SHOTGUN, false);
}
game.create_sound(realpos, SOUND_SHOTGUN_FIRE);
}
}
} break;
case B_HEALTH: case B_ARMOR: {
CCharacter *c = GetNearest(ms_PhysSize, m_Team);
if(c) {
if(m_Decay == 0) { //wait for open first
if(m_AnimDecay == 0 && m_Decay == 0 && m_Anim < 4) {
m_AnimDecay = 3;
m_Anim++;
}
else if(m_AnimDecay == 0) {
if(m_Type == B_HEALTH && c->m_Health < 10) {
m_Decay = 150;
c->IncreaseHealth(3);
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
c->m_Ill = false;
} else if(m_Type == B_HEALTH) {
c->m_Ill = false;
} else if(m_Type == B_ARMOR && c->m_Armor < 10) {
m_Decay = 150;
c->IncreaseArmor(3);
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
}
}
}
}
else {
if(m_AnimDecay == 0 && m_Decay == 0 && m_Anim > 0) {
m_AnimDecay = 3;
m_Anim--;
}
}
} break;
case B_SHIELD: {
if(Server()->Tick() % 50 == 0 && m_Power) {
if(m_Armor < 30)
m_Armor++;
//game.create_damageind(pos, 3.141592, armor > 0 ? (int)(10.0f*armor/30) : 0);
}
if(Server()->Tick() % 5 == 0) {
if(m_Hit > 0)
m_Hit--;
if(m_Power && m_Armor > 0) {
CProjectile *pProj[128];