Help - Search - Members - Calendar
Full Version: Creating secret containers
The Black Wyrm's Lair - Forums > Mod development resources & discussion > Tutorials, hints & tips
egm
This tutorial is meant to create secret container, detectable like traps, with the Search skill of the thief. Special thanks to Vlàsak for the tips wink.gif
In BGII, you just press the TAB key and all containers magically highlight, allowing you to loot every piece you want. If you want to make things harder, then this tuto is for ya!

You need some files in order to make your first try.

- An .ARE file, named ARTEST.ARE;
- a .bcs file, named ARTEST.BCS, as it's the area's script;
- another .bcs file, named TRSE01.BCS, where TRSE01 is a trap;

The ARE file==========
You need first to add a container to your map. Set any x/y value for the box dimension or position; name it CTSE01.
Then create a new region (with the type TRAP), with the same dimension and location. Call it TRSE01.
Add a new variable to your area, let's say "CTSE01", with a base value of 0.

The Area script=======
It must contain the following block:

QUOTE
IF
Global("ContainerStuff","ARTEST",0)
THEN
RESPONSE #100
ContainerEnable("CTSE01",0)
SetGlobal("CTSE01","ARTEST",1)
END


This block ensure that the container is unavailable the first time you enter the area.
In game, it's juste invisible, non-selectable.

The Trap script=======
It must contain the following block:

QUOTE
IF
Detected([ANYONE])
Global("CTSE01","ARTEST",1) //ensure that party got the XP only once and all the stuff is proceeded just once
THEN
RESPONSE #100
  RemoveTraps("TRSE01")
  ContainerEnable("CTSE01",1)
  DisplayStringHead("LastTrigger",XXXXX)//You have detected a secret container!
  AddexperienceParty(YYY)//where yyy is the amount of XP gained
  SetGlobal("CTSE01","ARTEST",2)
END


If you detect the trap, it's instantly removed, and the hidden container is just available.
The party gets some XP in the example. If you don't want that, just remove the AddexperienceParty(YYY)

You can set how difficult it is to detect the secret container by modifying the trap right in the ARE file.

You can repeat this operation for any container you want to make secret and harder to find (with name like CTSE02, 03 and so on).

Note==========
Detected() is just not triggered by using the spell Detect traps. I'm working to know how bypass that (perhaps with the SpellCast and Range triggers - I'm not quite sure if the Range trigger is available for Traps).
pro5
QUOTE(egm @ Feb 3 2006, 10:14 AM) *
This block ensure that the container is unavailable the first time you enter the area.
In game, it's juste invisible, non-selectable.

Unfortunately, ContainerEnable() doesn't remove TAB highlighting of disabled container (they just cannot be selected), thus the whole "secret container" thing becomes pointless. sad.gif
Galactygon
Fortunately, light map colours affect container highlighting, so it is possible to cover that area in black. That does not mean the highlight disappears - it simply becomes black rather than bright cyan. However, black blends easily with a dark background.

In that case, the player will manually have to detect the container rather than using thieving, and the container remains invisible unless you enable an animation to mimick detected containers.

-Galactygon
pro5
I've painted container location with black in both light-map and search-map. No effect, it's still cyan when I use TAB?
Galactygon
So then lightmapping only works with dropped items?

IPB Image

-Galactygon
devSin
Are you talking about the LUM map or the search map (you first said search, now you say LUM)?

If you're talking about the LUM map, then no, the area background isn't affected.
Galactygon
It is lightmapping, my mistake. I am used to making posts about search maps, so it is a reflex. smile.gif

-Galactygon
devSin
I guess I'm not really surprised that ground items get the dynamic lighting. IIRC, the "highlighting" is actually a special frame in the ground icon BAM (how cheap); whereas the engine has special code to deal with highlighting trigger regions (including doors and containers), highlighting items is just done by switching to the highlight frame and gets the light adjustments. I don't think there's any way to trick the engine into concealing the hard-coded highlights (they even show up through the black mask, sigh).

The light maps shouldn't affect anything else beyond characters and ground icons (and animations, provided the appropriate flag is set).
Sir-Kill
Damn
had hope but no
Galactygon
QUOTE

The light maps shouldn't affect anything else beyond characters and ground icons (and animations, provided the appropriate flag is set).


It's a shame, really; I was hoping it would work.

-Galactygon
Cuv
I know it has been a while since this post was answered... but I have been thinking about the problem presented and sorta have a solution... or at least a workaround worthy of further exploration.

I created a container in an area and flagged it as a Pile. This way it only shows up as the ground icon of the object inside the container.

I then created an item and made a new BAM that looks like a chest. Assigned it to a book copy. You can see from the below picture that the chest is visible (just to demonstrate), but it does not show up as a marked container like the ones around it.

Click to view attachment

... but you can put your cursor over it and it will give you the 'grabby' hand icon.

Click to view attachment

Anyways, something to think about. I suppose you could either write a script to replace the item you want to hide when the time is right.. or put something else in the container with no ground icon. Or just create the item that looks like your container on the ground by either having some invis creature drop it at the appropriate time, or other ways.

Here's the item and bam if you want to give it a try. Might spark some creative ideas

Click to view attachment

Hope this helps.
Cuv



devSin
I'd be worried about the game purging the pile (I can't remember the specifics of what it does and does not decide to periodically erase), but it does seem like a neat solution (you have to use a custom BAM that doesn't have the highlight frame).

I just use the pile type to get rid of containers I don't want anymore (easier than deleting them); I wouldn't have thought to do it this way.
igi
I remember reading that you can simply delete the vertices relating to the outline of the container.

However, I don't remember where I read it, nor if it worked.
devSin
But then you have to update the vertex index of every other structure in the ARE. No thanks. ;)

I think setting the bounding rect coords to 0 or -1 should work fine (you shouldn't even have to touch the vertices), but why bother when you can just change the type to pile (unless the container has items and you don't want to delete them, but then I'm not sure what you'd be trying to do)?
Cuv
From where exactly are those container types referenced in the .ARE? It must be an IDS, but I can't seem to find it. Anyone know the file name? I want to find out more about Pile, and why whatever shape or size container polygon I draw for it remains invisible. Could be a solution in there somewhere.

Cuv
devSin
Container types are hardcoded; there's not much difference beyond the search sound and icon, but piles are handled differently.

You'll never get a pile that respects any region polygons (a pile is simply a point on the ground where contents of the container may be placed). The engine creates fake piles for lots of stuff (most of which you'll never see).

You should be able to change the highlight frame of your container icon to mimic the normal highlighting effect (instead of the cyan border that normal item icons have, you could just use a cyan overlay).
Cuv
Ah, I was afraid of that. Thanks for the info DevSin smile.gif

I will keep thinking on the problem and see what else I can come up with... I might need a secret container myself at some point.

cheers,

cuv
Cuv
Another question for the programming type people (as I am not one of those):

Where might I locate the actual program coding for CGameContainer.cpp? Is it actually coded into the BGMain.exe or as a file elsewhere?

I found the hardcoding Offset in the BGMain.exe for the containers using a hex editor (but didnt change anything), just as you described... and now I am wondering if there is a way to patch in what I want smile.gif What I really want to do is to patch the coding for the map size restrictions and adding new animation slots (found those offsets too at roughly 0075:****)

D:\dev\baldur\CGameContainer.cpp

BAG CHEST DRAWER PILE TABLE SHELF ALTAR NONVISIBLE SPELLBOOK BODY BARREL CRATE FALSE

OFFSET 0070:F6C0 BGMain.exe

Cuv

devSin
It's part of the actual program code; the source file itself is not available. What you found is more likely the location of strings used for assertions than the location where container handling is done.

You can change some simple values in the compiled executable, but you won't be able to do anything worthwhile (and adding anything is out of the question).
Cuv
Thanks again DevSin smile.gif

I may poke around a bit more... and might even try adding or changing some things around. This is a third install of the ToB game... the stripped-down version that I use for testing out things. If it crashes or destroys it, no biggie.. will just re-install the TCCore.

Cuv

Will certainly keep you all informed if I can achieve any worthwhile changes or find out anything new about the engine.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.