Skip to content

Commit

Permalink
Merge branch 'master' into huntern-zh_cn
Browse files Browse the repository at this point in the history
  • Loading branch information
Hu1night committed Feb 14, 2024
2 parents 9cafcda + 8c9dcef commit a014f5f
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 58 deletions.
32 changes: 2 additions & 30 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/game/server/entities/projectile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
32 changes: 26 additions & 6 deletions src/game/server/gamecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -2920,7 +2921,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;
Expand All @@ -2929,12 +2930,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)
{
Expand Down
5 changes: 3 additions & 2 deletions src/game/server/gamecontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -435,7 +436,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;
Expand Down
19 changes: 10 additions & 9 deletions src/game/server/gamemodes/huntern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "huntern.h"
#include <game/server/entities/character.h>
#include <game/server/weapons.h>
#include <game/server/entities/pickup.h>
//#include <game/server/entities/pickup.h>
#include <game/server/classes.h>

// HunterN commands
Expand All @@ -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");
Expand Down Expand Up @@ -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)
Expand All @@ -88,15 +88,16 @@ 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)");

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) // 职业重置(出生后)
Expand Down Expand Up @@ -361,7 +362,7 @@ void CGameControllerHunterN::DoWincheckRound() // check for time based win

if(!DoWinchenkClassTick && TeamBlueCount && TeamRedCount)
{
--DoWinchenkClassTick;
DoWinchenkClassTick = -1; // 关闭DoWincheck
return;
}

Expand Down Expand Up @@ -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);
Expand Down
38 changes: 28 additions & 10 deletions src/game/server/weapons/grenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/game/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a014f5f

Please sign in to comment.