#unitbase
Explore tagged Tumblr posts
zephthepto · 7 months ago
Text
Nebula topic 2 - Battle manager system
Our game was designed to be a turn based game, meaning that only one character can be doing actions at any given time, and that they can only do a single action during any point in their turn. This was a gameplay system that needed considerable planning otherwise things could easily break. 
There were several pitfalls I wanted to avoid when designing this system:
Having multiple characters thinking its their turn to do an action
Having a character start one action while already doing another
Having characters do actions despite being dead
Having the battle stuck on a dead character’s turn
Unfortunately, I had fallen into these pitfalls and many more plenty of times throughout the development of this system. The system has undergone 3 major iterations so far, and I currently see the latest one as an overall very elegant solution.
The first iteration of the system was being designed from the ground up. I was focusing a lot of effort on the planning of this solution to build a very stable foundation for everything else to be built atop of. From the beginning, I was aiming for maximising the modularity of the systems, meaning that even as this evolved, the surrounding systems didn’t need to care about the exact implementation to produce the results they were supposed to produce.
The general idea of this system is quite simple; there is to be a singleton BattleManager which is the main heart of the operation. This prepares a battle, taking all of the participants and tells them to prepare before the battle begins. Once all the preparations are done, it looks at its queue and tells the first unit to begin its turn, by which point it waits for a response back from the unit that its turn has completed. When this happens, it checks if the battle should be over, and if not, it shifts the active unit to the back of the queue and repeats the process until the battle is determined to be over.
The units in this case are represented by a UnitTurnController script which gets attached to objects that already have a UnitBase script. This UnitTurnController script handles every action a unit may choose to do on their turn, namely using cards, doing movement and ending their turn. This of course comes with plenty of utility functions too while also outsourcing the complex actions to their own managers, namely the CardEffectManager and the MovementManager. This script then gets inherited from to create the PlayerTurnController and NPCTurnController, which are used for the player character and any non player characters respectively. Each of these overrides several functions to allow the relevant systems to interface with them. For instance, the PlayerTurnController interfaces with certain UI elements to tell the player what they are able to do at any given point, and allows the player to make actions on behalf of their character. On the other hand, we have the NPC turn controller who would have an algorithm controlling what choices they make. 
Tumblr media
It may be hard to make out the exact details of the illustration, but this general plan has been developed further into a more specific, sectioned flow chart. This illustrates relevant scripts in the saturated title boxes, following an internally consistent colour scheme I used for development. The overarching idea here is that the battle manager has a loop which continues whenever it is told a turn has been completed. This happens when a given UnitTurnController’s internal loop is told its turn should be completed. This happens whenever ending the turn is chosen as an action. Alternate actions can keep being taken until ending the turn is chosen. Each alternate action outsources to some manager.
Tumblr media
This system, while functional with basic functionality, really struggled when status effects were introduced. Namely, the issue was that units could die on their own turn, which becomes a major obstacle. The system was able to be kept afloat for a while with some workarounds thrown into the functions, but it was by no means a long term solution. The issues piled up further when it was time to add the functionality that lets the player win a battle. This is when I realised a severe rework was going to be in order.
What I needed is a system designed to be fully interruptible from any point in a character’s turn. It needs to always know that the game is in a state where it is permitted to do an action before it does an action. Another issue I’ve been having with the previous system is that certain things are simply unable to wait to be finished before the next thing happens. This is also crucial because at this stage in development, item drops were about to be added to the game, and it needed to be able to allocate the time for the item to drop to a designated position before a new action can be taken. In essence, the system had to fundamentally guarantee only one thing can be happening at any given time
Tumblr media
By this point in the project, I had been getting much more comfortable with using coroutines, which had already been put to use in creating the battle system. One thing the previous implementation lacked was commitment to using coroutines. It had coroutines stopping and waiting for a new thing to start a fresh coroutine anew. It was creating a lot of loose ends that were hard to keep on the same page.
With this all in mind, I had formulated a new plan that distinctly splits the gameplay into several interwoven loops. 
The Game as a whole contains everything, this level handles what happens before a battle starts and after a battle ends. For instance, this can make new battles begin after a previous one ends. 
The Battle Encounter contains things specific to the battle happening at a given time. This includes preparing everything before a battle, cleaning everything up after a battle, and telling a unit in the queue to do its turn.
The Unit Turn contains specifically what a unit is able to do before its turn ends. This includes setting itself up to start a turn, cleaning up if the turn needs to be ended, along with looping through actions while permitted.
The Action Permission Loop is what happens when a unit determines whether it can do an action. Here, the first thing that happens is the unit asks the battle manager if it is able to do an action. The battle manager determines whether or not this unit is dead, whether the battle is continuing and whether this unit actually had previously asked to end its turn. Based on all of that, it splits into either ending the battle, ending the turn or actually permitting the unit to do an action. With something very similar to the previous implementation of the actual action selection.
Tumblr media
While I was working on implementing this into the engine, I had a discussion with my module tutor, making me realise that this system is in reality quite redundant. As such I had made a few modifications off the top of my head to make it more aligned to how I interpreted the suggestions. It essentially boils down to making everything entirely function within layered coroutines. Due to my very modular design work up until this point, switching the implementation proved to not be too challenging.
Tumblr media
Unfortunately, this visualisation of the system came after the fact, I did not at all think to change the individual turn actions out of running in parallel, since they were already mostly functional. Because of this oversight, the implementation of the NPC turn choice algorithms ended up making it to playtesting with a lot of outdated code trying to start new parallel actions during actions, causing the coroutine to branch several times. It was very hard to debug and had grounded me back to remembering why I used to dislike working with coroutines the few times I had previously done so.
The fix was simple once I had found it, I had some old StartCoroutines from the initial reply system firing off to manually loop the sections, whilst it was already looping automatically. As I’m writing this blog, I realise that despite this being an issue with refactoring, it does not entirely fit my personal criteria of being an elegant solution in the state it is now. I think it could be interesting to see if I could manage to get it all into one continuous coroutine, I believe this would make the implementation even more reliable, and could simplify several other aspects of the game which need to check if an action is permitted in the first place. 
Tumblr media
0 notes
Photo
Tumblr media
When the very important Ben from “West Country Film Caterers” volunteered to model the merch, just imagine my face 🤩 #filmcatering #westcountryfilmcatering #fls #filmlocationsupport #setlife #productionlife #tvwork #unitbase #tvlocation (at Saltash, Cornwall) https://www.instagram.com/p/Bn1OU9SHTd6/?utm_source=ig_tumblr_share&igshid=1tp1kfe92ccf4
0 notes
blockbustersgang · 8 years ago
Photo
Tumblr media
Heads of Locations and Props having their offices set at out unit base. #unitbase #officework (at Valofirma)
0 notes
tomhardyitalia · 7 years ago
Text
Tumblr media
#tb #tomhardy
Ig @ieuan.rob
Back when I was working on Peaky's season 4 production.. can't wait for 5 #peakyblinders #tomhardy #alfiesolomons #filmset #unitbase
20 notes · View notes
mersy · 5 years ago
Text
ビジネスを加速させるGoogleタグマネージャー(GTM)の活用 | Web制作会社 | UNITBASE Inc. – 株式会社ユニットベース https://bit.ly/3hmfJWP
ビジネスを加速させるGoogleタグマネージャー(GTM)の活用 | Web制作会社 | UNITBASE Inc. – 株式会社ユニットベース https://t.co/ESalU6Mnlt
— Masashi Yanagiya@bit part (@mersy) August 23, 2020
from Twitter https://twitter.com/mersy August 23, 2020 at 05:31PM via IFTTT
0 notes
Photo
Tumblr media
Continuing our theme of not tagging Mercedes, if you’re planning on crossing the Tamar into Cornwall and back into Devon you’re best to invest in #tamartag honestly its genius £1.50 without 75p with and by magic the barrier just opens.......... ❤️my #tamartag if I’m crossing the #Tamar I’ve always got my #tag at hand....... #devon into #cornwall #nottaggingmerc #tamarbridge #fls #filmlocationsupport #unitbase #unitcar #unitdriver (at Tamar Bridge)
0 notes
cosyroom · 7 years ago
Photo
Tumblr media
UNITBASE Inc. http://ift.tt/2Ck2SR3
0 notes
kurano · 8 years ago
Link
0 notes
Photo
Tumblr media
That look you throw when security show you the nails they’ve collected off the unitbase in 10mins 😳🙄😳🙄😳🤦🏻‍♂️🥊 #flattire #flattireproblems #fls #filmlocationsupport #unitbase #filmsecurity #tvsecurity #basesecurity #unitmanager #nails #tvwork #tvfixer #unitcar #unitdriver #transportcaptain (at Wadebridge)
0 notes
Photo
Tumblr media
Good morning “Base” I’ll park right here if you don’t mind..........🚗💨🤦🏻‍♂️ #fls #filmlocationsupport #filmlondon #unitbase #unitcar #unitdriver #baselife #unitmanager #transportcaptain #locationmanager #lineproducer #productionmanager
0 notes
Photo
Tumblr media
Still no ••••••• ☀️ Hope the rest of you are enjoying the heat wave. When we say we’ll work anywhere I’m excluding here. #fls #filmlocationsupport #nosun #coldandfoggy #seamist #unitdriver #unitbase
0 notes
Photo
Tumblr media
Left home at 5am with beautiful sun all the way..... While the rest of the U.K. enjoys a hot bank holiday we’re set with mist for two days. GREAT.......... ☀️ not ⛅️ yes #fls #filmlocationsupport #bankholidayworking #nosun #foggyweather #setlife #production #productionlife #filmwork #unitdriver #unitdrivers #transportcaptain #unitbase
0 notes
mersy · 5 years ago
Text
読んだ >>> KPTがチームにもたらす重要なこと | Web制作会社 | UNITBASE Inc. – 株式会社ユニットベース https://bit.ly/2EltoyE
読んだ >>> KPTがチームにもたらす重要なこと | Web制作会社 | UNITBASE Inc. – 株式会社ユニットベース https://t.co/1AYKfGA3D8
— Masashi Yanagiya@bit part (@mersy) July 26, 2020
from Twitter https://twitter.com/mersy July 26, 2020 at 04:42PM via IFTTT
0 notes
Photo
Tumblr media
That’s us finished up the capital looking forward to starting work closer to home in #Cornwall. Although first pick up is back up London. #fls #filmlocationsupport #tvwork #tvfixer #unitcar #unitbase #unitdriver #unitdrivers #unitmanager #delicious #filmcornwall (at London, United Kingdom)
0 notes