Search the Community
Showing results for tags 'chest'.
-
Hi Folks, I'm trying to use the Merry Chest 2 prefab in my mission but cannot get it to open in game. Does anyone know how to fix this ? Many thanks
-
Hey Guys, I apologize ahead of time, I am a novice at scripting. I am trying to create a thief-style chest; one that when opened, the items are automatically dumped into the player's inventory. I have pretty hacky prototype. Once the player frobs open the lid (atdm:mover_binarymover_base), it targets a func_callscriptfunction. I have a hacky Stim/response that removes the lid's targets when frobbed. This prevents the player from getting items every time they open the chest. The problem is when I try to lock the lid or attach a froblock, it breaks and nothing happens. The lid doesn't seem to like having other entities bound to it or target it. Any suggestions or help would be awesome? Thanks a bunch guys. EDIT (Solved). Thanks for everyone's help with this. Here is the .script and .def for anyone who is interested in using this in their FM. Here is the script by SteveL: #ifndef AUTOLOOT_CHEST #define AUTOLOOT_CHEST //Script for autoloot chest by SteveL // Spawnargs: "random_spawn", "random_chance" //"random_spawn" = name of inventory item. (example "atdm:ammo_gasarrow") //"random_chance" = Probability of spawn. (0 to 1) void autoloot_chest(entity chest, boolean bOpen, boolean bLocked, boolean bInterrupted) { // Fire only if map has been open 3 seconds (avoiding map initialisation) and // only the first time the door/lid is fully opened. if ( sys.getTime() > 3 && bOpen && !chest.getBoolKey("already_opened") ) { chest.setKey("already_opened", "1"); // Search through "random_spawn" spawnargs, and find a matching "random_chance" spawnarg string key = chest.getNextKey("random_spawn", ""); while ( key != "" ) { float chance = chest.getFloatKey(sys.strReplace(key, "_spawn", "_chance")); float r = sys.random(1.0); if ( chance > r ) { entity newItem1 = sys.spawn(chest.getKey(key)); newItem1.addItemToInv($player1); sys.wait(1.0); } key = chest.getNextKey("random_spawn", key); } } } #endif And the def file: Be sure to replace the YOUR FM with your fm's directory. //++++++++++++++++++++++++Frob Chest++++++++++++++++++++++++++++++ //Auto Loot Chest //Uses script "autoloot_chest" by SteveL //Spawnargs: "random_spawn", "random_chance" //"random_spawn" = Name of inventory item. (example "atdm:ammo_gasarrow") //"random_chance" = Probability of spawn. (0 to 1) entityDef frob_chest_lid { //editor stuff "inherit" "atdm:mover_binarymover_base" "editor_displayFolder" "YOUR FM/autoloot_chest/" "editor_usage" "Auto loot chest. Random_spawn = name of inventory item. (example: atdm:ammo_gasarrow). Random_chance = Probability of spawn. (0 to 1)." "editor_color" "1.00 0.82 0.29" "spawnclass" "CFrobDoor" //model "model" "models/darkmod/containers/openable/footlocker_wood_lid.ase" //sound "snd_open" "chest_wood_open" "snd_close" "chest_wood_close" //movement "rotate" "0 0 -80" "move_time" "0.4" //interaction "frobable" "1" "locked" "0" "state_change_callback" "autoloot_chest" } //Chest Body entityDef frob_chest { //editor stuff "inherit" "atdm:entity_base" "spawnclass" "idStaticEntity" "editor_displayFolder" "YOUR FM/autoloot_chest/" "editor_usage" "Auto loot chest." "editor_color" "1.00 0.82 0.29" //model "model" "models/darkmod/containers/openable/footlocker_wood.ase" //other stuff "solid" "1" }