Random Generated events

From PSwiki
Revision as of 14:20, 20 August 2025 by Talad (talk | contribs) (All Tags)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A new capability has been added to PSUnreal about generating random events in the game.

Event location

An event is defined to happen in an "area type", it can be for example "forest" or "tavern" or specific location. There is relationiship beween random_events.area and random_event_locs.event_areatype.

If you want the event to happen in a specific path network waypoint, you can specify a random_events.area with this syntax: wp:<waypoint1|waypoint2|...>

Event Probability

In addition there is also random_event_locs.event_probability which is a % of chance of that event happening.

Database structure:

Scripting:

  • Prerequisites (random_events.prerequisite)
    • The same syntax of quest prerequisites can be used with the following additions:
      • <skillsinrange name="Sword" min="10" max="20" range="10"> (works as skill but checks all the players in range and sum up their skills). If the name is empty it sums up the total skills of all players in range.
  • Script for the event (random_events.script)

Race and traits

Race and traits are numerical as defined in the database. Maybe in the future we make it text. Check here for the list.

Options:

  • You can specify a name and lastname in the <spawnnpc> tag, if omitted the NPC will have a random name and lastname.
  • You can have a description, useful if you are specifying the name and the race of the NPC. If not specified it will empty.
  • You can specify certain traits, if missing, the server will randomize by choosing the ones available for the given race.

Inventory:

The valid locations for inventory items are: "righthand,lefthand,helm,rightfinger,leftfinger,neck,back,arms,gloves,boots,legs,belt,bracers,torso,mind" . For bothhands we need TO CHECK it.

Example:

   <time seconds="0">
	<spawnnpc id="1" name="Erisal" lastname="Baloe" race="0|1|2|3|5|6|7|9|10|11" invulnerable="yes" hp="400" mana="400" loot_category="22" locx="1" locy="1" locz="0" description="A young dermorian girl, with a nice smile." traits="42|363|380">
	  <inventory>
		 <item name="Small Battle Axe" location="righthand"/>
		 <item name="Falchion" location="bulk1" quantity="65"/>
		 <item name="Chainmail Legs Armor" location="legs"/>
	  </inventory>
	  <skills>
		 <skill name="Sword" value="50"/>
	  </skills>
	  <stats str="80" agi="70" end="60" int="75" wil="55" cha="90"/>
	  <kas>
		 <ka name="Merchant" priority="1"/>
	  </kas>
	  <specifickas>
		 <trigger trigger="greetings" response1="Hello" response2="How are you?"/>
	  </specifickas>
	  <merchant>
		<category name="Weapons"/>
		<category name="Armor"/>
	  </merchant>
	  <trainer>
		<skill name="Strength" min_rank="0" max_rank="20" min_faction="0"/>
	  </trainer>
	  <factions>
		<faction name="orcs" value="50"/>
	  </factions>
	  <variables>
		<variable name="scale" value="1.5"/>
	  </variables>
          <npctype name="performer" parent="Fighter" >
		  <behavior name="start_show" completion_decay="0" growth="0" initial="0">
			<emote cmd="/bow" />
			<talk text="Welcome to my show" target="false" />
			<busy/>
		  </behavior>
		  <behavior name="show" completion_decay="0" growth="0" initial="0">
		    <emote cmd="/greet" />
			<wait duration="30" anim="play" />
		   </behavior>
		   <behavior name="showidle">
				<idle />
		   </behavior>
	   </npctype>
	</spawnnpc>
	<spawnitem id="2" name="Long Bow" pickup="yes">
	   <location x="1" y="1" z="0"/>
	</spawnitem>
</time>
<time seconds="30">
     <trigger behavior="start_show" npc="1"/>
</time>
<time seconds="45">
     <trigger behavior="show" npc="1"/>
</time>
<time seconds="60">
     <trigger behavior="showidle" npc="1"/>
</time>
<time seconds="70">
    <destroynpc id="1"/>
	<destroyitem id="2"/>
	<schedulenext/>
</time>

All Tags

<time>

  • Defines a timed step of the event.
  • Attributes:
    • seconds → number of seconds after the event start when this block of actions should be executed.
  • Children: can contain
    • spawnnpc
    • spawnitem
    • trigger
    • destroynpc
    • destroyitem
    • schedulenext
    • message
    • sound


<spawnnpc>

  • Spawns a new NPC into the event.
  • Attributes: handled in psRandomEventsNPC::LoadXML()

Attributes:

  • id(required) numeric identifier for this NPC within the event. Must be non-zero.
  • name → optional first name. If empty, a random name will be generated.
  • lastname → optional last name.
  • race(required) one or more race IDs (separated by |). All races must exist in the database.
  • description → optional text description of the NPC.
  • invulnerable"yes" or "no". Determines if the NPC can be damaged.
  • HP → starting hit points.
  • Mana → starting mana points.
  • loot_category → numeric loot category ID used for drop tables.
  • locx, locy, locz → spawn location coordinates.
  • rot → rotation (facing direction) in degrees.
  • traits → optional set of trait IDs, separated by |. Only valid if a single race is defined.

Child Tags:

  • <inventory>
    • Contains <item> entries.
    • Attributes (item):
      • name → item name (must exist).
      • location → inventory slot name (must exist in slot hash).
      • quantity → number of items.
  • <skills>
    • Contains <skill> entries.
    • Attributes (skill):
      • name → skill name (must exist).
      • value → starting value.
  • <kas>
    • Contains <ka> entries.
    • Attributes (ka):
      • name → knowledge area name (must exist).
      • priority → priority number.
  • <specifickas>
    • Contains <trigger> entries.
    • Attributes (trigger):
      • trigger → text that activates the response.
      • response1..5 → one or more response lines. response1 must be present.
  • <merchant>
    • Contains <category> entries.
    • Attributes (category):
      • name → merchant category name (e.g., "Weapons - Shortsword").
  • <trainer>
    • Contains <skill> entries.
    • Attributes (skill):
      • name → skill name (must exist).
      • min_rank → minimum rank the trainer teaches.
      • max_rank → maximum rank.
      • min_faction → minimum faction value required.
  • <factions>
    • Contains <faction> entries.
    • Attributes (faction):
      • name → faction name (must exist).
      • value → starting standing with that faction.
  • <variables>
    • Contains <variable> entries.
    • Attributes (variable):
      • name → variable key.
      • value → variable value (string or number).
  • <npctype>
    • Defines NPC brain/type using external NPCType. Attributes/structure depend on NPCType::Load().

<spawnitem>

  • Spawns a new item into the event.
  • Attributes: handled in psRandomEventsItem::LoadXML()

Attributes:

  • id(required) numeric identifier for this item within the event. Must be non-zero.
  • name(required) item name (must exist in database).
  • pickup"yes" or "no". Determines if the item can be picked up by players.

Child Tags:

  • <location>
    • Attributes:
      • x, y, z → world coordinates where the item should spawn. (Values are multiplied by 100 internally to convert to centimeters.)

<trigger>

  • Sends a behavior trigger to a spawned NPC.
  • Attributes:
    • behavior → name of the behavior to trigger (e.g., "start_show").
    • npc → the numeric ID of the NPC that should execute this behavior.

<destroynpc>

  • Removes an NPC from the event.
  • Attributes:
    • id → numeric ID of the NPC to destroy.

<destroyitem>

  • Removes an item from the event.
  • Attributes:
    • id → numeric ID of the item to destroy.

<schedulenext>

  • Marks that after this timed step, the next event in the sequence should be scheduled automatically.
  • Attributes: none.

<message>

  • Sends a message to the client visible on screen and in the chat
  • Attributes:
    • text → the text to display

<sound>

  • Plays a sound to the client visible on screen and in the chat
  • Attributes:
    • sound → the sound to play
    • location → can be "player" or "event". If "player" the sound will be centered on the player, if "event" it will be at the starting location of the event
    • attenuation → If the sound should use 3d spatial attenuation or not