Jump to content


Photo

Toss your semi-useful WeiDU macros here


66 replies to this topic

#61 c4_angel

c4_angel
  • Members
  • 28 posts
  • Gender:Male
  • Location:Shanghai, China

Posted 27 November 2017 - 02:15 PM

I may toss one here, but flawed I think.
 
Since TobEx expands the use of STATS.IDS to support new hard-coded stats and custom stats, this function aims ease-to-use and work in EE engine as well.
It should be used along with script trigger:
CheckStat(O:Object*,I:Value*,I:StatNum*Stats) for vanilla games (so ToBEx must be installed to make this happen) and CheckSpellState(O:Object*,I:State*splstate) for EE games.    
 
If anyone already have a better function to do this job please let me know.
 
Codes are here: https://github.com/S...unique_mark.tpa

Borrowed the FJ_SPL_ITM_REINDEX function for file correction, thanks to authors.
 

Function name: C4_FIND_STAT_SLOT and C4_ADD_UNIQUE_MARK

 

C4_FIND_STAT_SLOT is an action function, checks all creature/item/spell files in game which have effect using opcode #318 (vanilla game) or opcode #328 (EE game), also values in STATS.IDS or SPLSTATE.IDS, find an unused one from 501 to 32767, and append a line with an user defined "identifier"(requred). Return "available_stat" for further usage.

Spoiler

 

C4_ADD_UNIQUE_MARK is a patch function, calls C4_FIND_STAT_SLOT, and uses function CLONE_EFFECT to add an effect to creature/item/spell file with an user defined "identifier"(also requred), other parameters of the "match_" part are same with CLONE_EFFECT.

Spoiler

 

Take mage spell Blur for example:

Spoiler

 

Note the I:Value* must be fixed to 1, since CheckSpellState has no value parameter.


Edited by c4_angel, 27 November 2017 - 02:21 PM.


#62 kjeron

kjeron
  • Members
  • 72 posts

Posted 27 November 2017 - 02:36 PM

 

C4_FIND_STAT_SLOT is an action function, checks all creature/item/spell files in game which have effect using opcode #318 (vanilla game) or opcode #328 (EE game), also values in STATS.IDS or SPLSTATE.IDS, find an unused one from 501 to 32767, and append a line with an user defined "identifier"(requred). Return "available_stat" for further usage.

SPLSTATE values 256+ are set by the engine for other purposes. (STATS, Bardsong, Backstab, New Opcodes, some pulled straight from the EXE).

Setting them manually has no effect(mostly), but checking them is not reliable.



#63 c4_angel

c4_angel
  • Members
  • 28 posts
  • Gender:Male
  • Location:Shanghai, China

Posted 27 November 2017 - 02:47 PM

 

 

C4_FIND_STAT_SLOT is an action function, checks all creature/item/spell files in game which have effect using opcode #318 (vanilla game) or opcode #328 (EE game), also values in STATS.IDS or SPLSTATE.IDS, find an unused one from 501 to 32767, and append a line with an user defined "identifier"(requred). Return "available_stat" for further usage.

SPLSTATE values 256+ are set by the engine for other purposes. (STATS, Bardsong, Backstab, New Opcodes, some pulled straight from the EXE).

Setting them manually has no effect(mostly), but checking them is not reliable.

 

I did test in my mod at 500+, no bug found by now, is there any range already found? 32767 is top...

 

And are there any reliable way?


Edited by c4_angel, 27 November 2017 - 03:01 PM.


#64 kjeron

kjeron
  • Members
  • 72 posts

Posted 27 November 2017 - 03:42 PM

There are two gaps of 32 splstates that I haven't been able to map, one at 1664-1695 and one at 4224-4255, and then several semi-random gaps beyond 6240(where it starts pulling from the EXE).

 

SPLSTATE  500, for example, is set by BIT4 of the RESISTFIRE stat.

496 is set by BIT0 of RESISTFIRE, 497 of BIT1, 498 by BIT2, 499 by BIT3, 501 by BIT5 502 by BIT6, 503 by BIT7, 504 by BIT 8, 510 by BIT14, 511 by BIT15, then 512 is BIT0 of RESISTCOLD, and it continues on.

 

There are some usable SPLSTATE ranges within the stats, as some stats cannot carry values other than zero or one (BIT0), leaving the other 15 bits open, such as HELD (1409-1439), PLYMORPHED (1441-1471), ENTANGLE (1473-1503), SANCTUARY (1505-1535), MINORGLOBE (1537-1567), SHIELDGLOBE (1569-1599), GREASE (1601-1631), and WEB (1633-1663).

 

I made a table of all this here, excluding the values above 6240, as it varies depending on game version.



#65 c4_angel

c4_angel
  • Members
  • 28 posts
  • Gender:Male
  • Location:Shanghai, China

Posted 27 November 2017 - 09:40 PM

 

I made a table of all this here, excluding the values above 6240, as it varies depending on game version.

 

That's a great table. Thank you very much!

 

And I still may need help in two issues:

1. You mentioned "Spellstates 6240+ are dependent on the game campaign/version, read directly from specific offsets of the EXE. Pattern is 32(set) - 160(emtpy) - 32(set), and repeats semi-consistently up to the max (32767)". If I skip 6240-6271, use 6272-6431, then skip 6432-6463 ...etc, will function as expected?

 

2. Can I use splprot.2da to check them in script ? And how?



#66 kjeron

kjeron
  • Members
  • 72 posts

Posted 28 November 2017 - 04:22 AM

 

 

I made a table of all this here, excluding the values above 6240, as it varies depending on game version.

 

That's a great table. Thank you very much!

 

And I still may need help in two issues:

1. You mentioned "Spellstates 6240+ are dependent on the game campaign/version, read directly from specific offsets of the EXE. Pattern is 32(set) - 160(emtpy) - 32(set), and repeats semi-consistently up to the max (32767)". If I skip 6240-6271, use 6272-6431, then skip 6432-6463 ...etc, will function as expected?

 

2. Can I use splprot.2da to check them in script ? And how?

The semi-consistent part is that it occasionally has an extra multiple of 160 empty SPLSTATES between sets.  For example, BGSOD v2.3.67.3, starting from 6240, has:

3x(32 - 160 - 32) - 160 - 7x(32 - 160 - 32) - 1600 - (32 - 160 - 32) - (32 - 160 - 32) etc...

But I don't know if every game version has the same pattern off extra space or not.  I didn't go very far with it, other than to check from the other end (32767) to see if it was still in effect.  The second 32 of each such set has always had the exact same value though, 0x0000000a, using only bits 1 and 3.

 

SPLPROT only works in spells/items/projectiles, and comes with an entry for checking SPLSTATES, entry 110, using Parameter1 to specifcy the spellstate.

Scripts still have to use CheckSpellState().


Edited by kjeron, 28 November 2017 - 04:23 AM.


#67 c4_angel

c4_angel
  • Members
  • 28 posts
  • Gender:Male
  • Location:Shanghai, China

Posted 28 November 2017 - 04:55 AM

 

 

 

I made a table of all this here, excluding the values above 6240, as it varies depending on game version.

 

That's a great table. Thank you very much!

 

And I still may need help in two issues:

1. You mentioned "Spellstates 6240+ are dependent on the game campaign/version, read directly from specific offsets of the EXE. Pattern is 32(set) - 160(emtpy) - 32(set), and repeats semi-consistently up to the max (32767)". If I skip 6240-6271, use 6272-6431, then skip 6432-6463 ...etc, will function as expected?

 

2. Can I use splprot.2da to check them in script ? And how?

The semi-consistent part is that it occasionally has an extra multiple of 160 empty SPLSTATES between sets.  For example, BGSOD v2.3.67.3, starting from 6240, has:

3x(32 - 160 - 32) - 160 - 7x(32 - 160 - 32) - 1600 - (32 - 160 - 32) - (32 - 160 - 32) etc...

But I don't know if every game version has the same pattern off extra space or not.  I didn't go very far with it, other than to check from the other end (32767) to see if it was still in effect.  The second 32 of each such set has always had the exact same value though, 0x0000000a, using only bits 1 and 3.

 

SPLPROT only works in spells/items/projectiles, and comes with an entry for checking SPLSTATES, entry 110, using Parameter1 to specifcy the spellstate.

Scripts still have to use CheckSpellState().

 

 

a little confused with the pattern, but try start from 32767 will be a good idea, thank you.





Reply to this topic



  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users