Loot

From The DarkMod Wiki
Jump to navigationJump to search

Introduction

This wikipage is for general information and guides dealing with loot related things.

Basic Loot Objects

You can add loot into your map by right clicking the orthoview in DR and selecting 'create entity'. Preconfigured loot objects are available in the entity lists. You can also make new non-standard loot objects by changing the spawnargs or an already added loot item: inv_loot_value, model, etc.

Advanced Loot Objects

Sometimes more elaborate loot elements are required.

Loot Cache

A Loot Cache is a special object that gives items to the player upon frobbing. A closed bag, for example. The player frobs it and receives an arrow. He frobs again and receives a health potion. When the player frobs the third time the bag is empty and the player gets nothing. These kind of objects could be useful for random stashes in the map. Mapper could prepare such a bag and teleport it anywhere in the map upon each mission restart, making the loot to be located in a different place each playtime, increasing replayability of the mission. When placing Loot Caches, be sure to make them seem unusual and different from their surroundings, luring the player to go and frob it.

Recipe: Create a func_static stash object. A bag, for example. Give it "name loot_cache" and "frobable 1". Select the object and open it in the S&R editor. Add frob from the response list. The effect of the response should be trigger. Have it to trigger an entity named exec_inventory_grab. Create a atdm:target_callscriptfunction-entity and name it "exec_inventory_grab". Also give it spawnarg "call inventory_grab".

The end result should be that when the object receives a frob, the S&R triggers the exec_inventory_grab, which in turn calls a script named inventory_grab.

Create in your maps folder, alongside the mission-name.map a file called mission-name.script. Enter this kind of script into the file:

float cache_state = 0; // a global mapwide variable to tell the map how much stuff the player has taken from the cache.
void inventory_grab()
{
sys.println("inventory grab script running"); // Print the text to the console
   if ( cache_state == 0 ) {
       sys.println("Give item 0");
       $item_name_0.addItemToInv($player1); //put item_name_0 into player inventory and let the player know about it.
   }
   if ( cache_state == 1 ) {
       sys.println("Give item 1");
       $item_name_1.addItemToInv($player1);
   }
   if ( cache_state == 2 ) {
       sys.println("Give item 2");
       $item_name_2.addItemToInv($player1);
   }
cache_state = cache_state + 1; // increment the variable to make the script give the next object to the player when he frobs the cache again.
}

You need to create item_name_X objects into your map's blueroom. These objects could be anything that can be picked up: loot, scrolls, books, player tools, player weapons, arrows. Expand the script if you have more objects in the cache, i.e. add more if sentences. Handy tip: remember that arrows have the inv_ammo_amount spawnarg. Setting this to 10 on the arrow entity could make the player receive 10 broadheads with a single frob.

If you like, you could make a visual cue suggesting the Loot Cache contains objects. You could place a dummy func_static object, a broadhead shaft for example, to stick out from the Cache. Give the dummy-func_static spawnargs: "name dummy_arrow" "bind loot_cache", "frobable 1", "frob_distance 1". Give the loot_cache spawnarg "frob_peer_1 dummy_arrow". Now the arrow shaft is glued on the Cache and moves with it when the Cache is teleported. Also when the Cache is frob-highlighted, the dummy arrowshaft will highlight as well. If you add the command

$dummy_arrow.remove();

to the last if sentence, the arrow shaft will vanish when the last object has been taken out from the cache, providing a visual clue that the cache indeed is now empty.

See also