Thread: Make npc's spawn from certain locations, and how many spawn?

Results 1 to 5 of 5
  1. #1 Make npc's spawn from certain locations, and how many spawn? 
    Registered Member
    Join Date
    Jul 2007
    Posts
    358
    Thanks given
    0
    Thanks received
    0
    Rep Power
    26
    Hello,

    How do I make npc's spawn in a certain area, with me stating how many will spawn there at a certain time, because i'm doing a minigame where you have to stay alive for as long as possible.

    Thanks
    James
    ~Violated Removed
    Reply With Quote  
     

  2. #2  
    Registered Member
    Whired's Avatar
    Join Date
    Aug 2007
    Posts
    2,126
    Thanks given
    238
    Thanks received
    500
    Rep Power
    822
    What base?
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jul 2007
    Posts
    358
    Thanks given
    0
    Thanks received
    0
    Rep Power
    26
    I was thinking delta.
    ~Violated Removed
    Reply With Quote  
     

  4. #4  
    Registered Member
    Whired's Avatar
    Join Date
    Aug 2007
    Posts
    2,126
    Thanks given
    238
    Thanks received
    500
    Rep Power
    822
    Delta already has
    Code:
    public void spawnANPC(int npcID, int absX, int absY, int height)
    {
    server.npcHandler.newNPC(npcID, (absX), (absY), height, absX + 3, absY + 3, absX - 3, absY - 3, 0, server.npcHandler.GetNpcListHP(npcID), false);
    }
    in NPCHandler.java

    You could also add this method (sort of pseudo code, I'm writing on the spot)
    Code:
    public void spawnMultipleNpcs(int npcID, int absX, int absY, int height, int walkarea, int amount)
    {
    	for(int i = 0; i < amount; i++)
    	{
    		int[] xrange = { (absX-3), (absX-2), (absX-1), absX, (absX+1), (absX+2), (absX+3) }; //X precision
    		int[] yrange = { (absY-3), (absY-2), (absY-1), absY, (absY+1), (absY+2), (absY+3) };// Y precision
    		int x = xrange[misc.random(xrange.length)];//pick random x from xrange
    		int y = yrange[misc.random(yrange.length)];//pick random y from yrange
    		server.npcHandler.newNPC(npcID, x, y, height, (x + walkarea), (y + walkarea), (x - walkarea), (y - walkarea), 0, server.npcHandler.GetNpcListHP(npcID), false);
    	}
    }
    
    public void spawnManyDifNpcs(npcsToSpawn, X, Y, height, area, amount)
    {
    /*
    where:
    	X is the original X, the center.
    	Y is the original Y, the center.
    	height is the height level on which to spawn
    	area is how far the npc can walk in any direction
    	amount is the number you want to spawn per each npcid
    */
    	for(int i = 0; i < npcsToSpawn.length; i++)
    	{
    		spawnMultipleNpcs(npcsToSpawn[i], X, Y, height, area, amount);
    	}
    }
    
    //and call it like this
    int[] npcs = { 1, 7, 700, 4034, 2103 };//Different IDs of NPCs
    spawnManyDifNpcs(npcs, 3024, 2114, 1, 3, 2);
    Hope that helps, if only a little
    Reply With Quote  
     

  5. #5  
    Registered Member Hexagon's Avatar
    Join Date
    May 2008
    Posts
    672
    Thanks given
    28
    Thanks received
    18
    Rep Power
    33
    i think you could do this:
    Code:
    public void spawnminigame(){
     server.npcHandler.spawnANPC(XXXX2, YYYY, ####, heightLevel);
    }
    
      public boolean inwaitplace() {
        if (absX >= XXXX && absX <= YYYY && absY >= XXXX && absY <=YYYY) {
          return true;
    
        } else {
          return false;
        }
      }
    on process:
    Code:
    if(inwaitplace() && PlayerHandler.minigameTimer == 1){
    spawnminigame();
    }
    on playerhandler just add minigametimer
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •