mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Merge branch 'master' of https://github.com/teeworlds/teeworlds
This commit is contained in:
commit
9b6db9b26c
|
@ -231,8 +231,12 @@ Objects = [
|
|||
NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'),
|
||||
]),
|
||||
|
||||
NetEvent("DamageInd:Common", [
|
||||
NetEvent("Damage:Common", [ # Unused yet
|
||||
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
|
||||
NetIntAny("m_Angle"),
|
||||
NetIntRange("m_HealthAmount", 1, 9),
|
||||
NetIntRange("m_ArmorAmount", 1, 9),
|
||||
NetBool("m_Self"),
|
||||
]),
|
||||
]
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ void CBroadcast::RenderServerBroadcast()
|
|||
if(m_aSrvBroadcastMsg[0] == 0 || DeltaTime > DisplayDuration)
|
||||
return;
|
||||
|
||||
if(m_pClient->m_pChat->IsActive())
|
||||
return;
|
||||
if(m_pClient->m_pChat->IsActive() || m_pClient->Client()->State() != IClient::STATE_ONLINE)
|
||||
return;
|
||||
|
||||
const float Fade = 1.0f - max(0.0f, (DeltaTime - DisplayStartFade) / (DisplayDuration - DisplayStartFade));
|
||||
|
||||
|
@ -251,6 +251,7 @@ void CBroadcast::DoBroadcast(const char *pText)
|
|||
void CBroadcast::OnReset()
|
||||
{
|
||||
m_BroadcastTime = 0;
|
||||
m_SrvBroadcastReceivedTime = 0;
|
||||
}
|
||||
|
||||
void CBroadcast::OnMessage(int MsgType, void* pRawMsg)
|
||||
|
@ -409,12 +410,15 @@ void CBroadcast::OnMessage(int MsgType, void* pRawMsg)
|
|||
|
||||
void CBroadcast::OnRender()
|
||||
{
|
||||
// server broadcast
|
||||
RenderServerBroadcast();
|
||||
|
||||
// client broadcast
|
||||
if(m_pClient->m_pScoreboard->Active() || m_pClient->m_pMotd->IsActive())
|
||||
return;
|
||||
|
||||
Graphics()->MapScreen(0, 0, 300*Graphics()->ScreenAspect(), 300);
|
||||
|
||||
// client broadcast
|
||||
if(Client()->LocalTime() < m_BroadcastTime)
|
||||
{
|
||||
CTextCursor Cursor;
|
||||
|
@ -422,8 +426,5 @@ void CBroadcast::OnRender()
|
|||
Cursor.m_LineWidth = 300*Graphics()->ScreenAspect()-m_BroadcastRenderOffset;
|
||||
TextRender()->TextEx(&Cursor, m_aBroadcastText, -1);
|
||||
}
|
||||
|
||||
// server broadcast
|
||||
RenderServerBroadcast();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ CEffects::CEffects()
|
|||
{
|
||||
m_Add50hz = false;
|
||||
m_Add100hz = false;
|
||||
m_DamageTaken = 0;
|
||||
m_DamageTakenTick = 0;
|
||||
}
|
||||
|
||||
void CEffects::AirJump(vec2 Pos)
|
||||
|
@ -47,9 +49,32 @@ void CEffects::AirJump(vec2 Pos)
|
|||
m_pClient->m_pSounds->PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_AIRJUMP, 1.0f, Pos);
|
||||
}
|
||||
|
||||
void CEffects::DamageIndicator(vec2 Pos, vec2 Dir)
|
||||
void CEffects::DamageIndicator(vec2 Pos, int Amount)
|
||||
{
|
||||
m_pClient->m_pDamageind->Create(Pos, Dir);
|
||||
m_DamageTaken++;
|
||||
int Angle;
|
||||
// create healthmod indicator
|
||||
if(Client()->LocalTime() < m_DamageTakenTick+0.5f)
|
||||
{
|
||||
// make sure that the damage indicators don't group together
|
||||
Angle = m_DamageTaken*0.25f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_DamageTaken = 0;
|
||||
Angle = 0;
|
||||
}
|
||||
|
||||
float a = 3*pi/2 + Angle;
|
||||
float s = a-pi/3;
|
||||
float e = a+pi/3;
|
||||
for(int i = 0; i < Amount; i++)
|
||||
{
|
||||
float f = mix(s, e, float(i+1)/float(Amount+2));
|
||||
m_pClient->m_pDamageind->Create(vec2(Pos.x, Pos.y), direction(f));
|
||||
}
|
||||
|
||||
m_DamageTakenTick = Client()->LocalTime();
|
||||
}
|
||||
|
||||
void CEffects::PowerupShine(vec2 Pos, vec2 size)
|
||||
|
|
|
@ -8,6 +8,9 @@ class CEffects : public CComponent
|
|||
{
|
||||
bool m_Add50hz;
|
||||
bool m_Add100hz;
|
||||
|
||||
int m_DamageTaken;
|
||||
float m_DamageTakenTick;
|
||||
public:
|
||||
CEffects();
|
||||
|
||||
|
@ -19,7 +22,7 @@ public:
|
|||
void Explosion(vec2 Pos);
|
||||
void HammerHit(vec2 Pos);
|
||||
void AirJump(vec2 Pos);
|
||||
void DamageIndicator(vec2 Pos, vec2 Dir);
|
||||
void DamageIndicator(vec2 Pos, int Amount);
|
||||
void PlayerSpawn(vec2 Pos);
|
||||
void PlayerDeath(vec2 Pos, int ClientID);
|
||||
void PowerupShine(vec2 Pos, vec2 Size);
|
||||
|
|
|
@ -820,10 +820,10 @@ void CGameClient::ProcessEvents()
|
|||
IClient::CSnapItem Item;
|
||||
const void *pData = Client()->SnapGetItem(SnapType, Index, &Item);
|
||||
|
||||
if(Item.m_Type == NETEVENTTYPE_DAMAGEIND)
|
||||
if(Item.m_Type == NETEVENTTYPE_DAMAGE)
|
||||
{
|
||||
CNetEvent_DamageInd *ev = (CNetEvent_DamageInd *)pData;
|
||||
m_pEffects->DamageIndicator(vec2(ev->m_X, ev->m_Y), direction(ev->m_Angle/256.0f));
|
||||
CNetEvent_Damage *ev = (CNetEvent_Damage *)pData;
|
||||
m_pEffects->DamageIndicator(vec2(ev->m_X, ev->m_Y), ev->m_HealthAmount + ev->m_ArmorAmount);
|
||||
}
|
||||
else if(Item.m_Type == NETEVENTTYPE_EXPLOSION)
|
||||
{
|
||||
|
|
|
@ -4538,8 +4538,8 @@ void CEditor::Init()
|
|||
#endif
|
||||
}
|
||||
|
||||
static char *s_aMaps[] = {"ctf1", "ctf2", "ctf3", "ctf4", "ctf5", "ctf6", "ctf7", "ctf8", "dm1", "dm2", "dm3", "dm6", "dm7", "dm8", "dm9", "lms1"};
|
||||
static char *s_aImageName[] = { "grass_doodads", "winter_main" };
|
||||
static const char *s_aMaps[] = {"ctf1", "ctf2", "ctf3", "ctf4", "ctf5", "ctf6", "ctf7", "ctf8", "dm1", "dm2", "dm3", "dm6", "dm7", "dm8", "dm9", "lms1"};
|
||||
static const char *s_aImageName[] = { "grass_doodads", "winter_main" };
|
||||
|
||||
static int s_GrassDoodadsIndicesOld[] = { 42, 43, 44, 58, 59, 60, 74, 75, 76, 132, 133, 148, 149, 163, 164, 165, 169, 170, 185, 186 };
|
||||
static int s_GrassDoodadsIndicesNew[] = { 217, 218, 219, 233, 234, 235, 249, 250, 251, 182, 183, 198, 199, 213, 214, 215, 184, 185, 200, 201 };
|
||||
|
@ -4551,7 +4551,7 @@ void CEditor::ConMapMagic(IConsole::IResult *pResult, void *pUserData)
|
|||
CEditor *pSelf = static_cast<CEditor *>(pUserData);
|
||||
int Flag = pResult->GetInteger(0);
|
||||
|
||||
for(int m = 0; m < sizeof(s_aMaps) / sizeof(s_aMaps[0]); ++m)
|
||||
for(unsigned m = 0; m < sizeof(s_aMaps) / sizeof(s_aMaps[0]); ++m)
|
||||
{
|
||||
char aBuf[64] = { 0 };
|
||||
str_format(aBuf, sizeof(aBuf), "maps/%s.map", s_aMaps[m]);
|
||||
|
@ -4562,7 +4562,7 @@ void CEditor::ConMapMagic(IConsole::IResult *pResult, void *pUserData)
|
|||
// find image
|
||||
for(int i = 0; i < pSelf->m_Map.m_lImages.size(); ++i)
|
||||
{
|
||||
for(int SrcIndex = 0; SrcIndex < sizeof(s_aImageName) / sizeof(s_aImageName[0]); ++SrcIndex)
|
||||
for(unsigned SrcIndex = 0; SrcIndex < sizeof(s_aImageName) / sizeof(s_aImageName[0]); ++SrcIndex)
|
||||
{
|
||||
if(((1 << SrcIndex)&Flag) && !str_comp(pSelf->m_Map.m_lImages[i]->m_aName, s_aImageName[SrcIndex]))
|
||||
{
|
||||
|
@ -4597,7 +4597,7 @@ void CEditor::DoMapMagic(int ImageID, int SrcIndex)
|
|||
{
|
||||
if(SrcIndex == 0) // grass_doodads
|
||||
{
|
||||
for(int TileIndex = 0; TileIndex < sizeof(s_GrassDoodadsIndicesOld) / sizeof(s_GrassDoodadsIndicesOld[0]); ++TileIndex)
|
||||
for(unsigned TileIndex = 0; TileIndex < sizeof(s_GrassDoodadsIndicesOld) / sizeof(s_GrassDoodadsIndicesOld[0]); ++TileIndex)
|
||||
{
|
||||
if(pLayer->m_pTiles[Count].m_Index == s_GrassDoodadsIndicesOld[TileIndex])
|
||||
{
|
||||
|
@ -4608,7 +4608,7 @@ void CEditor::DoMapMagic(int ImageID, int SrcIndex)
|
|||
}
|
||||
else if(SrcIndex == 1) // winter_main
|
||||
{
|
||||
for(int TileIndex = 0; TileIndex < sizeof(s_WinterMainIndicesOld) / sizeof(s_WinterMainIndicesOld[0]); ++TileIndex)
|
||||
for(unsigned TileIndex = 0; TileIndex < sizeof(s_WinterMainIndicesOld) / sizeof(s_WinterMainIndicesOld[0]); ++TileIndex)
|
||||
{
|
||||
if(pLayer->m_pTiles[Count].m_Index == s_WinterMainIndicesOld[TileIndex])
|
||||
{
|
||||
|
@ -4654,7 +4654,7 @@ void CEditor::UpdateAndRender()
|
|||
UI()->StartCheck();
|
||||
|
||||
// handle mouse movement
|
||||
float mx, my, Mwx, Mwy;
|
||||
float mx, my, Mwx, Mwy, Mdx, Mdy;
|
||||
float rx = 0.0f, ry = 0.0f;
|
||||
{
|
||||
Input()->MouseRelative(&rx, &ry);
|
||||
|
@ -4674,6 +4674,8 @@ void CEditor::UpdateAndRender()
|
|||
// update the ui
|
||||
mx = (s_MouseX/(float)Graphics()->ScreenWidth())*UI()->Screen()->w;
|
||||
my = (s_MouseY/(float)Graphics()->ScreenHeight())*UI()->Screen()->h;
|
||||
Mdx = (m_MouseDeltaX/(float)Graphics()->ScreenWidth())*UI()->Screen()->w;
|
||||
Mdy = (m_MouseDeltaY/(float)Graphics()->ScreenHeight())*UI()->Screen()->h;
|
||||
Mwx = 0;
|
||||
Mwy = 0;
|
||||
|
||||
|
@ -4689,8 +4691,8 @@ void CEditor::UpdateAndRender()
|
|||
|
||||
Mwx = aPoints[0] + WorldWidth * (mx/UI()->Screen()->w);
|
||||
Mwy = aPoints[1] + WorldHeight * (my/UI()->Screen()->h);
|
||||
m_MouseDeltaWx = m_MouseDeltaX*(WorldWidth / UI()->Screen()->w);
|
||||
m_MouseDeltaWy = m_MouseDeltaY*(WorldHeight / UI()->Screen()->h);
|
||||
m_MouseDeltaWx = Mdx*(WorldWidth / UI()->Screen()->w);
|
||||
m_MouseDeltaWy = Mdy*(WorldHeight / UI()->Screen()->h);
|
||||
}
|
||||
|
||||
int Buttons = 0;
|
||||
|
|
|
@ -187,7 +187,7 @@ void CCharacter::HandleNinja()
|
|||
if(m_NumObjectsHit < 10)
|
||||
m_apHitObjects[m_NumObjectsHit++] = aEnts[i];
|
||||
|
||||
aEnts[i]->TakeDamage(vec2(0, -10.0f), g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA);
|
||||
aEnts[i]->TakeDamage(vec2(0, -10.0f), m_Ninja.m_ActivationDir*-1, g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ void CCharacter::FireWeapon()
|
|||
else
|
||||
Dir = vec2(0.f, -1.f);
|
||||
|
||||
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,
|
||||
pTarget->TakeDamage(vec2(0.f, -1.f) + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f, Dir*-1, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage,
|
||||
m_pPlayer->GetCID(), m_ActiveWeapon);
|
||||
Hits++;
|
||||
}
|
||||
|
@ -620,7 +620,6 @@ void CCharacter::TickDefered()
|
|||
void CCharacter::TickPaused()
|
||||
{
|
||||
++m_AttackTick;
|
||||
++m_DamageTakenTick;
|
||||
++m_Ninja.m_ActivationTick;
|
||||
++m_ReckoningTick;
|
||||
if(m_LastAction != -1)
|
||||
|
@ -679,7 +678,7 @@ void CCharacter::Die(int Killer, int Weapon)
|
|||
GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID());
|
||||
}
|
||||
|
||||
bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
|
||||
bool CCharacter::TakeDamage(vec2 Force, vec2 Source, int Dmg, int From, int Weapon)
|
||||
{
|
||||
m_Core.m_Vel += Force;
|
||||
|
||||
|
@ -690,20 +689,7 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
|
|||
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);
|
||||
}
|
||||
|
||||
int OldHealth = m_Health, OldArmor = m_Armor;
|
||||
if(Dmg)
|
||||
{
|
||||
if(m_Armor)
|
||||
|
@ -729,7 +715,8 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
|
|||
m_Health -= Dmg;
|
||||
}
|
||||
|
||||
m_DamageTakenTick = Server()->Tick();
|
||||
// create healthmod indicator
|
||||
GameServer()->CreateDamage(m_Pos, m_pPlayer->GetCID(), Source, OldHealth-m_Health, OldArmor-m_Armor, From == m_pPlayer->GetCID());
|
||||
|
||||
// do damage Hit sound
|
||||
if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From])
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
void FireWeapon();
|
||||
|
||||
void Die(int Killer, int Weapon);
|
||||
bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon);
|
||||
bool TakeDamage(vec2 Force, vec2 Source, int Dmg, int From, int Weapon);
|
||||
|
||||
bool Spawn(class CPlayer *pPlayer, vec2 Pos);
|
||||
bool Remove();
|
||||
|
@ -83,8 +83,6 @@ private:
|
|||
int m_ReloadTimer;
|
||||
int m_AttackTick;
|
||||
|
||||
int m_DamageTaken;
|
||||
|
||||
int m_EmoteType;
|
||||
int m_EmoteStop;
|
||||
|
||||
|
@ -101,8 +99,6 @@ private:
|
|||
int m_NumInputs;
|
||||
int m_Jumped;
|
||||
|
||||
int m_DamageTakenTick;
|
||||
|
||||
int m_Health;
|
||||
int m_Armor;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ bool CLaser::HitCharacter(vec2 From, vec2 To)
|
|||
m_From = From;
|
||||
m_Pos = At;
|
||||
m_Energy = -1;
|
||||
pHit->TakeDamage(vec2(0.f, 0.f), g_pData->m_Weapons.m_aId[WEAPON_LASER].m_Damage, m_Owner, WEAPON_LASER);
|
||||
pHit->TakeDamage(vec2(0.f, 0.f), normalize(To-From), g_pData->m_Weapons.m_aId[WEAPON_LASER].m_Damage, m_Owner, WEAPON_LASER);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ void CProjectile::Tick()
|
|||
GameServer()->CreateExplosion(CurPos, m_Owner, m_Weapon, m_Damage);
|
||||
|
||||
else if(TargetChr)
|
||||
TargetChr->TakeDamage(m_Direction * max(0.001f, m_Force), m_Damage, m_Owner, m_Weapon);
|
||||
TargetChr->TakeDamage(m_Direction * max(0.001f, m_Force), m_Direction*-1, m_Damage, m_Owner, m_Weapon);
|
||||
|
||||
GameServer()->m_World.DestroyEntity(this);
|
||||
}
|
||||
|
|
|
@ -93,22 +93,19 @@ class CCharacter *CGameContext::GetPlayerChar(int ClientID)
|
|||
return m_apPlayers[ClientID]->GetCharacter();
|
||||
}
|
||||
|
||||
void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount)
|
||||
void CGameContext::CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount, bool Self)
|
||||
{
|
||||
float a = 3*pi/2 + Angle;
|
||||
//float a = get_angle(dir);
|
||||
float s = a-pi/3;
|
||||
float e = a+pi/3;
|
||||
for(int i = 0; i < Amount; i++)
|
||||
float f = angle(Source);
|
||||
CNetEvent_Damage *pEvent = (CNetEvent_Damage *)m_Events.Create(NETEVENTTYPE_DAMAGE, sizeof(CNetEvent_Damage));
|
||||
if(pEvent)
|
||||
{
|
||||
float f = mix(s, e, float(i+1)/float(Amount+2));
|
||||
CNetEvent_DamageInd *pEvent = (CNetEvent_DamageInd *)m_Events.Create(NETEVENTTYPE_DAMAGEIND, sizeof(CNetEvent_DamageInd));
|
||||
if(pEvent)
|
||||
{
|
||||
pEvent->m_X = (int)Pos.x;
|
||||
pEvent->m_Y = (int)Pos.y;
|
||||
pEvent->m_Angle = (int)(f*256.0f);
|
||||
}
|
||||
pEvent->m_X = (int)Pos.x;
|
||||
pEvent->m_Y = (int)Pos.y;
|
||||
pEvent->m_ClientID = Id;
|
||||
pEvent->m_Angle = (int)(f*256.0f);
|
||||
pEvent->m_HealthAmount = HealthAmount;
|
||||
pEvent->m_ArmorAmount = ArmorAmount;
|
||||
pEvent->m_Self = Self;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +146,7 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, int MaxDamag
|
|||
Force = normalize(Diff) * MaxForce;
|
||||
float Factor = 1 - clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f);
|
||||
if((int)(Factor * MaxDamage))
|
||||
apEnts[i]->TakeDamage(Force * Factor, (int)(Factor * MaxDamage), Owner, Weapon);
|
||||
apEnts[i]->TakeDamage(Force * Factor, Diff*-1, (int)(Factor * MaxDamage), Owner, Weapon);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
CVoteOptionServer *m_pVoteOptionLast;
|
||||
|
||||
// helper functions
|
||||
void CreateDamageInd(vec2 Pos, float AngleMod, int Amount);
|
||||
void CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount, bool Self);
|
||||
void CreateExplosion(vec2 Pos, int Owner, int Weapon, int MaxDamage);
|
||||
void CreateHammerHit(vec2 Pos);
|
||||
void CreatePlayerSpawn(vec2 Pos);
|
||||
|
|
Loading…
Reference in a new issue