From 4210588de96cb37c6133f133d24cbb4fc1ec7817 Mon Sep 17 00:00:00 2001 From: Hu1night <2506405864@qq.com> Date: Thu, 8 Feb 2024 00:14:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8A=8ASendKillMsg=E4=BB=8ECCharacter?= =?UTF-8?q?=E5=BD=92=E8=BF=98=E5=88=B0IGameController=20=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=9D=9E=E6=97=81=E8=A7=82=E7=9A=84=E6=AD=BB=E4=BA=BA?= =?UTF-8?q?=E7=9C=8B=E4=B8=8D=E5=88=B0=E6=AD=BB=E5=9B=A0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game/server/entities/character.cpp | 32 ++------------------------ src/game/server/gamecontroller.cpp | 29 +++++++++++++++++++---- src/game/server/gamecontroller.h | 2 +- 3 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 85775013d7..355a3f857c 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -630,38 +630,10 @@ void CCharacter::Die(int Killer, int Weapon) int DeathFlag = Controller()->OnInternalCharacterDeath(this, GameServer()->m_apPlayers[Killer], Weapon); int ModeSpecial = DeathFlag & (DEATH_KILLER_HAS_FLAG | DEATH_VICTIM_HAS_FLAG); + int IsHideReason = (DeathFlag & DEATH_NO_REASON); if(!(DeathFlag & DEATH_NO_KILL_MSG)) - { - /* Hunter Start */ - CNetMsg_Sv_KillMsg Msg; - Msg.m_Killer = Killer; - Msg.m_Victim = m_pPlayer->GetCID(); - Msg.m_Weapon = Weapon; - Msg.m_ModeSpecial = ModeSpecial; - - if(DeathFlag & DEATH_NO_REASON) - { - CNetMsg_Sv_KillMsg PlayerMsg(Msg); - PlayerMsg.m_Killer = m_pPlayer->GetCID(); // This makes the killer Anonymous - PlayerMsg.m_Weapon = WEAPON_WORLD; - - for(int i = 0; i < MAX_CLIENTS; ++i) - { - if(GameServer()->PlayerExists(i) && GameServer()->GetPlayerDDRTeam(i) == GameWorld()->Team()) - Server()->SendPackMsg((GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) ? &PlayerMsg : &Msg, MSGFLAG_VITAL, i); - } - } - else - { - for(int i = 0; i < MAX_CLIENTS; ++i) - { - if(GameServer()->PlayerExists(i) && GameServer()->GetPlayerDDRTeam(i) == GameWorld()->Team()) - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i); - } - } - /* Hunter End */ - } + Controller()->SendKillMsg(Killer, m_pPlayer->GetCID(), Weapon, ModeSpecial, IsHideReason); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "kill killer='%d:%s' victim='%d:%s' weapon=%d special=%d", diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 4cbf2b0ef6..e8ac8f71d8 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -2920,7 +2920,7 @@ void IGameController::SendBroadcast(const char *pText, int ClientID, bool IsImpo GameServer()->SendBroadcast(pText, i, IsImportant); } -/*void IGameController::SendKillMsg(int Killer, int Victim, int Weapon, int ModeSpecial) const +void IGameController::SendKillMsg(int Killer, int Victim, int Weapon, int ModeSpecial, bool IsHideReason) const { // send the kill message CNetMsg_Sv_KillMsg Msg; @@ -2929,12 +2929,31 @@ void IGameController::SendBroadcast(const char *pText, int ClientID, bool IsImpo Msg.m_Weapon = Weapon; Msg.m_ModeSpecial = ModeSpecial; - for(int i = 0; i < MAX_CLIENTS; ++i) + /* Hunter Start */ + if(IsHideReason) { - if(GetPlayerIfInRoom(i)) - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i); + CNetMsg_Sv_KillMsg PlayerMsg(Msg); + PlayerMsg.m_Killer = Victim; // This makes the killer Anonymous + PlayerMsg.m_Weapon = WEAPON_WORLD; + + for(int i = 0; i < MAX_CLIENTS; ++i) + { + if(GetPlayerIfInRoom(i)) + Server()->SendPackMsg((GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS || !(GameServer()->m_apPlayers[i]->GetCharacter() && GameServer()->m_apPlayers[i]->GetCharacter()->IsAlive())) ? + &PlayerMsg : &Msg, // Is Hide Reason + MSGFLAG_VITAL, i); + } } -}*/ + else + { + for(int i = 0; i < MAX_CLIENTS; ++i) + { + if(GetPlayerIfInRoom(i)) + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i); + } + } + /* Hunter End */ +} void IGameController::InstanceConsolePrint(const char *pStr, void *pUser) { diff --git a/src/game/server/gamecontroller.h b/src/game/server/gamecontroller.h index fd15bb4153..4f121a513c 100644 --- a/src/game/server/gamecontroller.h +++ b/src/game/server/gamecontroller.h @@ -435,7 +435,7 @@ class IGameController // Instance Space Ops void SendChatTarget(int To, const char *pText, int Flags = 3) const; void SendBroadcast(const char *pText, int ClientID, bool IsImportant = true) const; - //void SendKillMsg(int Killer, int Victim, int Weapon, int ModeSpecial = 0) const; + void SendKillMsg(int Killer, int Victim, int Weapon, int ModeSpecial = 0, bool IsHideReason = false) const; // helpers bool IsDDNetEntity(int Index) const; From 82886b634f32df546a4f8627bb688f383668362d Mon Sep 17 00:00:00 2001 From: Hu1night <2506405864@qq.com> Date: Thu, 8 Feb 2024 20:50:22 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=9B=9E=E6=BB=9AConRevive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game/server/gamemodes/huntern.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/server/gamemodes/huntern.cpp b/src/game/server/gamemodes/huntern.cpp index 6f286c1714..39488516c7 100644 --- a/src/game/server/gamemodes/huntern.cpp +++ b/src/game/server/gamemodes/huntern.cpp @@ -69,7 +69,7 @@ static void ConRevive(IConsole::IResult *pResult, void *pUserData) CPlayer *pPlayer = pSelf->GetPlayerIfInRoom((pResult->NumArguments() > 0) ? pResult->GetInteger(0) : pResult->m_ClientID); if(!pPlayer) // If the player does not exist pSelf->InstanceConsole()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "huntern", "invalid client id"); - else if(!pResult->GetInteger(1) && pPlayer->GetCharacter() && pPlayer->GetCharacter()->IsAlive()) + else if(pPlayer->GetCharacter() && pPlayer->GetCharacter()->IsAlive()) pSelf->InstanceConsole()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "huntern", "character is alive"); else { if(pPlayer->m_Class == CLASS_NONE) @@ -96,7 +96,7 @@ CGameControllerHunterN::CGameControllerHunterN() : InstanceConsole()->Register("htn_setclass", "i[class-id] ?i[CID] ?i[team-id] ?i[hunt-weapon]", CFGFLAG_CHAT | CFGFLAG_INSTANCE, ConSetClass, this, "给玩家设置职业(1平民,2猎人,4剑圣)"); InstanceConsole()->Register("htn_giveweapon", "i[weapon-id] i[slot] ?i[CID] ?i[ammo-num]", CFGFLAG_CHAT | CFGFLAG_INSTANCE, ConGiveWeapon, this, "给玩家武器"); InstanceConsole()->Register("htn_setheal", "i[health] ?i[armor] ?i[CID] ?i[max-health] ?i[max-armor]", CFGFLAG_CHAT | CFGFLAG_INSTANCE, ConSetHeal, this, "给玩家血量和盾"); - InstanceConsole()->Register("htn_revive", "?i[CID] ?i[force-respawn]", CFGFLAG_CHAT | CFGFLAG_INSTANCE, ConRevive, this, "复活吧"); + InstanceConsole()->Register("htn_revive", "?i[CID]", CFGFLAG_CHAT | CFGFLAG_INSTANCE, ConRevive, this, "复活吧"); } void CGameControllerHunterN::OnResetClass(CCharacter *pChr) // 职业重置(出生后) From 6075537e6598272344fc1f4e5b4be4d9afaa9854 Mon Sep 17 00:00:00 2001 From: Hu1night <2506405864@qq.com> Date: Wed, 14 Feb 2024 18:00:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=89=E9=A1=B9?= =?UTF-8?q?=EF=BC=9A=E7=8C=8E=E6=A6=B4=E4=B8=8D=E5=91=BD=E4=B8=AD=E5=88=99?= =?UTF-8?q?=E7=A0=B4=E7=89=8714=E6=A0=BC=E5=86=85=E8=BF=BD=E8=B8=AA?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game/server/entities/projectile.h | 1 + src/game/server/gamecontroller.cpp | 3 ++- src/game/server/gamecontroller.h | 3 ++- src/game/server/gamemodes/huntern.cpp | 15 ++++++----- src/game/server/weapons/grenade.cpp | 38 ++++++++++++++++++++------- 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/game/server/entities/projectile.h b/src/game/server/entities/projectile.h index e520638189..1ec3d00b3a 100644 --- a/src/game/server/entities/projectile.h +++ b/src/game/server/entities/projectile.h @@ -67,6 +67,7 @@ class CProjectile : public CEntity int GetOwner() { return m_Owner; } int GetWeaponID() { return m_WeaponID; } /* Hunter Start */ + int GetStartTick() { return m_StartTick; } void SetOwner(int Owner) { m_Owner = Owner; } void SetStartTick(int Tick) { m_StartTick = Tick; } void SetStartPos(vec2 Pos) { m_StartPos = Pos; } diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index e8ac8f71d8..4f108f493d 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -454,7 +454,8 @@ IGameController::IGameController() m_ResendVotes = false; m_NumPlayerNotReady = 0; - m_HuntFragsNum = 18; // Hunter + m_HuntFragNum = 18; // Hunter + m_HuntFragTrack = 0; // Hunter // fake client broadcast mem_zero(m_aFakeClientBroadcast, sizeof(m_aFakeClientBroadcast)); diff --git a/src/game/server/gamecontroller.h b/src/game/server/gamecontroller.h index 4f121a513c..96f3e306ab 100644 --- a/src/game/server/gamecontroller.h +++ b/src/game/server/gamecontroller.h @@ -313,7 +313,8 @@ class IGameController int m_ResetOnMatchEnd; int m_PausePerMatch; int m_MinimumPlayers; - int m_HuntFragsNum; // Hunter + int m_HuntFragNum; // Hunter + int m_HuntFragTrack; // Hunter // mega map stuff char m_aMap[128]; diff --git a/src/game/server/gamemodes/huntern.cpp b/src/game/server/gamemodes/huntern.cpp index 39488516c7..8b2fcf3817 100644 --- a/src/game/server/gamemodes/huntern.cpp +++ b/src/game/server/gamemodes/huntern.cpp @@ -5,7 +5,7 @@ #include "huntern.h" #include #include -#include +//#include #include // HunterN commands @@ -31,7 +31,7 @@ static void ConGiveWeapon(IConsole::IResult *pResult, void *pUserData) IGameController *pSelf = (IGameController *)pUserData; CPlayer *pPlayer = pSelf->GetPlayerIfInRoom((pResult->NumArguments() > 2) ? pResult->GetInteger(2) : pResult->m_ClientID); - if(!pPlayer) + if(!pPlayer) pSelf->InstanceConsole()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "huntern", "invalid client id"); else if(!pPlayer->GetCharacter() || !pPlayer->GetCharacter()->IsAlive()) pSelf->InstanceConsole()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "huntern", "character is dead"); @@ -88,7 +88,8 @@ CGameControllerHunterN::CGameControllerHunterN() : //INSTANCE_CONFIG_INT(&m_BroadcastHunterList, "htn_hunt_broadcast_list", 0, 0, 1, CFGFLAG_CHAT | CFGFLAG_INSTANCE, "是否全体广播猎人列表(开关,默认0,限制0~1)"); INSTANCE_CONFIG_INT(&m_BroadcastHunterDeath, "htn_hunt_broadcast_death", 0, 0, 1, CFGFLAG_CHAT | CFGFLAG_INSTANCE, "是否全体广播猎人死亡(开关,默认0,限制0~1)"); INSTANCE_CONFIG_INT(&m_EffectHunterDeath, "htn_hunt_effert_death", 0, 0, 1, CFGFLAG_CHAT | CFGFLAG_INSTANCE, "猎人死亡是否使用出生烟(开关,默认0,限制0~1)"); - INSTANCE_CONFIG_INT(&m_HuntFragsNum, "htn_hunt_frags_num", 18, 0, 0xFFFFFFF, CFGFLAG_CHAT | CFGFLAG_INSTANCE, "猎人榴弹产生的破片数量(整数,默认18,限制0~268435455)"); + INSTANCE_CONFIG_INT(&m_HuntFragNum, "htn_hunt_frag_num", 18, 0, 0xFFFFFFF, CFGFLAG_CHAT | CFGFLAG_INSTANCE, "猎人榴弹产生的破片数量(整数,默认18,限制0~268435455)"); + INSTANCE_CONFIG_INT(&m_HuntFragTrack, "htn_hunt_frag_track", 18, 0, 0xFFFFFFF, CFGFLAG_CHAT | CFGFLAG_INSTANCE, "猎人榴弹产生的破片数量(整数,默认18,限制0~268435455)"); INSTANCE_CONFIG_INT(&m_Wincheckdeley, "htn_wincheck_deley", 100, 0, 0xFFFFFFF, CFGFLAG_CHAT | CFGFLAG_INSTANCE, "终局判断延时毫秒(整数,默认100,限制0~268435455)"); INSTANCE_CONFIG_INT(&m_GameoverTime, "htn_gameover_time", 7, 0, 0xFFFFFFF, CFGFLAG_CHAT | CFGFLAG_INSTANCE, "结算界面时长秒数(整数,默认0,限制0~268435455)"); //INSTANCE_CONFIG_INT(&m_RoundMode, "htn_round_mode", 0, 0, 1, CFGFLAG_CHAT | CFGFLAG_INSTANCE, "回合模式 正常0 娱乐1(整数,默认0,限制0~1)"); @@ -361,7 +362,7 @@ void CGameControllerHunterN::DoWincheckRound() // check for time based win if(!DoWinchenkClassTick && TeamBlueCount && TeamRedCount) { - --DoWinchenkClassTick; + DoWinchenkClassTick = -1; // 关闭DoWincheck return; } @@ -460,9 +461,9 @@ int CGameControllerHunterN::OnCharacterDeath(class CCharacter *pVictim, class CP } else { - char aBuff[16]; - str_format(aBuff, sizeof(aBuff), "%d Hunter left.", nHunter); - str_append(aBuf, aBuff, sizeof(aBuf)); + char aBufEx[16]; + str_format(aBufEx, sizeof(aBufEx), "%d Hunter left.", nHunter); + str_append(aBuf, aBufEx, sizeof(aBuf)); for(int i = 0; i < MAX_CLIENTS; ++i) // 逐个给所有人根据职业发送死亡消息 { CPlayer *pPlayer = GetPlayerIfInRoom(i); diff --git a/src/game/server/weapons/grenade.cpp b/src/game/server/weapons/grenade.cpp index 9386ada357..fda67d9078 100644 --- a/src/game/server/weapons/grenade.cpp +++ b/src/game/server/weapons/grenade.cpp @@ -37,26 +37,44 @@ bool CGrenade::GrenadeCollide(CProjectile *pProj, vec2 Pos, CCharacter *pHit, bo if(pProj->GameServer()->m_apPlayers[pProj->GetOwner()]->m_UseHunterWeapon) { float a = (rand()%314)/5.0; - vec2 d = vec2(cosf(a), sinf(a)) * 80; + vec2 ParticleDir = vec2(cosf(a), sinf(a)) * 80; - pProj->GameWorld()->CreateExplosionParticle(Pos + d); // Create Particle - pProj->GameWorld()->CreateExplosionParticle(Pos + vec2(d.y, -d.x)); - pProj->GameWorld()->CreateExplosionParticle(Pos + vec2(-d.x, -d.y)); - pProj->GameWorld()->CreateExplosionParticle(Pos + vec2(-d.y, d.x)); + pProj->GameWorld()->CreateExplosionParticle(Pos + ParticleDir); // vec2(d.x, d.y) // Create Particle + pProj->GameWorld()->CreateExplosionParticle(Pos + vec2(ParticleDir.y, -ParticleDir.x)); + pProj->GameWorld()->CreateExplosionParticle(Pos + vec2(-ParticleDir.x, -ParticleDir.y)); + pProj->GameWorld()->CreateExplosionParticle(Pos + vec2(-ParticleDir.y, ParticleDir.x)); + + vec2 DirChr; // 指向玩家 + vec2 FragPos; // 破片生成的位置 + CCharacter* ClosestCharacter = 0; // 最近的其他的玩家的角色的指针 + + if(!pHit && pProj->Controller()->m_HuntFragTrack) // 打得好 给了他们狠狠一击! + { + FragPos = pProj->GetPos((pProj->Server()->Tick() - pProj->GetStartTick() - 1) / (float)pProj->Server()->TickSpeed()); // 上一刻位置 让破片不至于埋土里 + + ClosestCharacter = (CCharacter *)pProj->GameWorld()->ClosestEntity(FragPos, 448.f, CGameWorld::ENTTYPE_CHARACTER, pProj->GameServer()->m_apPlayers[pProj->GetOwner()]->GetCharacter()); + if(ClosestCharacter) // 如果14格内没有其他玩家 + DirChr = normalize(ClosestCharacter->m_Pos - FragPos); // 指向玩家 + } + else + FragPos = Pos; CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE); - Msg.AddInt(pProj->Controller()->m_HuntFragsNum); + Msg.AddInt(pProj->Controller()->m_HuntFragNum); - for(int i = 0; i < pProj->Controller()->m_HuntFragsNum; i++) // Create Fragments + for(int i = 0; i < pProj->Controller()->m_HuntFragNum; i++) // Create Fragments { - float a = (rand()%314)/5.0; - vec2 d = vec2(cosf(a), sinf(a)); + float a = (rand()%314)/5.f; + vec2 d = vec2(cosf(a), sinf(a)); // 随机指向 + if(ClosestCharacter) + d = normalize((d * 0.5f) + DirChr); // 飞向玩家 + CProjectile *pProjFrag = new CProjectile( pProj->GameWorld(), WEAPON_SHOTGUN, //Type pProj->GetWeaponID(), //WeaponID pProj->GetOwner(), //Owner - Pos + d, //Pos + FragPos, //Pos d * 0.5f, //Dir 6.0f, // Radius 0.2f * pProj->Server()->TickSpeed(), //Span From 8c9dcef94f94c6e3b63a5b34bc973e5f45cf957e Mon Sep 17 00:00:00 2001 From: Hu1night <2506405864@qq.com> Date: Wed, 14 Feb 2024 20:55:06 +0800 Subject: [PATCH 4/4] Stable-Release 0.3a1 --- src/game/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/version.h b/src/game/version.h index bba8d2c117..74d582155e 100644 --- a/src/game/version.h +++ b/src/game/version.h @@ -5,7 +5,7 @@ #ifndef GAME_RELEASE_VERSION #define GAME_RELEASE_VERSION "15.4" #endif -#define GAME_VERSION "0.6.4, " GAME_RELEASE_VERSION ", 0.3a1_p4" +#define GAME_VERSION "0.6.4, " GAME_RELEASE_VERSION ", 0.3a1" #define GAME_NETVERSION "0.6 626fce9a778df4d4" #define GAME_NAME "DDNet" #define CLIENT_VERSIONNR 15040