Variable Points System

TurtleRescueNES

Active member
ezgif-1-cd681d2b5f64.gif

In the above clip, you'll notice two things. First, the monsters spawn a point value that rises upon defeat. Second, different monsters generate different point values and the appropriate values are added to the player's score. Simple stuff, right? Well, none of that was delivered out of the box with the NESmaker adventure and platforming modules. But now you can add this feature to your game with the following steps.

Step 1: GAME OBJECT TILES

Open your GameObjectTiles.bmp. You will need 8 tiles to store your points.
One tile should house "00". The other seven should house the numbers "1" through "7".
See image below for sample styles. Try creating your own look, but follow this structure.

GameObjectTiles.jpg

STEP 2: CUSTOM AI SCRIPT

You will need a dedicated AI Script that makes the points always move up.
The script is as easy as this:

LDA #%00100000
STA Object_movement,x

STEP 3: POINTS GAME OBJECT SETUP

Pick a Game Object to represent your point values. You only need one.
We will create code later that tells this singular object to display one of eight possible results. In my case, the points object is tenth in the list, so starting my count with zero, this is object number nine. Make note of this object number for later.

Your object should be one tile high and two tiles wide.

STEP 4: OBJECT ANIMATIONS

Click on Manage Animations. Create eight animations. Call them:
Points100
Points200
Points300
Points400
Points500
Points600
Points700
NoPoints

Within each animation, assign the appropriate graphic tiles to match the names of the animations you created. Note that for "NoPoints" you want to assign a blank tile. Each animation only requires one frame each.

PointsObject.jpg

STEP 5: OBJECT DETAILS - ANIMATIONS

Click on Object Details button. Create eight Animation Types. Call them:
100
200
300
400
500
600
700
NoPoints

Assign the appropriate Animations to each Type's directional movement.
Points will always move up, but to be safe, make them all match.

PointsAnimations.jpg

STEP 6: OBJECT DETAILS - DETAILS

Set both Normal Max Speed and Acceleration Speed to 16
All other settings should be defaults or unclicked.

STEP 7: OBJECT DETAILS - ACTIONS

You will utilize all eight action steps. They must be set up on the following order:

Action Step 0: Animation Type = NoPoints; Action = 0-Null; Timer = 0; EndAction = DestroyMe; EndAnimation = DestroyMe
Action Step 1: Animation Type = 100; Action = Move Up (Points); Timer = 2; EndAction = DestroyMe; EndAnimation = Loop
Action Step 2: Animation Type = 200; Action = Move Up (Points); Timer = 2; EndAction = DestroyMe; EndAnimation = Loop
Action Step 3: Animation Type = 300; Action = Move Up (Points); Timer = 2; EndAction = DestroyMe; EndAnimation = Loop
Action Step 4: Animation Type = 400; Action = Move Up (Points); Timer = 2; EndAction = DestroyMe; EndAnimation = Loop
Action Step 5: Animation Type = 500; Action = Move Up (Points); Timer = 2; EndAction = DestroyMe; EndAnimation = Loop
Action Step 6: Animation Type = 600; Action = Move Up (Points); Timer = 2; EndAction = DestroyMe; EndAnimation = Loop
Action Step 7: Animation Type = 700; Action = Move Up (Points); Timer = 2; EndAction = DestroyMe; EndAnimation = Loop

No animation speeds nor settings need to be checked for these action steps.
No bounding box needs to be set.

PointsActions0.jpg
PointsActions1.jpg

STEP 8: PROJECT SETTINGS

From the menu, select Project > Project Settings
Click on the User Variables tab
Create a variable called "varTempPoints" with a default value of 0
Click on User Constants tab
Create a constant called "#OBJ_MONSTER_DEATH" that contains the value of the Game Object you created to house the points. In my case, it was the ninth object so I have 9. Remember to start your count with zero.

STEP 9: CUSTOM CODE - HANDLE DROPS

Now we get to customize our game's code. Important: Your game may vary based on your base module and/or any customizing you may have done up to this point. We're not changing a whole lot, but still proceed with caution! Back up your scripts or comment out old code to easily restore it.

Open Scripts > Defined Scripts
Locate "Handle Drops" script
Locate the label "donePickup:"
Directly beneath that, alter/add the following code:

CreateObject temp, temp1, #OBJ_MONSTER_DEATH, #varTempPoints

What did we do? This code originally created the little poof effect when a monster is defeated.
Instead, we are calling the points object. The varTempPoints tells the points object which action state to display, from zero to eight. Remember, we defaulted that variable to zero, so nothing should actually appear yet.


STEP 10: CUSTOM CODE - HANDLE MONSTER HURT

Locate "Handle Monster Hurt" script
Locate the label "skipRecoilBecauseOnEdge:"
Move down to the macro "DeactivateCurrentObject"
Directly beneath that, you will need to replace the scoring code with the following:

LDY Object_type,x
LDA ObjectWorth,y
STA varTempPoints
AddValue #$06, myScore, varTempPoints, #$02

What did we do? This code is called when the monster is destroyed and is supposed to increment your score. In this case it wants to increment the score in the hundreds place with the value of varTempPoints. We defaulted that variable to zero, but this code is overwriting that value with the contents of "ObjectWorth". What's that, you say? This is the fun part!

STEP 11: ASSIGN POINT VALUES TO YOUR MONSTERS!

Open up one of your monster's Object Details
Click on Details tab
Look at the Experience setting. Experience defaults to 0, and before the above code was added, monster experience values were never utilized. You can now set each of your monster's experience to a value from 0 to 7. 0 represents no points/no action, 1 represents 100 points, 2 represents 200 points and so on...

MonsterExp.jpg

CONGRATULATIONS!

You now have a variable scoring system in place that behaves similarly to many of the classic games of the 80s and 90s! There is a known limitation with this setup in that you cannot go higher than 700 points, but maybe someone can improve upon this approach.

Happy gaming!

Joe
"Turtle Rescue"
 

TolerantX

Active member
Since nobody else posted on this topic, I will post my specific problem I'm having. I am using the two player single screen module provided by Dale Coop. I'm using a Melee object for weapons... and when I kill the monster the game freezes momentarily.. then makes the number (wrong number) and removes the HUD completely.. (*you've seen the video) Thank you for your help, Turtle Master Joe.
 

TurtleRescueNES

Active member
(Side note for others reading, I was given a video that was not shared publicly)

You're doing a platforming game, so gravity is always in play. Make sure your Points object is set to ignore gravity.

I see the HUD disappears before the points spawn. That tells me something is up with the monster collision with your melee and/or hero. Notice how the HUD disappears tile by tile? That tells me its a text box. Is it possible your monster is flagged as an NPC and it's trying to fill the HUD with a text box? If you haven't already, it's always a good idea to place something in Text Entry 0 so if a text box is accidentally called, you'll know it.
 

TolerantX

Active member
Okay... I did a fresh install of NESmaker 4.1.5 using Single Screen Platformer... I enabled the real object melee weapon (not the sprite weapon) and other than that my install is vanilla NESM 415.

I keep getting this error:

Routines\Basic\ModuleScripts\HurtWinLoseDeath\HandleDrops.asm(38):CreateObject(36): Unknown label.
demo.txt written.

(I sent you the pics of the error and other things that may affect it. I dont have a website to post them to and share here.)

varTempPoints is setup to my knowledge correctly. My object used in mine is also number 9 as well.
Please help me fix this error. Thank You.
 

TurtleRescueNES

Active member
Open up the Handle Drops script. Is this on line 36:?

CreateObject temp, temp1, #OBJ_MONSTER_DEATH, #varTempPoints

Then the compiler is having issues with one of the two labels, either OBJ_MONSTER_DEATH or varTempPoints.

Make sure OBJ_MONSTER_DEATH is declared in Projects > User Constants and varTempPoints is defined in Projects > User Variables

Is this the only error you get? I'd think that you should be getting more if the labels are not defined correctly.
 

PewkoGames

Member
I'm positive its in the right spots
I'm not sure why its not working

Here are screens:

unknown.png

unknown.png


and edited scripts:

unknown.png

unknown.png


Zero clue what It could be.
 

TurtleRescueNES

Active member
Do this for me. Find the demo.txt file in your NESmaker directory. Search for "UserVariables"
Do you see it, and do you see varTempPoints right below it?
 

TurtleRescueNES

Active member
I see something now. You're on a newer module than I was when I built this system so my module doesn't require currentNametable

Your line should actually be this:
CreateObject temp, temp1, #OBJ_MONSTER_DEATH, varTempPoints, currentNametable
 

PewkoGames

Member
Okay! I can at least play it! So there is 2 issues I'm noticing. 1: When I use my melee weapon, my player floats to the top of the screen. And when I attack an enemy, I only get 1 point and the graphics of the point values do not show up.
 

PewkoGames

Member
So I tried something: I used a null AI action (AI ACtion 11) for the moveup points script. By changing it back to Null that fixed the issue of the player floating to the top. I tried making a NEW action for the moveup points but I have zero clue how to add that to my monster object details menu.
 

TurtleRescueNES

Active member
Sorry, wasn't able to log in last night. Here now!

So you now have an alternate action for points moving up? Which number action is it? Because this is actually easy.
Whichever action (AI) script is it, just go into Project Settings > Labels > Action Types and find the appropriate number and rename it "Move Up (Points)" BTW, this step is optional, but helps make things easier later on. Once you do that, go to your Points object and go through every Action Step and change every Action to Points (Move Up). See my original STEP 7 if that doesn't make sense.
 

PewkoGames

Member
Hey! So I did that. But its still not working. Like, the game runs but when I kill an enemy it just disappears and I get 1 point per enemy. Its AI action 11 by the way.
 

TurtleRescueNES

Active member
Try this to prove it works or not:

Two different enemies in your monster group. Differentiate them somehow, even if its by color.

Monster 1 has Experience of 3 while Monster 2 has Experience of 4 (Step 11 in my original post)

Just change those things, compile, kill 'em and report back.
 

PewkoGames

Member
[media]https://www.youtube.com/watch?v=_vLokej5nEs[/media]

Tried that too.

2 different monsters (they have the same color but 1 has 3 exp, 1 has 4 exp)

I don't know why this isn't working.
 
Top Bottom