Oct 11, 2015 at 10:05 PM
The TideWalker
Modding Community Discord Founder
"That dog!"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 26
so setting npc.inuse (as according to noxid's defines.txt) to 0 is suppose to make the NPC no longer appear on the map and makes the NPC's ID number avalible to be overwritten with another NPC by calling the NPC create command right?

Because it isn't doing it for me.


I made a simple NPC that moves around and creates children; the children display 4 sprites over 4 frames and then dissapears and sets NPC inuse to 0 the only issue is that after 100x0 entites spawn it stops and other NPC's on the map that create children NPC's stop doing so as well.

all children NPC's start with an ID above 100x0 for refrence.

I'm sorry to post all these issues that I can't figure out on my own, but It's not like I have someone I partner with that actually is good with asembly.

code for refrence:

Code:
offset NPC265 ;Replaces doctor Proj slow ball

#define

L_framerect_distance = 0
U_framerect_distance = 20

sprite height    = 10
sprite width     = 10

moveXvel         = 20
maxmoveXvel      = 500
moveYvel         = 20
max frames       = 4

npc.color        = [ecx+48]

#enddefine

push ebp
mov ebp,esp
setpointer
cmp npc.parent, 1
jge :child
add edx, moveXvel
cmp edx, maxmoveXvel
jl :move_vel_ok
mov edx, maxmoveXvel
:move_vel_ok
cmp npc.direction, 2
jne :vel_left
neg edx
:vel_left
;U/D movement
cmp npc.directive, 0
jne :setup_movement
mov npc.objecttimer, 28
mov npc.directive, 1
:setup_movement
inc npc.objecttimer
cmp npc.objecttimer, 50
jl :moveU
cmp npc.objecttimer, A0
jl :moveD
xor eax, eax
mov npc.objecttimer, al
jmp :setup_movement
:moveU
add eax, moveYvel
jmp :add_vels
:moveD
add eax, -moveYvel
:add_vels
add npc.Y eax
add npc.X edx
push 100 
;---
push 1
push 0
call RANDOM
add esp, 8
setpointer
xor edx, edx
;----
push eax    ;parent
push 0
push 0  
push 0
mov eax, npc.Y
push eax          
mov eax, npc.X
push eax          
push 109         ;265 dec   spawns itself  
call 46efd0      
add esp,20
xor edx, edx
mov npc.DisplayU, edx 
mov npc.DisplayD, edx 
mov npc.DisplayL, edx 
mov npc.DisplayR, edx 
jmp :end_of_code
;-------------------------------------------------
:child
inc npc.framenum
cmp npc.framenum, max frames
jl :render
xor eax, eax
mov npc.inuse, eax
;-------------------------------------------------
:Render 
xor edx, edx      
mov npc.displayU, dl                        
mov edx, npc.framenum              
imul dl, dl, sprite width
add dl, 80 
mov npc.DisplayU, edx                    
add edx, sprite width                          
mov npc.displayD, edx

mov eax npc.parent 
imul al, al, sprite height
sub al, 10 ;because npc.parent can't be 0 and sprites start at 0 on X axis
add npc.displayL, eax      
add eax, sprite height                  
mov npc.displayR,eax  

:end_of_code
mov esp, ebp
pop ebp
retn
 
Oct 13, 2015 at 6:35 PM
Lvl 1
Forum Moderator
"Life begins and ends with Nu."
Join Date: May 28, 2008
Location: PMMM MMO
Posts: 3713
Age: 31
Your definition names really really shouldn't have any spaces in them ( "sprite height", "max frames"). I'm not sure if this is what's causing your issues but I'd strongly recommend you use underscores instead. Also, are you stepping through the code and confirming that the line "mov npc.inuse, eax" is actually getting hit?

And if you want more help, I'd like to see your base define file as well, so we can see what "npc.inuse" is and whatnot.
 
Oct 13, 2015 at 7:06 PM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
well from what I can tell, for one when you create the entity you're handing it a random value of 0 or 1 for the parent attribute, which means children have a 50% chance of being parents. You should be pushing [ebp+8] for that value.
That might not be exclusively the problem but that might contribute to it.
Also the createNPC function has 8 arguments, you only push 7. Your 'starting slot' is completely undefined and i'm amazed it doesn't just crash.

@GIR npc.inuse is part of my personal defines set so it points to the right stuff using [ecx+XX] whatever
 
Oct 14, 2015 at 5:49 AM
The TideWalker
Modding Community Discord Founder
"That dog!"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 26
Umm, the 8th one that sets the starting slot is above the random function.

the sprites were suppose to change according to npc. parent, It was suppose to be 1-7 but somehow it got set to 0-1?

@GiR, it's perfectly ok to have spaces in the defines in the most recent version of the assembler.
 
Oct 14, 2015 at 4:19 PM
Lvl 1
Forum Moderator
"Life begins and ends with Nu."
Join Date: May 28, 2008
Location: PMMM MMO
Posts: 3713
Age: 31
@GiR, it's perfectly ok to have spaces in the defines in the most recent version of the assembler.

I still would strongly recommend against doing so, it's a bad habit to get into (variable names almost always have to have no whitespace in them in most languages).

But did you try stepping through the code to make sure the line where .inuse is set to 0 is actually getting hit?
 
Oct 15, 2015 at 2:23 AM
Neophyte Member
"Fresh from the Bakery"
Join Date: Mar 28, 2014
Location:
Posts: 7
I've seen this multiple times. How do I do this?
 
Oct 18, 2015 at 3:31 AM
Senior Member
"This is the greatest handgun ever made! You have to ask yourself, do I feel lucky?"
Join Date: Apr 29, 2015
Location:
Posts: 104
Age: 21
How do I set how much energy is dropped from capsules? When I destroy one in my level it drops nothing.
 
Oct 18, 2015 at 3:37 AM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
you set its flag ID or event number
 
Oct 23, 2015 at 11:38 PM
Off-screen redemption arc
"Ha! Ha! Ha! Mega Man is no match for my Mimiga Man!"
Join Date: Mar 28, 2014
Location: Los Angeles
Posts: 256
Age: 22
Can someone help me with using the Eye Door? I'm trying to copy Pixel's code (with the necessary adjustments of course) but I'm having trouble figuring out what is necessary for the door and what is just part of the game's intro (i.e. cutting to the Shelter cutscenes and stuff).
 
Oct 25, 2015 at 9:21 AM
Bonds that separate us
Forum Administrator
"Life begins and ends with Nu."
Join Date: Aug 20, 2006
Location:
Posts: 2850
Age: 33
There shouldn't be any TSC code to copy, the eye door is just an entity that animates when you move near it and does damage on contact. It then sets it own flag after dying so that it doesn't reappear again, leaving the doorway 'open'.
 
Oct 25, 2015 at 4:34 PM
Off-screen redemption arc
"Ha! Ha! Ha! Mega Man is no match for my Mimiga Man!"
Join Date: Mar 28, 2014
Location: Los Angeles
Posts: 256
Age: 22
Okay, thank you. I got confused and thought it turned into a door after it died.
 
Oct 25, 2015 at 5:15 PM
The "C" in "college" is for "crippling debt".
Bobomb says: "I need a hug!"
Join Date: Nov 12, 2014
Location: East Coast America
Posts: 759
Age: 23
How do I put a new sound effect into an empty sound effects slot? Like say if I wanted to keep all the current sounds but add one of my own for another event.
 
Oct 25, 2015 at 10:51 PM
The TideWalker
Modding Community Discord Founder
"That dog!"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 26
I'm currently trying to add on to my ASM hacking guide, I've written out some stuff on doing more with velocities and getting things to move fluently, but I then realised that I haven't ever actually done anyting like that before.


How do I get an object to move around another point like the red crystal moves around the doctor in vanilla?

How do I make NPC's move back and forth with fluid movement. I tried making a formula where X is added every frame and then after Y amount of time X negated is added every frame, but that only works if the said object is at a standstill on startup and you add 1/2 Y time on startup... I think, it's rather confusing and I'm not getting much of anywhere....

Other then that I have to make some other shortcuts you can take while modding, but yeah.

I'm terribly sorry if some of the questions have super simple answers, but I've never worked with this stuff in particular and can't find any example code/don't know where to look....
 
Oct 26, 2015 at 12:19 AM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
well I'm gonna preface this by saying that if you want to know how the crystal moves then the most direct approach would be to look at its code yourself, but

it's all just math and physics, really. Every object has a position, and a speed (velocity) which is the change in its position over time. You also have acceleration, which is the change in speed over time. There's also another level deeper called "jerk" which is change in acceleration over time, but we'll disregard that because it doesn't help us much in most cases.
In order to have believable motion you should manipulate acceleration to effect a change in position. Pick an acceleration speed, and each frame add it to your speed. In turn, each frame you also add your speed to your position. Simple as that. In cave story acceleration is usually represented by adding/subtracting hard-coded values to the speed directly because there isn't a variable for objects to store their acceleration. You can also simulate friction by adding an acceleration in the opposite direction to motion.

Now, for a more specific example I believe the crystal probably works on a simple "orbit point" algorithm. For this you just always accelerate towards the point in both the x and y axis, so if you're to the left of the point accelerate right, if you're above it accelerate down and vice versa. When you pass it you'll have a high speed so the change in acceleration will slow it down until it stops and starts going back the other way.
 
Oct 27, 2015 at 12:57 AM
Stoned Member
"All your forum are belong to us!"
Join Date: Sep 22, 2012
Location: Hell
Posts: 558
(this has probably been asked before)

Does anyone know what offset the location of the health bar is? I want to re-position it to the bottom left.
 
Oct 27, 2015 at 2:01 AM
Senior Member
"Huzzah!"
Join Date: Aug 24, 2013
Location: 0xDEADBEEF
Posts: 211
Top