This library is an improved version of some now almost ten year old scripts that would give entities random names, color selections, and other "get started" stuff. I haven't had a chance to do a full readme write up yet, so I'll add the use basics here.
DC Initialize
First install the library (duh). The readme will tell you how.
Names:
The old version from would pull random names from a spreadsheet style text file you could edit live while the module ran. This is cool an all, but kind of memory intensive and I've since decided on a less flashy but more practical method.
[list type=decimal]
[*]In the model's onspawnscript, use dc_initialize_alias_quick_add(<char name>) to add an alias. Repeat this as many times as you like to add more aliases. I HIGHLY recommend you use OpenBOR's oncreate() function to do this.
[*]Now you can run dc_initialize_random_alias(); to get a random alias for the calling entity (you can change the target entity elsewhere). Note this does not actually change the alias. It just picks a random choice from the list you defined.
[*]Change the entity property "name" to the random alias. You might want to have some kind of condition for this - I have one that I'll explain below.
[/list]
Colors:
Super simple.
[list type=decimal]
[*]Make color sets like you always do.
[*]Run dc_random_color_set(), and it will return a random color index. Hidden maps are automatically excluded.
[*]Change the entity property "map" to the random index. Again, you might want to put a conditional on this.
[/list]
Example:
There is also a function called dc_initialize_level_spawn() that shortcuts all of this, and adds preset conditionals. You still need to set up random names in each models's onspawn script, but that's it. Running this function does the following:
[list type=decimal]
[*]If the entity is spawned in with an alias of "Random", it will be re-assigned a random name.
[*]If the entity is spawned with map 1, it will re-assigned a random map
[/list]
onspawnscript.c example:
Spawn entry example:
DC Initialize
First install the library (duh). The readme will tell you how.
Names:
The old version from would pull random names from a spreadsheet style text file you could edit live while the module ran. This is cool an all, but kind of memory intensive and I've since decided on a less flashy but more practical method.
[list type=decimal]
[*]In the model's onspawnscript, use dc_initialize_alias_quick_add(<char name>) to add an alias. Repeat this as many times as you like to add more aliases. I HIGHLY recommend you use OpenBOR's oncreate() function to do this.
[*]Now you can run dc_initialize_random_alias(); to get a random alias for the calling entity (you can change the target entity elsewhere). Note this does not actually change the alias. It just picks a random choice from the list you defined.
[*]Change the entity property "name" to the random alias. You might want to have some kind of condition for this - I have one that I'll explain below.
[/list]
Colors:
Super simple.
[list type=decimal]
[*]Make color sets like you always do.
[*]Run dc_random_color_set(), and it will return a random color index. Hidden maps are automatically excluded.
[*]Change the entity property "map" to the random index. Again, you might want to put a conditional on this.
[/list]
Example:
There is also a function called dc_initialize_level_spawn() that shortcuts all of this, and adds preset conditionals. You still need to set up random names in each models's onspawn script, but that's it. Running this function does the following:
[list type=decimal]
[*]If the entity is spawned in with an alias of "Random", it will be re-assigned a random name.
[*]If the entity is spawned with map 1, it will re-assigned a random map
[/list]
onspawnscript.c example:
Code:
#include "data/scripts/dc_initialize/main.c"
void oncreate()
{
dc_initialize_alias_quick_add("Ray");
dc_initialize_alias_quick_add("Aussie");
dc_initialize_alias_quick_add("Baxter");
dc_initialize_alias_quick_add("Bloundie");
dc_initialize_alias_quick_add("Brush");
dc_initialize_alias_quick_add("Bryl");
dc_initialize_alias_quick_add("Dapper");
dc_initialize_alias_quick_add("Dep");
dc_initialize_alias_quick_add("Fop");
dc_initialize_alias_quick_add("Gel");
dc_initialize_alias_quick_add("Mesh");
dc_initialize_alias_quick_add("Moouse");
dc_initialize_alias_quick_add("Mug");
dc_initialize_alias_quick_add("Silky");
dc_initialize_alias_quick_add("Slick");
dc_initialize_alias_quick_add("Spike");
dc_initialize_alias_quick_add("Woody");
}
void main()
{
dc_initialize_level_spawn();
}
Spawn entry example:
Code:
spawn ray
alias Random
map 1
health 100
coords 550 210