View Full Version : Max Item Increase
Lelouche Vi Britannia
02-17-2018, 12:41 PM
I haven't tried this yet, but just a quick question if anyone knows the answer.
I've set up a system were there are 4 types of potions, all with separate counters to keep track of amounts. I've been trying to figure out a way to use one item to increase the max counter size for all 4 of them.
I'm not sure how to go about this since I don't script often enough to "get good" which means every time I go back to my project, I have to do a little bit of reorienting and relearning. I imagine the functions "Max" and "Max Increment" are used somehow.
Sorry for being such a noob/pain, but am I anywhere close?
const int CR_POTA = 9;
const int CR_POTB = 10;
const int CR_POTC = 11;
const int CR_POTD = 12;
item script counterpickup
{
void run(int countermax, int pustring)
{
Game->Max[CR_POTA] == countermax;
Game->Counter[CR_POTA] == countermax;
Game->Max[CR_POTB] == countermax;
Game->Counter[CR_POTB] == countermax;
Game->Max[CR_POTC] == countermax;
Game->Counter[CR_POTC] == countermax;
Game->Max[CR_POTD] == countermax;
Game->Counter[CR_POTD] == countermax;
Screen->Message(pustring);
}
}
Anarchy_Balsac
02-17-2018, 01:00 PM
The Game->Max variables may themselves be constants, and even if they aren't, I don't recommend using them this way. You may not plan to use the things that they correspond to now, but if you decide to later, it'll mess you up badly.
Instead, I recommend using newly declared integers as your max, and using scripted pick up items that check for the max value before incrementing their respective item.
Lelouche Vi Britannia
02-17-2018, 07:25 PM
The Game->Max variables may themselves be constants, and even if they aren't, I don't recommend using them this way. You may not plan to use the things that they correspond to now, but if you decide to later, it'll mess you up badly.
Instead, I recommend using newly declared integers as your max, and using scripted pick up items that check for the max value before incrementing their respective item.
That's seems even more convoluted than how I did things before; which was creating ghost items for the potions, each designated max counter changes, and then using a "real" item with a bundle script to add them on pick up.
Anarchy_Balsac
02-17-2018, 11:13 PM
That's seems even more convoluted than how I did things before; which was creating ghost items for the potions, each designated max counter changes, and then using a "real" item with a bundle script to add them on pick up.
Video Game Programming is NOT simple. You do not have to like it, but it is the truth. even a simple NES style game takes more lines of code than you will ever remember, and if it is an RPG or anything involving an inventory and a wide array of monsters and power ups, you can easily do 10's of 1000's of lines of code.
So yeah, you shouldn't be going for simplicity, but for what works.
Lelouche Vi Britannia
02-18-2018, 02:08 AM
Video Game Programming is NOT simple. You do not have to like it, but it is the truth. even a simple NES style game takes more lines of code than you will ever remember, and if it is an RPG or anything involving an inventory and a wide array of monsters and power ups, you can easily do 10's of 1000's of lines of code.
So yeah, you shouldn't be going for simplicity, but for what works.
And this is why I'm not a programmer. The simplest solution is always the preferred. That being said, how would you even code what you just suggested?
Gleeok
02-18-2018, 04:23 AM
I haven't tried this yet, but just a quick question if anyone knows the answer.
I've set up a system were there are 4 types of potions, all with separate counters to keep track of amounts. I've been trying to figure out a way to use one item to increase the max counter size for all 4 of them.
I'm not sure how to go about this since I don't script often enough to "get good" which means every time I go back to my project, I have to do a little bit of reorienting and relearning. I imagine the functions "Max" and "Max Increment" are used somehow.
Sorry for being such a noob/pain, but am I anywhere close?
const int CR_POTA = 9;
const int CR_POTB = 10;
const int CR_POTC = 11;
const int CR_POTD = 12;
item script counterpickup
{
void run(int countermax, int pustring)
{
Game->Max[CR_POTA] == countermax;
Game->Counter[CR_POTA] == countermax;
Game->Max[CR_POTB] == countermax;
Game->Counter[CR_POTB] == countermax;
Game->Max[CR_POTC] == countermax;
Game->Counter[CR_POTC] == countermax;
Game->Max[CR_POTD] == countermax;
Game->Counter[CR_POTD] == countermax;
Screen->Message(pustring);
}
}
Game->Counter[] looks correct, but I'm not sure what Game->Max[] does here. I think you meant: "Game->MCounter[]" (M = Max).
Also you want to use"=" instead of "==" there. "=" to set a value, and "==" to test the values for equality (equals).
That looks like it should get it working. :)
Lelouche Vi Britannia
02-18-2018, 10:13 AM
Game->Counter[] looks correct, but I'm not sure what Game->Max[] does here. I think you meant: "Game->MCounter[]" (M = Max).
Also you want to use"=" instead of "==" there. "=" to set a value, and "==" to test the values for equality (equals).
That looks like it should get it working. :)
I knew I was close! And here I thought I forgot everything, thanks Gleeok!
Anarchy_Balsac
02-18-2018, 08:13 PM
And this is why I'm not a programmer. The simplest solution is always the preferred. That being said, how would you even code what you just suggested?
Yes and no, you don't want to over-complicate things, but taking shortcuts can REALLY fuck your game up, literally.
And it isn't difficult, just declare the new variables then swap them out with MCounter.
ZoriaRPG
02-20-2018, 05:01 PM
Video Game Programming is NOT simple. You do not have to like it, but it is the truth. even a simple NES style game takes more lines of code than you will ever remember, and if it is an RPG or anything involving an inventory and a wide array of monsters and power ups, you can easily do 10's of 1000's of lines of code.
So yeah, you shouldn't be going for simplicity, but for what works.
Actually, if you use CC65, you can write a basic NES (NROM) game, and remember all of it. :D
CC65 is a NES C compiler. Of course, that is a very simple game, unless you delve into ASM.
My suggestion on priorities:
Readability / Cleanliness
Efficiency
Minimalism (do the needed task)
Anarchy_Balsac
02-20-2018, 05:04 PM
Well sure, if you write a breakout clone. Then again, if you want to write a GOOD one, you probably WON'T be able to memorize it.
Curious, does CC65 have canned software like other compilers?
ZoriaRPG
02-22-2018, 05:14 AM
Well sure, if you write a breakout clone. Then again, if you want to write a GOOD one, you probably WON'T be able to memorize it.
Curious, does CC65 have canned software like other compilers?
CC65 has example software and NES .ROM file outputs to test, if you want to learn it.
It can only compileto NROM, which means that the limits are games similar to Donkey Kong. I think that the RAM table limit is 4KiB. I'd love to see something in the future that supports CNROM or MMC1, but I'm not holding me breath. Choke, cough.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.