Ok I have some ideas which involved a group of global vars, for mobs, items/ For statement, if this break state. But just wonder if anyone can get me going in the right direction for randoming placing a mob or obj in a space that has a density of 0 on the map. Also add in a random sleep timer so they are not spawn at the same time like clock work.
LJR
ID:149816
![]() Feb 14 2002, 3:07 am
|
|
Not being an expert on BYOND, I think I can at least give you something to chew on...
you should be able to put a mob at a random location with something like this (not BYOND specific, but convertable I would imagine): map_width = 100 // width of map map_height = 100 // height of map turf_level = 0 // turf level x = random number between 1 and map_width y = random number between 1 and map_height (I guess you could have random turf levels too) if location(x, y, turf_level) has density of 0, then the mob can be moved there by normal means else re-run the randomization of x and y and try again... the random sleep timer can also be implemented before the if-check is performed, or before the randomization...hope that steers you in the right direction... |
LordJR wrote:
Ok I have some ideas which involved a group of global vars, for mobs, items/ For statement, if this break state. But just wonder if anyone can get me going in the right direction for randoming placing a mob or obj in a space that has a density of 0 on the map. Also add in a random sleep timer so they are not spawn at the same time like clock work. A way could be to have special spawn areas, and just locate() a turf in that area. Having seen your game in action, I don't see why you should have a problem with this. :) But I didn't understand the break state and global vars exactly. Please explain more if you need help. /Andreas |
Well, I posted an example of spawner obj's that do something very similar to this. You can find it here.
-James |
My spawning code still isn't working beyond the 1st time when the game is booted.
My spawner is an obj that I place through out the map. I have multiple spawn areas through out my maps. Somehow I need to tag a monster for when they come out of the spawner so it knows to spawned -- from the right spawner. What the code below does works find the 1st time around. Also the proc I created at the bottom is called from the mob/npc/ when it does a health check. Once a monster is killed it never respawns because the spawned -- is not telling the spawner to make a new mob. I know this much but not how to correct the problem. LJR snippet.. obj/spawner name = null // Mob Maxes var/MAX_KINGRATS = 25 var/spawned = 0 // count of mobs spawned New() ..() while (1) src.check_spawn() // start the spawn calls sleep(100) // wait 10 secs proc/check_spawn() // called periodically to check to see if // any new mobs should be generated if(spawned < MAX_KINGRATS) // make sure we haven't reached limit var/mob/npc/M = new /mob/npc/King_Rat(src.loc) // generate mob M.Move(loc) spawned ++ // increment the counter proc/npc_death() spawned -- This is the code that calls the npc_death() NPCDeath(mob/pc/M) /obj/spawner/proc/npc_death ..blah..blah |
Okay, I assume NPCDeath is called when the mob gets killed. An easier way might be to make a mob/var/obj/spawner/spawned_by on the mob that is set to the spawning object when the mob is initially spawned. That why in its del() proc you can just call src.spawned_by.spawned --. That why every mob will adjust their specific spawner when deleted.
-James |
LJR