Unit 8:Devlog 8-Assorted features

Firstly I created the price numbers above the units with a similar widget to the damage numbers but with a different animation and setup.

In the widget it has:

In the placement code I added 3 tiny bits of code to incorporate the price within the placing.

This gets the price of the unit during the placement code and sets the cost to be used in the loop where the unit moves to the cursor and checks if it can be placed the whole time.

Within the loop this code below simply checks if It could minus the cost and not go negative, then enable the placement if it could.

Within the placement onto the map code I added.

Which minuses the unit cost (Im using a previously created function but no unit costs essence to place and minus 0 essencce has no effect) and then updates the upgrade UI so that the upgrade buttons display properly.

I then created a upgrade cap because because I manually input the values in a table and therefore if its over the max the value would just be unset or for unreal[0].

Firstly I check for the values setting themselves back to 0

In the text for the upgrade I added which sets the upgrade to a unachievable price (I hope).

Finally in the upgrade button it displays Max instead of the high number and I also fixed a bug with the essence price not disappearing when its empty because it technically still equalled 0 instead of being empty. So I cheked for it starting with 0 instead.

I then made the sell button with a button on my upgrade screen

And the function it runs is:

Which gets the unit price (determined by the stat table since it adds the price of the upgrade onto the placement price) and simply adds it back then deletes itself.

I also just added a tiny bit of code that I left space for in my ‘Z to cancel placement’ code that runs the same function if you use the shortcut instead.

I then started to add some sound effects for the game.

The SW files are the raw files from pixabay, occasionally slightly cut and softened in Adobe audition.

Within the SC files I usually do something like this where I get the SW files and match the volumes so some of them arent way louder then others then add extra variation to them by having a range that the pitch can choose from.

Implementing them Into buttons is easy as I can simply just add them in.

And within blueprints, it is just as easy tho sometimes I might need to go searching between the blueprint interfaced functions to find where I want to put the sound.

I then finished planning the wave structure and enemy stats

And then from this table I implemented what I didnt already have into unreal.

These values are not final as I haven’t fine tuned the spawn intervals and delays to my liking.

I then factored in the damage resistance to the attack maths and also made the damage numbers more customiseable with prefixs and colour.

As you can see in the bottom image the colour is different for the explosion.

This Is what I tweaked in the damage number to account for this.

I then created a system to check if there is a upgraded range and then display the upgrade range when you hover over the upgrade button. I split the code into 3 images.

A summary of what it does it get the current range and next range then if they are different display a new range that previews it. The end is just some visual fixes to make it not glitch when you then press upgrade and there is a new range it will switch to the new range or hide itself if theres not.

I will show a preview of this in the video at the bottom of my weekly blog.

I then fixed the bars to properly display with the path and level and also block out the wrong path instead of closing it.

As you can see the top path has 0 levels and is closed and the bottom path has 2 levels.

The black square on the right is there for If I had time to create a visual change for each upgrade, the icon would also display a drawn icon of the upgrade change.

I also fixed the text to say other path selected and max path:

I made the grey out by changing the detection code to change boolean instead of hiding and showing the widget

Then in the module it shows or hides the darkening overlay based of the last code.

I want the widget component to be visible instead of not hit testable since I want it to stop the players ability to click below.

Then to set the upgrade buttons to the right level I run this at the start of the widgets construct.

This sets the colour refernce from a green and grey styled indicator then sets the indicators to an array in the right order to be used in the script below.

This gets all of the indicators and sets them to grey then depending on the level of the clicked units sets them back to green with the amount being the corresponding level.

The max text is set by which simply runs when it detects its maxxed.

And in the normal unit widget the second path also runs

I then created the money making units in which I thought of two ways to do.

My first idea was to get the amount of groups in the wave then multiply the end of group income with some maths to make sure it generates the same amount after every group spawned.

I planned it fully out but didn’t reallly like how the intervals would be un-even.

I then realised that I was already getting the group amounts why don’t I just get all of the info from the table and calculate the wave time by multiplying the amount of enemies by the spawn interval of the enemies.

This image above is the core of this math where I add together the spawn timings and delays to get a total wave time then divide this by the essence sales that wave (+1 because it waits then fires the generation code so to have 3 even intervals I want it to be every 25% of the wave ignoring the last tick since the wave would have ended)

Before the core is this:

This just determins wether to calculate how many intervals to do based of the normal math or time taken for you to place it in the level. This is so if you place a unit during the end of the wave of half way through the wave they will all generate the same amount of ticks as the unit from the start of the wave.

So simply, if you have good timing you can place one at the start of the wave and miss 0 ticks. If you place it mid wave you will miss a few ticks of generation and if you place it after the last tick would have fired you miss all of them for that unit that wave.

Obviously after the wave end it revert to the normal generation code and will run at the same times of the units with the same path.(1 path generates larger amounts of cash slower where the other generates smaller amounts faster [meaning they tick differently but will still limit correctly])

This is the mid wave code just after the the core code.

Then just after that the actual money tick runs:

This gets the current essence amount then checks whether it could sell the essence for cash and not go negative, If it would go negative instead of selling the correct amout it will sell whatever the current essence is * the sell price (if its 0 you wont gain any cash).

Then finally it checks whether it has done enough sales for the wave (since it technically would try to do a 4th one at the end of the wave from the timing code) and stops the loop when it has done enough.

I will add a video of all these systems I created in the weekly blog.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *