Jump to content

Photo

Modder Discussion: Additional AreaType() Flagging for Mods

weidu tp2 coding mod development AreaType() AreaCheck() aran whitehand dialog coding scripting extending functionality

66 replies to this topic

#16 cmorgan

cmorgan

    journeyman investigator

  • Gibberlings
  • 7097 posts
  • Gender:Male
  • Location:Glencoe, IL, USA

Posted 27 January 2011 - 07:45 AM

Wait a sec - the Fixpack removes the CITY flag from places like
~ar0406.are~ ~override~ //Copper Coronet
~ar0513.are~ ~override~ //Calbor's Inn, first floor
~ar0514.are~ ~override~ //Calbor's Inn, second floor
~ar0515.are~ ~override~ //Calbor's Inn, third floor
~ar0901.are~ ~override~ //Temple District, Helm temple
~ar0902.are~ ~override~ //Temple District, Lathander temple
~ar0904.are~ ~override~ //Temple District, Talos temple
~ar0905.are~ ~override~ //Temple District, Pimlico's Estate
~ar0906.are~ ~override~ //Temple District, guarded compound ground floor
~ar0907.are~ ~override~ //Temple District, guarded compound second floor
~ar5507.are~ ~override~ //Saradush, basement entrance to Gromnir's castle

I assume because having CITY return true there messes with vanilla BioWare™ stuff...

is there a specific reason, before I go about doing something like patching every Inn area found in the install to have a CITY flag?
I love deadlines. I love the whooshing noise they make as they go by. - Douglas Adams

#17 CamDawg

CamDawg

    ALL GLORY TO THE HYPNOTOAD

  • Gibberling Poobah
  • 9751 posts
  • Gender:Not Telling

Posted 27 January 2011 - 07:53 AM

Wow, I'm having to go way back in the memory here, but as I recall BioWare's scripting generally expected the city flag to mean outdoor city areas.

Why is this Hypnotoad video so popu... ALL GLORY TO THE HYPNOTOAD.


#18 cmorgan

cmorgan

    journeyman investigator

  • Gibberlings
  • 7097 posts
  • Gender:Male
  • Location:Glencoe, IL, USA

Posted 27 January 2011 - 12:06 PM

That makes sense.

Hmmm.

Pity there is not a flag for "This area is an Inn".
I love deadlines. I love the whooshing noise they make as they go by. - Douglas Adams

#19 the bigg

the bigg

    The Avatar of F/Ts

  • Modders
  • 2337 posts
  • Gender:Male
  • Location:Modena (Italy)

Posted 27 January 2011 - 12:33 PM

So, make up one! The game might have space for an additional 8 area flags (unless ARE 0x48 is handled as byte, in which case no space is free for area flags).

ACTION_IF !FILE_CONTAINS_EVALUATED (~areaflag.ids~ ~CD_INN~) THEN BEGIN
  OUTER_SET value = BIT8 // should actually be code to figure out "first unallocated power of two in areaflag.ids"
  APPEND ~areaflag.ids~ ~%value% CD_INN~
END
COPY_EXISTING ~area1.are~ ~override~
  ~area2.are~ ~override~
<snip>
WRITE_SHORT 0x48 THIS | value

<in some dialogue file>
CHAIN IF ~AreaType(CD_INN) IsAvailableForPartyDialog("Edwin")~ THEN BMINSC innComment
~We are in an inn! We should look for some nuts for Boo!~
== BEDWIN ~I prefer to look for whores.~
EXIT

Italian users: help test the Stivan NPC!

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - TB#Characters - Traify Tool - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Code dumps: Detect custom secondary types - Stutter Investigator

If possible, send diffs, translations and other contributions using Git.

#20 cmorgan

cmorgan

    journeyman investigator

  • Gibberlings
  • 7097 posts
  • Gender:Male
  • Location:Glencoe, IL, USA

Posted 27 January 2011 - 02:36 PM

Now THAT would be cool - and working up a configurable list is way easy. I am off to look at IESDP and that areaflag.ids; there are samples to contrast against yours in both Fixpack and BG1NPC. Very cool idea!

If it doesn't turn out to be possible to do so this way, there is a blunt-force-trauma kind of way, based on a script implementation of this idea - set up an end-of-install thing like Crossmod or Aran_Aware that extends each areascript with

in mymod/baf/indentify_all_inns.baf
IF
  Global("cd_inn",MYAREA,0)
THEN 
  SetGlobal("cd_inn",MYAREA,1)
  Continue()
END

with a straightforward

ACTION_FOR_EACH ~innscript~ IN
~ar~
BEGIN 
	ACTION_IF FILE_EXISTS_IN_GAME ~%innscript%~ THEN BEGIN
	  EXTEND_TOP ~%innscript%.bcs~ ~mymod/baf/indentify_all_inns.baf~
	END
END

Or, wait - to make sure things haven't already been installed to do that... so decompile the area script, look for CD_INN, and

ACTION_FOR_EACH ~innscript~ IN
	~AR0021~	  // Crooked Crane, 1st floor
	~AR0313~	   // Sea's Bounty, 1st floor
	~AR0406~	   // Copper Coronet
	~AR0509~	   // Five Flagons, 1st floor
	~AR0513~	   // Delosar's, 1st floor
	~AR0522~	   // Five Flagons, 1st floor (stronghold)
	~AR0704~	   // Mithrest Inn
	~AR0709~	   // Den of the Seven Vales
	~AR1105~	   // Imnesvale Inn
	~AR1602~	   // Vulgar Monkey
	~AR2010~	   // Trademeet Inn
	~C-AR01~	  // The broken Sword
	~ModArea~	// other mod-added inn
BEGIN 
	ACTION_IF FILE_EXISTS_IN_GAME ~%innscript%~ THEN BEGIN
		ACTION_IF FILE_CONTAINS_EVALUATED(~%innscript%~  ~CD_INN~) THEN BEGIN
		  PRINT ~%innscript% is already defined as an Inn~
	   END
	   ELSE
		  EXTEND_TOP ~%innscript%.bcs~ ~mymod/baf/indentify_all_inns.baf~
	   END
	END
END

And detection as Global("CD_INN",MYAREA,1)...

that is, if MYAREA works the way I think it does. And F_C_E, for that matter.

Edited by cmorgan, 27 January 2011 - 03:22 PM.

I love deadlines. I love the whooshing noise they make as they go by. - Douglas Adams

#21 Wisp

Wisp
  • Modders
  • 1142 posts
  • Gender:Male

Posted 27 January 2011 - 03:32 PM

The AreaType field is a word. I use AreaType(512) for detecting inn and stronghold areas in aTweaks. Prior to that I had some nice BWP people run scans for used values in the upper range. Aside from one area in Darkest Day (case of randomness, I'm pretty sure) [1] no areas seem to use high values.

You can also use AddAreaType(512) etc.

[1]And now, aTweaks, of course. But I don't stake any particular claims on bit 9.

Edited by Wisp, 27 January 2011 - 03:37 PM.


#22 cmorgan

cmorgan

    journeyman investigator

  • Gibberlings
  • 7097 posts
  • Gender:Male
  • Location:Glencoe, IL, USA

Posted 27 January 2011 - 03:45 PM

Wow - I had better go grab the latest aTweaks to see how you do that -

330 AddAreaType(I:Type*AREATYPE)
This action will add area type flags (e.g. outdoor, dungeon) to the current area. The areatype value is OR'd, so multiple values can be set. Values are from areatype.ids


If I match your values and do some quick "detect if it is already done", we could save that space for other folks; I really like the simplicity of having a standard "go to" identifier for everyone.
I love deadlines. I love the whooshing noise they make as they go by. - Douglas Adams

#23 Wisp

Wisp
  • Modders
  • 1142 posts
  • Gender:Male

Posted 27 January 2011 - 04:00 PM

Well, the way I currently use bit 9 is not very conductive to a standardised system (since I don't bother with areatype.ids). It's also not using bit 9 as CD_INN, but more like CD_INN_OR_STRONGHOLD.
If you guys want a way to detect inns with CD_INN (first unused bit in areatype.ids) I'll happily follow suit and use an analogous label for detecting strongholds.

The code in aTweaks is in aTweaks/LIB/c115.tpa, which also includes a list of most, or possibly all, inn areas in BG1 and BG2, both standard and mod-added.

#24 cmorgan

cmorgan

    journeyman investigator

  • Gibberlings
  • 7097 posts
  • Gender:Male
  • Location:Glencoe, IL, USA

Posted 27 January 2011 - 04:20 PM

Wisp, you are seriously heavy-duty. Way cool. c115.tpa makes me want to learn even more.

As a side note, you may want to grab the inns information from Fishing For Trouble (Y's cool new lots-of-areas mod), and I will save you some editing: my indoor areas can match the ones you anticipated ???

OK, so a check on this -

ACTION_IF !FILE_CONTAINS_EVALUATED (~areaflag.ids~ ~CD_INN~) THEN BEGIN
  APPEND ~areaflag.ids~ ~512 CD_INN~
END

/* Needs recheck an deletion on BG2 to separate out strongholds areas from actual inns, as this is entirely cribbed from Wisp */
  ACTION_FOR_EACH area IN  // almost all inns in BG2 and ToB content
  /*Bonehill:*/ bh0107 bh0120 bh0123 bh0115 bh2020 bh2024
  /*Aran Whitehand:*/ "c-ar01" "c-inn0" "c-inn1" "c-inn2" "c-inn3" "c-inn4"
  /*TDD:*/ dd9x03 dd3334 dd3335 dd3302 dd1008 dd1008b dd0119 dd0118 arpo06 arpo07
  /*RoT:*/ rr3117 rr3118 ra3901 rr3305 rr3312 rr3105 rr3104 ra5104 ra5105
  /*Undying:*/ cm7000 cm7100
  /*Aurora:*/ ag3801 ag1111
  /*NTotSC*/ ar33pb /*ar4003/*(BG1)*/*/
  /*BG2:*/ ar0021 ar0022 ar0313 ar0314 ar0406 ar0509 ar0510 ar0511 ar0513 ar0514 ar0515 ar0704 ar0709 ar0712 ar1105 ar1602 ar2010 ar2100 ar2202 ar2203 ar5003 ar5501
  /*thief - counts as an inn, I think... */ar0321 ar0322 ar0323 ar0324 
  /*Soubar:*/ ar4264 ar4265 ar4266 ar4267 ar4268 ar4269 ar4272 ar4273 ar4274 ar4275 ar4276 ar4262 ar4263
  /*CtB:*/ ar3651 ar3652
  BEGIN
	ACTION_IF FILE_EXISTS_IN_GAME "%area%.are" BEGIN
	  COPY_EXISTING "%area%.are" override
		PATCH_IF SOURCE_SIZE > 0x11b BEGIN
		READ_SHORT 0x48 ~innarea~
		  ACTION_MATCH ~innarea~
		  WITH
		  512
		  BEGIN
			PRINT ~%area% is already defined as an Inn~
		  END
		  DEFAULT
			WRITE_SHORT 0x48 (THIS BOR 512)
		  END
		END
	  BUT_ONLY
	END
  END
or is READ_SHORT the wrong read?

And the trigger becomes

AreaType(CD_INN)
or
AreaType(512)

edit: Sorry - slow cross-posting on my part.

I am happy any way the bigg, you, and CamDawg want to go. Flagging two things, WISP_STRONGHOLD and CD_INN could be useful, I bet.

Edited by cmorgan, 27 January 2011 - 04:34 PM.

I love deadlines. I love the whooshing noise they make as they go by. - Douglas Adams

#25 Wisp

Wisp
  • Modders
  • 1142 posts
  • Gender:Male

Posted 27 January 2011 - 05:42 PM

You should probably use something like this for adding the IDS entry:
OUTER_SET CD_INN = IDS_OF_SYMBOL (areatype CD_INN)
ACTION_IF CD_INN < 0 BEGIN //if the label CD_INN does not exist
  OUTER_FOR (power=8;power<16;++power) BEGIN 
	OUTER_SET CD_INN = 2 ** power
	ACTION_IF !FILE_CONTAINS_EVALUATED (areatype.ids "^[ %TAB%]*%CD_INN%") BEGIN
	  APPEND areatype.ids "%CD_INN% CD_INN"
	  OUTER_SET power = 16
	END
  END //maybe there should be something in here for the eventuality all flags have already been taken by non-CD_INN labels?
END

and then write the value to the area with
WRITE_SHORT 0x48 THIS BOR CD_INN

As a side note, you may want to grab the inns information from Fishing For Trouble (Y's cool new lots-of-areas mod)

Oh, yeah, you're right.

or is READ_SHORT the wrong read?

It isn't wrong, but to check on the value you need to use BAND, since multiple area flags can be set
E.g.:
PATCH_IF (innarea BAND CD_INN) != 0 BEGIN //area is already an inn
But it's probably not necessary to check if the area's already been flagged. There's no harm in writing the value multiple times, and the redundancy is filtered out by BUT_ONLY.

But I don't know how many of those mega mods are for BG2. I think most of them are for BG1/BGT, so if you are only concerned with inns accessible from BG2 you can probably slim the list down quite a bit.

#26 Miloch

Miloch

    Barbarian

  • Modders
  • 4819 posts
  • Gender:Male
  • Location:At Large

Posted 27 January 2011 - 06:44 PM

I guess ag2020 and ag4815 should be added to that list of inn areas for Aurora. I interpreted the original request as "any area where you can rent a bed" and forgot we also add inn cellars. So I suppose it depends on what you want to script in an inn whether those should be counted as inn areas.

If I remember, I'll flag these areas with whatever value you agree on, though it doesn't hurt to have redundant flagging code in mods. But to that end, I think the area IDS numeric values should be fixed rather than dynamically determined. It's not like you're going to run out of values, even if people want to throw in some bizarre flags.

Also if it matters, ag1111 and ag2020 are BG2 areas; ag3801 and ag4815 are in Tutu and BGT.

Edit: also I should perhaps clarify the other areas' status as "inn"... ag3801 is a mad hermit's distillery where you can rent cots (possibly necessary after sampling his wares) and ag1111 is a druidess's retreat carved out of a rock where you can do the same. So again, depends on what you want to script there.

Edited by Miloch, 27 January 2011 - 06:47 PM.

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
================================================================
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it." -Terry Pratchett


#27 the bigg

the bigg

    The Avatar of F/Ts

  • Modders
  • 2337 posts
  • Gender:Male
  • Location:Modena (Italy)

Posted 28 January 2011 - 01:03 AM

But to that end, I think the area IDS numeric values should be fixed rather than dynamically determined. It's not like you're going to run out of values, even if people want to throw in some bizarre flags.

There's only (at best) 8 free flags on standard BG2, so space *is* at a premium.
Italian users: help test the Stivan NPC!

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - TB#Characters - Traify Tool - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Code dumps: Detect custom secondary types - Stutter Investigator

If possible, send diffs, translations and other contributions using Git.

#28 Wisp

Wisp
  • Modders
  • 1142 posts
  • Gender:Male

Posted 28 January 2011 - 03:04 AM

But to that end, I think the area IDS numeric values should be fixed rather than dynamically determined. It's not like you're going to run out of values, even if people want to throw in some bizarre flags.

There's only (at best) 8 free flags on standard BG2, so space *is* at a premium.

And you already have at least one irresponsible person (me) wanting to use one of those flags to tag a handful of areas. Besides, where would the list of fixed values be stored? Who would administrate it?

Much like Miloch, I should add that the mod-added areas are inns in the sense there's a creature in the area whose dialogue file references a store that includes rooms in its services. They may not necessarily be located in a populated town, or be inns in a conventional sense.

By comparison, the standard BG/1BG2 areas have withstood slightly more scrutiny and do not include e.g. the Underdark (AR2100), since that area is mostly not an inn.

#29 the bigg

the bigg

    The Avatar of F/Ts

  • Modders
  • 2337 posts
  • Gender:Male
  • Location:Modena (Italy)

Posted 28 January 2011 - 04:08 AM

And you already have at least one irresponsible person (me) wanting to use one of those flags to tag a handful of areas. Besides, where would the list of fixed values be stored? Who would administrate it?

By using an ADD_AREA_FLAG tp2 command that finds an unused bit in areaflag.ids?
Italian users: help test the Stivan NPC!

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - TB#Characters - Traify Tool - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Code dumps: Detect custom secondary types - Stutter Investigator

If possible, send diffs, translations and other contributions using Git.

#30 Wisp

Wisp
  • Modders
  • 1142 posts
  • Gender:Male

Posted 28 January 2011 - 04:28 AM

By using an ADD_AREA_FLAG tp2 command that finds an unused bit in areaflag.ids?

Be my guest. A standardised way of adding rows to areatype.ids would be good if adding area types becomes more common.

Edited by Wisp, 28 January 2011 - 04:28 AM.




Reply to this topic



  



Also tagged with one or more of these keywords: weidu tp2 coding, mod development, AreaType(), AreaCheck(), aran whitehand, dialog coding, scripting, extending functionality

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users