Post new topic    
Liquid Metal Slime
Send private message
Spawning Enemies Question 
 PostMon Jan 18, 2010 7:39 pm
Send private message Reply with quote
I have a script that spawns an enemy in a random place on the map. It also check walls and recreates an npc if necessary.

It works fine but right now it will only spawn enemies in places that are touching absolutely no walls. I'd like to allow them to spawn anywhere except for when they are completely walled in on all four side, but am unsure how to write that.

Here's my current script. Any suggestions are much appreciated:

Code:
      powerx := random(1,15)
      powery := random (1,9)
      create npc (20,powerx,powery)
      alter NPC (20,NPCstat:move type,npcmovetype:pace)
      alter npc (20,NPCstat:picture,5)
      while (check npc wall (20,north) ,or, check npc wall (20,south) ,or, check npc wall (20,east) ,or, check npc wall (20,west)) do (
         destroy npc (20)
         powerx := random(1,15)
         powery := random (1,9)
         create npc (20,powerx,powery)
         alter NPC (20,NPCstat:move type,npcmovetype:pace)
         alter npc (20,NPCstat:picture,5)
)

Cornbread Chemist
Super Slime
Send private message
 
 PostMon Jan 18, 2010 8:09 pm
Send private message Reply with quote
If you want any square that does not have all four walls to be legal, all you have to do is this:

Code:
while (read pass block(powerx, powery) <> (north wall + south wall + east wall + west wall)) do (


If you want to verify that the NPC isn't walled in, period, I really suggest using one of the vehicle pass bits to mark unusable tiles.
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
Liquid Metal Slime
Send private message
 
 PostMon Jan 18, 2010 9:20 pm
Send private message Reply with quote
Nice, it's working great.

The only other question I have is whether these "spawns" can spawn on top of other npcs or the hero. I haven't seen either occur, but I assume that they can spawn at least on top of the hero. Any way to prevent that, if neccessary?
Cornbread Chemist
Super Slime
Send private message
 
 PostMon Jan 18, 2010 9:49 pm
Send private message Reply with quote
NPCs: Check npc at spot, easy.

Heroes: Iterate through the heroes and verify that (powerx == herox(who) && powery == heroy(who)) == false for each one.
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
Display posts from previous: