bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) { m_Core.m_Vel += Force; if(GameServer()->m_pController->IsFriendlyFire(m_pPlayer->GetCID(), From)) return false; // m_pPlayer only inflicts half damage on self if(From == m_pPlayer->GetCID()) Dmg = max(1, Dmg/2); m_DamageTaken++; // create healthmod indicator if(Server()->Tick() < m_DamageTakenTick+25) { // make sure that the damage indicators doesn't group together GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg); } else { m_DamageTaken = 0; GameServer()->CreateDamageInd(m_Pos, 0, Dmg); } if(Dmg) { if(m_Armor) { if(Dmg > 1) { m_Health--; Dmg--; } if(Dmg > m_Armor) { Dmg -= m_Armor; m_Armor = 0; } else { m_Armor -= Dmg; Dmg = 0; } } m_Health -= Dmg; } m_DamageTakenTick = Server()->Tick(); // do damage Hit sound if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) { int Mask = CmaskOne(From); for(int i = 0; i < MAX_CLIENTS; i++) { if(GameServer()->m_apPlayers[i] && (GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS || GameServer()->m_apPlayers[i]->m_DeadSpecMode) && GameServer()->m_apPlayers[i]->GetSpectatorID() == From) Mask |= CmaskOne(i); } GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, Mask); } // check for death if(m_Health <= 0) { Die(From, Weapon); // set attacker's face to happy (taunt!) if (From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) { CCharacter *pChr = GameServer()->m_apPlayers[From]->GetCharacter(); if (pChr) { pChr->m_EmoteType = EMOTE_HAPPY; pChr->m_EmoteStop = Server()->Tick() + Server()->TickSpeed(); } } return false; } if (Dmg > 2) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG); else GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_SHORT); m_EmoteType = EMOTE_PAIN; m_EmoteStop = Server()->Tick() + 500 * Server()->TickSpeed() / 1000; return true; }
void CGameControllerSoloFNG::DoInteractions() { DoHookers(); for(int i = 0; i < MAX_CLIENTS; i++) { CCharacter *pChr = CHAR(i); if (!pChr) continue; int FrzTicks = pChr->GetFreezeTicks(); int Col = GameServer()->Collision()->GetCollisionAt(pChr->m_Pos.x, pChr->m_Pos.y); if (Col == TILE_SHRINE_ALL || Col == TILE_SHRINE_RED || Col == TILE_SHRINE_BLUE) { if (FrzTicks > 0 && m_aLastInteraction[i] < 0) pChr->Freeze(FrzTicks = 0); bool WasSacrificed = false; if (FrzTicks > 0) { int ShrineTeam = Col == TILE_SHRINE_RED ? TEAM_RED : Col == TILE_SHRINE_BLUE ? TEAM_BLUE : -1; HandleSacr(m_aLastInteraction[i], i, ShrineTeam); WasSacrificed = true; } pChr->Die(pChr->GetPlayer()->GetCID(), WEAPON_WORLD, WasSacrificed); } if (FrzTicks > 0) { if ((FrzTicks+1) % TS == 0) { if (pChr->GetPlayer()->GetTeam() != -1) GS->CreateDamageInd(pChr->m_Pos, 0, (FrzTicks+1) / TS, CmaskOne(pChr->GetPlayer()->GetCID())); else GS->CreateDamageInd(pChr->m_Pos, 0, (FrzTicks+1) / TS, m_aCltMask[pChr->GetPlayer()->GetTeam()&1]); if (g_Config.m_SvTickSound == 1) GS->CreateSound(GS->m_apPlayers[i]->m_ViewPos, SOUND_WEAPON_NOAMMO, CmaskOne(i)); if (g_Config.m_SvTickSound == 2) GS->CreateSound(pChr->m_Pos, SOUND_WEAPON_NOAMMO); } if (FrzTicks == 1 && CFG(MeltSafeticks)) pChr->SetEmote(EMOTE_SURPRISE, TICK + CFG(MeltSafeticks) + 1); m_aMoltenBy[i] = -1; if (m_aFrozenBy[i] != -1) continue; int Killer = pChr->WasFrozenBy(); if (Killer < 0) //may happen then the gods are not pleased { m_aFrozenBy[i] = -1; continue; } m_aFrozenBy[i] = Killer; HandleFreeze(Killer, i); } else { m_aFrozenBy[i] = -1; /* int Melter = pChr->WasMoltenBy(); if (Melter < 0) m_aMoltenBy[i] = -1; if (Melter == m_aMoltenBy[i]) continue; m_aMoltenBy[i] = Melter; HandleMelt(Melter, i); */ } } }
bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) { m_Core.m_Vel += Force; /* INFECTION MODIFICATION START ***************************************/ CPlayer* pKillerPlayer = GameServer()->m_apPlayers[From]; if(pKillerPlayer && pKillerPlayer->IsInfected() == IsInfected() && From != m_pPlayer->GetCID()) return false; /* INFECTION MODIFICATION END *****************************************/ // m_pPlayer only inflicts half damage on self if(From == m_pPlayer->GetCID()) Dmg = max(1, Dmg/2); m_DamageTaken++; // create healthmod indicator if(Server()->Tick() < m_DamageTakenTick+25) { // make sure that the damage indicators doesn't group together GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg); } else { m_DamageTaken = 0; GameServer()->CreateDamageInd(m_Pos, 0, Dmg); } if(Dmg) { if(m_Armor) { if(Dmg > 1) { m_Health--; Dmg--; } if(Dmg > m_Armor) { Dmg -= m_Armor; m_Armor = 0; } else { m_Armor -= Dmg; Dmg = 0; } } m_Health -= Dmg; } m_DamageTakenTick = Server()->Tick(); // do damage Hit sound if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) { int Mask = CmaskOne(From); for(int i = 0; i < MAX_CLIENTS; i++) { if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS && GameServer()->m_apPlayers[i]->m_SpectatorID == From) Mask |= CmaskOne(i); } GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, Mask); } /* INFECTION MODIFICATION START ***************************************/ if(GameServer()->m_apPlayers[From]->IsInfected() && !IsInfected()) { if(!(GameServer()->m_apPlayers[From]->GetClass() == PLAYERCLASS_ZOMBIE && Weapon == WEAPON_NINJA)) { m_pPlayer->StartInfection(); CNetMsg_Sv_KillMsg Msg; Msg.m_Killer = From; Msg.m_Victim = m_pPlayer->GetCID(); Msg.m_Weapon = WEAPON_HAMMER; Msg.m_ModeSpecial = 0; Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); } } /* INFECTION MODIFICATION END *****************************************/ // check for death if(m_Health <= 0) { Die(From, Weapon); // set attacker's face to happy (taunt!) if (From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) { CCharacter *pChr = GameServer()->m_apPlayers[From]->GetCharacter(); if (pChr) { pChr->m_EmoteType = EMOTE_HAPPY; pChr->m_EmoteStop = Server()->Tick() + Server()->TickSpeed(); } } return false; } if (Dmg > 2) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG); else GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_SHORT); m_EmoteType = EMOTE_PAIN; m_EmoteStop = Server()->Tick() + 500 * Server()->TickSpeed() / 1000; return true; }
//Moon notes //Change here for taking damage event bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) { //modControl is a binary number like 1111 //4th num for FORCE check //3th num for EMOTION check //2th num for SOUND check //1th num for DAMAGE check modDamageTakenAction mta; for(std::set<mod *>::iterator i = modLoaderGetter::modloader_main->modList.begin(); i != modLoaderGetter::modloader_main->modList.end(); i++){ modDamageTakenAction c = (*i)->OnDamageTaken(Force, Dmg, From, Weapon, this); if(!c.do_sound){ mta.do_sound = false; } if(!c.do_emotion){ mta.do_emotion = false; } if(!c.do_force){ mta.do_force = false; } if(!c.do_damage){ mta.do_damage = false; } } // for (unsigned int i = 0; i < (*modloader_main).modList.size(); ++i) { // modControl = modControl || (*modloader_main).modList.at(i)->OnDamageTaken(Force, Dmg, From, Weapon, this); // } if(mta.do_force) { m_Core.m_Vel += Force; } if(GameServer()->m_pController->IsFriendlyFire(m_pPlayer->GetCID(), From) && !g_Config.m_SvTeamdamage) return false; // m_pPlayer only inflicts half damage on self if(From == m_pPlayer->GetCID()) Dmg = max(1, Dmg/2); m_DamageTaken++; // create healthmod indicator if(Server()->Tick() < m_DamageTakenTick+25) { // make sure that the damage indicators doesn't group together GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg); } else { m_DamageTaken = 0; GameServer()->CreateDamageInd(m_Pos, 0, Dmg); } if(Dmg && mta.do_damage) { if(m_Armor) { if(Dmg > 1) { m_Health--; Dmg--; } if(Dmg > m_Armor) { Dmg -= m_Armor; m_Armor = 0; } else { m_Armor -= Dmg; Dmg = 0; } } m_Health -= Dmg; } m_DamageTakenTick = Server()->Tick(); // do damage Hit sound if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From] ) { int Mask = CmaskOne(From); for(int i = 0; i < MAX_CLIENTS; i++) { if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS && GameServer()->m_apPlayers[i]->m_SpectatorID == From) Mask |= CmaskOne(i); } GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, Mask); } // check for death if(m_Health <= 0) { Die(From, Weapon); // set attacker's face to happy (taunt!) if (From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) { CCharacter *pChr = GameServer()->m_apPlayers[From]->GetCharacter(); if (pChr) { pChr->m_EmoteType = EMOTE_HAPPY; pChr->m_EmoteStop = Server()->Tick() + Server()->TickSpeed(); } } return false; } if(mta.do_sound) { if (Dmg > 2) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG); else GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_SHORT); } if(mta.do_emotion) { m_EmoteType = EMOTE_PAIN; m_EmoteStop = Server()->Tick() + 500 * Server()->TickSpeed() / 1000; } return true; }