Thread: Dynamic NPC Definitions

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 38
  1. #1 Dynamic NPC Definitions 
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    General:

    Welcome to my second informative thread!
    This time I’m going to inform you about dynamic npc definitions.
    Note this has been written for a standard 317 cache.
    Newer caches may have more/less or different dynamic npc definitions.

    In a server, we define a type of NPC by the id of its NPCDefinition.
    Whilst this id doesn’t change (unless an NPC is transformed), some NPCs can show dynamic behaviour by changing a configuration value in the client.

    These definitions are different from normal ones.
    I call them dynamic NPCDefinitions (as opposed to static, not to be confused with the static keyword used in java).

    I might use the word stage in this text. I use this word to refer to any different state of a dynamic NPCDefinition. Note that 2 stages may refer to the exact same static NPCDefinition.

    In this guide I will instruct you on the different properties of dynamic and static NPCDefinitions.
    More interesting for most of you, I will give a list of NPCs with dynamic definitions, tell you what properties each stage has to offer and of course give you the information you need to make these changes.

    Note that I intend to document all the dynamic NPCDefinitions given in the list.
    But as it’s a very big list, I’ll take it step by step.
    If you have a request for a specific definition to be documented in all its glory, let me know.
    The quick overview lets you know which definitions are documented:
    Green is documented, red is undocumented.

    I also want you people to know that, when a configuration’s value is changed, other things might have changed as well.
    Don’t be surprised that when you change a configuration, a certain object changes as well.

    Latest updates:

    Started thread.

    Thanks go to:

    Scu11 for being an awesome mod and suggesting I use images to show some of the differences.
    uhrd for helping me correct the little errors in this guide and being a great person to talk to about these things.
    My informative threads:
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     


  2. #2  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Table of content:

    For who to use
    How does it work
    -Configurations
    -Varbits
    Changing configurations
    -Changing varbits
    Properties of NPCDefinitions
    -Properties of Dynamic NPCDefinitions
    -Properties of Static NPCDefinitions
    -Common properties
    -Consequences for dynamic possibilities
    Explanation of the documentation format
    A 'quick' overview of the dynamic NPC definitions
    -NPCs dynamic by varbit
    -NPCs dynamic by configuration
    Dynamic NPCDefinitions using Configurations
    Dynamic NPCDefinitions using varbits
    Reply With Quote  
     

  3. #3  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    For who to use:

    You might ask yourself: why would I use dynamic NPCDefinitions?
    Quests!
    That’s right, quests. If you take a look at the list of dynamic NPCDefinitions, you’ll notice quite a lot of npcs that belong to quests.
    Using dynamic npcDefinitions, jagex can just spawn the npcs for everyone to see and then use client configurations to allow them to be visible or not. Advancing the stages might give the appearance an npc has moved to another location.
    This requires less processing on the server’s side.
    So if you’re making a quest where you need dynamic npcs, you can use an existing one or make one yourself to use.

    Objects have a similar system which is also used in farming.

    How does it work:

    The general idea boils down to this:
    The dynamic NPCDefinition has a list of other NPCDefinitions.
    Based on a configuration’s value, the client uses one (or none) of the possible NPCDefinition as the active one.
    When the value is 0, the active definition is the first one (index 0 in the possible NPCDefinitions array).
    When the value is 1, the active definition is the second one (index 1).
    This goes on and on, until the index is greater than the last index in the array.
    In this case, and when the value is lesser than 0, no NPCDefinition is active.
    When the active NPCDefinition refers to definition -1, no definition is active either.
    The configuration value can be grabbed in 2 ways (1 per definition):

    Configuration
    Varbits

    I’ll start with the easiest one to understand: configuration.

    Configurations

    The client holds a list (array) of integer (4 bytes) configuration values. These values can change when clicking buttons, changing settings and so on.
    You refer to them by their index in the array, which I will call configId.
    When using the normal configuration way, the value is simply the integer at index configId in the configuration array.

    Varbits

    The second one is a bit harder to understand and requires some bit logic (you will need to do some self-research on masks, bitwise operators and bit shifting): varbits.
    To understand this, we have to delve into the world of bits and bytes.
    As said before, configuration values are integers. This means they consist of 4 bytes (4 x 8 = 32 bits).
    The first method uses all the 4 bytes to determine the value. This method however, uses 1 or more adjacent bits.
    A varbit tells which bits to use.
    The varbit itself contains 3 values:

    The least significant bit of the mask
    The most significant bit of the mask
    The configId to apply the mask on.

    When you get a varbit value. The configuration’s value is taken, shifted to the right until the least significant bit of the mask is the least significant bit of the mask and then the correct mask is applied with a bitwise and operation.
    The resulting value is the varbit’s value.
    Reply With Quote  
     

  4. #4  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Changing configurations:

    Configurations can easily by changed by sending the appropriate value to the client with one of the sendConfig packets.
    There are 2 types of this packet. One sends the whole integer value, the other sends just a byte value (for configuration values that can fit in 1 byte).
    Both also need to send the configId.
    The packetIds for these packets are:

    Code:
    Value		Protocol	PacketId
    integer		317		87
    byte		317		36
    integer		474		10
    byte		474		253
    More information on the 474 protocol can be found here: [Only registered and activated users can see links. ]

    Changing varbits:

    Varbit (read as: the bits at the specific position as specified in the mask) can be changed in the same way.
    The downside is you have to send the whole configuration value you want to change.
    This must be done as multiple varbits can use the same configuration (which is actually the strong side of the varbit concept)

    Properties of NPCDefinitions:

    NPCDefinitions have various properties (fields in programmer terms). In the client, both types of NPCDefinitions are shared by the same class.
    Some fields however, are only used by the dynamic NPCDefinitions, while others are used by the static version.
    If a dynamic NPCDefinition needs a value that’s only set for static definitions, it finds the active static definition and uses that one.

    Properties of Dynamic NPCDefinitions

    An array of possible NPCDefinitions
    VarbitId OR ConfigId

    Properties of Static NPCDefinitions

    Name
    Combatlevel
    Right click options
    Examine text
    An array of modelIds for the head model (used in dialogues)
    An array of modelIds for the full body model
    Clickable (boolean)
    Shown on minimap (boolean)
    Model ambient lighting
    Model contrast
    Model Y scale factor
    Model XZ scale factor

    Common properties

    Walk forwards animation id
    Walk backwards animation id
    Stand animation id
    Step left animation id
    Step right animation id
    Degrees to turn
    NPCSize (in tiles)
    HeadIcon
    Render priority (boolean)
    NPCId

    Consequences for dynamic possibilities

    Dynamic NPCDefinitions can only change the properties in the static section.
    As a result, all the movement animations cannot change when changing the stage of a dynamic definition.

    Some properties that can change are the right click options.
    This means that one stage can have an option, whereas the next one has none.
    Reply With Quote  
     

  5. #5  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Explanation of the documentation format:

    Code:
    Configuration Id:  399
    Affected npcs:  1668, 1669, 1671, 1672
    Number of stages:  9
    Table of stages: 
    Stage	NPC 1668	NPC 1669	NPC 1671	NPC 1672
    0	1670		-1		1673		-1
    1	1670		-1		1673		-1
    2	1670		-1		1673		-1
    3	1670		-1		1673		-1
    4	1670		-1		1673		-1
    5	1670		-1		1673		-1
    6	1670		-1		1673		-1
    7	1670		-1		1673		-1
    8	-1		1670		-1		1674
    Used NPCs: 
    	NPC:  1670
    	Name:  Dr Fenkenstrain
    	Examine:  Dr Fenkenstrain I presume.
    	Options:  Talk-to; Pickpocket
    
    	NPC:  1673
    	Name:  Fenkenstrain’s Monster
    	Examine:  A hideous mix of human flesh.
    	Options:  Talk-to
    	Note:  Npc 1674 uses the same head and body model.
    
    	NPC:  1674
    	Name:  Lord Rologarth
    	Examine:  It looks like he has got his castle back at last.
    	Options:  Talk-to
    	Note:  Npc 1673 uses the same head and body model.
    Note:  This is a good example on how you can make npcs appear to have change location.
    During stages 0-7, both npcs remain unchanged in the same location. However, when the monster supposedly scares away dr Fenkenstrain and claims back his castle. He wanders off (in another location) as dynamic npc 1672 while the doctor (dynamic npc 1669) hides from him.
    The new monster even has his title back.
    The documentation is grouped per configuration. Below is a list of what each section means:

    Configuration Id: The configuration’s id that causes the change in stages.
    Affected npcs: all the dynamic npcdefinitions who are affected by this configuration
    Number of stages: The number of stages for this configuration (based on the affected npcdefinitions). It is possible a greater number of stages exist and when it’s possible, it will result in all affected npcs becoming invisible.
    Table of stages:
    For the table, let’s take the example from above:

    Code:
    Stage	NPC 1668	NPC 1669	NPC 1671	NPC 1672
    0	1670		-1		1673		-1
    1	1670		-1		1673		-1
    2	1670		-1		1673		-1
    3	1670		-1		1673		-1
    4	1670		-1		1673		-1
    5	1670		-1		1673		-1
    6	1670		-1		1673		-1
    7	1670		-1		1673		-1
    8	-1		1670		-1		1674
    The first column contains the stage number, notice it starts at 0.
    The next columns will contain the definition ids the dynamic definition of those columns refers to.
    The dynamic definition’s id of each column can be found at top.
    Remember that -1 means the npc won’t be there.
    Used NPCs: This section will list all the npcDefinitions the dynamic ones refer to.
    They’ll use one or more of the following categories to define whatever is special to the npc.

    Code:
    	NPC:  The definition’s id.
    	Name:  The name.
    	Examine:  The  examine text
    	Options:  The available right-click options.
    	Note:  Notes that might be important, relevant to the npc.
    When describing varbits like:
    Varbits: 559 ((value & 1) << 0)
    The number is the varbit number, which (when it is present), shall also appear above the tables of stages.
    The meaning of ((value & <number>) << <number>) is for writing the value and should be clear to those who have initiated themselves with bitwise operations and bit shifting (which I advised you to do).
    Reply With Quote  
     

  6. #6  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    A ‘quick’ overview of the dynamic NPC definitions:

    NPCs dynamic by varbit:

    The following list provides the dynamic NPCDefinition and the varbit used to determine the active NPCDefinition. The 3 other columns belong to the varbit and NOT to the npcdefinition.

    Code:
    Npc id	Varbit id	Config id	Shift position	Mask size (hex) 
    
    226	2054		12		4		1
    292	801		518		13		1
    293	803		518		15		1
    294	800		518		12		1
    295	802		518		14		1
    335	1784		667		1		1
    647	1036		568		26		1
    715	1784		667		1		1
    1666	185		400		31		1
    1667	185		400		31		1
    1687	217		408		28		f
    1811	269		423		25		1
    1836	299		433		0		ff
    1845	299		433		0		ff
    1869	344		435		18		1
    1876	334		435		0		3f
    1877	338		435		9		1
    1879	340		435		11		3
    1882	340		435		11		3
    1887	340		435		11		3
    1891	340		435		11		3
    1895	340		435		11		3
    1899	335		435		6		1
    1900	336		435		7		1
    1903	340		435		11		3
    1907	348		437		7		7
    1922	358		440		0		7fff
    1924	358		440		0		7fff
    1932	382		442		19		1f
    1943	380		442		17		1
    1945	381		442		18		1
    1947	382		442		19		1f
    1949	382		442		19		1f
    1970	358		440		0		7fff
    1984	418		445		0		1f
    1985	408		443		14		3
    1987	418		445		0		1f
    2002	415		443		26		3
    2003	415		443		26		3
    2004	415		443		26		3
    2011	418		445		0		1f
    2013	449		446		4		1
    2020	396		388		25		1
    2079	532		465		0		7ff
    2080	540		465		21		1
    2081	532		465		0		7ff
    2085	532		465		0		7ff
    2123	581		482		25		1
    2125	581		482		25		1
    2142	576		482		11		f
    2202	559		470		0		1
    2231	579		482		23		1
    2295	346		437		0		1f
    2297	395		443		20		1
    2299	395		443		20		1
    2302	395		443		20		1
    2303	346		437		0		1f
    2370	799		518		8		f
    2375	797		518		0		1
    2381	393		440		21		1
    2382	393		440		21		1
    2383	393		440		21		1
    2384	393		440		21		1
    2385	393		440		21		1
    2386	393		440		21		1
    2387	393		440		21		1
    2388	393		440		21		1
    2389	393		440		21		1
    2390	393		440		21		1
    2391	393		440		21		1
    2392	393		440		21		1
    2393	393		440		21		1
    2394	393		440		21		1
    2395	393		440		21		1
    2396	393		440		21		1
    2403	582		482		26		1
    2404	582		482		26		1
    2405	582		482		26		1
    2406	582		482		26		1
    2407	582		482		26		1
    2408	582		482		26		1
    2435	814		520		13		1
    2504	892		534		0		7
    2507	892		534		0		7
    2510	894		534		6		7
    2513	895		534		9		7
    2516	896		534		12		7
    2519	897		534		15		7
    2522	898		534		18		7
    2525	899		534		21		7
    2528	900		534		24		7
    2531	901		534		27		7
    2585	965		553		11		3
    2652	1028		568		0		7f
    2654	1032		568		13		f
    2756	1065		571		18		1
    2757	1067		571		20		1
    2758	1069		571		22		1
    2759	1071		571		24		1
    2760	1073		571		26		1
    2761	1075		571		28		1
    2762	1077		571		30		1
    2763	1079		572		0		1
    2764	1081		572		2		1
    2765	1083		572		4		1
    2766	1085		572		6		1
    2767	1087		572		8		1
    2768	1089		572		10		1
    2769	1091		572		12		1
    2770	1093		572		14		1
    2771	1095		572		16		1
    2772	1097		572		18		1
    2773	1099		572		20		1
    2774	1101		572		22		1
    2775	1069		571		22		1
    2788	1330		594		25		1
    2795	1344		597		0		7
    2813	1353		599		31		1
    2816	1353		599		31		1
    2817	1353		599		31		1
    2818	1353		599		31		1
    2819	1353		599		31		1
    2897	1372		602		0		7f
    2898	1382		602		30		3
    2901	1381		602		28		3
    2908	1372		602		0		7f
    2920	1372		602		0		7f
    2922	1380		602		26		3
    2923	1380		602		26		3
    2924	1381		602		28		3
    2925	1382		602		30		3
    2926	348		437		7		7
    2929	1372		602		0		7f
    2930	1372		602		0		7f
    2933	1387		604		13		1
    2936	1388		604		14		1
    2974	1424		609		7		1
    2975	1425		609		8		1
    2976	1426		609		9		1
    2977	1427		609		10		1
    2978	1428		609		11		1
    2979	1429		609		12		1
    3049	1451		616		16		1
    3074	1467		622		27		3
    3076	1467		622		27		3
    3110	1535		636		0		3
    3111	1535		636		0		3
    3128	1560		641		0		7f
    3132	1577		642		1		1
    3134	1578		642		2		1
    3136	1605		643		4		3
    3139	1606		643		6		3
    3143	1604		643		0		f
    3144	1604		643		0		f
    3145	1604		643		0		f
    3146	1604		643		0		f
    3152	1606		643		6		3
    3213	1783		667		0		1
    3214	1783		667		0		1
    3314	1807		671		22		1
    3315	1808		671		23		1
    3316	1808		671		23		1
    3317	1808		671		23		1
    3318	1803		671		0		7f
    3323	1838		673		0		3
    3373	1864		679		6		1
    3379	1862		679		4		1
    3383	1850		678		0		7f
    3384	1850		678		0		7f
    3399	1850		678		0		7f
    3401	1890		680		28		7
    3404	1890		680		28		7
    3409	1859		679		1		1
    3411	1859		679		1		1
    3417	1860		679		2		1
    3450	1861		679		3		1
    3462	1863		679		5		1
    3465	1905		684		11		1
    3469	1908		684		17		1
    3470	1908		684		17		1
    3479	1865		679		7		1
    3510	1981		704		23		3
    3512	1981		704		23		3
    3513	1981		704		23		3
    3516	1981		704		23		3
    3566	1979		704		19		3
    3567	1979		704		19		3
    3623	1954		700		0		1
    3625	1954		700		0		1
    3627	1954		700		0		1
    3629	1954		700		0		1
    3631	1954		700		0		1
    3633	1954		700		0		1
    3638	2026		710		0		1
    3642	2025		709		31		1
    3820	2098		723		0		1ff
    3828	2098		723		0		1ff
    3829	2098		723		0		1ff
    3832	2098		723		0		1ff
    3833	2098		723		0		1ff
    3834	2098		723		0		1ff
    NPCs dynamic by configuration:

    Code:
    NPC id	Config id
    
    1668	399
    1669	399
    1671	399
    1672	399
    2257	492
    2260	492
    2483	320
    2484	320
    2485	320
    2486	320
    2487	320
    2488	320
    3289	32
    3290	32
    Reply With Quote  
     

  7. #7  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Dynamic NPCDefinitions using Configurations:

    What follows will contain information on what certain NPCDefinitions will result in when the given configuration is altered.

    It was hard for me decide how I would arrange these. I finally opted to group them per configId. The reason for this is that I can list all NPCDefinitions per stage that change with the same configuration.

    ==================================================

    Configuration Id: 399
    Affected npcs: 1668, 1669, 1671, 1672
    Number of stages: 9
    Table of stages:
    Code:
    Stage	NPC 1668	NPC 1669	NPC 1671	NPC 1672
    0	1670		-1		1673		-1
    1	1670		-1		1673		-1
    2	1670		-1		1673		-1
    3	1670		-1		1673		-1
    4	1670		-1		1673		-1
    5	1670		-1		1673		-1
    6	1670		-1		1673		-1
    7	1670		-1		1673		-1
    8	-1		1670		-1		1674
    Used NPCs:
    Code:
    	NPC:  1670
    	Name:  Dr Fenkenstrain
    	Examine:  Dr Fenkenstrain I presume.
    	Options:  Talk-to; Pickpocket
    
    	NPC:  1673
    	Name:  Fenkenstrain’s Monster
    	Examine:  A hideous mix of human flesh.
    	Options:  Talk-to
    	Note:  Npc 1674 uses the same head and body model.
    
    	NPC:  1674
    	Name:  Lord Rologarth
    	Examine:  It looks like he has got his castle back at last.
    	Options:  Talk-to
    	Note:  Npc 1673 uses the same head and body model.
    Note: This is a good example on how you can make npcs appear to change location.
    During stages 0-7, both npcs remain unchanged in the same location. However, when the monster supposedly scares away dr Fenkenstrain and claims back his castle. He wanders off (in another location) as dynamic npc 1672 while the doctor (dynamic npc 1669) hides from him.
    The new monster even has his title back.

    ==================================================
    Reply With Quote  
     

  8. #8  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Dynamic NPCDefinitions using varbits:

    Configuration Id: 470
    Varbits: 559 ((value & 1) << 0)
    Affected npcs: 2202
    Number of stages: 2
    Table of stages:
    Varbit 559
    Code:
    Stage	NPC 2202
    0	2203
    1	2204
    Used NPCs:
    Code:
    	NPC:  2203
    	Name:  Drunken Dwarf
    	Examine:  He's had a fair bit to drink...
    	Options:  Talk-to
    	Note:  Uses the normal drunken dwarf model
    
    	NPC:  2204
    	Name:  Drunken Dwarf
    	Examine:  He's had a fair bit to drink...
    	Options:  Talk-to
    	Note:  Uses the model of a kebab!
    Note: Using this dynamic definition, you can make it appear as if the drunken dwarf (known to carry a kebab with him at all times) has been eaten. By, for example, a certain troll.



    ==================================================
    Reply With Quote  
     

  9. #9  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Reserved post as I expect to expand.
    Reply With Quote  
     

  10. #10  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Reserved post as I expect to expand in the future.
    Reply With Quote  
     

Page 1 of 4 123 ... LastLast

Thread Information
Users Browsing this Thread

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

Similar Threads

  1. 562 Npc Definitions help!
    By Nadroj m4 in forum Help
    Replies: 2
    Last Post: 10-02-2010, 12:49 AM
  2. [562] NPC definitions REP+
    By bulletnose in forum Help
    Replies: 2
    Last Post: 08-20-2010, 03:35 AM
  3. NPC definitions
    By legitizpro in forum Requests
    Replies: 1
    Last Post: 06-20-2010, 06:15 PM
  4. [Galkon's] NPC definitions
    By philby93 in forum Snippets
    Replies: 1
    Last Post: 05-05-2010, 10:22 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •