Aller au contenu

Photo

Custom tokens and state containers


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
FollowTheGourd

FollowTheGourd
  • Members
  • 572 messages
Hi,

So I put together something that can almost give you custom tokens like in NWN2 - maybe not as good, but something that would work in journal entries, conversations, and whatnot. In order to do so I'm abusing world map pins to hold the "state", since I need a bridge between DAScript and the UI. Token substitution seems to be normally done in the engine, called from the UI, but I don't have access to that.

The main thing is that you'd need to keep these "special" primary world map pins in sync. The primary world map doesn't change too often though, and I think you need to reset them when the game is reloaded. So I figure it's not that onerous and you define your own pin tag to keep from conflicting with other modules. (I altered the world map to hide pins above a certain state value, not just for the "not active" pin state.) It should also work with addins to other campaigns, since you can create child maps, although that might feel a little messy.

I'll release a test version of what I have in a couple of days or so, but mainly I'm just wondering if anybody can think of any problems with doing this or perhaps even an easier way. My main restriction is something that the user can set in DAScript and that the UI can read arbitrarily.  E.g., inventory on another container doesn't really work because the UI seems to only know the current container and if I put it in the party's inventory then that would probably be even messier.

A simplified example of the token 2DA columns would be something like this:
- Token (e.g., "class")
- Strref (Tlk reference, String literal, or built-in player/party value like "[race]" where it looks it up itself dynamically).
- PlayerCondition (gender/race/class etc) - Optional.
- ForceHero (for player conditions: use the hero or first player in party)
- StateTag (tag of a map pin to be abused as a token state holder) - Optional
- State. Required state for StateTag in order to match - set in DAScript with WR_SetWorldMapLocationStatus(GetObjectByTag(StateTag), STATE_BASE + someState). - Optional
If it has no condition or states set, then the row is treated as fallback match if nothing else matches.

That way you could have multiple rows with the same token but with exclusive (or first to match) conditions leading to different Strref values that get subbed in.

I'm also still trying to see if I can't let you define a string within DAScript instead of a strref or string in the 2DA. SetName doesn't seem to work on map pins.

Modifié par FollowTheGourd, 08 novembre 2010 - 02:14 .


#2
TimelordDC

TimelordDC
  • Members
  • 923 messages
Hi FtG,

1. When you say certain states beyond a certain state value will be hidden, what is the cut-off state? The location_states 2DA has only 6 states and as far as I can see, it is not an M2DA. So, have you tested this by making location_states an M2DA? Or are you using one of the existing states as the cut-off?

2. I assume you are going with the world map because it is always loaded? If so, can you extend var_module table and use it instead?

3. About the pin name, have you tried SetWorldMapLocationLocName?

EDIT: The only reason I am suggesting an alternative to the worldmaps 2DA is because only IDs less than 255 work to show the map correctly in-game and I don't want to shorten the already short range. Of course, since this doesn't require the world map to be shown, an ID greater than that can be used - as long as it is made clear that they should use that only [or can it be included as part of the GUI check?]

Also, have you found out what the StringTokens 2DA is used for? It seems to contain references to the tokens currently in use - perhaps that can be modified/extended?

Modifié par TimelordDC, 08 novembre 2010 - 05:12 .


#3
FollowTheGourd

FollowTheGourd
  • Members
  • 572 messages
Hi TimelordDC,

I wouldn't be touching any map 2DAs or using up any of their ranges. Just to clarify things - I modded the worldmap UI file itself to hide pins with a higher state, not the worldmap 2DA. In the original UI script it has a check like "if pin state != STATE_NOT_ACTIVE, then add the pin to the map", but my check is "if pin state != STATE_NOT_ACTIVE  and state less than 100, then add the pin to the map".

I arbitrarily chose 100, since it's a nice round number and I don't see that many actual map pin states ever being introduced in a game patch, if any for that matter. The location_states 2DA shouldn't really matter, since you wouldn't be setting it in the toolset - but through DAScript with WR_SetWorldMapLocationStatus. I haven't checked how high a value works yet, but it at least still goes into the thousands.

I'm not especially keen on abusing map pins this way. I'd love for there to be some way for the UI to read arbitrary variables set from DAScript, but I haven't seen any way to. I'm also half wondering if abusing the fade map might actually be better, since there can only be one. I'm not sure off-hand if you can create a child map for it though - I doubt your pins would show up, but all that matters is that they're valid objects.

I don't know if we could extend the toolset/StringTokens 2DA but even if we could, I don't think we could get the same flexibility. I remember Bryan Derksen mentioning almost a year ago that he lobbied for custom tokens but they never really made it into the game.

SetWorldMapLocationLocName takes a strref argument, but I was thinking something more along the way of dynamic text.

Edit: Heh, seems to work OK using a "child" map to the fade map and you don't even need to call WR_SetWorldMapPrimary first. Only if you're not in the single player module, then you have to open up your child fade map in a GFF editor and change its parent resource to  "fade_map" after you export it... but using the fade map outside the single player campaign is already a little hackish. Just gotta make sure it doesn't break anything in the fade map, but I don't think I need to make any changes to it.

Modifié par FollowTheGourd, 09 novembre 2010 - 03:20 .