Jekyll2019-08-26T16:53:20+00:00http://darshan3.github.io/feed.xmlDarshan TankMy Personal Blog: https://darshan3.github.ioGSoC Wrap Up!2019-08-26T00:00:00+00:002019-08-26T00:00:00+00:00http://darshan3.github.io/gsoc-wrap-up<p>Today marks the final day of my GSoC journey! I had always wished to participate in this prestigious program but could never enter the world of OpenSource, until I stumbled upon The Terasology Foundation! I love games and coding, how about combining them both?! Terasology is a voxel-based sandbox game with various gameplay modes and extensible through lots of modules. My project was to extend the Light and Shadow gameplay module and complete a basic Capture-The-Flag mode with many other features!</p>
<p>The journey was a full rollercoaster ride with many ups and downs. At times I found myself immersed for hours to ultimately find the bug with a one line solution! I learnt a lot about the Entity-Component-System architechture, the ‘multi-faceted’ World Generation along with skills like maintaining code quality, documenting, testing and debugging.</p>
<h1 id="features-added">Features Added</h1>
<h2 id="gameplay-features">Gameplay features</h2>
<p>A lot of basic gameplay features were added to take the Gameplay Arc of my project to completion. Check my PRs to know more! I also had to deal with certain other problems like correction of the mesh of players and game UI which weren’t originally the part of the planned project.</p>
<p><strong>Game Over screen with Statistics:</strong>
<img src="/images/gsoc-wrap-up/stats.png" alt="Game Over screen with Statistics" /></p>
<h2 id="towers">Towers</h2>
<p>Towers were perhaps the most time-consuming part of my project. We discussed several implementations and studied other modules like MultiBlock, StructureTemplates before deciding to go forward with the current implementation. Currently, Towers exist as a single block which can be placed wherever you want. Then you have to interact with it to get to activate it.</p>
<p><strong>Rook based Tower:</strong>
<img src="/images/gsoc-wrap-up/tower.png" alt="Rook based Tower" /></p>
<p><strong>What is left?</strong>
Towers need to be made modular so that they can be used with the other module ‘GooeyDefence’.</p>
<h2 id="markets">Markets</h2>
<p>Markets module was created by me to add a barter system based buying. Barter System was chosen so that we can have players mine for certain resources to buy the items instead of just resources. It also helps us implement an upgrading system where a more powerful weapon can be bought only in exchange for some other weapon. One needs to add <code class="highlighter-rouge">Purchasable Component</code> to an item to add it to Market.</p>
<p><strong>Market Screen:</strong> (Pardon the icon size)
<img src="/images/gsoc-wrap-up/market.png" alt="Market Screen" /></p>
<p><strong>What is left?</strong>
The current state of this module is such that buy is implemented to work in exchange for a single item. The multi-item and block removal system has been implemented and awaiting merge. Once it gets merged, Basic Market would be complete.</p>
<h2 id="minimap">Minimap</h2>
<p>Minimap module was currently supported only for a single user. I extended the functionality for Multiplayer mode and also added support for custom icons instead of the arrow.</p>
<p><strong>Spades and Hearts showing different team players on Minimap:</strong>
<img src="/images/gsoc-wrap-up/minimap.png" alt="Spades and Hearts showing different team players on Minimap" /></p>
<h2 id="weapons">Weapons</h2>
<p>I extended the basic staff based weapon in CombatSystem module, combined with some AlterationEffects and gave it LightAndShadow Twist. The weapons are based on the Classic Card Game Symbols.</p>
<ul>
<li><strong>Hearts Staff:</strong> Attracts the enemy towards you</li>
<li><strong>Spades Staff:</strong> Repels the enemy away from you</li>
<li><strong>Diamonds Staff:</strong> Stuns the enemy</li>
<li><strong>Clubs Staff:</strong> Adds Poison damage to the enemy</li>
</ul>
<p><strong>The LaS Weapons!:</strong> (Thank You Tejas ‘majordwarf’ Tank for the custom textures :D)
<img src="/images/gsoc-wrap-up/weapons.png" alt="The LaS Weapons!" /></p>
<h2 id="world-generation">World Generation</h2>
<p>World generation was the most different feature I came across during this project. The concepts were very different and this wiki was very helpful to understand them. I implement a small arena with surrounding regions raised. I also tried to add a small ying-yang pedestal at the center.</p>
<p><strong>LaS Game Arena:</strong>
<img src="/images/gsoc-wrap-up/world.png" alt="LaS Game Arena" /></p>
<h1 id="contribution-summary">Contribution Summary</h1>
<h2 id="lightandshadow">LightAndShadow:</h2>
<ul>
<li>Health HUD reskinning based on team <a href="https://github.com/Terasology/LightAndShadow/pull/79">#79</a></li>
<li>Changing player skins through skeletal mesh <a href="https://github.com/Terasology/LightAndShadow/pull/80">#80</a></li>
<li>Respawn and heal player on death <a href="https://github.com/Terasology/LightAndShadow/pull/82">#82</a></li>
<li>Handle inventory on death <a href="https://github.com/Terasology/LightAndShadow/pull/83">#83</a></li>
<li>Added Statistics and Game Restart Systems <a href="https://github.com/Terasology/LightAndShadow/pull/88">#88</a></li>
<li>Destroy dropped items on death after a delay<a href="https://github.com/Terasology/LightAndShadow/pull/89">#89</a> (Closed due to #93)</li>
<li>Health hud fix for reconnects and restarts <a href="https://github.com/Terasology/LightAndShadow/pull/90">#90</a></li>
<li>Game Restart Implementation <a href="https://github.com/Terasology/LightAndShadow/pull/91">#91</a></li>
<li>Player Statistics Implementation <a href="https://github.com/Terasology/LightAndShadow/pull/92">#92</a></li>
<li>Teleport flag after delay on drop <a href="https://github.com/Terasology/LightAndShadow/pull/89">#93</a></li>
<li>Clear game over screen on close <a href="https://github.com/Terasology/LightAndShadow/pull/95">#95</a></li>
<li>Teleport Held Flags on Restart <a href="https://github.com/Terasology/LightAndShadow/pull/96">#96</a></li>
<li>Restart permission <a href="https://github.com/Terasology/LightAndShadow/pull/97">#97</a></li>
<li>Halt sun on game start <a href="https://github.com/Terasology/LightAndShadow/pull/100">#100</a></li>
<li>LAS Global Entity Implementation <a href="https://github.com/Terasology/LightAndShadow/pull/101">#101</a></li>
<li>Remove statistics wigdet in deathscreen when it is closed <a href="https://github.com/Terasology/LightAndShadow/pull/103">#103</a></li>
<li>Integrate minimap with LASTeam based icons <a href="https://github.com/Terasology/LightAndShadow/pull/104">#104</a></li>
<li>Implement LightAndShadow Capture-The-Flag World! <a href="https://github.com/Terasology/LightAndShadow/pull/105">#105</a></li>
</ul>
<h2 id="engine">Engine:</h2>
<ul>
<li>Fix for Incorrect VisualCharacter entity <a href="https://github.com/MovingBlocks/Terasology/pull/3686">#3686</a></li>
<li>Fix getText() function in UIText <a href="https://github.com/MovingBlocks/Terasology/pull/3689">#3689</a></li>
<li>VisualCharacterSystemTest Fix and Whitelist PermissionManager <a href="https://github.com/MovingBlocks/Terasology/pull/3695">#3695</a></li>
</ul>
<h2 id="other-modules">Other Modules</h2>
<ul>
<li>Basic Implementation for Towers <a href="https://github.com/Terasology/Towers/pull/1">#1</a></li>
<li>Basic Implementation for Market <a href="https://github.com/Terasology/Market/pull/1">#1</a></li>
<li>Add remove command <a href="https://github.com/Terasology/Inventory/pull/1">#1</a></li>
<li>Implement multiplayer support for minimap <a href="https://github.com/Terasology/Minimap/pull/10">#10</a></li>
<li>Add support for custom icons for players <a href="https://github.com/Terasology/Minimap/pull/12">#12</a></li>
<li>Added hearts and spades icons for minimap <a href="https://github.com/Terasology/LightAndShadowResources/pull/31">#31</a></li>
<li>Added custom staff textures <a href="https://github.com/Terasology/LightAndShadowResources/pull/32">#32</a></li>
<li>Add LaS Themed Weapons! <a href="https://github.com/Terasology/LightAndShadowResources/pull/33">#33</a></li>
<li>Add Alteration effects and Impulse based weapons support <a href="https://github.com/Terasology/CombatSystem/pull/43">#43</a></li>
</ul>
<h1 id="future-plans-and-ideas">Future Plans and Ideas</h1>
<p>Live statistics screen can be added instead of online players overlay. Currently, the statistics are only shown at the game over screen.
Team balance
Entities loading incorrectly when loading a saved game.</p>
<h1 id="relevant-links">Relevant Links</h1>
<ul>
<li>Proposal: <a href="https://docs.google.com/document/d/1oCJkH3_xWyyEUc85LJE6sklgDZvNIcZU2DI0OT5pz98/edit?usp=sharing">LightAndShadowRemastered</a></li>
<li>Github: <a href="https://github.com/orgs/Terasology/projects/17">Project #17</a></li>
<li>Forum: <a href="https://forum.terasology.org/threads/gsoc-2019-light-and-shadow-remastered.2266/">Weekly Updates</a></li>
<li>Discord: #light-and-shadow at Terasology’s <a href="http://discord.gg/Terasology">discord server</a></li>
</ul>
<h2 id="repositories">Repositories</h2>
<ul>
<li><a href="https://github.com/MovingBlocks/Terasology">Engine</a></li>
<li><a href="https://github.com/Terasology/LightAndShadow">LightAndShadow</a></li>
<li><a href="https://github.com/Terasology/LightAndShadowResources">LightAndShadowResources</a></li>
<li><a href="https://github.com/Terasology/Towers">Towers</a></li>
<li><a href="https://github.com/Terasology/Market">Market</a></li>
<li><a href="https://github.com/Terasology/Minimap">Minimap</a></li>
<li><a href="https://github.com/Terasology/CombatSystem">CombatSystem</a></li>
<li><a href="https://github.com/Terasology/AlterationEffects">AlterationEffects</a></li>
</ul>
<h1 id="acknowledgements">Acknowledgements</h1>
<p>I would like to thank The Terasology Foundation and Google for providing me with this wonderful opportunity to work and contribute to Open Source. I would like to thank my mentors Tobias ‘skaldarnar’ Nett, Nihal ‘nihal111’ Singh, Iaron ‘iaronaraujo’ Araujo for their support and guidance throughout the summers. I would also like to thank Rasmus ‘cervator’ Praestholm, Quinn ‘jellysnake’ Roberts and all others who are a part of this wonderful community, for helping me whenever needed and getting acquainted with the codebase.</p>
<p>It has been a summer full of learning and there’s more, right? I would like to learn more about Terasology’s Behavior and Rendering systems in future. I would love to keep contributing to Terasology and help others coming to this organisation :D</p>Today marks the final day of my GSoC journey! I had always wished to participate in this prestigious program but could never enter the world of OpenSource, until I stumbled upon The Terasology Foundation! I love games and coding, how about combining them both?! Terasology is a voxel-based sandbox game with various gameplay modes and extensible through lots of modules. My project was to extend the Light and Shadow gameplay module and complete a basic Capture-The-Flag mode with many other features!GSoC Week 11-12: EndGame2019-08-18T00:00:00+00:002019-08-18T00:00:00+00:00http://darshan3.github.io/gsoc-week-11-12<p>Phew! Today marks end of 2 hectic weeks! The final submissions open tomorrow as I near my project completion. Read ahead to know what’s done and what’s left.</p>
<h3 id="custom-minimap-icons">Custom Minimap Icons</h3>
<p><strong>PR</strong>: Add support for custom icons for players <a href="https://github.com/Terasology/Minimap/pull/12">#12</a><br />
<strong>PR</strong>: Added hearts and spades icons for minimap <a href="https://github.com/Terasology/LightAndShadowResources/pull/31">#31</a><br />
<strong>PR</strong>: Integrate minimap with LASTeam based icons <a href="https://github.com/Terasology/LightAndShadow/pull/104">#104</a></p>
<h3 id="weapons">Weapons</h3>
<p><strong>PR</strong>: Add Alteration effects and Impulse based weapons support <a href="https://github.com/Terasology/CombatSystem/pull/43">#43</a><br />
<strong>PR</strong>: Added custom staff textures <a href="https://github.com/Terasology/LightAndShadowResources/pull/32">#32</a><br />
<strong>PR</strong>: Add LaS Themed Weapons! <a href="https://github.com/Terasology/LightAndShadowResources/pull/33">#33</a></p>
<h3 id="world-generation">World Generation</h3>
<p><strong>PR</strong>: Implement LightAndShadow Capture-The-Flag World! <a href="https://github.com/Terasology/LightAndShadow/pull/105">#105</a></p>
<h3 id="market-integration">Market Integration</h3>
<p><strong>PR</strong>: Add remove command <a href="https://github.com/Terasology/Inventory/pull/1">#1</a></p>
<h3 id="whats-next">What’s Next?</h3>
<p>Two cards remain pending on my Github board which are basically integration on Towers and Market module into Light And Shadow repository. I will complete them ASAP and write my final project blog this week!</p>Phew! Today marks end of 2 hectic weeks! The final submissions open tomorrow as I near my project completion. Read ahead to know what’s done and what’s left.GSoC Week 9-10: Prestige2019-08-06T00:00:00+00:002019-08-06T00:00:00+00:00http://darshan3.github.io/gsoc-week-9-10<p>My college started and Professor gave some urgent work for my Master’s Thesis. Hence, I got really busy with that and wasn’t able to contribute much for Gsoc work. However, with that sorted now, let’s complete LightAndShadow!</p>
<h3 id="minimap-integration">Minimap Integration</h3>
<p>There is a minimap module already in place for Terasology. However, it lacks multiplayer support. I wanted to integrate minimap in Light and Shadow, so I worked on modifying its functionality for multiplayer.<br />
Minimap module has updates the map at each default <code class="highlighter-rouge">update</code> call. I could have simply scanned for other players through
<code class="highlighter-rouge">entityManager.getEntitiesWith(AliveCharacterComponent.class)</code> here but the call has impact on performance as it iterates over entire entity pool. Hence, I am storing a HashSet of entities with <code class="highlighter-rouge">AliveCharacterComponent</code> and updating it whenever a player dies and whenever a player spawns or respawns. Iterating over this HashSet is quite fast and works like a charm!</p>
<p><strong>PR</strong>: Implement multiplayer support for minimap <a href="https://github.com/Terasology/Minimap/pull/10">#10</a></p>
<h3 id="towers">Towers</h3>
<p>I added AlterationEffects and TargetingSystem for Towers. I added a <code class="highlighter-rouge">PlayerManager</code> System to store and update HashSet of entities with <code class="highlighter-rouge">AliveCharacterComponent</code> to search for targets. This way all targets can use the same list instead of search for players again and again. For all players in the range, I add an <code class="highlighter-rouge">DamageOverTime</code> alteration effect. More effects can be added latter. The new commits have been added to the previous PR.</p>
<p><strong>PR</strong>: Basic Implementation for Towers <a href="https://github.com/Terasology/Towers/pull/1">#1</a></p>
<h3 id="whats-next">What’s Next?</h3>
<p>I am currently working on loading a custom list to be displayed in Market place. I plan to complete it and Weapons this week.</p>My college started and Professor gave some urgent work for my Master’s Thesis. Hence, I got really busy with that and wasn’t able to contribute much for Gsoc work. However, with that sorted now, let’s complete LightAndShadow!GSoC Week 8: Wolf of Wall Street2019-07-21T00:00:00+00:002019-07-21T00:00:00+00:00http://darshan3.github.io/gsoc-week-8<p>So I finally took some rest from implementing weapons based systems and started implementing ‘Market’ Module and meanwhile, also created a Towers module to push my tested code.</p>
<h3 id="market">Market</h3>
<p>Markets form a quite basic module that all other gameplays can adopt. There is always supply and demand of items.
I had to implement markets in such a way that they don’t hinder the gameplay speed much. So the implementation had to be such that people can buy items within one-two clicks without wasting much time.</p>
<p>I have added Market module in the form a screen which appears when you click a button (‘Z’ in this case). The screen has items icons listed in the left. Click them shows their details in the right column and you can buy the item by clicking the buy button.</p>
<p>One major setback here was that the ItemIcons are not interactable. So clicking them doesn’t result in any function callback. Luckily, I found UIInteraction Wrapper widget written by @jellysnake, which eased the process.</p>
<p><strong>PR</strong>: Basic Implementation for Market <a href="https://github.com/Terasology/Market/pull/1">#1</a></p>
<h3 id="towers">Towers</h3>
<p>“We are in the endgame (for Towers) now!” So, after weeks of discussions and trying various things, I settled down for this particular implementation of towers.</p>
<p>You can a single block as TowerRoot. You can place it at any strategic location you want. This block is interactable. You can interact with it to activate it. Activating displays the prefab for the tower and also adds periodic action to the tower entity to search and attack enemies at equal intervals of time.</p>
<p>I plan to add a separate Targetor module which has all sorts of enemy targetting techniques. There is an Alteration Effect module already present which can be used to apply different effects to enemies. Both of these modules will increase the flexibility of forming different types of towers.</p>
<p><strong>PR</strong>: Basic Implementation for Towers <a href="https://github.com/Terasology/Towers/pull/1">#1</a></p>
<h3 id="whats-next">What’s Next?</h3>
<p>I would try to finish implementation of Towers by adding dependency to Alteration Effects and Targetor modules as soon as possible. Once this is done, I will have to make LightAndShadow gameplay depend on Towers module and customize it. For markets, I have to add a system to check if a player has required amount of items to buy a market item. I am planning to finish this much by end of coming week.</p>So I finally took some rest from implementing weapons based systems and started implementing ‘Market’ Module and meanwhile, also created a Towers module to push my tested code.GSoC Week 5: A Quiet Place2019-06-30T00:00:00+00:002019-06-30T00:00:00+00:00http://darshan3.github.io/gsoc-week-5<p>Past week has been rather dull or quiet as I would like to put it. My mentors were busy with their exams and I was caught up in some work too. Hence, the progress has slowed down a little bit. I will surely make up for the lost time next week!</p>
<h3 id="visual-entity-test">Visual Entity Test</h3>
<p>So my fix for visual entity engine caused the builds to fail in next few prs. Some inspection showed that a unit test regarding the same was failing. However, it was working perfectly for the wrong code. Important lesson learnt: Unit Tests are as good only if you write them correctly!</p>
<p><strong>PR</strong>: VisualCharacterSystemTest Fix and Whitelist PermissionManager <a href="https://github.com/MovingBlocks/Terasology/pull/3695">#3695</a></p>
<h3 id="restart-permission">Restart Permission</h3>
<p>As you noticed above, I also sneaked in a tiny feature to whitelist the Permission manager. Now, it can be used by modules to add custom permissions. Hours of work saved which I would have spent on creating such a system on my own! Coding does go hand in hand with reusability. I changed the systems in Light and Shadow to now use permission manager.</p>
<p><strong>PR</strong>: Restart permission <a href="https://github.com/Terasology/LightAndShadow/pull/97">#97</a></p>
<h3 id="global-entity">Global Entity</h3>
<p>One major issue that I was facing was that the scores for each team weren’t getting stored. They were variables in Systems and hence not persistant. Terasology engine stores only entities and components. So after some discussion with my mentor, it was decided to create a global entity, to store all such common variables which we want to save and load.</p>
<h3 id="towers">Towers</h3>
<p>I went through another module <code class="highlighter-rouge">Gooey Defence</code>’s code. It was a good starting point as it has some good implementation of modular towers. Now, the aim is to extract out these towers into a new module, so that both Gooey Defence and Light and Shadow can use it for their use cases.</p>
<h3 id="whats-next">What’s Next?</h3>
<p>Complete the global entity thingy and Towers!</p>Past week has been rather dull or quiet as I would like to put it. My mentors were busy with their exams and I was caught up in some work too. Hence, the progress has slowed down a little bit. I will surely make up for the lost time next week!GSoC Week 4: Ready Player One2019-06-23T00:00:00+00:002019-06-23T00:00:00+00:00http://darshan3.github.io/gsoc-week-4<p>First Evaluation is here and I am (almost) done with the Gameplay Arc Phase of my GSoC! Well, ‘almost’ because there are a few tiny little fixes and adjustments here and there that can be done. As my mentor <a href="https://forum.terasology.org/members/skaldarnar.270/">@skaldarnar</a> states it, <code class="highlighter-rouge">"One can spend an (un-)reasonable amount (of time) on fine-tuning"</code>.</p>
<h3 id="handling-general-flag-drops">Handling General Flag Drops</h3>
<p>As discussed in last week’s blog, the method implemented in pull request <a href="https://github.com/Terasology/LightAndShadow/pull/89">#89</a> worked only when a player died. We wanted to implement it in such a way that whenever a player drops a flag, due to any reason, we want to teleport it back to the base after a delay. Luckily, I was able to find event <code class="highlighter-rouge">DropItemEvent</code> which all items receive on being thrown into the world. I wrote a receiver to check if the item being dropped is flag or not, just add delay event using <code class="highlighter-rouge">DelayManager</code> and tada! we are done.</p>
<p><strong>Old PR</strong>: Destroy dropped items on death after a delay <a href="https://github.com/Terasology/LightAndShadow/pull/89">#89</a><br />
<strong>New PR</strong>: Teleport flag after delay on drop <a href="https://github.com/Terasology/LightAndShadow/pull/89">#93</a></p>
<h3 id="old-statistics">Old Statistics</h3>
<p>So this minor issue <a href="https://github.com/Terasology/LightAndShadow/issues/94">#94</a> showed up after merging <a href="https://github.com/Terasology/LightAndShadow/pull/91">#91</a> and <a href="https://github.com/Terasology/LightAndShadow/pull/92">#92</a>. I was trying push statistics to the widget and not clearing them when the game over screen was closed. Due to this, statistics of previous rounds were still being displayed. Easy fix!</p>
<p><strong>Issue</strong>: Old statistics being showed after 2nd round <a href="https://github.com/Terasology/LightAndShadow/issues/94">#94</a><br />
<strong>PR</strong>: Clear game over screen on close <a href="https://github.com/Terasology/LightAndShadow/pull/95">#95</a></p>
<h3 id="more-updates-to-restart-system">More Updates to Restart System</h3>
<p>I added one major improvement to the restart system I added last week. It turns out that when two people had flags and one of them captures it first, if it results in a win, then we teleported all the players back to their bases. So the other player with flag still had it. I checked for all entities with <code class="highlighter-rouge">HeldFlagComponent</code> and did the needful.</p>
<p><strong>PR</strong>: Teleport Held Flags on Restart <a href="https://github.com/Terasology/LightAndShadow/pull/96">#96</a></p>
<h3 id="restart-permissions">Restart Permissions</h3>
<p>After merging <a href="https://github.com/Terasology/LightAndShadow/pull/91">#91</a>, it was decided to display restart button to only those who could interact with it. It also works only for server-client systems and not on a headless server. So I figured out that we can use the existing <code class="highlighter-rouge">PermissionManager</code> to add a custom permission and only display button to those with the permission. We can use the core command <code class="highlighter-rouge">givePermission</code> to allow certain users to restart in a headless server setup. However, <code class="highlighter-rouge">PermissionManager</code> isn’t whitelisted. Once we add it to whitelist, we are done! The work is currently in progress in branch.</p>
<p><strong>Branch</strong>: <a href="https://github.com/Terasology/LightAndShadow/tree/RestartPermission">[WIP]RestartPermission</a></p>
<h3 id="whats-next">What’s Next?</h3>
<p>I will try to finish RestartPermission once the <code class="highlighter-rouge">PermissionManager</code> is whitelisted. We are done with major gameplay features, time to add some weapons and towers!</p>First Evaluation is here and I am (almost) done with the Gameplay Arc Phase of my GSoC! Well, ‘almost’ because there are a few tiny little fixes and adjustments here and there that can be done. As my mentor @skaldarnar states it, "One can spend an (un-)reasonable amount (of time) on fine-tuning".GSoC Week 3: Sherlock2019-06-16T00:00:00+00:002019-06-16T00:00:00+00:00http://darshan3.github.io/gsoc-week-3<p>Last week was quite frustrating! You must have noticed by now that I am naming my GSoC weekly blogs after movies. So, I decided to name it after my favorite fictional detective’s movie to symbolize all the detective work it took this week to hunt down the source of bugs.</p>
<h3 id="the-incorrect-visual-entity">The Incorrect Visual Entity</h3>
<p>So, it turned out that player skinning method did not work for one specific test case. This problem had me scratching my head for quite some days. The code seemed to be correct but did not seem to work. So after lots of logging, debugging and sleepless nights, I was finally able to trace down the root of the issue! There was a minor mistake in game engine’s implementation for visual entity which I immediately corrected and I finally took a breathe of relief!</p>
<p><strong>Issue</strong>: VisualCharacter Entity is being set for local character too for clients <a href="https://github.com/MovingBlocks/Terasology/issues/3685">#3685</a><br />
<strong>PR</strong>: Fix for Incorrect VisualCharacter entity <a href="https://github.com/MovingBlocks/Terasology/pull/3686">#3686</a></p>
<h3 id="the-trailing-whitespace">The Trailing Whitespace</h3>
<p>Sometimes, it is the tiny things that do matter a lot. A missing semicolon can make you busy with hours of debugging. Another big issue showed up, which led to game not being loaded correctly if a saved game was present. I really liked debugging this one. It turned out a recent change in UI widget was returning an extra trailing whitespace character which broke a lot of systems. Lesson learnt: Pay attention to the tiny details!</p>
<p><strong>Issue</strong>: Terrible things happen when starting a <em>second</em> game without a game restart <a href="https://github.com/MovingBlocks/Terasology/issues/3688">#3688</a>
<strong>PR</strong>: Fix getText() function in UIText <a href="https://github.com/MovingBlocks/Terasology/pull/3689">#3689</a></p>
<h3 id="fixing-health-hud">Fixing Health Hud</h3>
<p>It turned out that event based method to change Health Hud wasn’t working well. The Hud would only change only when the event was recieved. Hence, when a player leaves the game and rejoins, aur loads a saved game, the Health hud would go back to white. Hence I implemented a fix similar last week’s skeletal mesh fix <a href="https://github.com/Terasology/LightAndShadow/pull/80">#80</a> based a persisting LASTeam component.</p>
<p><strong>PR</strong>: Health hud fix for reconnects and restarts <a href="https://github.com/Terasology/LightAndShadow/pull/90">#90</a></p>
<h3 id="fixing-game-restart-and-player-statistics">Fixing Game Restart and Player Statistics</h3>
<p>I finally figured out how multiplayer systems work and got quite comfortable with it. I refactored the code for restart implemented in a correct way and created a new pull request. There was a minor issue in player statistics wherein the remote clients were not being able to see other players’ details. I tested it out and it turned out be an engine issue. I was fortunately able to find a workaround the same.</p>
<p><strong>Issue</strong>: ‘entityManager.getEntitiesWith(ClientComponent.class)’ not working on Remote Clients <a href="https://github.com/MovingBlocks/Terasology/issues/3693">#3693</a><br />
<strong>PR</strong>: Game Restart Implementation <a href="https://github.com/Terasology/LightAndShadow/pull/91">#91</a><br />
<strong>PR</strong>: Player Statistics Implementation <a href="https://github.com/Terasology/LightAndShadow/pull/92">#92</a></p>
<h3 id="handling-item-drops">Handling Item Drops</h3>
<p>This was another issue I worked on, this week. When items are dropped after a player’s death, they should be destroyed after some delay and flag should be teleported back to base. However, after some discussion it was decided that there should be a general implementation such that whenever an item is dropped or thrown, above mentioned things should happedn. Hence, this pr will be closed and I will try to find an alternative.</p>
<p><strong>PR</strong>: Destroy dropped items on death after a delay <a href="https://github.com/Terasology/LightAndShadow/pull/89">#89</a></p>
<h3 id="whats-next">What’s Next?</h3>
<p>This almost completes my first month of work for GSoC. I will try to find an alternate solution <a href="https://github.com/Terasology/LightAndShadow/pull/89">#89</a> and implement auto restart and other minor issues. I will also try to refactor and document the entire LightandShadow code before the First Evaluation!</p>Last week was quite frustrating! You must have noticed by now that I am naming my GSoC weekly blogs after movies. So, I decided to name it after my favorite fictional detective’s movie to symbolize all the detective work it took this week to hunt down the source of bugs.GSoC Week 2: Total Restart!2019-06-09T00:00:00+00:002019-06-09T00:00:00+00:00http://darshan3.github.io/gsoc-week-2<p>Another week of GSoC has flew by! This week, I worked on implementing Game Restart and Player Statistics systems. I learnt a lot about implementing things correctly for a multiplayer gameplay through trial-and-error.</p>
<h3 id="player-statistics-system">Player Statistics System</h3>
<p>Player Statistics system includes storing information about kills and deaths of player in the game. It is necessary to store a statistics in a way such that everyone who is playing can check them. However, no one except the main server should be able to make changes to it. So, a <code class="highlighter-rouge">PlayerStatistics</code> Component was added to the player with its fields marked with <code class="highlighter-rouge">@Replicate</code>. Terasology engine does not copy all the components from server to clients. Hence it is necessary to mark the fields and components, which we want each player/client to have access to, with <code class="highlighter-rouge">@Replicate</code>. Default replication mode is Server-to-Client which just suits our needs! Next, task was to add a system to modify this component. Similar to Components, Terasology engine provides a way to separate where a particular system is going to run. Hence, a simple <code class="highlighter-rouge">RegisterMode.Authority</code> does the trick to ensure that the given system runs only on server.</p>
<p>Now, once the game is over and Game Over Screen is displayed, we need to display the Statistics correctly too. Hence, I used <code class="highlighter-rouge">migLayout</code> for this purpose which functions essentially as a table layout. You go on adding cells to a row and specify when to change to a new row. More details can be found <a href="https://github.com/Terasology/TutorialNui/wiki/MigLayout">here</a>.</p>
<p>Here’s the final outcome:
<img src="/images/gsoc-week-2/stats-1.png" alt="Game Over Screen" /></p>
<h3 id="game-restart-system">Game Restart System</h3>
<p>Events are always replicated as opposed to Components. One can specify which the type of replication through annotations like <code class="highlighter-rouge">@ServerEvent</code>, <code class="highlighter-rouge">@BroadcastEvent</code>, etc. You can read more about it <a href="https://github.com/MovingBlocks/Terasology/wiki/Entities%2C-Components-and-Events-on-the-Network">here</a>. So, I used a ServerEvent when Restart Button is pressed to prevent clients from any kind of cheating. Then, once relevant changes are done on server, I used a BroadcastEvent to specify all the clients that restart process has completed.</p>
<p><strong>PR</strong>: Added Statistics and Game Restart Systems <a href="https://github.com/Terasology/LightAndShadow/pull/88">#88</a></p>
<h3 id="problems-with-player-skinning">Problems with Player Skinning</h3>
<p>Some bugs were discovered in a pr I worked during Community Bonding period. I was saving the <code class="highlighter-rouge">SkeletalMesh</code> Component after modifying it but it was discovered that <code class="highlighter-rouge">VisualCharacter</code> Entity that holds this component is not replicated on clients. Hence, I used another component <code class="highlighter-rouge">LASTeam</code>, which is replicated to clients, to modify the skeletal mesh everytime a character is spawned or the <code class="highlighter-rouge">LASTeam</code> Component is changed. It now works correctly when a player leaves and joins again or even if the game loaded from a save file.</p>
<p><strong>PR</strong>: Changing player skins through skeletal mesh <a href="https://github.com/Terasology/LightAndShadow/pull/80">#80</a></p>
<p>How it looks now:
<img src="/images/gsoc-week-2/skin-1.png" alt="Player skinning" /></p>
<h3 id="whats-next">What’s Next?</h3>
<p>I am planning to work on minor but essential things pending for Gameplay system like automatically taking flag back to base if they haven’t been taken by anyone for some time after dropping, randomizing spawn position, ensuring that loading game from save file works properly, etc.</p>Another week of GSoC has flew by! This week, I worked on implementing Game Restart and Player Statistics systems. I learnt a lot about implementing things correctly for a multiplayer gameplay through trial-and-error.GSoC Week 1: Die Hard (Or Not!)2019-06-02T00:00:00+00:002019-06-02T00:00:00+00:00http://darshan3.github.io/gsoc-week-1<p>GSoC official coding period began this week. I worked on what happens when a player dies in-game this week. The github project card can be found <a href="https://github.com/orgs/Terasology/projects/17#card-21937677">here</a>.</p>
<h3 id="handling-death">Handling Death</h3>
<p>In the normal gameplay mode of Terasology, when a player dies, you are shown a death screen with the reason of your death. You disappear from the game play area. However, we are aiming at fast-paced capture-the-flag type gameplay for Light and Shadow. We want the player to teleport back to its team’s base and health should be refilled to 100%.</p>
<p>I initially struggled to get this right without breaking other systems. A player’s death is indicated to the client through the <code class="highlighter-rouge">PlayerDeath</code> Event. This is send from a system which handles destruction of the entities by capturing <code class="highlighter-rouge">BeforeDestroy</code> Event. I created a new method with higher priority to capture and consume the <code class="highlighter-rouge">BeforeDestroy</code> Event. Now I use two other events <code class="highlighter-rouge">DoHeal</code> and <code class="highlighter-rouge">CharacterTeleport</code> to refill the dead player’s health and send it back to its base.</p>
<p><strong>PR</strong>: Respawn and heal player on death <a href="https://github.com/Terasology/LightAndShadow/pull/82">#82</a></p>
<h3 id="handling-inventory">Handling Inventory</h3>
<p>Next task was to empty the inventory of the dead player. However, we can’t delect the player’s <code class="highlighter-rouge">MagicStaff</code> weapon since it is given only once to the players. This task was quite straight forward. I just iterated through the inventory and if the item was not the <code class="highlighter-rouge">MagicStaff</code>, I dropped the all the items in the corresponding inventory slot.</p>
<p><strong>PR</strong>: Handle inventory on death <a href="https://github.com/Terasology/LightAndShadow/pull/83">#83</a></p>
<h3 id="whats-next">What’s Next?</h3>
<p>Now we move on to resetting the game once one of the team wins. We need to clear the gameplay region and take players to their respective bases. This will be followed by addition of StatSystem to store the various game statistics like kills, deaths, etc.</p>GSoC official coding period began this week. I worked on what happens when a player dies in-game this week. The github project card can be found here.Hello World!2019-05-22T00:00:00+00:002019-05-22T00:00:00+00:00http://darshan3.github.io/hello-world<p>Hello everyone!</p>
<p>It is said that a journey of thousand miles begins with a single step. So I finally decided to create my own blog. I will be posting about my experiences, adventures and any interesting stuff that I come across.</p>
<p>Stay tune!</p>Hello everyone!