Jump to content

Add projectiles


Demivrgvs

Recommended Posts

I'm not very familiar with these things...what have i to do if i want to assign a cfbatto.pro only to one header of the item?

 

ADD_PROJECTILE ~Item_rev\itm\CFBATTO.PRO~

 

COPY ~Item_rev\itm\SW1H51.ITM~ ~override\SW1H51.ITM~

SAY NAME1 ~Katana~

SAY NAME2 ~Celestial Fury +3~

SAY UNIDENTIFIED_DESC ~bla bla~

SAY DESC ~bla bla~

 

WRITE_SHORT 0x98 ~%cfbatto%~ // i suppose it will not work

 

Celestial fury has three headers...melee/magical/magical and i want to assign the .pro only to the second header. :)

Link to comment

Yeah, but if some other mod already makes heavy changes to the item, it's possible that the offset won't be the data you want to change (say somebody deleted an ability or two for whatever reason: your code would end up writing into some effect or out of bounds). The likelihood of this ever actually happening is fairly small, though, so I wouldn't worry too much.

 

For now, you should be pretty safe (it'll do what you want and should allow you to at least test it, and you can go back and come up with something more compatible in the future).

Link to comment
No, you need a loop to walk through each ability and set the projectile (every ability defines its own projectile).

 

You'd want one of the more compatible (more compatible-looking at least) renditions of (note that I'm just guessing at the offsets; I've been on vacation for a few months):

READ_LONG 0x64 ao
FOR (READ_SHORT 0x68 na; na; na -= 0x1) BEGIN
 WRITE_SHORT ao + 0x26 MY_PRO
 ao += 0x28
END

Keep in mind that when working with extended structures (like spell and item abilities) you shouldn't ever use absolute offsets in your writes (your WRITE_SHORT 0x98 could conceivably fail if somebody else's mod deleted the abilities and effects for whatever reason). For items and spells, if the offset is greater than 0x72, you'd want to look at reading the structure offset (0x64 for abilities and 0x6a for effects IIRC) and then writing into the structure from that offset (as with 'ao + 0x26' in the above code).

 

When in doubt, find the corresponding code from the fixpack and copy and modify it for your own use! :help:

 

 

What exactly is the structure offset? Is this the part that tells me how many extended ability headers are attached to the spell/item ability or is it something different? I'm not totally clear on what is being read into 'ao'.

 

FOR (READ_SHORT 0x68 na; na; na -= 0x1) BEGIN

I'm guessing that this says Apply the next lines after the BEGIN to each of the extended headers starting with "na" equal to the total number of extended header in the abilitys and effects section, subtract one from 'na' each time this loops'

 

Where I'm a little confused is this doesn't appear to tell it when to stop the loop, or does it automatically stop when it hits extended header 1?

 

WRITE_SHORT ao + 0x26 MY_PRO

 

Ok, I understand that here we are doing the equivalent of the WRITE_SHORT 0x98 ~CA#WAVE~ that I did in my batch of code, but instead responding to what the actual structure of the particular file is. However, why do you use the + 0x26, and how would I go about constructing a similar section of code without copying from one of the offset hacking masters?

 

ao += 0x28

 

Again, why use 0x28. What exactly is being done here?

Link to comment
What exactly is the structure offset? Is this the part that tells me how many extended ability headers are attached to the spell/item ability or is it something different? I'm not totally clear on what is being read into 'ao'.
'ao' is the abilities offset, listed at 0x64. It is the location into the resource where the ability structures are stored; for the count of the abilities (stored at 0x68), there is one 0x28 byte structure (0x38 bytes for items). The total size of the abilities is the count * 0x28 (the location of the end of the abilities begin offset + (count * 0x28)).

 

I'm guessing that this says Apply the next lines after the BEGIN to each of the extended headers starting with "na" equal to the total number of extended header in the abilitys and effects section, subtract one from 'na' each time this loops'
Correct. Every complete pass through the loop executes the code between BEGIN and END.

 

Where I'm a little confused is this doesn't appear to tell it when to stop the loop, or does it automatically stop when it hits extended header 1?
In a boolean condition, 0 is false and !0 (anything other than 0) is true. In the loop given, the number of abilities is read into 'na', the value of 'na' is checked (if 'na' is 0, the loop exits -- none of the code is run -- otherwise, the code is executed), and the value of 'na' is finally decremented by 1. Eventually, 'na' will be 0 and the loop will exit; with the given code, this happens to be once we've iterated through every single ability (since the count of abilities is 'na').

 

Ok, I understand that here we are doing the equivalent of the WRITE_SHORT 0x98 ~CA#WAVE~ that I did in my batch of code, but instead responding to what the actual structure of the particular file is. However, why do you use the + 0x26, and how would I go about constructing a similar section of code without copying from one of the offset hacking masters?
Because certain structures are optional (abilities, effects, etc.), a resource can't be assumed to have a size greater than 0x98 (your write would fail if the file had no abilities or effects; if it had only effects, you'd likely corrupt an effect by writing garbage (%CA#WAVE%) at some point in a particular effect). Knowing a given offset *into the particular structure*, you can always calculate the location of a particular field (in this case, projectiles are stored 0x26 bytes into an ability structure). Generally, you need the abilities offset and the count of abilities stored in some variable, and then can calculate the location of the projectile value in any one of the available abilities:

 

"offset + (0x2 * 0x28) + 0x26" is the offset of the projectile value of the third ability in the given spell.

 

Again, why use 0x28. What exactly is being done here?
'ao' is the abilities offset, and abilities are 0x28 bytes in size; each pass through the loop, the value of 'ao' is incremented, giving us the offset of the next ability (so if abilities started at 0x0, our first pass through the loop would be working with the first ability; on the second pass, 'ao' would be 0x28, and we'd be working with the second ability). It's also common to calculate this on the fly by just using more complex equations in the loop:
READ_LONG 0x64 ao
READ_SHORT 0x68 na
FOR (i = 0x0; i < na; i += 0x1) BEGIN
 WRITE_SHORT ao + (i * 0x28) + 0x26 MY_PRO
END

In this case, the value of 'ao' never changes, but for each pass through the loop, we're incrementing 'i', and adding "i * 0x28" to the abilities offset will be the offset of the i+1 ability in the file (e.g., on our second pass through the loop, 'i' will be 1, and "ao + (1 * 0x28)" is the offset of the second ability in the file).

Link to comment

I had to cut myself off (too much detail will cause my explanations to devolve into nonsensical blathering). If you have any specific questions for any of the stuff I tried to overview, don't hesitate to ask (at the least, one of the other "hacking masters" might be able to answer something more clearly).

Link to comment

Will do. I think what you laid out there gave me the insight I needed into the how and why you constructed the patching loop code and how I might adapt it for whatever modding purposes I may have.

 

One question though, if I am creating a custom spell with a custom projectile, all using my own naming convention is there any real advantage to using the loop over just a plain WRITE_SHORT 0x98 ~MYPRO~. It would seem that the simpler block of code would take less time to execute, and if someone else is messing around with my custom files then nothing I patched ahead of their fiddling is really going to stop them?

Link to comment
One question though, if I am creating a custom spell with a custom projectile, all using my own naming convention is there any real advantage to using the loop over just a plain WRITE_SHORT 0x98 ~MYPRO~. It would seem that the simpler block of code would take less time to execute, and if someone else is messing around with my custom files then nothing I patched ahead of their fiddling is really going to stop them?
None whatsoever. If you COPY your custom item (included with the mod), you can use absolute offsets without fear of anything bad happening. People who mess with your stuff assume the responsibility of ensuring that they don't break anything.

 

Re time, we're talking milliseconds here. There will be no observable difference between the loop and the straight WRITE. The only benefit is that there's less work for you to do (it's easier to WRITE_SHORT 0x98 than to construct a loop to do the same thing).

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...