Author Topic: Spawn Random Numbers Of Creature On Enter  (Read 403 times)

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Spawn Random Numbers Of Creature On Enter
« on: March 16, 2011, 02:29:15 am »


               How would I script to Spawn Random Numbers Of Creature when a PC enters an Area then have them random walk?
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Spawn Random Numbers Of Creature On Enter
« Reply #1 on: March 16, 2011, 05:41:47 pm »


               Well...we'd need a bit more specifics on things like if this is going to be used in more than one area, if you are going to be using different npcs/creatures, will the creatures spawn at different locations, should this only happen once, etc... But for what you have asked you could do something like this:

-first put down a waypoint where you want the creatures to spawn.
-then put a script in the area's OnEnter event like so:

void main()
{
    object oWaypoint = GetWaypointByTag("Tag of waypoint here");
    location lSpawn = GetLocation(oWaypoint);
    string sResRef = "res ref of creature to spawn here";
    int iRandom = Random(3)+1;//change the 3 to how many spawns you want

    while (iRandom > 0)
    {
        object oSpawn = CreateObject(OBJECT_TYPE_CREATURE, sResRef, lSpawn);
        AssignCommand(oSpawn, ActionRandomWalk());
        iRandom--;
    }
}

Hope this gets the ball rolling.
               
               

               


                     Modifié par GhostOfGod, 16 mars 2011 - 05:42 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Spawn Random Numbers Of Creature On Enter
« Reply #2 on: March 16, 2011, 06:24:14 pm »


               To make a creature walk around randomly set a variable (int) on the creature blueprint called X2_L_SPAWN_USE_AMBIENT and set it to 1.

-420
               
               

               
            

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Spawn Random Numbers Of Creature On Enter
« Reply #3 on: March 16, 2011, 08:58:55 pm »


               Could I make that to multiple waypoints, and multiple creatures (1 more for female NPC)?


resrefs:  
human025 , and human023
               
               

               


                     Modifié par NWN Dragon-Blade, 16 mars 2011 - 09:04 .
                     
                  


            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Spawn Random Numbers Of Creature On Enter
« Reply #4 on: March 19, 2011, 01:13:05 am »


               I would check out random people on the vault.You can even make them evil so they are bad guys.
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Spawn Random Numbers Of Creature On Enter
« Reply #5 on: March 19, 2011, 01:13:41 am »


               Then look for random stats on the vault.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Spawn Random Numbers Of Creature On Enter
« Reply #6 on: March 19, 2011, 01:56:28 am »


               There are spawn systems such as NESS which do much of this scripting for you. It might be worth it to check these systems out if you are doing things like this throughout your module.