Jump to content

Programming emergent npc behavior through scripting


Recommended Posts

Posted

So I'm interested in emergent properties that NPC's might find themselves in as they walk the map and bump into each other. So far I'm using a network of waypoints and I have the npc's spawnscript spawn a wander script

The script is very simple and I suck at it.

Quote

//Generated by BehavEd

rem ( "comment" );
set ( /*@SET_TYPES*/ "SET_BEHAVIOR_STATE", /*@BSTATE_STRINGS*/ "BS_WANDER" );
 

What I'm interested is programming into the script a certain level of randomness, or perhaps two or more factions that wander the map and intermingle, resulting in a firefight.

Would anyone be able to help me with this

 

Many thanks 

Spoiler

 

waipoints.jpg

waypoints-rendered.jpg

 

 

Posted

Randomness does indeed exist within the commands: through IF and ELSE commands. 

For this you'll most likely need 3 tasks (each task = with a command to change behaviour "set"), like Task1, Task2, Task3.
And then the lines such as these ones:

Quote

if ( $random( 0, 1 )$, $<$, 0.340 )
{
  do ( "task1" );
  wait ( "task1" );
}


else (  )
{

  if ( $random( 0, 1 )$, $<$, 0.510 )
  {
    do ( "task2" );
    wait ( "task2" );
  }


  else (  )
  {
    do ( "task3" );
    wait ( "task3" );
  }

}

In this case the game would Run one of the three tasks randomly.
You'll have to experiments with numbers (instead of 0.340, 0.510) in order to achieve the result you want.

 

Asgarath83 likes this
  • 3 weeks later...
Posted
On 1/26/2021 at 7:15 PM, quakefreed said:

Great, can you tell me for example what tasks they should do? Sorry when I open behaveED I am lost. 

Start with Affect (enter the name of your NPC – his NPC_targetname in the map), add tasks (give them names too), and then add (set < E "set_types">, <str>) line inside them. One such line is responsible for one option (task, action, etc). When you've added this line to your script – double click on the 'set'.

By default it would offer you to use SET_PARM1 which is set to DEFAULT. Click on SET_PARM1 and look through the whole list of commands there. Most options have a short description. Don't forget to press [Re-Evaluate] button in order to see the specifics of each option.

 

E.g.

SET_FORCE_JUMP_LEVEL		0
(you can change now the level of this Force power from 0 to 1-2-3)

SET_ENEMY 					NULL 
(usually used for NPC enemies, so this command will make the character feel angry towards a specific NPC in your map. Change NULL to a targetname from GTKRadiant, like 'Freddy', for instance)

 

Sunny98 likes this

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...