Welcome to the Builder Academy

Question is this possible with dg_scripts

More
16 Jul 2012 23:41 #383 by bakarus
I want to make a script that will globally make an array of every mob currently ingame, then use a random() to pick 10 mobs of all that exist and give them an item in their inventories.

Basically a mob[], then a random(mob[].sizeof()), then pick out 10 mob vnums at random, and then load and give them an item.

Thanks for you help, in advance :)

Please Log in or Create an account to join the conversation.

More
17 Jul 2012 00:31 #384 by Fizban
Technically - no.

Can you essentially do the same thing in a somewhat hack-job manner? Yes.
Code:
1) Name : Load Object to Random Mob 2) Intended for : Mobiles 3) Trigger types: Load 4) Numeric Arg : 100 5) Arguments : 6) Commands: set i 0 while %i% < 10 set num %random.65535% if %num.vnum% > 0 else break end %teleport% %self% %num% if %self.room.vnum(%num%)% set char %random.char% if !%char.is_pc% %load% obj 57700 %char% inv eval i %i% + 1 end end done

Something like that should do roughly the same.

Please Log in or Create an account to join the conversation.

More
17 Jul 2012 01:38 #385 by bakarus
So I need to use this trigger on a mob? It could possibly still work for what I want, is there a way to set the invis lvl of the mob using this trigger, also I assume this trigger will only run when the mob loads.

Please Log in or Create an account to join the conversation.

More
17 Jul 2012 19:46 #386 by bakarus
Made a new mob, added this script to him, not sure how to use this script, it doesn't fire when he loads, nor on copyover/reboot anything. What am I doing wrong? :)

Please Log in or Create an account to join the conversation.

More
18 Jul 2012 02:56 #388 by Vatiken
It may be easier, and more efficient to just add another variable in dg_variables.c for "mob_in_game", and do "random.mob_in_game" in your script.
Code:
struct char_data * get_random_mob(void) { int mobs = max_mob_id - MOB_ID_BASE; int random, count; struct char_data *tch; random = rand_number(0, mobs); for (count = 0;tch = character_list; tch; tch = tch->next) { if (!IS_NPC(tch)) continue; if (count++ == random) return(tch); } return NULL; }

Something like that???

tbaMUD developer/programmer

Please Log in or Create an account to join the conversation.

More
18 Jul 2012 05:12 #389 by bakarus
Thanks Vatiken, I was attempting to see if it was possible exclusively with dg_scripts. The code change is probably the best solution, thanks for your input, it's very much appreciated.

Please Log in or Create an account to join the conversation.

Time to create page: 0.189 seconds