ID:164735
Apr 24 2007, 5:49 pm
|
|
I'm trying to create a code that will generate a random treasure from a pool of different treasures. Specifically, I'd like to be able to place a symbol or chest in a square and have a random weapon in it. Can anyone help?
|
In response to KirbyAllStar
|
|
Why not just directly use pick() on a list of specific outcomes...?
#define otypesof(x) (typesof(x)-x) |
In response to Kaioken
|
|
Yeah do that one, lol
Could you explain it a little more, I think I get it but I'm not sure. -KirbyAllStar |
In response to KirbyAllStar
|
|
Well, that is simple code... what is confusing you? The #define? Usage of pick()? new()?
|
In response to Kaioken
|
|
The #define is all I should have said that in the other post.
|
In response to KirbyAllStar
|
|
typesof() returns a list of the child types, INCLUDING the main, parent type. This means if you have these paths:
obj/item typesof(/obj/item) will return: list(/obj/item,/obj/item/box,/obj/item/apple) Now, very frequently, including these times, you won't actually need or use the base type (/obj/item), and need to skip it. You can quickly do it with the - operator: typesof(/parent_path) - /parent_path It will subtract (remove) the parent path from the list typesof() returns. This is where the #define comes in, its just a shorthand for that, so you don't have to manually add a minus and copy the path each time. Note that this is a short way for convenience, and can be more efficient; since you're using the '-' operator, it creates another list. You can avoid this and only create one: var/list/paths = typesof(/parent_path) |
In response to Kaioken
|
|
Ah ok thanks, I've used typesof() but never really understood everything about it.
Thanks again -KirbyAllStar |
Thats probably not the best way to do it, especially if you want to have it pick different treasures more often than others. For that you would have to ask someone more experienced. I'm sure I can do it, but it would take some time that I don't have at the moment, and if you want to do that it would be better for you to do it yourself so you have the experience.
-KirbyAllStar