Jump to content


Photo

Setting a spell state with Weidu


  • Please log in to reply
56 replies to this topic

#41 Avenger_teambg

Avenger_teambg
  • Member
  • 604 posts

Posted 11 December 2017 - 03:58 AM

There is nothing wrong with testing the fringes of engine capabilities. Hell, i did the same 10 years ago and it was much more fun than writing yet another romance mod.

There isn't even any problem if you don't realize the limits of the engine.

The problem is where you react totally hostile when someone points at the limits.

I recall arguing with David Gaider on the old Bioware forum about inner workings of the scripting engine, but i never behaved even close to what you are performing here.


Avenger

#42 -kjeron-

-kjeron-
  • Guest

Posted 11 December 2017 - 04:58 AM

The higher spellstates are set by just about everything else, but setting them has almost no noticable effect, until you reach the 3rd byte, then random crashes start occurring.  Thus far: https://forums.beamd...#Comment_901480



#43 temnix

temnix
  • Member
  • 983 posts

Posted 11 December 2017 - 09:28 AM

:lol2:  What is the 3rd byte in human language? And you're going to have to explain this to me: "These are all a one-way influence, they will set the spellstates, but the spellstates have no effect on the value used by them if you were to set them manually through opcode 328/335."

 

If this means that the engine doesn't differentiate between those high states, then that's not true. As I've said in the beginning, a script made to check for 521, BOY does not return true for 521, GIRL, when a creature is in both those states.



#44 Avenger_teambg

Avenger_teambg
  • Member
  • 604 posts

Posted 11 December 2017 - 10:38 AM

:lol2:  What is the 3rd byte in human language? And you're going to have to explain this to me: "These are all a one-way influence, they will set the spellstates, but the spellstates have no effect on the value used by them if you were to set them manually through opcode 328/335."

 

If this means that the engine doesn't differentiate between those high states, then that's not true. As I've said in the beginning, a script made to check for 521, BOY does not return true for 521, GIRL, when a creature is in both those states.

 

Reading the mirror image of a bit of a stat doesn't mean you have full control over that bit. What you see is a temporary copy. Depending on where you try to tamper with it (equipping effect or not equipping effect), or the effects surrounding your 'state setting' attempt (whether they force a reevaluation of the effect stack or not), may very well change the outcome.  I think he meant 3rd byte as 3rd byte in the spell state index. 

Like a spell state >65535. And yeah, using sufficiently large numbers, you totally index out of the creature into random memory land. But even small numbers could be fatal, if you hit a complex variable type and not simple resrefs and integers, you can get pretty nice memory allocation errors or the stuff i called malware.


Edited by Avenger_teambg, 11 December 2017 - 10:39 AM.

Avenger

#45 temnix

temnix
  • Member
  • 983 posts

Posted 12 December 2017 - 01:39 AM

Get your terms straight. Malware is software made to harm - not software that admits and uses flaws. With this engine it's necessary sometimes to go by the back door. Unless you are prepared to stay on the nice island of small expectations. Then you're safe, sure. And I still have seen no trouble from these states, and kjeron says the engine uses a whole lot of those numbers for its purposes, crashing nothing. I'm not going to worry about bugs that may not ever materialize. If they do, then I'll cross that bridge. End of a very boring discussion.



#46 -kjeron-

-kjeron-
  • Guest

Posted 12 December 2017 - 05:20 AM

Even if the lower 256+ values do not crash, that doesn't mean they are reliable.  For example, spellstate 522 is set by the creatures Cold Resistance stat, so certain cold resistance values will interfere with detecting it.  They won't prevent it from being detected, but instead cause it to always return true/set.



#47 temnix

temnix
  • Member
  • 983 posts

Posted 12 December 2017 - 08:53 AM

How serious is it? Does any cold resistance set it off? Let's see what we can do with it and what not. In this case it wouldn't matter, because I'm patching only innocents with four states, and they don't have any cold resistance.



#48 Avenger_teambg

Avenger_teambg
  • Member
  • 604 posts

Posted 12 December 2017 - 12:49 PM

Either your state won't be set, in this case you detect one bit of whatever value is written to the cold resistance field (always 0 for your innocents)

or you will be able to set the value, in this case, you will make your innocents cold resistant yourself.

 

And this is the less of the problem. If you were only about to change or read otherwise unreachable bits, it could work.

 

But you want to store 2 bits of information on a single bit. Once overwritten, the old value is lost. You cannot stuff the worms back into an opened can of worms. And you cannot go backwards in time.


Avenger

#49 Cuv

Cuv

    Area Maker (retired)

  • Modder
  • 925 posts

Posted 12 December 2017 - 01:22 PM

Wow, just wow

 

If you refuse to listen to the person who KNOWS, maybe you should leave modding to actual modders Temnix?  Just a thought.  



#50 temnix

temnix
  • Member
  • 983 posts

Posted 13 December 2017 - 12:45 AM

Either your state won't be set, in this case you detect one bit of whatever value is written to the cold resistance field (always 0 for your innocents)

or you will be able to set the value, in this case, you will make your innocents cold resistant yourself.

 

I could pick some other values, if there really was resistance-setting. But I tested just now and the states 520-523 that I use for innocents are both set and detected and give them no resistances to any damage type. Any more speculations?



#51 -kjeron-

-kjeron-
  • Guest

Posted 13 December 2017 - 04:53 AM

I could pick some other values, if there really was resistance-setting. But I tested just now and the states 520-523 that I use for innocents are both set and detected and give them no resistances to any damage type. Any more speculations?

It's the other way around, any creature with specific cold resistance values will always have those spellstates set.  IIIRC, most negative cold resistance values will set number 522.  It's not just those 4 innocents you need to worry about, but every other creature in the game that might have cold resistance, even temporary cold resistance from spells/items.

 

I've only seen false positives when checking spellstates set with opcode 328, while setting them with opcode 335 has produced both false positives and false negatives under certain conditions.



#52 temnix

temnix
  • Member
  • 983 posts

Posted 13 December 2017 - 04:58 AM

Negative cold resistance? Who has that? Anyway, since innocents don't have cold resistance and the spell state check is preceded by a class check, this isn't going to be a factor. More generally, the point is.... but then, I've already given enough metaphors.



#53 subtledoctor

subtledoctor
  • Modder
  • 656 posts

Posted 13 December 2017 - 11:57 AM

Profiles in Courage over here. :lol:

EDIT, because I'm nice and try to stay on-topic and productive:

It's only silly because there's no actual upside to using spellstate 12,463 instead of 127 or another available one below 256. There aren't remotely enough mods on the horizon to expect players will run out. And even if they do run out you can just use your higher bit as a back-up alternative.

And if you want to use a bunch of spellstates yourself, say, two or three hundred of them like the mod I've been tinkering with, then you should just use a proficiency instead of spellstates. It's functionally equivalent and there are a metric ton of unused values.

But what do I know, apparently I live in a box? :P

Edited by subtledoctor, 13 December 2017 - 12:14 PM.


#54 temnix

temnix
  • Member
  • 983 posts

Posted 20 December 2017 - 06:31 PM

kjeron, are you here, by any chance? Considering this "overflow" thing, one variable being written into instead of another, what would correspond to the "XP value" field of CREs? Where would I need to make "misplaced" changes to overwrite that?



#55 subtledoctor

subtledoctor
  • Modder
  • 656 posts

Posted 25 December 2017 - 09:54 PM

Somewhat on this subject: is there in fact a macro floating around for finding and using the next available spellstate in splstate.ids?  I think I'm finally going to bite the bullet and use a spellstate for something, I've found a situation where it works better than a proficiency (I think).



#56 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 26 December 2017 - 10:27 AM

https://github.com/G...ib/ds.tph#L1025

 

LAF ds_resolve_stat INT_VAR ids=1 STR_VAR id= MY_NEW_SPELLSTATE RET stat_ind=stat_ind END
PRINT ~MY_NEW_SPELLSTATE was assigned %stat_ind% value~

For more context/commentary, see from around here https://github.com/G...lib/ds.tph#L605


Retired from modding.


#57 subtledoctor

subtledoctor
  • Modder
  • 656 posts

Posted 26 December 2017 - 10:57 AM

Awesome, thx. (Though, I might end up using a stat after all, since I just learned how to use spellstates for bitwise stat checks and I had already set aside a bit in stat 134 to use for this... we'll see.)

Edited by subtledoctor, 26 December 2017 - 10:57 AM.