Skip to content

Commit

Permalink
Merge pull request #1 from teeframe/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
miguilimzero authored Mar 14, 2022
2 parents 5e52c98 + cf8b831 commit 52eda9f
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 197 deletions.
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CONTRIBUTING

Contributions are welcome, and are accepted via pull requests.
Please review these guidelines before submitting any pull requests.

## Process

1. Fork the project.
1. Create a new branch.
1. Code, test, commit and push.
1. Open a pull request detailing your changes. Make sure to follow the [template](.github/PULL_REQUEST_TEMPLATE.md).

## Guidelines

* You may need to [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to avoid merge conflicts.
155 changes: 9 additions & 146 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,154 +1,17 @@
# DDNet Skeleton
<p align="center"><img src="https://teeframe.com/img/ddnet-skeleton/logo.png" alt="DDNet-Skeleton Logo"></p>

This repository aims to be the skeleton for creating modifications on top of the latest DDNet version. It currently modify the DDNet code so it can support teams, damage, ammo and pickup respawn features.
# DDNet-Skeleton

## How to create your Modification
This repository aims to be the skeleton for creating modifications on top of the latest DDNet version. It currently modify the DDNet code so it can support removed vanilla features and comment out the code related to DDRace exclusive functionalities.

In order to create your mod, you will need to download this repository with the following command. **Please do not fork this repository or download the ZIP file without the Git History**:
```bash
git clone https://github.com/teeframe/ddnet-skeleton
```
## Official Documentation

After downloading the repository, you will need to add your repository remote and create two branches with the following commands **inside the repository folder:**
Documentation for DDNet-Skeleton can be found on the [TeeFrame website](https://teeframe.com/ddnet-skeleton).

```bash
git remote remove origin
git remote add origin YOUR_REPOSITORY_URL
git branch -M main && git push -u origin main
git branch upstream && git push -u origin upstream
```
## Contributing

You will create `main` and upstream. The `main` will be used to code your mod and the `upstream` will be used to keep your mod updated.
Thank you for considering contributing to DDNet-Skeleton. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).

This repository comes with an automatic Github Action, **Rebase from Skeleton**, that will sync the `upstream` changes from the skeleton to your `upstream` branch every day. In order to use that you need to activate Actions within **Actions Tab** in your repository.
## License

This repository also comes with a Github Action that syncs with the DDNet repository. **The Rebase from DDNet action should be removed from your repository.**

## What changes?

Below are the changes made on top of the DDNet version:

- Comments DDNet table creation.
- Comments all DDNet commands related.
- Comments all DDNet config options related.
- Comments DDNet score thread initializer.
- Implements a map rotation system.
- Add new configs options: `sv_self_kill` and `sv_spectable`.
- Add mod name constant that displays on chat (among with the server browser game type).
- Add version constants after DDNet version.
- Add dynamic max health and dynamic max shield support.
- Bring back the ammo amount parameter to give weapon function.
- Bring back the damage parameter to projectile entity.
- Bring back the teams system from Teeworlds.

## Important Instructions

Below are some instructions you should be aware of for game type modification.

### Mod Version

`src/game/version.h` - Change the information about your mod.

***Editable Constants***

- `GAME_MOD_NAME` - Game mod name.
- `GAME_MOD_RELEASE_VERSION` - Game mod version.
- `GAME_TYPE_NAME` - In game mod name (Server browser).
- `TEST_TYPE_NAME` - In game mod name on testing (Server browser).

### Game Type

- `src/game/server/gamecontroller.cpp ~ m_GameFlags` - Defines the type of game mode.

***Possible Values***

- `0` - Unified Team
- `GAMEFLAG_TEAMS` - Red and Blue team
- `GAMEFLAG_TEAMS | GAMEFLAG_FLAGS` - Red and Blue team with Flags

### Mod Information

- `src/game/server/ddracechat.cpp ~ ConInfo` - Changes the /info messages command.
- `src/game/server/ddracechat.cpp ~ ConCredits` - Changes the /credits messages command.
- `src/game/server/ddracechat.cpp ~ ConSettings` - Changes the /settings listing messages command.

### Game Information Flags

- `src/game/server/gamecontroller.cpp ~ pGameInfoEx->m_Flags` - Some instructions about how the server works for the client.

***Info Flags***

- `GAMEINFOFLAG_TIMESCORE` - Uses time scoring on Tab and Top 1,2 instead of points scoring.
- `GAMEINFOFLAG_UNLIMITED_AMMO` - Send information to the client that all guns have unlimited ammo.
- `GAMEINFOFLAG_RACE_RECORD_MESSAGE` - Send information to the client that the server may send a "new record" message on chat.
- `GAMEINFOFLAG_ALLOW_EYE_WHEEL` - Enable eye wheel on the emojis menu on client side.
- `GAMEINFOFLAG_ALLOW_HOOK_COLL` - ???

***Other Flags***

- `GAMEINFOFLAG_BUG_DDRACE_GHOST` - Fix a bug with ghost recording on client side.
- `GAMEINFOFLAG_BUG_DDRACE_INPUT` - Fix motion bug in specific situations on client side (Example: try to move with chat enabled).
- `GAMEINFOFLAG_PREDICT_DDRACE` - Enable DDrace prediction situations (???).
- `GAMEINFOFLAG_PREDICT_DDRACE_TILES` - Enable DDRace prediction tiles (Remove if your mod changes the DDRace tiles).
- `GAMEINFOFLAG_ENTITIES_DDNET` - Send to the client that the server uses the DDRace entities.

***Game Flags***

- `GAMEINFOFLAG_GAMETYPE_DDNET` - Send information to the client that the game mode is DDNet.
- `GAMEINFOFLAG_GAMETYPE_PLUS` - Send information to the client that the game mode is Vanilla+ (Supports Eye Wheel).

***Legacy Flags***

- `GAMEINFOFLAG_GAMETYPE_RACE` - Do the same thing as `GAMEINFOFLAG_GAMETYPE_DDNET` but for older clients.
- `GAMEINFOFLAG_GAMETYPE_DDRACE` - Do the same thing as `GAMEINFOFLAG_GAMETYPE_DDNET` but for older clients.
- `GAMEINFOFLAG_ENTITIES_DDRACE` - Do the same thing as `GAMEINFOFLAG_ENTITIES_DDNET` but for older clients.
- `GAMEINFOFLAG_ENTITIES_RACE` - Do the same thing as `GAMEINFOFLAG_ENTITIES_DDNET` but for older clients.

### Game Context

Important files/functions for how the game handles the rounds, teams, points, player management and time limit.

***Default GameController***

- `src/game/server/gamecontroller.cpp ~ IGameController` - Control the start of the game context (Set sudden death, teams points and others).
- `src/game/server/gamecontroller.cpp ~ GetTeamName` - Define the teams name (Also for unified team).
- `src/game/server/gamecontroller.cpp ~ OnEntity` - Handle spawn entities on the map.
- `src/game/server/gamecontroller.cpp ~ StartRound` - Control the start of the round (Also control if the round will start or not).
- `src/game/server/gamecontroller.cpp ~ EndRound` - Control the end the round.
- `src/game/server/gamecontroller.cpp ~ GetAutoTeam` - Define the start team for new players.
- `src/game/server/gamecontroller.cpp ~ Snap` - Control the information about team scoring, rounds limit, current round, points limits, time limits and others.
(Set CNetObj_GameData to enable team points display on right-down).

***Mod GameController***

- `src/game/server/gamemodes/DDRace.cpp ~ HandleCharacterTiles` - Handle the tiles actions when player relay on it.
- `src/game/server/gamemodes/DDRace.cpp ~ OnCharacterSpawn` - Handle the character spawn (Give specific weapons, set health, set shield).
- `src/game/server/gamemodes/DDRace.cpp ~ OnPlayerConnect` - Handle the player connection (get data, spawn, login, etc...)
- `src/game/server/gamemodes/DDRace.cpp ~ OnPlayerDisconnect` - Handle the player disconnection (get rebalanced, penalty, etc...)
- `src/game/server/gamemodes/DDRace.cpp ~ DoTeamChange` - Handle the player change team action (can be used to check if the player can change team).

***Other Contexts***

- `src/game/server/gamecontext.cpp ~ OnInit` - Control tunings such as player collision, hook collision (Also to change DDNet gun & shotgun tunning).
- `src/game/server/gamecontext.cpp ~ ResetTuning` - Change tunning reset params (Also to change DDNet gun & shotgun tunning).

- `src/game/server/score.cpp ~ CScore` - To re-enable the top score thread by DDNet.
- `src/game/server/score.cpp ~ LoadPlayerData` - To re-enable the player score thread by DDNet.

### Weapons & Damage

Important files/functions if you would like to change how weapons and projectiles works.

***Character***
- `src/game/server/entities/character.cpp ~ FireWeapon` - Handle what kind of thing every weapon will throw (To revert DDNet changes).
- `src/game/server/entities/character.cpp ~ TakeDamage` - Handle how the player hit will take the damage.

***Projectile***
- `src/game/server/entities/projectile.cpp ~ GetPos` - Handle the position calculation of the projectile.
- `src/game/server/entities/projectile.cpp ~ Tick` - Handle the tick of the projectile (if have new position, what will happen if it reach something).

***Pick Up***
- `src/game/server/entities/pickup.cpp ~ Reset` - Handle the PickUp respawn delay (To revert DDNet changes).
- `src/game/server/entities/pickup.cpp ~ Tick` - Handle the PickUp respawn time and ammo giving (To revert DDNet changes).
- `src/game/server/entities/pickup.cpp ~ TickPaused` - Handle the PickUp respawn time on paused (To revert DDNet changes).
- `src/game/server/entities/pickup.cpp ~ Snap` - Handle the PickUp visibility on cooldown (Tor revert DDNet changes).
DDNet-Skeleton is an open-sourced software licensed under the license at [license.txt](license.txt).
7 changes: 7 additions & 0 deletions src/game/server/ddracechat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,13 @@ void CGameContext::ConProtectedKill(IConsole::IResult *pResult, void *pUserData)
if(!pChr)
return;

// DDNet-Skeleton
if(!g_Config.m_SvSelfKill)
{
pSelf->SendChatTarget(pResult->m_ClientID, "You cannot kill your self.");
return;
}

int CurrTime = (pSelf->Server()->Tick() - pChr->m_StartTime) / pSelf->Server()->TickSpeed();
if(g_Config.m_SvKillProtection != 0 && CurrTime >= (60 * g_Config.m_SvKillProtection) && pChr->m_DDRaceState == DDRACE_STARTED)
{
Expand Down
6 changes: 3 additions & 3 deletions src/game/server/ddracecommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,16 +347,16 @@ void CGameContext::ConKill(IConsole::IResult *pResult, void *pUserData)
return;
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];

if(!pPlayer || (pPlayer->m_LastKill && pPlayer->m_LastKill + pSelf->Server()->TickSpeed() * g_Config.m_SvKillDelay > pSelf->Server()->Tick()))
return;

// DDNet-Skeleton
if(!g_Config.m_SvSelfKill)
{
pSelf->SendChatTarget(pResult->m_ClientID, "You cannot kill your self.");
return;
}

if(!pPlayer || (pPlayer->m_LastKill && pPlayer->m_LastKill + pSelf->Server()->TickSpeed() * g_Config.m_SvKillDelay > pSelf->Server()->Tick()))
return;

pPlayer->m_LastKill = pSelf->Server()->Tick();
pPlayer->KillCharacter(WEAPON_SELF);
//pPlayer->m_RespawnTick = pSelf->Server()->Tick() + pSelf->Server()->TickSpeed() * g_Config.m_SvSuicidePenalty;
Expand Down
43 changes: 5 additions & 38 deletions src/game/server/entities/pickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <game/server/gamecontext.h>
#include <game/server/player.h>

#include <game/generated/server_data.h>
#include <game/server/teams.h>
#include <game/version.h>

Expand All @@ -26,8 +27,8 @@ CPickup::CPickup(CGameWorld *pGameWorld, int Type, int SubType, int Layer, int N

void CPickup::Reset()
{
// if (GetPickUpRespawnDelay(m_Type) > 0)
// m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * GetPickUpRespawnDelay(m_Type);
// if (g_pData->m_aPickups[m_Type].m_Spawndelay > 0)
// m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * g_pData->m_aPickups[m_Type].m_Spawndelay;
// else
// m_SpawnTick = -1;

Expand Down Expand Up @@ -103,7 +104,7 @@ void CPickup::Tick()
{
pChr->GiveWeapon(m_Subtype);

// RespawnTime = GetPickUpRespawnTime(m_Type);
// RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;

if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE, pChr->TeamMask());
Expand All @@ -121,7 +122,7 @@ void CPickup::Tick()
{
// activate ninja on target player
pChr->GiveNinja();
// RespawnTime = GetPickUpRespawnTime(m_Type);
// RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;

// loop through all players, setting their emotes
// CCharacter *pC = static_cast<CCharacter *>(GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER));
Expand Down Expand Up @@ -215,38 +216,4 @@ void CPickup::Move()
}
m_Pos += m_Core;
}
}

// DDNet-Skeleton
// 0 = health, 1 = armor, 2 = weapon, 3 = ninja
int CPickup::GetPickUpRespawnTime(int Type)
{
if(Type == 0)
{
return 15;
}
if(Type == 1)
{
return 15;
}
if(Type == 2)
{
return 15;
}
if(Type == 3)
{
return 15;
}

return 0;
}

int CPickup::GetPickUpRespawnDelay(int Type)
{
if(Type == 3)
{
return 90;
}

return 0;
}
4 changes: 0 additions & 4 deletions src/game/server/entities/pickup.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ class CPickup : public CEntity

void Move();
vec2 m_Core;

// DDNet-Skeleton
virtual int GetPickUpRespawnTime(int Type);
virtual int GetPickUpRespawnDelay(int Type);
};

#endif
7 changes: 7 additions & 0 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,13 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
return;
}

// DDNet-Skeleton
if(!g_Config.m_SvSelfKill)
{
SendChatTarget(ClientID, "You cannot kill your self.");
return;
}

pPlayer->m_LastKill = Server()->Tick();
pPlayer->KillCharacter(WEAPON_SELF);
pPlayer->Respawn();
Expand Down
18 changes: 13 additions & 5 deletions src/game/server/gamecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ bool IGameController::CanSpawn(int Team, vec2 *pOutPos, int DDTeam)
Eval.m_FriendlyTeam = Team;

// first try own team spawn, then normal spawn and then enemy
EvaluateSpawnType(&Eval, 0 + (Team & 1), DDTeam);
EvaluateSpawnType(&Eval, 1 + Team, DDTeam);
if(!Eval.m_Got)
{
EvaluateSpawnType(&Eval, 0, DDTeam);
if(!Eval.m_Got)
EvaluateSpawnType(&Eval, 0 + ((Team + 1) & 1), DDTeam);
EvaluateSpawnType(&Eval, 1 + (1 - Team), DDTeam);
}
}
else
Expand Down Expand Up @@ -573,6 +573,8 @@ void IGameController::Tick()
}
}

DoWinCheck();

DoActivityCheck();
}

Expand All @@ -594,7 +596,7 @@ void IGameController::Snap(int SnappingClient)
pGameInfoObj->m_WarmupTimer = m_Warmup;

// pGameInfoObj->m_ScoreLimit = 0;
// pGameInfoObj->m_TimeLimit = g_Config.m_SvTimelimit;
// pGameInfoObj->m_TimeLimit = g_Config.m_SvTimeLimit;

pGameInfoObj->m_RoundNum = (str_length(g_Config.m_SvMapRotation) && g_Config.m_SvRoundsPerMap) ? g_Config.m_SvRoundsPerMap : 0;
pGameInfoObj->m_RoundCurrent = m_RoundCount + 1;
Expand Down Expand Up @@ -846,14 +848,20 @@ bool IGameController::IsTeamplay()
return m_GameFlags & GAMEFLAG_TEAMS;
}

void IGameController::DoWinCheck()
{
if(g_Config.m_SvTimeLimit > 0 && (Server()->Tick() - m_RoundStartTick) >= g_Config.m_SvTimeLimit * Server()->TickSpeed() * 60)
EndRound();
}

void IGameController::QueueMap(const char *pToMap)
{
str_copy(m_aQueuedMap, pToMap, sizeof(m_aQueuedMap));
}

bool IGameController::IsWordSeparator(char c)
{
return c == ';' || c == ' ' || c == ',' || c == '\t';
return c == ';' || c == ',' || c == '\t';
}

void IGameController::GetWordFromList(char *pNextWord, const char *pList, int ListIndex)
Expand Down Expand Up @@ -996,7 +1004,7 @@ void IGameController::CycleMap()

char aBufMsg[256];
str_format(aBufMsg, sizeof(aBufMsg), "rotating map to %s", aBuf);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBufMsg);
ChangeMap(aBuf);
}

Expand Down
1 change: 1 addition & 0 deletions src/game/server/gamecontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class IGameController
char m_aPreviousMap[MAX_MAP_LENGTH];

bool IsTeamplay();
void DoWinCheck();

struct CMapRotationInfo
{
Expand Down
Loading

0 comments on commit 52eda9f

Please sign in to comment.