What's wrong with this again?

what's wrong with this again?

Attached: 1591759345527.jpg (799x773, 75.2K)

Other urls found in this thread:

youtu.be/G43G0B5gQpU?t=5530
m.youtube.com/watch?v=rRH5c2gJWFU
youtube.com/watch?v=ARxFC1fFbD8
twitter.com/SFWRedditGifs

you've been told the reason 10+ times
literally everything about it

Nothing, people here know nothing about programming and just parrot memes.

poorly structured and difficult to maintain

Most people don't really know. They just asume switching to switch statements would fix it.

it's 2 + 2 + 2 ... + 2 = 1 000 000 instead of 2 x 500 000 = 1 000 000

you're supposed to use a case for 0.0000000001 milliseconds of efficiency apparently
the shit parts of his code is where he does things not how he uses ifs

Nothing, this is a pretty normal solution to a complex NPC situation that stupid pseuds on Zig Forums can’t appreciate with their sub-community college CS education

That doesn't look like an npc script.

Its using a sickening amount of if statements when it should be a teacher class with methods. The general logic can be written in a much cleaner and modular way. The first line is pathetic and it only goes downhill.

This is well structured and easy as shit to maintain, literally zero chance of someone fucking it up due to obscurity. I bet you'd rather write a bunch of convoluted logic that makes zero impact on actual performance on today's hardware, however will not be understood by anyone including yourself easily, and will introduce a bug as soon as an intern gets a task to modify something for a specific case.

A parent class of an NPC with child classes representing different types of NPCs would eliminate the need for many of these if statements and split them up in such a way that they can be run as needed by a child class and not by every NPC at every frame.

what's wrong with this again?

Attached: Get tomorrow's date.jpg (694x801, 36.94K)

Major copes. Please drop out of college.

how do you know it should be in class with methods if you don't know context.

only wrong things I can see on that picture is that string are not defined in one place as constants which is more readable and maintainable and retyping on float 6 should be just by calling '6.0' if it's c++

this has to be bait or picture who created some wannabe programmer who saw funny picture with diploma already and thought this is same case

What if there's an issue with this.Witnessed where these statements need to be changed? You'd have to go through each statement and change them individually instead of just changing one line of code that checks for the line at the start.
This isn't well structured at all you fool.

Sorry too busy collecting my 200k a year paycheck

I'm just now reading and watching videos about this game and its developer. And while he is a shit coder, the pseudo programmers that make videos about it, spouting factually erroneous information are also pretty cringe, like video related

youtu.be/G43G0B5gQpU?t=5530
>1:32:10

How's the game going Eva? Perhaps the fact that you game still isn't finished implies that you're not an efficient coder.
Even if you accept that elseif statements are the most efficient way to do things, half the lines are still obsolete.

Criss crawss...
m.youtube.com/watch?v=rRH5c2gJWFU

Has cum chalice guy written unit tests?

It works, but it isn't nice to look at.
Should've gone with switch statements for clarity.
Also, I don't know how the label shit works (I assume the different labels will trigger different reactions), but using strings in a comparison is bad from an efficiency standpoint. Even though the difference won't ever be noticeable.

Attached: 1591200890809.jpg (882x731, 112.95K)

you have to wait a day to get tomorrow's date

Nothing, if you're a first year programming student who is learning the very basics of programming.
For game design, it's completely unacceptable and anyone with even an iota of proper training would be able to condense this code into something much cleaner and more manageable. That's why he hasn't made any progress, because sifting through 10 trillion lines of code to fix a small thing is insane.

i dont know how 2 program but couldnt you make a single table to pull a state from?

>all these retarded replies
>not one single mention of abusing string comparisons
Jesus christ, you people should never write a single line of code.

It's been mentioned before already, are you new? Newfag?

Listen here karthik, it's like said.
This is just really unecessary and the first line implies this is running for every npc. It isn't organized properly and looks sloppy. I know it should be in a class because an NPC class with various types of NPC's as subclass is extremely common in game programming. Constants and 6 vs 6.0 is a meaningless analysis that just scratches the surface. With object oriented programming we don't need a nest of if statements. We can make code simpler, easier to read, maintainable, modular. The OP image has none of that.

So it works.

>let's continue to point out and discuss the one thing that everyone is 100% agreed on being retarded
Take your own advice, maybe start with crayons or something

It's just redundant.

You can easily fix this with an array or a broader generalization statement that pulls from another statement.

Just off the top of my head.
>if teacher witnesses event (event determined by modifiers applied to session) teacher.event==x (pulled from array, defined in sub section).

Literally removes hundreds of if/else-if statements.
You can also easily pull this same information from the array for other purposes in game. Instead of making once again, another 100+ else if statements.

The problem as we have discussed a thousand times is that IF statements can easily bloat code and are horribly inefficient for scripting.

Placeholders and modifiers are generally much better as they update and stop asking questions until a script is activated in which the game says "hey should I ask a question?"

It's no different than Skyrim or literally any other modern game.
You kill an NPC in town does the game
A. constantly ask if anyone can see you at any given moment?
or
B. ask could anyone see you at the moment you killed said NPC

If you think the answer is A, you have some serious code inefficiency.

A happens when you go into stealth mode, which literally keeps asking "can anyone see me" as shown by the eye symbol.
In fact a large amount of beta issues in Elder Scroll games came about from stealthing in public places when they switched to the new engines.
Which caused huge lag spikes.

BIG REMINDER that this fucking yandere dev meme is fucking stupid. Write your code however you want even if its fucking terrible and could be better. If it works it works. Unless your code breaks something or affects performance it doesnt matter how its written. Nobody gives a fuck how you code it if its working as intented and nobody will notice. One of the main things you should be mindfull when coding is structure and performance.

Attached: 1570915044150.png (493x411, 257.73K)

Without knowing the context of the entire class, the this.Witnessed being a String really annoys me.
Doing 10 string comparisons at worst after another sounds like horrible performance. and if i remember from all the other threads shitting on him this shit is in the update function so it runs every frame.
Also the strings for GameOverCause and in Update Label.
Either they are strings that are displayed to the player and should be maintained somewhere else seperately for easy maintenance and potential multi language support (not that he's ever gonna do that)
or
He's just gonna do the same shit with them and use them solely for other comparisons in which case they should just be an enum.

Literally 1 minute before I posted, obviously I typed my response before updating the thread you fucking moron. Not to mention that the other guy who posted it is dumb as fuck and thinks a switch is somehow more clear when it absolutely isn't and the main benefit of it is that it is more likely to be compiled into a jump table.

This meme of if statements being bad is something you only see in places that idiots gather (e.g. Zig Forums).

Coding seems really hard, how do you remember all this bits of writing and how its supposed to interact with everything else at the same time?

Classes and methods are a shit meme pushed by colleges because "woah so complex we teach you so worth your money" when all it does is create too many areas to fuck up your code when you're linking it across tons of shit after all your code is done

Not enough documentation explaining how it gets tomorrow's date exactly

Real question. If you needed to compare something similar, what would you use instead of strings?

Inefficient and hard-to-maintain if-else chain which is performing the role of a case selector. Also, UpdateLabel and GameOverCause should be combined somehow (separate function or UpdateLabel within GameOverCause) since they're necessarily linked.

>literally zero chance of someone fucking it up due to obscurity
It's an if-else chain; if someone fucks up changing one of the cases and forgets an if or else, it will fuck up the chain at and past that point.

Inheritance doesn't solve the conditional issue, it actually accentuates it. Inheritance is the bane of OOP that's why you often hear to go for composition instead of inheritance. The most used and popular design patterns favor composition and basically attempt to ditch inheritance as much as much as they can.

Most common example would be an enum or in C++ a class enum to gain that small little bit of static analysis help.

Did anyone played the game, when does it have performance problems exactly?

So how many fps does this game run at on average?

>It's an if-else chain; if someone fucks up changing one of the cases and forgets an if or else, it will fuck up the chain at and past that point.
As opposed to a switch where someone can forget a single break and fuck everything up? What the fuck is wrong with you?

Just keep studying until you know all use-case scenarios, just like any other thing you're trying to learn

How do you remember the idiosyncrasies and vocabulary of language?
Practice and reference.

nice bait. you almost had me

>makes zero impact on actual performance on today's hardware
The game struggles to eclipse 20fps on top-end PC hardware.

>don't worry bro just build up an insane amount of technical debt!
Worst advice you could give someone

This is just decompiled code by machine. How do people know that he actually wrote it this way?

Thats not the hard part of coding. The hard part of coding is problem solving. Wanting to solve a problem and spending time figuring it out. Writting code is like 10% of the battle.
Is like driving. Getting your drivers license is really fucking easy, but really learning how to drive takes years and a lot of practice. Coding is no different. You can learn the basics of coding in a week. But knowing how to code well is what takes a lot of time.

piss poor framerate

2-10

Dude, its fucking game dev, not software enginering for nasa. Most of the indie scene are games made on Unity, Godot or Game maker. So fuck off

Thanks for your input, Todd.

Enums. Give each one a power of 2.
So
Weapon = 1
Blood = 2
Violence = 4
etc.
That way you can OR them together and store them in one value. So 7 would be blood and weapon and violence.
That way you can just do a simple AND operation and see if it's still greater than 0.
>if((this.Witnessed & WEAPON) > 0)
>{...}
>else if ((this.Witnessed & BLOOD) > 0)
>{...}
>etc.
This way you can also see which one has priority over what. Looking at his code for example Insanity seems to have highest priority but fuck it is hard to read.

There's 2 hours of this shit and you have to wonder about Alex's thought process youtube.com/watch?v=ARxFC1fFbD8

>technical debt is only a probelm if you are writing for space launches.
hoo boy

If you practice what you preach then you have big problems my man

Fucking up a switch case in most languages will fuck up that one case and depending on the fuckup, the case after it. Unless the fuckup in the if-else chain is the last or second to last item, there's more harm in the if-else fuckup.

>That way you can OR them together and store them in one value. So 7 would be blood and weapon and violence.
>That way you can just do a simple AND operation and see if it's still greater than 0.
wtf this is sorcery

Isn't the problem that he is doing this every frame rather than on a callback or a separate thread?

>Unless it affects performance
Doesn't this thing run horribly on any machine because of the insane spaghetti code? Writing stuff in 10 fold nested if statements is possibly never a good idea. And if you write shit like this for literally anyone that might have to be maintained by someone else, I pray to god that you never get hired.

If you forget the else then it will cause performance issues but the code should still work because your variable can only have 1 value, more comparisons won't break anything. If you forget an if then your compiler will complain. If you forget a break then at least one case of your code is completely broken.

no matter how many times people explain it to me i always forget what's exactly wrong with this code
it looks retarded, yes, but i don't know why
do a brainlet a favor and maybe show how it SHOULD be written instead
t. managed to freeze the system with hello world like 15 years ago

Attached: file.png (646x694, 205.95K)

It is called using a bitmask, user. You define what each bit in a number means and then you can check any, or multiple, of the bits to get your value. It is efficient in memory usage and speed since checking bits is a very quick operation.

Yeah, I agree. To me it seems like a simple "polling when you should have an observer" issue.

No because when you get the result it will be todays date and not tomorrows date.