Author Topic: monsters wandering randomly  (Read 713 times)

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
monsters wandering randomly
« on: July 14, 2011, 10:43:48 pm »


               I want to have monsters wander around randomly. I know how to have them walk between waypoints, but that doesn't seem, somehow, organic. There must be a random function if you can generate random numbers of monsters in an encounter. Probably some talented programmer out there can tell me how to do this. Thanx!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
monsters wandering randomly
« Reply #1 on: July 14, 2011, 10:52:06 pm »


               Function - ActionRandomWalk
               
               

               
            

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
monsters wandering randomly
« Reply #2 on: July 14, 2011, 11:28:56 pm »


               If you want to be super lazy there's a default on spawn script x2_spn_rndwalk that does this quite nicely.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
monsters wandering randomly
« Reply #3 on: July 14, 2011, 11:37:20 pm »


               If you are using the default OnSpawn Event - either nw_c2_default9 or x2_def_spawn (which executes nw_c2_default9) - you can use variables to modify creature behavior through the BioWare AI. The particular one you want is X2_L_SPAWN_USE_AMBIENT.

From The Builders Project's Guide to Building Vol. I - The Toolset Manual

Variables: By clicking on the “Variable” button (under the Advanced Tab in the Creature Properties window) you can set local variables on the creature. These variables can be used in any script involving this specific creature. Some specific variables have already been coded by Bioware and can be used to modify the behaviour of your creatures. Here is a list of these already coded variables:

X2_SPELL_RANDOM
Setting this variable to 1 on a spellcaster creature will make its spell use a bit more random, but their spell selection may not always be appropriate to the situation anymore.

X2_L_SPAWN_USE_STEALTH
Set to 1 to make the creature activate stealth mode after spawn.

X2_L_SPAWN_USE_SEARCH
Set to 1 to make the creature activate detect mode after spawn.

X2_L_SPAWN_USE_AMBIENT
Set to 1 to make the creature play mobile ambient animations after spawn. The creature will then move in the area where it is located, salute other creatures, scratch its head, etc.

X2_L_SPAWN_USE_AMBIENT_IMMOBILE
Set to 1 to make the creature play immobile ambient animations after spawn.

X1_L_IMMUNE_TO_DISPEL
Set to 1 to make the creature immune to dispel magic (used for statues).

X2_L_IS_INCORPOREAL
Set this variable to 1 on a creature to make it walk through other creatures.

X2_L_NUMBER_OF_ATTACKS
Set this variable to 1 - 6 to override the number of attacks a creature has based on its base attack bonus.

X2_L_BEH_MAGIC
The value of this variable (int) is added to the chance that a creature will use magic in combat. Set to 100 for always, 0 for never.

X2_L_BEH_OFFENSE
The higher value of this variable, the higher the chance that the creature will use offensive abilities in combat. Set to 0 to make them flee.

X2_L_BEH_COMPASSION
The higher value of this variable, the higher the chance that the creature will aid friendly creatures in combat. Note that helping usually degrades the overall difficulty of an encounter, but makes it more interesting.

X2_S_PM_SPECIAL_ITEM
This allows you to script items that enhance a palemaster's summoned creatures. You need to put the name of a script into this variable that will be run on any creature called by the pale master's summon undead ability. You can use this script to add effects to the creature. You can use the OnEquip/OnUnEquip event hooks to set this variable.
               
               

               


                     Modifié par Pstemarie, 14 juillet 2011 - 10:44 .
                     
                  


            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
monsters wandering randomly
« Reply #4 on: July 15, 2011, 01:10:57 am »


               Cool! This'll make my senario come alive. I'll post it here when I'm finished.
               
               

               
            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
monsters wandering randomly
« Reply #5 on: July 15, 2011, 01:13:15 am »


               Cool! This'll make my scenario come alive. I'll post it here when it's finished.
               
               

               
            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
monsters wandering randomly
« Reply #6 on: July 15, 2011, 08:53:04 pm »


               I don't have the expansion pack so I can't do any of these. Where do I put the function call ActionRandomWalk?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
monsters wandering randomly
« Reply #7 on: July 16, 2011, 01:43:47 am »


               You could put it in the OnSpawn event.  

Have you updated the Game to 1.69 ?  

I do not think you need the expansion packs to do any of the stuff suggested in this thread.   I could be wrong on that though.
               
               

               
            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
monsters wandering randomly
« Reply #8 on: July 16, 2011, 02:43:24 am »


               All the x on spawn scripts come with Hotu.
               
               

               
            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
monsters wandering randomly
« Reply #9 on: July 16, 2011, 02:50:31 am »


               No I'm rollin with v 1.10
               
               

               
            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
monsters wandering randomly
« Reply #10 on: July 16, 2011, 02:51:51 am »


               Naw I'm rollin with v 1.10
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
monsters wandering randomly
« Reply #11 on: July 16, 2011, 08:05:15 am »


               Just make a custom OnSpawn script that looks like this:
[nwscript]// Random walking creature OnSpawn
void main()
{ ExecuteScript( "nw_c2_default9", OBJECT_SELF );
 ClearAllActions();
 ActionRandomWalk();
}[/nwscript]

You probably also need a way to get him random walking again if he survives a battle or has a conversation or something that interrupts him. This is a quick and dirty heartbeat method that should work:
[nwscript]// OnHeartbeat script random walking critter
void main()
{ ExecuteScript( "nw_c2_default1", OBJECT_SELF );
 if( !GetIsInCombat() && !IsInConversation( OBJECT_SELF ))
 { ClearAllActions();
   ActionRandomWalk();
 }
}[/nwscript]
               
               

               
            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
monsters wandering randomly
« Reply #12 on: July 16, 2011, 12:10:19 pm »


               

Pstemarie wrote...

If you are using the default OnSpawn Event - either nw_c2_default9 or x2_def_spawn (which executes nw_c2_default9) - you can use variables to modify creature behavior through the BioWare AI. The particular one you want is X2_L_SPAWN_USE_AMBIENT.


What he said.

Groove Widdit wrote...

I don't have the expansion pack so I can't do any of these.


Is there any reason why you don't want to just get the expansion packs? You can get a copy of NWN Diamond for download now for $9.99 US at gog.com. I've considered it more or less an axiom since I started modding NWN six years ago that having both expansions is pre-requisite for doing any serious NWN modding work. The amount of additional material they'll give you to work with (this being just a single example) is enormous.
               
               

               


                     Modifié par AndarianTD, 16 juillet 2011 - 11:15 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
monsters wandering randomly
« Reply #13 on: July 16, 2011, 01:25:03 pm »


               Wow - no expansions? You don't see that often. I was just looking at ebay and found a copy of the expansions for $1.00 each.
               
               

               
            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
monsters wandering randomly
« Reply #14 on: July 16, 2011, 08:10:12 pm »


               There's a Half Price Books by my house. THanks for the scripts.