Jump to content


Photo

Help me out with a script, will you?


  • Please log in to reply
14 replies to this topic

#1 temnix

temnix
  • Member
  • 983 posts

Posted 12 June 2017 - 08:29 AM

I want to patch all creatures to apply a Polymorph (135) on themselves at creation, the polymorph pointing to the file name of the creature. They would turn into themselves. Why? Here is what I wrote at Beamdog's, but I think stand a better chance of getting good code here, I think. Less noise in the air.

 

"Animations come with ready sounds when they should not. No matter what you put in a CRE's ATTACK, DYING and DAMAGE sounds (and those sounds play), the animation's ready sound will play also. Anybody with an ogre avatar gives a shrill yell when he dies, anyone with a xvart avatar screams "Eeeeeee" when he attacks. An imp avatar always squeaks, and if you make an invisible imp to use as a minion, you can't shut it up in case of accidental damage. These integrated sounds of creatures play even under Silence. I don't know why Bioware did it this way, maybe there was no difference in their minds yet between an animation and a creature. They wanted to embed sounds in visuals and then just use those. But now that there are all sorts of avatar-changing tricks and polymorphs, many more than actual creature types, animations need to be cleansed of these internal sounds. Someone at Beamdog should sit down and look in those files, and after sounds uproot other weirdness, like the Volo avatar's immortality. The Burning Man avatar has in-built fire resistance. And so on.

After I typed this and was ready to send, I realized there was one polymorph possibility I had not explored, so I did: Polymorph (135) with "Change into" (stat 0). And I was surprised. The other parameters, "Appearance only," and other ways of changing the avatar all produce figures with these ingrained sounds. But 135 with stat 0 takes them away. This is what allows your character not to bubble like an ooze if you are killed polymorphed into one but scream your own death scream instead. What should be done for all monsters - and this shows you what an awkward situation we are in - is for them to receive this Change-0-polymorph into themselves, so they lose the ingrained sounds. They would still keep their regular sound bits from the TLK as written in the CRE file, but now modders would be able to mod creature sound sets.

To put it simply: right now you can't diversify or change the sound set for, say, ogres, nor create your own breed of ogres who sing falsetto. You just can't, because they will die and groan and attack with their ingrained thing. Your custom sounds will play alongside with that or you will have to compromise and just stick to the polite right-click sounds, SELECT_COMMON and INITIAL_MEETING. But change everybody into themselves first, and then assigned sounds will play properly."

 

So what I need is patching code that looks at a creature's filename, records it, then patches it with a Polymorph, stat 0, pointing to that file name in the Resource field. When that's done, not only is it going to benefit everyone, but also my animated corpses can start moaning like zombies should.

 

Another idea just offered at Beamdog's was to edit the INI files of animations and remove the sounds. May be easier?



#2 temnix

temnix
  • Member
  • 983 posts

Posted 14 June 2017 - 02:58 PM

Okay, never mind that one. What am I doing wrong here?

 


COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ override
PATCH_IF (0x272 = 144) | (0x272 = 145) | (0x272 = 149) (0x272 = 176) | (0x272 = 173) | (0x272 = 180) THEN BEGIN
  LPF ~ADD_CRE_EFFECT~ INT_VAR opcode = 146 target = 1 power = 1 casting_level = 0 parameter2 = 1 probability_1 = 100 timing = 1 duration = 0 resist_dispel = 0 STR_VAR resource = ~ANIMA2_#~ END END
  LPF ~ADD_CRE_EFFECT~ INT_VAR opcode = 206 target = 1 power = 1 casting_level = 0 parameter2 = 1 probability_1 = 100 timing = 1 duration = 0 resist_dispel = 0 STR_VAR resource = ~ANIMA6_#~        
        BUT_ONLY


#3 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5148 posts

Posted 14 June 2017 - 03:11 PM

Okay, never mind that one. What am I doing wrong here?

Is the second END in the wrong place, as in, are you trying to patch every creature the game has with the second effect, or ? Cause that's what the above does...

Or you might just need a ELSE there...

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ override
PATCH_IF (0x272 = 144) | (0x272 = 145) | (0x272 = 149) (0x272 = 176) | (0x272 = 173) | (0x272 = 180) THEN BEGIN
  LPF ~ADD_CRE_EFFECT~ INT_VAR opcode = 146 target = 1 power = 1 casting_level = 0 parameter2 = 1 probability_1 = 100 timing = 1 duration = 0 resist_dispel = 0 STR_VAR resource = ~ANIMA2_#~ END 
ELSE
  LPF ~ADD_CRE_EFFECT~ INT_VAR opcode = 206 target = 1 power = 1 casting_level = 0 parameter2 = 1 probability_1 = 100 timing = 1 duration = 0 resist_dispel = 0 STR_VAR resource = ~ANIMA6_#~ END
        BUT_ONLY

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#4 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 14 June 2017 - 05:03 PM

What am I doing wrong here?

 


1) You don't seem to read the 0x272 beforehand

2) There's no OR between 149 and 176

3) You're using | (which is BOR aka bitwise or) instead of || (which is simply OR). I once stepped onto this myself, heh.

4) As Jarno says, there's an extra END after the 1st LPF and no closing one after the second

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ override
 READ_BYTE 0x272 race
 PATCH_IF (race = 144) || (race = 145) || (race = 149) || (race = 176) || (race = 173) || (race = 180) THEN BEGIN
   LPF ~ADD_CRE_EFFECT~ INT_VAR opcode = 146 target = 1 power = 1 casting_level = 0 parameter2 = 1 probability_1 = 100 timing = 1 duration = 0 resist_dispel = 0 STR_VAR resource = ~ANIMA2_#~ END
   LPF ~ADD_CRE_EFFECT~ INT_VAR opcode = 206 target = 1 power = 1 casting_level = 0 parameter2 = 1 probability_1 = 100 timing = 1 duration = 0 resist_dispel = 0 STR_VAR resource = ~ANIMA6_#~ END
BUT_ONLY

Edited by GeN1e, 14 June 2017 - 05:03 PM.

Retired from modding.


#5 temnix

temnix
  • Member
  • 983 posts

Posted 15 June 2017 - 01:43 PM

That code has got spell names mixed up. I'm going to fix that now. It's true, I didn't read 0x272 first. There is no need for that, if I know what 0x0272 refers to. The missing OR - possibly that's the reason for the error. And I'll use II as you say, Ardanis. In answer to Imp, the reason the second bit of code is outside the patching function with its IF condition is because I want to patch only creatures of those races with that effect - it's an immunity to something that will happen to zombies. Those races are excluded. But every creature should be patched with the other effect - an invisible minion on death. The minions have been scripted not to respond to raising if the creature is of the wrong race, but they should still spawn to ensure corpse permanency, or rather endurance for 24 hours. Responsiveness to necromancy and decay overlap, but not completely. E.g. a golem should neither decay nor rise, but a shambling mound should decay but not rise; both should be immune to certain cosmetics, hence the protection. Control over decay is not here, though, it's inside the minion script.

 

So this needs to cover:

 

1) Select races get Protection from Spell, 206 (it's a different spell, as you can see)

2) Everybody gets Cast Spell, 146

 

Is this right?

 

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
PATCH_IF (0x272 = 144) || (0x272 = 145) || (0x272 = 149) || (0x272 = 176) || (0x272 = 173) || (0x272 = 180) THEN BEGIN

LPF ~ADD_CRE_EFFECT~ INT_VAR opcode = 206 target = 1 power = 1 casting_level = 0 parameter2 = 1 probability_1 = 100 timing = 1 duration = 0 resist_dispel = 0 STR_VAR resource = ~ANIMA6_#~
END
END
LPF ~ADD_CRE_EFFECT~ INT_VAR opcode = 146 target = 1 power = 1 casting_level = 0 parameter2 = 1 probability_1 = 100 timing = 1 duration = 0 resist_dispel = 0 STR_VAR resource = ~ANIMA2_#~ 
BUT_ONLY

 

Now that I think of it, though, I also need to include another universal patch here - to make all corpses permanent unless the creature is set to leave none. So, set flag 2 for that 0x10 offset unless flag 1 is already set.


Edited by temnix, 15 June 2017 - 01:46 PM.


#6 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 16 June 2017 - 12:17 AM

It's true, I didn't read 0x272 first. There is no need for that, if I know what 0x0272 refers to.

 

Maybe you do. WeiDU doesn't, however, and unless you read it somehow, it will compare the 0x272 value itself against the race list, not what's written at this offset.


Retired from modding.


#7 temnix

temnix
  • Member
  • 983 posts

Posted 16 June 2017 - 08:08 AM

Ardanis, you usually give proven advice. I've done this sort of thing a dozen times... How about code for "If this flag is not set, then set another flag"?



#8 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 16 June 2017 - 02:36 PM

I've done this sort of thing a dozen times...

 
You mean WeiDU actually recognizes (0x272 = 144) as (BYTE_AT 0x272 = 144)? That's news to me.
 

 

How about code for "If this flag is not set, then set another flag"?

 

WRITE_BYTE offset (THIS & BIT1) ? (THIS | BIT2) : THIS // if BIT1 is set, then set BIT2, else don't change
WRITE_BYTE offset !(THIS & BIT1) ? (THIS & `BIT2) : THIS // if BIT1 isn't set, then unset BIT2, else don't change


Edited by GeN1e, 16 June 2017 - 02:38 PM.

Retired from modding.


#9 temnix

temnix
  • Member
  • 983 posts

Posted 17 June 2017 - 05:03 PM

I've done this sort of thing a dozen times...

 
You mean WeiDU actually recognizes (0x272 = 144) as (BYTE_AT 0x272 = 144)? That's news to me.
 

 

Think about it. Machines aren't intelligent. They don't understand words. With your READ command you are converting what's originally a number into a word token, then you assign another number to that token. Why not just assign a number to a number? I'll check out your code.



#10 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 17 June 2017 - 06:09 PM

You MUST read a value from offset before you can evaluate it, with READ_BYTE, BYTE_AT or THIS (or something else I may have forgotten), whichever is appropriate in context. You CAN NOT just throw in a random number and expect the program to know it was the location of the value and not the value itself.

 

Why not just assign a number to a number?

Only if you did READ_BYTE 0x272 0x272 to assign the value at offset 0x272 to the variable named 0x272 (which is string, not a "number" as you say), which wasn't present in the code snippet you've posted. Although I've no idea if WeiDU would know to compare against the "0x272" variable instead of 0x272 value, won't be surprised if it doesn't...


Retired from modding.


#11 temnix

temnix
  • Member
  • 983 posts

Posted 18 June 2017 - 01:47 AM

You MUST read a value from offset before you can evaluate it, with READ_BYTE, BYTE_AT or THIS (or something else I may have forgotten), whichever is appropriate in context. You CAN NOT just throw in a random number and expect the program to know it was the location of the value and not the value itself.

 

Why not just assign a number to a number?

Only if you did READ_BYTE 0x272 0x272 to assign the value at offset 0x272 to the variable named 0x272 (which is string, not a "number" as you say), which wasn't present in the code snippet you've posted. Although I've no idea if WeiDU would know to compare against the "0x272" variable instead of 0x272 value, won't be surprised if it doesn't...

 

You aren't listening. I've told you it works perfectly. And for your information, there is no such thing as "strings" to a machine, any more than Bill Gates in his green sweater. This is all on the human interface level, in the macroworld, made convenient for us. The only thing a machine knows are on-off signals, bytes, and that the pretty and colorful stuff we get to see - words included - get converted into that. Naturally, I don't feed Weidu random numbers. I look the offsets using Near Infinity.



#12 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5148 posts

Posted 18 June 2017 - 03:12 AM

You aren't listening. I've told you it works perfectly. And for your information, there is no such thing as "strings" to a machine, any more than Bill Gates in his green sweater.

Yeah, the 0x242 is a number, but it's not 144 though, it's 578 in the normal decimal numbers. Aka not 144 or what ever other number you tried to equate it to. So the patching will never start to any of the .cre's. That's what GeN1e tries to say to you.

Aka you you HAVE to use a string variable to read the .cre's content to try to equate it to a number of your choice.... to actually try to get the above to work, as you intend it to.

As he knows this better than you, you should listen to him, not the otherway around, child.


Edited by The Imp, 18 June 2017 - 03:20 AM.

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#13 temnix

temnix
  • Member
  • 983 posts

Posted 19 June 2017 - 03:14 AM

Imp, you're dumb. This is now official.

 

Fucking go and run the code.



#14 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 19 June 2017 - 01:58 PM

Out of pure curiosity, have you even seen your code actually patch the golems with 206 effect?


Retired from modding.


#15 temnix

temnix
  • Member
  • 983 posts

Posted 20 June 2017 - 11:31 AM

I had the opcodes and effects mixed up, wrong names in the wrong places. But the patching was carried out.