S. P. Gardebiter said:
WeaponObj[0x00].NumImpacts?
That's the amount of impacts the bullet can take before disappearing (on an NPC; scenary is a little different.) Most weapons set it to 1 (disappear as soon as you hit something) but others have a higher value (such as the missile's explosions) so multiple targets can be hit by it.
S. P. Gardebiter said:
Drawing is the same as the NPC's right? Also the moving?
All structures in the ROM use the exact same mechanism. The API used to render things in CaveStory is DirectDraw, which works with RECTs rather than integers to describe positions. So whenever you want to render something, you'll have to define a RECT containing the current frame to render in the specific weapon/npc/effect/etc's handler.
Same goes with moving. Of course you'll have to write to the appropriate location in memory, but that goes without saying.
S. P. Gardebiter said:
I need to add 1 to the WeaponObj[0x00].Distance every frame right?
Not necessarily. "Distance" means the weapon has moved. Once it has moved "MaxDistance" units, the code is responsible for removing the bullet.
This opens a lot of possibilities: you could, for instance, have a weapon that "leapfrogs" from target to target. Its max distance could increase with every hit so that it'd have to keep hitting targets to "survive." Or your weapon could sit in place and fly right at an enemy once it comes within range - only then would its Distance member change.
S. P. Gardebiter said:
And at the start I need to set the WeaponObj[0x00].MaxDistance and then set WeaponObj[0x00].WasSetup?
Do I need to set WeaponObj[0x00].Damage too?
A lot of the members in the WeaponObj object don't have any use outside of the handler, so you can do whatever you want with them. WasSetup is one of those. This member is used internally by the programmer to keep track of when the setup phase is done. Your code should look like...
Code:
(frames go here)
if WasSetup then
(initialize everything)
else
(the bullet is now in motion - update it)
(render)
But you could use WasSetup for other things. Suppose you had a fireball that gets lobbed at the enemy, hits the ground, and burns for a while. You could store the burn duration in WasSetup for all CS cares - it can't tell the difference unless some OTHER bit of code uses it and expects it to behave that way.
Ideally, you shouldn't do that though.
It's risky and you might find yourself chasing down bugs for a long time.
As for MaxDistance, it is automatically set through the weapon data in the ROM (I posted this in another thread but just in case, poke around 0048F048. Each structure is 0x2C bytes in length. The fifth byte is the distance.)
S. P. Gardebiter said:
Is there anything to pay attention at left? D:
Your best bet, as always, is to have a look at the code that's already there.