Greetings, I've came to a point when I want to code NPC respawning in.
I have a few ideas.
1) Use areas for different types of mobs. It's bad though because I use areas to handle music. Any advice how to combine these too? I don't think it's possible to have two areas on one tile, am I right?
2) Upon the world creation save all placed critters' location. Then when they Die() send them to a room, and from time to time send them to their original location if there're no players around. How do I check if there're no mobs with keys around a location?
3) Make stationary invisible objects as markers. This one seems tempting because I should be able to see them on map, but I am not sure how to make this random because I don't want to make an object for EACH mob.
If people who have time and experience can share better ideas, I would really like to listen to them.
ID:273478
Jun 3 2010, 12:12 am
|
|
In response to Garthor
|
|
In 3 I was going to ask how to better make random pick between objects of a type.
So, let's say we have a "giant rat" respawn point. It has a variable type identical to "giant rat". How should I work from now on? for(/obj/respawn in world) if(respawn.type == "giant rat") move ... wouldn't work because it would pick the first obj in the list. What would be the best way to randomly pick one of respawn objects with a desired type? P.S. "oview(respawnlocation)" - thank you :). |
In response to Deon_Urist
|
|
for(/obj/respawn in world)
loops through all /obj/respawn in the world if you have a return it stops it. use continue. |
In response to Leur
|
|
Do you mean to make a roll(something) each time I encounter an object and if it succeeds then move and "return", otherwise "continue"? Sorry I didn't get your answer clearly :P.
|
In response to Deon_Urist
|
|
for(var/mob/M in world) {
if(M.type=/mob/player) dostuff else continue } Something like that is what I meant, you could obviously shorten that to mob/player/M in world. but I'm just showing you what I meant. |
In response to Leur
|
|
Leur wrote:
for(var/mob/M in world) { Eh, I surely know it. We must be misunderstanding each other. My question was totally different. About the random pick. |
In response to Deon_Urist
|
|
How should I work from now on?
for(/obj/respawn in world) if(respawn.type == "giant rat") move ... wouldn't work because it would pick the first obj in the list. What would be the best way to randomly pick one of respawn objects with a desired type? Is what I replied to.. I'm not sure, but I think pick can work like this too. pick(/obj/cake,/obj/pie) |
In response to Leur
|
|
Leur wrote:
How should I work from now on? I thought pick() works with numbers only. |
In response to Deon_Urist
|
|
mob Yup, it works :3 |
In response to Deon_Urist
|
|
To pick a random thing fitting some conditions:
var/list/L = list() |
No, a turf can only belong to one area.
This is basically identical to 2.