Jump to content


Photo

Adding String References


  • Please log in to reply
7 replies to this topic

#1 Jewels

Jewels
  • Member
  • 36 posts

Posted 06 August 2009 - 04:54 PM

I have a custom lower resistance spell which lowers resistance by 30%, and I want to be able to add that to the display text when the spell is cast. At the moment my I simply have SAY NAME1 and SAY NAME2 for the spell name when copying the spell (I haven't bothered with the description as it's an innate ability).

#2 Cuv

Cuv

    Area Maker (retired)

  • Modder
  • 925 posts

Posted 07 August 2009 - 12:35 AM

Below is a snip from a TP2 for a project that I was working on several years ago. You can set your string in the file during installation. You just need the hex address from the file you want to patch. I included the 'Prot/Good' spell because with a lower resist you might need also to patch each leveled effect.

Hope it helps, or at least gives you some ideas

Cuv


// ...Spells
COPY ~ExpAssylum/Spl/CVFFLOK.spl~ ~override~
SAY 0x8 ~Targetting~ // general name
SAY 0x50 ~This spell attempts to set a stat checkable by scripts to avoid friendly fire~
SAY 0xfe ~Locking Targets~ // String This spell also sets the GLOBAL "CVLock" to 1
COPY ~ExpAssylum/Spl/Kessyl1.spl~ ~override~
SAY 0x8 ~Topaz Dragon Breath~ // general name
COPY ~ExpAssylum/Spl/CUVDRG.spl~ ~override~
WRITE_ASCII 0xde ~KAwake~ // Global Variable
COPY ~ExpAssylum/Spl/CVPROGD.spl~ ~override~
SAY 0x8 ~Protection From Good 10' Radius~ // general name
SAY 0x50 ~Protection From Good 10' Radius
(Abjuration)
Level: 4
Sphere: Protection
Range: Touch
Duration: 1 turn/level
Area of Effect: 10' radius
Saving Throw: None

When this spell is cast, all creatures within a 10' radius are affected individually by 'protection from good'. It creates a magical barrier around the recipients at a distance of one foot. The barrier moves with the recipient and has two major effects: First, all attacks made by good or goodly enchanted creatures against the protected creature receive a penalty of -2 to each attack roll, and second, any saving throws caused by such attacks are made by the protected creature with a +2 bonus.~

SAY 0x2d6 ~Protection From Good 10' Radius~
SAY 0x546 ~Protection From Good 10' Radius~
SAY 0x7b6 ~Protection From Good 10' Radius~
SAY 0xa26 ~Protection From Good 10' Radius~
SAY 0xc96 ~Protection From Good 10' Radius~
SAY 0xf06 ~Protection From Good 10' Radius~
SAY 0x1176 ~Protection From Good 10' Radius~
SAY 0x13e6 ~Protection From Good 10' Radius~
SAY 0x1656 ~Protection From Good 10' Radius~
SAY 0x18c6 ~Protection From Good 10' Radius~
SAY 0x1b36 ~Protection From Good 10' Radius~
SAY 0x1da6 ~Protection From Good 10' Radius~
SAY 0x2016 ~Protection From Good 10' Radius~
SAY 0x2286 ~Protection From Good 10' Radius~

#3 Daulmakan

Daulmakan

    Comfortably numb

  • Member
  • 1065 posts

Posted 07 August 2009 - 05:53 AM

You could also take a look at header 12 of the Lower Resistance spell, which does precisely that.

item_pack.jpg   Drows.jpg

 


#4 Miloch

Miloch

    Barbarian

  • Modder
  • 6579 posts

Posted 07 August 2009 - 11:14 PM

At the moment my I simply have SAY NAME1

I really think that might be enough. You shouldn't even have to bother with a NAME2, since spells (unlike scrolls and other items) can't be "identified".

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#5 Jewels

Jewels
  • Member
  • 36 posts

Posted 08 August 2009 - 07:37 AM

You can set your string in the file during installation. You just need the hex address from the file you want to patch.

Show Hex Offsets in Near Infinity. I didn't know about that before -- certainly allows greater flexibility.

You could also take a look at header 12 of the Lower Resistance spell, which does precisely that.

True, though 30% is as high as it allows.

At the moment my I simply have SAY NAME1

I really think that might be enough. You shouldn't even have to bother with a NAME2, since spells (unlike scrolls and other items) can't be "identified".

Yes I can remove that. I was basing my code off of another .tp2 file in a different mod.

#6 Miloch

Miloch

    Barbarian

  • Modder
  • 6579 posts

Posted 08 August 2009 - 07:35 PM

Yes I can remove that. I was basing my code off of another .tp2 file in a different mod.

Ok, but what I meant was that the SAY NAME1 alone should be enough to get the spell text to display when cast, unless I'm not understanding the question. If it's an area effect spell, then Cuv's code may be more comprehensive.

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#7 Jewels

Jewels
  • Member
  • 36 posts

Posted 09 August 2009 - 07:50 AM

Yes I can remove that. I was basing my code off of another .tp2 file in a different mod.

Ok, but what I meant was that the SAY NAME1 alone should be enough to get the spell text to display when cast, unless I'm not understanding the question. If it's an area effect spell, then Cuv's code may be more comprehensive.

I wanted to customise the "Text: Display String [139]" text upon installation.

#8 Mike1072

Mike1072
  • Modder
  • 539 posts

Posted 09 August 2009 - 04:13 PM

I wanted to customise the "Text: Display String [139]" text upon installation.

Try this code:
COPY_EXISTING ~spwi514.spl~ ~override~
  PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
	READ_LONG  0x64 abilities_off
	READ_SHORT 0x68 num_abilities
	READ_LONG  0x6a effects_off
	FOR (i = 0; i < num_abilities; i += 1) BEGIN // for each ability
	  READ_SHORT (abilities_off + 0x28*i + 0x10) required_level
	  READ_SHORT (abilities_off + 0x28*i + 0x1e) num_features
	  READ_SHORT (abilities_off + 0x28*i + 0x20) features_ind
	  FOR (j = 0; j < num_features; j += 1) BEGIN // for each feature of the ability
		READ_SHORT (effects_off + 0x30*(features_ind + j) + 0x00) opcode
		PATCH_IF (opcode == 139) BEGIN // if this is 'display string' effect
		  SAY (effects_off + 0x30*(features_ind + j) + 0x04) ~Magic Resistance Lowered by 30%~ // add string to dialog.tlk and write its strref here
		END
	  END
	END
  END
  BUT_ONLY
If you don't already use patching to adjust the amount of magic resistance that's actually being lowered, you could add it into the above code fairly easily as well.