Skip to content

Commit

Permalink
Jug remake x3
Browse files Browse the repository at this point in the history
  • Loading branch information
Hu1night committed Sep 8, 2024
1 parent affde90 commit c02fe12
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/game/server/gamemodes/huntern.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CGameControllerHunterN : public IGameController
{0, 0}, // CLASS_NONE
{1, -1}, // CLASS_CIVIC
{4, -2}, // CLASS_HUNTER
//{8, -114514}, // CLASS_JUGGERNAUT
{100, -114514}, // CLASS_JUGGERNAUT
//{4, -2}, // CLASS_PUPPETEE
//{8, -2}, // CLASS_JOJO
};
Expand Down
78 changes: 57 additions & 21 deletions src/game/server/weapons/jughammer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ CJugHammer::CJugHammer(CCharacter *pOwnerChar) :
m_BounceMode = 0;
m_AttackEnergyTick = 0;

m_aBounceTypeTemp[0] = Server()->TickSpeed() / 5;
m_aBounceTypeTemp[1] = Server()->TickSpeed() / 5;
m_aBounceTypeTemp[2] = Server()->TickSpeed();
m_AttackEnergyLimit = 800;

for(int i = 0; i < (int)sizeof(m_SnapID); i++)
for(unsigned int i = 0; i < sizeof(m_SnapID) / sizeof(m_SnapID[0]); i++)
m_SnapID[i] = Server()->SnapNewID();
}

CJugHammer::~CJugHammer()
{
for(int i = 0; i < (int)sizeof(m_SnapID); i++)
for(unsigned int i = 0; i < sizeof(m_SnapID) / sizeof(m_SnapID[0]); i++)
Server()->SnapFreeID(m_SnapID[i]);
}

void CJugHammer::Snap(int SnappingClient, int OtherMode)
{
// Do attack range ind
vec2 Dir = normalize(vec2(Character()->GetInput()->m_TargetX, Character()->GetInput()->m_TargetY));
vec2 CirclePos = Pos() + Dir * 96.f;
vec2 CirclePoints[8] =
Expand All @@ -53,18 +57,20 @@ void CJugHammer::Snap(int SnappingClient, int OtherMode)
pObj->m_StartTick = Server()->Tick() - 2;
}

// Do attack energy ind
CNetObj_Laser *pAttackEnergyIndObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_SnapID[8], sizeof(CNetObj_Laser)));
if(!pAttackEnergyIndObj)
return;

vec2 AttackEnergyInd = CirclePos - (Dir * (minimum(m_AttackEnergyTick * Server()->TickSpeed(), m_AttackEnergyLimit) / 8));
vec2 AttackEnergyInd = CirclePos - (Dir * (clamp(m_AttackEnergyTick * Server()->TickSpeed() - 200, 0, m_AttackEnergyLimit) / 8));

pAttackEnergyIndObj->m_X = (int)CirclePos.x;
pAttackEnergyIndObj->m_Y = (int)CirclePos.y;
pAttackEnergyIndObj->m_FromX = (int)AttackEnergyInd.x;
pAttackEnergyIndObj->m_FromY = (int)AttackEnergyInd.y;
pAttackEnergyIndObj->m_StartTick = Server()->Tick() - 3;

// Do bounce temperature ind
CNetObj_Laser *pBounceTempIndObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_SnapID[9], sizeof(CNetObj_Laser)));
if(!pBounceTempIndObj)
return;
Expand All @@ -76,6 +82,26 @@ void CJugHammer::Snap(int SnappingClient, int OtherMode)
pBounceTempIndObj->m_FromX = (int)CirclePos.x;
pBounceTempIndObj->m_FromY = (int)CirclePos.y;
pBounceTempIndObj->m_StartTick = Server()->Tick() - 3;

// Do character track
if(SnappingClient != Character()->GetPlayer()->GetCID())
return;

CEntity *IndCharacter = GameWorld()->ClosestEntity(Pos(), 8192.f, CGameWorld::ENTTYPE_CHARACTER, Character());
if(!IndCharacter)
return;

CNetObj_Laser *pPlayerTrackIndObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_SnapID[10], sizeof(CNetObj_Laser)));
if(!pPlayerTrackIndObj)
return;

vec2 PlayerTrackInd = Pos() + vec2(0.f, -16.f) + normalize(IndCharacter->m_Pos - Pos() + vec2(0.f, -16.f)) * 128.f;

pPlayerTrackIndObj->m_X = (int)PlayerTrackInd.x;
pPlayerTrackIndObj->m_Y = (int)PlayerTrackInd.y;
pPlayerTrackIndObj->m_FromX = (int)Pos().x;
pPlayerTrackIndObj->m_FromY = (int)(Pos().y - 16.f);
pPlayerTrackIndObj->m_StartTick = Server()->Tick() - 3;
}

void CJugHammer::Tick()
Expand All @@ -87,24 +113,24 @@ void CJugHammer::Tick()
vec2 CirclePos = Pos() + Dir * 96.f;

CProjectile *apProj[64];
int Num = GameWorld()->FindEntities(CirclePos, 96.f, (CEntity **)apProj, 64, CGameWorld::ENTTYPE_PROJECTILE);
int Num = GameWorld()->FindEntities(CirclePos, 128.f, (CEntity **)apProj, 64, CGameWorld::ENTTYPE_PROJECTILE);

int AttackDmg = maximum(((minimum(m_AttackEnergyTick * Server()->TickSpeed(), m_AttackEnergyLimit) - 200) * 17) / 1000, 0);
bool IsBounced = false;
int HitProj;

if(PlayerInput->m_Fire & 1)
{
m_AttackEnergyTick++;
}
else if(Character()->GetPrevInput()->m_Fire & 1)
{
int AttackEnergyTime = minimum(m_AttackEnergyTick * Server()->TickSpeed(), m_AttackEnergyLimit);
CCharacter *pChr = (CCharacter *)GameWorld()->ClosestEntity(CirclePos, 1280.f, CGameWorld::ENTTYPE_CHARACTER, Character());

CCharacter *pChr = (CCharacter *)GameWorld()->ClosestEntity(CirclePos, 960.f, CGameWorld::ENTTYPE_CHARACTER, Character());
if(pChr)
if(pChr && length(pChr->m_Pos - CirclePos) < 96.f)
{
if(length(pChr->m_Pos - CirclePos) < 96.f) // Hit the Character
{
GameWorld()->CreateHammerHit(pChr->m_Pos);
pChr->TakeDamage(normalize(pChr->m_Pos - Pos()) * 4.f, (AttackEnergyTime * 12.5f) / 1000, Character()->GetPlayer()->GetCID(), WEAPON_HAMMER, GetWeaponID(), false);
}
GameWorld()->CreateHammerHit(pChr->m_Pos);
pChr->TakeDamage(normalize(pChr->m_Pos - Pos()) * 4.f, AttackDmg, Character()->GetPlayer()->GetCID(), WEAPON_HAMMER, GetWeaponID(), false);
}

for(int i = 0; i < Num; ++i)
Expand All @@ -119,21 +145,18 @@ void CJugHammer::Tick()
pProj->SetStartPos(pProj->m_Pos);
pProj->SetStartTick(Server()->Tick());
pProj->SetOwner(Character()->GetPlayer()->GetCID());
pProj->SetDir(normalize(pChr ? pChr->m_Pos - pProj->m_Pos : pProj->m_Pos - Character()->m_Pos) * (AttackEnergyTime * 2.5f / 1000.f));
pProj->SetDir(normalize(pChr ? pChr->m_Pos - pProj->m_Pos : pProj->m_Pos - Character()->m_Pos) * 2.f);
pProj->m_LifeSpan = 2 * Server()->TickSpeed();
pProj->m_IsFreeze = false;
}

m_AttackEnergyTick = 0;
}

bool IsBounced = false;

if(!(Character()->GetInput()->m_PlayerFlags & PLAYERFLAG_AIM) && m_BounceCooldownTick >= m_BounceTempTick / 4)
else if(m_BounceCooldownTick >= m_BounceTempTick / 4)
{
for(int i = 0; i < Num; ++i)
for(HitProj = 0; HitProj < Num; ++HitProj)
{
CProjectile *pProj = apProj[i];
CProjectile *pProj = apProj[HitProj];

if(!pProj->m_IsFreeze && pProj->GetOwner() != Character()->GetPlayer()->GetCID())
{
Expand All @@ -148,17 +171,30 @@ void CJugHammer::Tick()

if(IsBounced)
{
m_BounceTempTick = clamp((m_BounceTempTick - m_BounceCooldownTick - m_BounceTempTick / 4) * 4 + Server()->TickSpeed() / 10, Server()->TickSpeed() / 5, Server()->TickSpeed() * 3);
m_BounceTempTick = clamp((m_BounceTempTick - m_BounceCooldownTick - m_BounceTempTick / 4) * 2, 0, Server()->TickSpeed() * 3) + m_aBounceTypeTemp[apProj[HitProj]->m_Type - 1];
m_BounceCooldownTick = 0;
}
else
m_BounceCooldownTick++;

char aBuf[96];
str_format(aBuf, sizeof(aBuf), "子弹截停冷却: %d/%d\n近战蓄力伤害: %d\n辅助线榴弹跳: %d", maximum(m_BounceTempTick / 4 - m_BounceCooldownTick, 0), maximum(m_BounceTempTick - m_BounceCooldownTick, 0), AttackDmg, m_ReloadTimer);
GameServer()->SendBroadcast(aBuf, Character()->GetPlayer()->GetCID(), false);
}

void CJugHammer::Fire(vec2 Direction)
{
int ClientID = Character()->GetPlayer()->GetCID();
GameWorld()->CreateSound(Pos(), SOUND_HAMMER_FIRE);

if(Character()->GetInput()->m_PlayerFlags & PLAYERFLAG_AIM)
{
GameWorld()->CreateSound(Pos(), SOUND_GRENADE_EXPLODE);
GameWorld()->CreateExplosion(Pos() + Direction * 24.f, Character()->GetPlayer()->GetCID(), WEAPON_GRENADE, GetWeaponID(), 0, false);

m_ReloadTimer = Server()->TickSpeed();
}
else
GameWorld()->CreateSound(Pos(), SOUND_HAMMER_FIRE);

GameServer()->Antibot()->OnHammerFire(ClientID);
}
21 changes: 14 additions & 7 deletions src/game/server/weapons/jughammer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ class CJugHammer : public CWeapon
CJugHammer(CCharacter *pOwnerChar);
~CJugHammer();

void Snap(int SnappingClient, int OtherMode);
void Tick();
void Fire(vec2 Direction) override;
int GetType() override { return Character()->GetInput()->m_PlayerFlags & PLAYERFLAG_AIM ? WEAPON_NINJA : WEAPON_HAMMER; }
bool IsPowerupOver() override { return false; }

protected: // Value
int m_BounceTempTick;
int m_BounceCooldownTick;
int m_BounceMode;
int m_AttackEnergyTick;

int m_aBounceTypeTemp[NUM_WEAPONS - 3];
int m_AttackEnergyLimit;

int m_SnapID[8 + 2];
int m_SnapID[8 + 3];

public: // Functions
void Snap(int SnappingClient, int OtherMode);
void Tick();
void Fire(vec2 Direction) override;

public:
int GetType() override { return Character()->GetInput()->m_PlayerFlags & PLAYERFLAG_AIM ? WEAPON_NINJA : WEAPON_HAMMER; }
bool IsPowerupOver() override { return false; }

//protected: // Toolbox
};

#endif // GAME_SERVER_WEAPONS_JUGHAMMER_H

0 comments on commit c02fe12

Please sign in to comment.