I have made my mod. The chest and items spawn very well. But I cant make the chest start locked, even though I set the properties to be so by the editor.
Anyone know how to do this? Do I have to script it in or something?
How to make chests lockable?
Débuté par
Gambler1971
, déc. 18 2009 07:35
#1
Posté 18 décembre 2009 - 07:35
#2
Posté 18 décembre 2009 - 07:47
You do not need to script it. There should be a property that locks it and another property where you can put the item tag of the key that unlocks it, if there is one.
#3
Posté 19 décembre 2009 - 03:12
I have set --"Initial State"-- to CLOSED_LOCKED and --"Pick Lock Level"-- to SIMPLE (or even Impossible). No difference, still starts unlocked.
#4
Posté 19 décembre 2009 - 09:21
Works for me.
The fields I have are
Appearance - must include the text (Container).
Script - placeable_core
Initial State - closed_locked
Pick Lock Level - whatever you prefer
If you want to force the use of a key which is removed on success, the Key section needs to be completed:
Autoremove Key - TRUE
Key Required - TRUE
Key Tag - tag of the key item
The fields I have are
Appearance - must include the text (Container).
Script - placeable_core
Initial State - closed_locked
Pick Lock Level - whatever you prefer
If you want to force the use of a key which is removed on success, the Key section needs to be completed:
Autoremove Key - TRUE
Key Required - TRUE
Key Tag - tag of the key item
Modifié par Proleric1, 19 décembre 2009 - 09:21 .
#5
Posté 19 décembre 2009 - 02:40
It must be something I am doing, cause all that sounds like what I am doing.
I create a new PLACEABLE. Module = Core Game Resources.
Appearance = Chest, Iron (container)
Resource & Tag Names same as what I called the Placeable file above.
Script = placeable_core
Initial State = Closed_Locked
Pick Lock Level = Very Easy
Inventory = 2 daggers I made to test with
all others are default from creation
Spawn Script to make the item appear is:
// ---- SCRIPT STARTS HERE ----
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "placeable_h"
const string sChestName_01 = "g71_aoh_storage_1";
const resource rUtpName_01 = R"g71_aoh_storage_1.utp";
void main()
{
event ev = GetCurrentEvent();
int nEvent = GetEventType(ev);
int bEventHandled = FALSE;
switch (nEvent)
{
case EVENT_TYPE_MODULE_LOAD:
{
object oPlayer = GetHero();
object oChest_01 = UT_GetNearestObjectByTag(oPlayer, sChestName_01);
if (!IsObjectValid(oChest_01))
{
location lChestLocation = Location(GetArea(oPlayer), Vector(126.6, 76.52, -0.71), 78.41);
CreateObject(OBJECT_TYPE_PLACEABLE, rUtpName_01, lChestLocation);
bEventHandled = TRUE;
}
break;
}
default:
{
break;
}
}
if (!bEventHandled)
{
HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);
}
}
// ---- SCRIPT ENDS HERE ----
I am making it spawn at my feet atm, will place it in the real world when mod is complete.
I am using latest Toolset 1.01 and Game upgraded to 1.02
I create a new PLACEABLE. Module = Core Game Resources.
Appearance = Chest, Iron (container)
Resource & Tag Names same as what I called the Placeable file above.
Script = placeable_core
Initial State = Closed_Locked
Pick Lock Level = Very Easy
Inventory = 2 daggers I made to test with
all others are default from creation
Spawn Script to make the item appear is:
// ---- SCRIPT STARTS HERE ----
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "placeable_h"
const string sChestName_01 = "g71_aoh_storage_1";
const resource rUtpName_01 = R"g71_aoh_storage_1.utp";
void main()
{
event ev = GetCurrentEvent();
int nEvent = GetEventType(ev);
int bEventHandled = FALSE;
switch (nEvent)
{
case EVENT_TYPE_MODULE_LOAD:
{
object oPlayer = GetHero();
object oChest_01 = UT_GetNearestObjectByTag(oPlayer, sChestName_01);
if (!IsObjectValid(oChest_01))
{
location lChestLocation = Location(GetArea(oPlayer), Vector(126.6, 76.52, -0.71), 78.41);
CreateObject(OBJECT_TYPE_PLACEABLE, rUtpName_01, lChestLocation);
bEventHandled = TRUE;
}
break;
}
default:
{
break;
}
}
if (!bEventHandled)
{
HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);
}
}
// ---- SCRIPT ENDS HERE ----
I am making it spawn at my feet atm, will place it in the real world when mod is complete.
I am using latest Toolset 1.01 and Game upgraded to 1.02
Modifié par Gambler1971, 19 décembre 2009 - 04:25 .
#6
Posté 20 décembre 2009 - 10:36
I'm not sure why you're creating the chest rather than simply placing it in the toolset?
Your script looks OK, but I can guess why it might not work. The placeable state is a property of the instance. We know that when a chest is placed in the toolset, the initial properties of the instance are copied from the template, but does CreateObject work the same way?
You could try using SetPlaceableState to force the Closed_Locked status. I can't find a constant for that status (which suggests that you're trying to do something Bioware hasn't done before). If I'm reading placeable.xls correctly, the value you need is 1 (if not, GetPlaceableState on a chest placed using the toolset would give you the correct value).
I don't know enough about DA events yet to be confident that an area is well-established during the Module Load event - if my suggestion doesn't work, it might be better to wait until the player is in the area (or a trigger around the start location).
Your script looks OK, but I can guess why it might not work. The placeable state is a property of the instance. We know that when a chest is placed in the toolset, the initial properties of the instance are copied from the template, but does CreateObject work the same way?
You could try using SetPlaceableState to force the Closed_Locked status. I can't find a constant for that status (which suggests that you're trying to do something Bioware hasn't done before). If I'm reading placeable.xls correctly, the value you need is 1 (if not, GetPlaceableState on a chest placed using the toolset would give you the correct value).
I don't know enough about DA events yet to be confident that an area is well-established during the Module Load event - if my suggestion doesn't work, it might be better to wait until the player is in the area (or a trigger around the start location).
Modifié par Proleric1, 20 décembre 2009 - 10:36 .
#7
Posté 20 décembre 2009 - 01:19
Try using:
SetPlaceableState(oChest_01, PLC_STATE_CONTAINER_LOCKED);
I have never tried to use CreateObject() but since you have already created the resource for the chest I would presume that it should maintain the state specified in the resource. So, this could be a bug.
SetPlaceableState(oChest_01, PLC_STATE_CONTAINER_LOCKED);
I have never tried to use CreateObject() but since you have already created the resource for the chest I would presume that it should maintain the state specified in the resource. So, this could be a bug.
#8
Posté 20 décembre 2009 - 01:20
That got it.
Sadly, I know how to make the Placeable within the toolset, I have done that, but I dont know how to make it spawn without running the script.
My final script checks that I am in the correct zone and that it has not spawned previously before spawning the chest.
Sadly, I know how to make the Placeable within the toolset, I have done that, but I dont know how to make it spawn without running the script.
My final script checks that I am in the correct zone and that it has not spawned previously before spawning the chest.
#9
Posté 20 décembre 2009 - 02:17
Are you saying that you can't make an instance simply by selecting the placeable template in the palette and clicking somewhere in the area?
@BioSpirit - heh, my bad, I was looking for PLACEABLE constants, might have known it would be PLC!
@BioSpirit - heh, my bad, I was looking for PLACEABLE constants, might have known it would be PLC!
#10
Posté 20 décembre 2009 - 04:43
Proleric1 wrote...
Are you saying that you can't make an instance simply by selecting the placeable template in the palette and clicking somewhere in the area?
I honestly dont understand sorry. I made a UTP file for the chest, but I have no idea how to add it to an area other than scripting, which is a pain, but is the only way I know atm.
#11
Posté 21 décembre 2009 - 06:47
If you are adding it to the OC, then scripting is the only way. If you are adding it to your own area, then just click (or dbl-click I forget which) on the placeable in the palette window, then click somewhere in your area.





Retour en haut






