Is it a really bad idea to have an override not call the base function? I'm thinking that in order to synchronize some stuff, I need to re-do some stuff, and there's just enough overlap between most of the children classes that it's probably a good idea for me to just re-code more of the stuff to the parent so it's easier to manage, but there's one child type that doesn't behave at all like the other towers. So if I were to put the behaviour into a virtual, then have the one that behaves differently just not call the base function, would that be dumb?
Is it a really bad idea to have an override not call the base function? I'm thinking that in order to synchronize some stuff, I need to re-do some stuff, and there's just enough overlap between most of the children classes that it's probably a good idea for me to just re-code more of the stuff to the parent so it's easier to manage, but there's one child type that doesn't behave at all like the other towers. So if I were to put the behaviour into a virtual, then have the one that behaves differently just not call the base function, would that be dumb?
I guess "doesn't behave at all like other towers" was a dumb way to phrase it. It doees share several things with normal towers. The only thing that behaves differently is it's firing, which is continuous instead of a single hit every x beats. So the only thing that would be changed would be the logic of when to fire.
0
Options
AkimboEGMr. FancypantsWears very fine pants indeedRegistered Userregular
Again, that sounds like the perfect use for an intermediary subclass.
There's something called a tower, and all towers are different, but they share some similarities. These similarities should manifest in the parent Tower class. Some of these towers also share more similarities in the firing mechanics, but some don't. So most towers should inherit from a subclass of the initial tower class (say, BulletTower), while the different ones inherit either directly from Tower or from some other subclass (say, LaserTower).
I don't know which language you're working with, but you might also want to look into multiple inheritance or composition.
Give me a kiss to build a dream on; And my imagination will thrive upon that kiss; Sweetheart, I ask no more than this; A kiss to build a dream on
Is it a really bad idea to have an override not call the base function? I'm thinking that in order to synchronize some stuff, I need to re-do some stuff, and there's just enough overlap between most of the children classes that it's probably a good idea for me to just re-code more of the stuff to the parent so it's easier to manage, but there's one child type that doesn't behave at all like the other towers. So if I were to put the behaviour into a virtual, then have the one that behaves differently just not call the base function, would that be dumb?
If it's so different, why is it a child of that other class? Might be a time to rethink some class hierarchies
Is it a really bad idea to have an override not call the base function? I'm thinking that in order to synchronize some stuff, I need to re-do some stuff, and there's just enough overlap between most of the children classes that it's probably a good idea for me to just re-code more of the stuff to the parent so it's easier to manage, but there's one child type that doesn't behave at all like the other towers. So if I were to put the behaviour into a virtual, then have the one that behaves differently just not call the base function, would that be dumb?
If it's so different, why is it a child of that other class? Might be a time to rethink some class hierarchies
The hypothetical that comes to mind would be each other tower in the game shooting a particular kind of projectile, while there's this one weird tower whose behavior is some function of other nearby towers or a healing burst or something. Such that it constructs, takes damage, consumes resources, blocks pathfinding, and in all other ways behaves like the other towers... but when you say "your refire time is up, do your thing", it's the one kind of tower that doesn't "find nearest enemy, calculate target trajectory, produce projectile".
My favorite musical instrument is the air-raid siren.
Is it a really bad idea to have an override not call the base function? I'm thinking that in order to synchronize some stuff, I need to re-do some stuff, and there's just enough overlap between most of the children classes that it's probably a good idea for me to just re-code more of the stuff to the parent so it's easier to manage, but there's one child type that doesn't behave at all like the other towers. So if I were to put the behaviour into a virtual, then have the one that behaves differently just not call the base function, would that be dumb?
If it's so different, why is it a child of that other class? Might be a time to rethink some class hierarchies
The hypothetical that comes to mind would be each other tower in the game shooting a particular kind of projectile, while there's this one weird tower whose behavior is some function of other nearby towers or a healing burst or something. Such that it constructs, takes damage, consumes resources, blocks pathfinding, and in all other ways behaves like the other towers... but when you say "your refire time is up, do your thing", it's the one kind of tower that doesn't "find nearest enemy, calculate target trajectory, produce projectile".
Yeah, I understand the problem. Unfortunately I didn't see the new page when I replied, but what @AkimboEG suggests is precisely what I mean.
In detail:
Base class "Tower": contains logic concerning being placed, sold, upgraded, maybe also the base influence radius triggers.
Intermediate class "Tower_Shooting": contains targeting and damage event logic
All offensive towers could be children of the latter, while healing towers or radial slowdown towers could be direct children of the former. Or even of their own "Tower_RadialEffect" intermediate subclass.
I'm working on a cute little video game! Here's a link for you.
0
Options
MachwingIt looks like a harmless old computer, doesn't it?Left in this cave to rot ... or to flower!Registered Userregular
I was going to say take advantage of multiple inheritance and treat the refire behavior like a module, but apparently multiple inheritance isn't something you can do through blueprintttttttt
so here's a fun thing: the tech art team I'm on is sort of slowly superceding the tools development team, because it turns out we can write a program in python that does something they'd want to write in C++, but we can iterate on our programs in like a tenth of the time
I was going to say take advantage of multiple inheritance and treat the refire behavior like a module, but apparently multiple inheritance isn't something you can do through blueprintttttttt
so here's a fun thing: the tech art team I'm on is sort of slowly superceding the tools development team, because it turns out we can write a program in python that does something they'd want to write in C++, but we can iterate on our programs in like a tenth of the time
One thing to be wary of with that is the distribution is rather nonlinear. You need 4x the attacking stat to get to a reliable hit % (80%) and 9x to reach 90% but only 1/2 of the attacking stat to get to 33% to-hit and 1/4 gives you 20%. You'll need to design everything around not having reliable hits and most normalizing quickly to 50% and then very slowly up from that. It's also very difficult to get an actually reliably hit unless you have a 10x or more swing
Eg, if someone builds a unit that has 150 attack 50 defense and it's up against a 50 attack 150 defense it's an even match. But against a 100 attack 100 defense unit it will hit 60% of the time and get hit 66% of the time. It can confuse players about the value of their stats at the very least and just encourages either meaningless huge numbers or to-hit chances all in the 40-60 range IMO
This is why I'm in favor of having a base accuracy for all attacks and then operating on that.
You could modify the formula to instead be something like:
Assume BASE_HIT_CHANCE = .8
and MAX_HIT_BONUS = .2
Assuming AGI is an evasion stat and DEX is an accuracy stat, you get the following values:
AGI equals DEX: 80%
AGI half DEX: 90%
AGI twice DEX: 70%
Or make it a little swingier and set MAX_HIT_BONUS to .5
But a system like this has the advantage of a predefined total range. In the latter case that's .3-1.3
Accuracy above 1.0 doesn't matter unless you have attacks that are less accurate than other attacks. A reckless barbarian sort of archetype might have a lot of use for an accuracy stat which took his accuracy above 100%, if some of his attacks imposed a hefty accuracy penalty. Reliable reckless swings? YES PLEASE!
Of course you can easily tweak the base hit chance and max hit bonus to achieve various value ranges, but all of it depends very highly on how the progression of these stats are handled. How big is the differential likely to be?
Remember that as stats get higher and higher, the term "half of" or "double of" when talking about different stats gets waaaaaaaay less likely. If your max level characters have 10 in a bad stat and 30 in a good one, then it makes sense to use a ratio system like this. If they're going to have 100 in a bad stat and 150 in a good one, then as the game goes on your numbers are going to converge in a weird way.
Also as a side note, whenever I am working on an equation, I generally put something like this into wherever I initialize my variables:
int minAtk = 0
int maxAtk = 30
int minDef = 0
int maxDef = 30
int atkStride = 1;
int defStride = 1;
for(int atk = minAtk; atk <= maxAtk; atk += atkStride){
for(int def = minDef; def <= maxDef; def += defStride){
Log("For atk " + atk + " :: def " + def + ": value is " + getResultOfEquation(atk, def));
}
}
That way I can take a big dataset and examine how it looks from minimum to maximum, how fast it changes, etc. Use the stride to make the dataset bigger or smaller for ease of reading.
Ok, I redid some stuff with the "ShootTower" class for the towers that.. shoot.
There's now only one problem, which makes me wish I had multiple inheritance(now that I've looked it up), which is that I've got two variables and a function in the base Tower class which is used in two of the five towers, but one of the two towers is a ShootTower and the other is one of the odd men out. So it's on the base class, but unused in many.
I guess that's probably not actually a problem, since, whatever, it's just not called in some of the towers. It makes me a little sad that it seems wasteful when everything else is so clean and pretty now, but I guess them's the brakes.
Ok, I redid some stuff with the "ShootTower" class for the towers that.. shoot.
There's now only one problem, which makes me wish I had multiple inheritance(now that I've looked it up), which is that I've got two variables and a function in the base Tower class which is used in two of the five towers, but one of the two towers is a ShootTower and the other is one of the odd men out. So it's on the base class, but unused in many.
I guess that's probably not actually a problem, since, whatever, it's just not called in some of the towers. It makes me a little sad that it seems wasteful when everything else is so clean and pretty now, but I guess them's the brakes.
If you are lamenting a lack of multiple inheritance, you should try using an interface instead!
But to be honest I'm pretty sure it's no big deal the way you've described it. What exactly are the vars/functions in question?
Ok, I redid some stuff with the "ShootTower" class for the towers that.. shoot.
There's now only one problem, which makes me wish I had multiple inheritance(now that I've looked it up), which is that I've got two variables and a function in the base Tower class which is used in two of the five towers, but one of the two towers is a ShootTower and the other is one of the odd men out. So it's on the base class, but unused in many.
I guess that's probably not actually a problem, since, whatever, it's just not called in some of the towers. It makes me a little sad that it seems wasteful when everything else is so clean and pretty now, but I guess them's the brakes.
If you are lamenting a lack of multiple inheritance, you should try using an interface instead!
But to be honest I'm pretty sure it's no big deal the way you've described it. What exactly are the vars/functions in question?
Both the laser and gun towers have a 270 degree firing arc, and they have a function which points them at the enemy that they're shooting at(The sniper, shield, and missile just have static placement and fire in a 360 degree arc).
So there's just a separate coroutine that handles the looking, and the variables are the min and max angles. Two ints, and one coroutine/void to find and look at the enemy they're firing at.
It's probably not a big deal, to have those existing but not being called/running in the 3 towers that don't use them. They don't interfere with anything or change anything. For that matter, it's only about 30-some lines of code in total too, so it's not a huge thing.
I guess I could use an interface for them, but it's so small that I wonder if it's even worth thinking about.
Havent touched things in a while. But I've been working on tidying up utility calls
e.g. int? index = GameManager.instance.m?.GetTile(loc).objects.FindIndex(f => f.name == "Wall");
becomes
int index =GameManager.instance.m.GetObjectsOnTile(loc, "Wall").count;
And then I built a growing wall:
Antinumeric on
In this moment, I am euphoric. Not because of any phony god’s blessing. But because, I am enlightened by my intelligence.
+2
Options
MachwingIt looks like a harmless old computer, doesn't it?Left in this cave to rot ... or to flower!Registered Userregular
It's probably not a big deal, to have those existing but not being called/running in the 3 towers that don't use them. They don't interfere with anything or change anything. For that matter, it's only about 30-some lines of code in total too, so it's not a huge thing.
Actually, there is no memory overhead for having a method used by one subclass but not another. Every method only exists in memory once, whether it's a static method or an instance method. So, if you need the method for at least one subclass, there is no space "wasted."
I mean, even if there were, it would be an incredibly negligible amount, but in this case it's literally zero. Each method only has one instance in memory, so nothing is wasted.
In more light-hearted news, I just started a bake, went downtown to three different shops looking for more Ram, finally found one that had what I needed in stock, bought it, grabbed some lunch too and leisurely strolled home - and the bake was 17% done.
It's probably not a big deal, to have those existing but not being called/running in the 3 towers that don't use them. They don't interfere with anything or change anything. For that matter, it's only about 30-some lines of code in total too, so it's not a huge thing.
Actually, there is no memory overhead for having a method used by one subclass but not another. Every method only exists in memory once, whether it's a static method or an instance method. So, if you need the method for at least one subclass, there is no space "wasted."
I mean, even if there were, it would be an incredibly negligible amount, but in this case it's literally zero. Each method only has one instance in memory, so nothing is wasted.
Technically you're probably "wasting" 4 bytes per method in the class's vtable if they're virtual :biggrin:. "Wasting" in quotation marks because trying to "optimize out" functions from a vtable would generally take way more than 4 bytes per method.
It's probably not a big deal, to have those existing but not being called/running in the 3 towers that don't use them. They don't interfere with anything or change anything. For that matter, it's only about 30-some lines of code in total too, so it's not a huge thing.
Actually, there is no memory overhead for having a method used by one subclass but not another. Every method only exists in memory once, whether it's a static method or an instance method. So, if you need the method for at least one subclass, there is no space "wasted."
I mean, even if there were, it would be an incredibly negligible amount, but in this case it's literally zero. Each method only has one instance in memory, so nothing is wasted.
Technically you're probably "wasting" 4 bytes per method in the class's vtable if they're virtual :biggrin:. "Wasting" in quotation marks because trying to "optimize out" functions from a vtable would generally take way more than 4 bytes per method.
It's just one of those games that there are just too many individual hits for them to mean anything. HP bars are there too show the relative amount of damage you're doing, you don't also need the actual numbers too. It's like in old school jrpgs. The early game single hits matter because you can gauge if your damage is increasing or not because there is no HP bar. But late game when you do the big multi-hit attacks you just see a cascade of 9999s and block it out and think "Ok, that did a lot" rather than counting the hits and doing math or whatever. There just aren't many super 1 hit attacks in D3, there is too much emphasis on pumping out the most things as fast as you can for numbers to matter.
Haven't posted here in a while but something remarkable happened last night.
A feature that I never implemented before worked right on the first try!
I'm using Unity3D to make a Twitch chat bot and overlay controller. The current feature I'm working on is a music player that will play the viewers' song requests. I made a UI panel with the player buttons. I wanted it to be draggable so I could move it to different positions depending on what game I was playing.
Here is the miraculous part...I typed into google "how to make unity UI objects draggable", clicked the first link to a Unity answers page, followed the instructions in the answer, and it worked exactly like I wanted it to!
Question to the people releasing commercial Unity games; are you writing automated tests for your code, unit or otherwise? Coming from a traditional soft dev role there is part of me that feels like writings tests is the "the right thing to do", but on the other hand, all the traditional software dev projects I've worked on have rolling releases and the tests are mainly there to verify that people don't break things between releases, which is honestly not going to be as big of an issue on a single person game project that I hopefully won't have to update more then a handful of times.
"Make a game in 72 hours and have a chance to showcase it in person at the Game Jolt booth at the 2016 Game Developers Conference (GDC) in San Francisco on March 16-18!"
They are picking 5 winners and giving out expo passes for GDC and presenting their jam game at some indie booth and all that jazz. Sounds neat. Just thought I would share it!
Question to the people releasing commercial Unity games; are you writing automated tests for your code, unit or otherwise? Coming from a traditional soft dev role there is part of me that feels like writings tests is the "the right thing to do", but on the other hand, all the traditional software dev projects I've worked on have rolling releases and the tests are mainly there to verify that people don't break things between releases, which is honestly not going to be as big of an issue on a single person game project that I hopefully won't have to update more then a handful of times.
Thoughts?
We all probably SHOULD be writing unit tests. Unity's test tools are pretty sweet. But you are right, as a single dev its not super critical
Question to the people releasing commercial Unity games; are you writing automated tests for your code, unit or otherwise? Coming from a traditional soft dev role there is part of me that feels like writings tests is the "the right thing to do", but on the other hand, all the traditional software dev projects I've worked on have rolling releases and the tests are mainly there to verify that people don't break things between releases, which is honestly not going to be as big of an issue on a single person game project that I hopefully won't have to update more then a handful of times.
Thoughts?
We all probably SHOULD be writing unit tests. Unity's test tools are pretty sweet. But you are right, as a single dev its not super critical
I was reading more about Unity's test tools yesterday. Sounds like I'd need to do some re-architecture if I wanted to test effectively, which honestly might not be a bad thing to do.
Posts
I guess "doesn't behave at all like other towers" was a dumb way to phrase it. It doees share several things with normal towers. The only thing that behaves differently is it's firing, which is continuous instead of a single hit every x beats. So the only thing that would be changed would be the logic of when to fire.
There's something called a tower, and all towers are different, but they share some similarities. These similarities should manifest in the parent Tower class. Some of these towers also share more similarities in the firing mechanics, but some don't. So most towers should inherit from a subclass of the initial tower class (say, BulletTower), while the different ones inherit either directly from Tower or from some other subclass (say, LaserTower).
I don't know which language you're working with, but you might also want to look into multiple inheritance or composition.
Thanks!
If it's so different, why is it a child of that other class? Might be a time to rethink some class hierarchies
Unreal Engine 4 Developers Community.
I'm working on a cute little video game! Here's a link for you.
The hypothetical that comes to mind would be each other tower in the game shooting a particular kind of projectile, while there's this one weird tower whose behavior is some function of other nearby towers or a healing burst or something. Such that it constructs, takes damage, consumes resources, blocks pathfinding, and in all other ways behaves like the other towers... but when you say "your refire time is up, do your thing", it's the one kind of tower that doesn't "find nearest enemy, calculate target trajectory, produce projectile".
Yeah, I understand the problem. Unfortunately I didn't see the new page when I replied, but what @AkimboEG suggests is precisely what I mean.
In detail:
Base class "Tower": contains logic concerning being placed, sold, upgraded, maybe also the base influence radius triggers.
Intermediate class "Tower_Shooting": contains targeting and damage event logic
All offensive towers could be children of the latter, while healing towers or radial slowdown towers could be direct children of the former. Or even of their own "Tower_RadialEffect" intermediate subclass.
Unreal Engine 4 Developers Community.
I'm working on a cute little video game! Here's a link for you.
so here's a fun thing: the tech art team I'm on is sort of slowly superceding the tools development team, because it turns out we can write a program in python that does something they'd want to write in C++, but we can iterate on our programs in like a tenth of the time
Tech art powaaaah! *fistpump*
Unreal Engine 4 Developers Community.
I'm working on a cute little video game! Here's a link for you.
Some interesting stuff on how they display damage numbers, and pick the ones to emphasize.
This is why I'm in favor of having a base accuracy for all attacks and then operating on that.
You could modify the formula to instead be something like:
Assume BASE_HIT_CHANCE = .8
and MAX_HIT_BONUS = .2
Assuming AGI is an evasion stat and DEX is an accuracy stat, you get the following values:
AGI equals DEX: 80%
AGI half DEX: 90%
AGI twice DEX: 70%
Or make it a little swingier and set MAX_HIT_BONUS to .5
AGI = 20, DEX = 15: 60%
AGI = 17, DEX = 15: 74%
AGI = 18, DEX = 23: 91%
But a system like this has the advantage of a predefined total range. In the latter case that's .3-1.3
Accuracy above 1.0 doesn't matter unless you have attacks that are less accurate than other attacks. A reckless barbarian sort of archetype might have a lot of use for an accuracy stat which took his accuracy above 100%, if some of his attacks imposed a hefty accuracy penalty. Reliable reckless swings? YES PLEASE!
Of course you can easily tweak the base hit chance and max hit bonus to achieve various value ranges, but all of it depends very highly on how the progression of these stats are handled. How big is the differential likely to be?
Remember that as stats get higher and higher, the term "half of" or "double of" when talking about different stats gets waaaaaaaay less likely. If your max level characters have 10 in a bad stat and 30 in a good one, then it makes sense to use a ratio system like this. If they're going to have 100 in a bad stat and 150 in a good one, then as the game goes on your numbers are going to converge in a weird way.
That way I can take a big dataset and examine how it looks from minimum to maximum, how fast it changes, etc. Use the stride to make the dataset bigger or smaller for ease of reading.
There's now only one problem, which makes me wish I had multiple inheritance(now that I've looked it up), which is that I've got two variables and a function in the base Tower class which is used in two of the five towers, but one of the two towers is a ShootTower and the other is one of the odd men out. So it's on the base class, but unused in many.
I guess that's probably not actually a problem, since, whatever, it's just not called in some of the towers. It makes me a little sad that it seems wasteful when everything else is so clean and pretty now, but I guess them's the brakes.
If you are lamenting a lack of multiple inheritance, you should try using an interface instead!
But to be honest I'm pretty sure it's no big deal the way you've described it. What exactly are the vars/functions in question?
Both the laser and gun towers have a 270 degree firing arc, and they have a function which points them at the enemy that they're shooting at(The sniper, shield, and missile just have static placement and fire in a 360 degree arc).
So there's just a separate coroutine that handles the looking, and the variables are the min and max angles. Two ints, and one coroutine/void to find and look at the enemy they're firing at.
It's probably not a big deal, to have those existing but not being called/running in the 3 towers that don't use them. They don't interfere with anything or change anything. For that matter, it's only about 30-some lines of code in total too, so it's not a huge thing.
I guess I could use an interface for them, but it's so small that I wonder if it's even worth thinking about.
e.g. int? index = GameManager.instance.m?.GetTile(loc).objects.FindIndex(f => f.name == "Wall");
becomes
int index =GameManager.instance.m.GetObjectsOnTile(loc, "Wall").count;
And then I built a growing wall:
http://gamasutra.com/view/news/264310/Former_US_Defense_Secretary_Donald_Rumsfeld_is_dabbling_in_game_dev.php
Twitch: KoopahTroopah - Steam: Koopah
Actually, there is no memory overhead for having a method used by one subclass but not another. Every method only exists in memory once, whether it's a static method or an instance method. So, if you need the method for at least one subclass, there is no space "wasted."
I mean, even if there were, it would be an incredibly negligible amount, but in this case it's literally zero. Each method only has one instance in memory, so nothing is wasted.
I want one of those 32 core Xeons, you guys.
Unreal Engine 4 Developers Community.
I'm working on a cute little video game! Here's a link for you.
16K lightmap on a photoscanned highpoly mesh
Unreal Engine 4 Developers Community.
I'm working on a cute little video game! Here's a link for you.
Now you tell me!
Unreal Engine 4 Developers Community.
I'm working on a cute little video game! Here's a link for you.
Technically you're probably "wasting" 4 bytes per method in the class's vtable if they're virtual :biggrin:. "Wasting" in quotation marks because trying to "optimize out" functions from a vtable would generally take way more than 4 bytes per method.
BUT MY BYTES
What's funny to me is that my enjoyment of D3 increased alot when I turned off damage numbers.
Steam: https://steamcommunity.com/profiles/76561198004484595
A feature that I never implemented before worked right on the first try!
I'm using Unity3D to make a Twitch chat bot and overlay controller. The current feature I'm working on is a music player that will play the viewers' song requests. I made a UI panel with the player buttons. I wanted it to be draggable so I could move it to different positions depending on what game I was playing.
Here is the miraculous part...I typed into google "how to make unity UI objects draggable", clicked the first link to a Unity answers page, followed the instructions in the answer, and it worked exactly like I wanted it to!
Holy crap!
Thoughts?
I'd done a tiny bit of VB in highschool, handle some Ruby at work, but that's about it.
And we did it. Four utter amateurs made an ironic physics simulator about being a hungover wizard trying to make breakfast.
I hurt everywhere and this is definitely a new high point in my life.
God I need to do another game jam
They are so good
There's a UE4 game jam every month, you know.
Just sayin!
Unreal Engine 4 Developers Community.
I'm working on a cute little video game! Here's a link for you.
http://jams.gamejolt.io/gjgdcjam
"Make a game in 72 hours and have a chance to showcase it in person at the Game Jolt booth at the 2016 Game Developers Conference (GDC) in San Francisco on March 16-18!"
They are picking 5 winners and giving out expo passes for GDC and presenting their jam game at some indie booth and all that jazz. Sounds neat. Just thought I would share it!
We all probably SHOULD be writing unit tests. Unity's test tools are pretty sweet. But you are right, as a single dev its not super critical
I was reading more about Unity's test tools yesterday. Sounds like I'd need to do some re-architecture if I wanted to test effectively, which honestly might not be a bad thing to do.