Jump to content


Photo

Area Modding Tool & Tutorial by Qwinn


  • Please log in to reply
164 replies to this topic

#161 Sasha Al'Therin

Sasha Al'Therin
  • Modder
  • 615 posts

Posted 13 June 2009 - 01:45 PM

Does anyone know how to get the correct text value to be written while using the array structure?

You don't put quotes around an entire array entry. You do put quotes around the indices: "%index%" versus %index% or index.

Instead of:
WRITE_ASCII (%new_loc% + 0) ~$RT_NAME("%index%")~ (32)
Use:
WRITE_ASCII (%new_loc% + 0) $RT_NAME("%index%") (32)

Sorry but that doesn't work. This is what weidu has to say about it:
[bg_fixpack\tph\ab_FlorTrig.tph] PARSE ERROR at line 33 column 1-31
Near Text: $
	GLR parse error

[bg_fixpack\tph\ab_FlorTrig.tph]  ERROR at line 33 column 1-31
Near Text: $
	Parsing.Parse_error
ERROR: parsing [bg_fixpack\tph\ab_FlorTrig.tph]: Parsing.Parse_error
Stopping installation because of error.
The portion of code that this is referring to:
//string writes
  WRITE_ASCII (%new_loc% + 0) $RT_NAME("%index%") (32)			  //name
  WRITE_ASCII (%new_loc% + 0x74) $RT_KEY_ITEM("%index%")			//item to use as key
  WRITE_ASCII (%new_loc% + 0x7c) $RT_REGION_SCRIPT("%index%") (8)   //script for trigger
  PATCH_IF (GAME_IS ~pst~) BEGIN
   WRITE_ASCII (%new_loc% + 0xbc) $RT_DIALOG_FILE("%index%") (8)			  //dialog file used only in pst
  END

Just so ya know the tph file is an action function that calls up Qwinn's macros and still allows the user to add multiple floor triggers...

My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altheri...s.com/index.htm


#162 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 06 July 2009 - 10:01 AM

I compressed Q_ARE_InitVars and Q_AREAdd_InitVars macros into a more compact form that makes better use of arrays.

DEFINE_PATCH_MACRO ~Q_ARE_InitVars~ BEGIN

PATCH_IF (GAME_IS ~pst~)					 BEGIN Q_Game=1 END
PATCH_IF (GAME_IS ~bg2 tob tutu tutu_totsc~) BEGIN Q_Game=2 END
PATCH_IF (GAME_IS ~bg1 totsc iwd how~)	   BEGIN Q_Game=3 END

DEFINE_ARRAY object BEGIN Actor Trigg Spawn Entra Conta Items Ambie Varia Doors Tiled Vertx Explo Anima Songs RestS MapNo ProTr END
DEFINE_ARRAY Siz	BEGIN 0x110 0xc4  0xc8  0x68  0xc0  0x14  0xd4  0x54  0xc8  0x6c  0x4   0x0   0x4c  0x90  0xe4  0x34  0x1A  END
DEFINE_ARRAY OoN	BEGIN 0x58  0x5a  0x64  0x6c  0x74  0x76  0x82  0x8c  0xa4  0xb4  0x80  0x0   0xac  0x0   0x0   0xc8  0xd0  END
DEFINE_ARRAY OoO	BEGIN 0x54  0x5c  0x60  0x68  0x70  0x78  0x84  0x88  0xa8  0xb8  0x7c  0xa0  0xb0  0xbc  0xc0  0xc4  0xcc  END
DEFINE_ARRAY SoL	BEGIN 2	 2	 4	 4	 2	 2	 2	 4	 4	 4	 2	 0	 4	 0	 0	 4	 4	 END

FOR (i=0;i<17;i+=1) BEGIN
  SET $Q_Siz($object("%i%"))=$Siz("%i%")	 // size of object's section
  SET $Q_OoN($object("%i%"))=$OoN("%i%")	 // offset of number of objects
  SET $Q_OoO($object("%i%"))=$OoO("%i%")	 // offset of offset of objects
  SET $Q_SoL($object("%i%"))=$SoL("%i%")	 // SHORT or LONG offset of number of objects
  PATCH_IF i=15 & Q_Game=1 BEGIN								 // PST uses different values
	Q_OoN_MapNo=0xcc Q_OoO_MapNo=0xc8 END
  PATCH_IF $SoL("%i%")=2 BEGIN			   // number of objects
	READ_SHORT $Q_OoN($object("%i%")) $Q_Num($object("%i%")) END // if SoL = 2 = SHORT, then READ_SHORT
  PATCH_IF $SoL("%i%")=4 & ( i!=16 | Q_Game=2) BEGIN			 // non-BG2 games can't have projectiles
	READ_LONG  $Q_OoN($object("%i%")) $Q_Num($object("%i%")) END // if SoL = 4 = LONG, then READ_LONG
  PATCH_IF $SoL("%i%")=0 BEGIN								   // if SoL = 0 = not needed, don't READ, instead
	SET $Q_Num($object("%i%"))=1 END							 //   SET it to 1, as this can't be any other
  PATCH_IF i!=16 | Q_Game=2 BEGIN			// offset of objects
	READ_LONG  $Q_OoO($object("%i%")) $Q_Off($object("%i%")) END // offsets' READs always LONG
END

PATCH_IF Q_Game!=2 BEGIN										 // if it's non-BG2 then set everything
  Q_OoN_ProTr=0 Q_OoO_ProTr=0 Q_Num_ProTr=0 Q_Off_ProTr=0 END	// related to projectiles to zero

END

/////////////////////////////////////////////////

DEFINE_PATCH_MACRO ~Q_AREAdd_InitVars~ BEGIN
FOR (i=0;i<17;i+=1) BEGIN
  SET $Q_New($object("%i%"))=0		// number of new objects
  SET $Q_NewOffset($object("%i%"))=0  // writing offset for new objects
END
Q_ManualInsert=0
END

Edited by GeN1e, 06 July 2009 - 10:01 AM.

Retired from modding.


#163 Sasha Al'Therin

Sasha Al'Therin
  • Modder
  • 615 posts

Posted 06 July 2009 - 11:57 AM

Have you tested that? Does it work? Maybe I'm not understanding it properly but it doesn't look like things will match up with Q_AREAdd_Process... Perhaps Qwinn will understand this better...

My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altheri...s.com/index.htm


#164 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 06 July 2009 - 03:29 PM

Have you tested that? Does it work?

Yes and yes, at least for my test subject.

it doesn't look like things will match up with Q_AREAdd_Process

Both InitVars set a whole bunch of Q_Siz_Actor, Q_Siz_Trigg, Q_Siz_Spawn, ..., then the same for Q_OoN_, Q_OoO_, etc. All of which gets used by Add_Process. The said bunch is basically can be represented as Q_%VarType%_%ObjectType% and consists of 8 almost identical blocks. I effectively made all the input data (offsets) into a table, set the FOR loop and had weidu to read and build/set variables for each column. Well, technically that's not a table, but several separate arrays, but it ends up being even better than a normal 2da, as there's not need to READ_2DA_ENTRY, since it's already loaded in memory.

BTW, I've also corrected Q_OoN_ProTr to 0xd0, as what IESDP says (it was 0xcc, same as Q_OoO_ProTr).

Retired from modding.


#165 Qwinn

Qwinn
  • Modder
  • 3092 posts

Posted 07 July 2009 - 01:42 AM

No reason I can think of why that wouldn't work. I mostly laid it out the way I did so as to try to make it less confusing for someone learning how it works, but if the user doesn't care or already understands it, sure, that should work fine.

And nice catch on the ProTr bit, my mistake. BG2 only so not something I could catch with my PS:T testing.

I'm a bit busy atm, but give me a couple days and I'll try it on all my PS:T mods and see if it works okay.

Qwinn

Edited by Qwinn, 07 July 2009 - 01:46 AM.