Just as you can set the properties on newly spawned objects, you can also add items to spawned mobs or containers.
The ADD keyword can be used to add items to the pack of a mob or into a container.
The syntax for this keyword is
ADD[,probability]/itemtype
You can also add items and change their properties at the same time by using the special grouping characters '<' and '>'
ADD[,probability/<itemtype/propertyname/value...>
this will create the item, set the properties on it, and then add the result to the mob or container.
For example, to add a piece of armor to a spawned mobs pack you could use a spawn entry like
orc/ADD/plategorget
to add it to a container is the same thing
metalbox/ADD/plategorget
To add more than one item, just keep adding more ADD keywords
orc/ADD/plategorget/ADD,0.3/gold,500
that will add both the gorget and 500 gold pieces, but the gold will only be added 30% of the time (probability of 0.3)
To set the hue of the gorget before adding it you would use the grouping brackets like
orc/ADD/<plategorget/hue/500>/ADD/gold,500
A few things to note here.
1) The 'gold' is created using a constructor that takes a quantity argument (that's what the 500 is). This is possible because the 'gold' item actual has such a constructor defined for its class. Not all objects will have such a constructor available, and conversely, some objects will have other constructors that can take other arguments. You need to look at the documentation for a particular item class to know what is available and what is not.
2) if the grouping brackets were not used, then the Hue property would end up being set on the orc, instead of on the plategorget.
I hate to be so noobish, but when i tried to ADD stuff to spawned containers, it doesnt work for me.
QUOTE (Nagozi @ November 18, 2008 06:00 pm) |
I hate to be so noobish, but when i tried to ADD stuff to spawned containers, it doesnt work for me. |
It works great for me. Since I'm not sure how you're doing it, I'll show you how I do it. I spawned a metal box inside a metal box and spawned a saw inside each box by using this line:
metalbox/ADD/saw/ADD/<metalbox/ADD/saw>
Then I spawned a bag inside a bag inside a bag and spawned a saw inside the innermost bag using this line:
bag/ADD/<bag/ADD/<bag/ADD/saw>>
This worked perfectly for me.
Esattamente come si può modificare le proprietà di un qualsiasi oggetto spawnato, si può anche aggiungere oggetti ad un mob o ad un contenitore spawnato.
Il comando ADD può essere usato per aggiungere oggetti al loot di un mob o dentro un contenitore (casse,mobili,ecc.).
Il comando è:
ADD[,probability]/itemtype
Si può inoltre modificare le proprietà delloggetto aggiunto con l’uso delle parentesi “<” e “>”
ADD[,probability]/<itemtype/propertyname/value...>
Questo commando crerà l’oggetto, modificherà le sue proprietà e quindi lo aggiungerà al loot del mob o all’interno del contenitore.
Per esempio, per aggiungere il pezzo di una armatura ad un mob spawnato, si potrebbe usare il comando:
orc/ADD/plategorget
per aggiungerlo ad un contenitore è la stessa cosa
metalbox/ADD/plategorget
Per aggiungere più di un oggetto, basta aggiungere più comandi ADD
orc/ADD/plategorget/ADD,0.3/gold,500
questo aggiungerà sia la gorgiera che le 500 monete, ma l’oro verrà aggiunto solo nel 30% dei casi (probabilità di 0,3).
Per modificare il colore della gorgiera prima di aggiungerla, si possono usare le parentesi
orc/ADD/<plategorget/hue/500>/ADD/gold,500
Un paio di cose da notare:
1) L’oro è stato creato con un sistema che possiede l’argomento quantità ( ecco perchè il 500 nel comando). Questo è possibile perchè l’oro ha un sistema definito per la sua classe. Non tutti gli oggetti hanno un sistema come questo, e conseguentemente, altri oggetti avranno altri sistemi con altri argomenti specifici.
2) Se non si usano le parentesi, le proprietà verranno modificate al mob e non all’oggetto che si vuole aggiungere alla sua sacca.