This topic is now archived and is closed to further replies.


[2015-12-31] FAKE_NPC and the NPC View ID -1

Recommended Posts

This is part of the NPC scripts standardization project. In the past, NPCs were defined with numeric View IDs, while now we've replaced most of them with more human-readable (and as such easier to maintain) constants - the same constants that AEGIS scripts use, making the numeric IDs obsolete (and deprecated).

When the NPC View IDs were converted to constants, the only leftover was the special ID '-1' we use for invisible / floating NPCs, that didn't have an equivalent constant defined at the time.
This changeset defines a constant 'FAKE_NPC' for it, and replaces all the '-1' view IDs with the new constant.
The exception for the -1 case is removed from the code (making it effectively deprecated, just like the other numeric IDs).

The impact of this changeset on custom scripts is low. All old code will still work (but it'll throw a deprecation warning).
It's recommended to update all the affected code as soon as possible - the support for the old style IDs may be removed from the code at any time in the future (after at least a month from the commit).

The use of the sprite ID '-1' in NPC headers to specify an invisible NPC is now deprecated. 'FAKE_NPC' should be used instead. This affects all NPC types (script, shop, trader, duplicate, etc)
/* Before: */
-	script	TurboTrap#tt_main	-1,{
	// ...
in_moc_16,65,162,0	duplicate(SinTrap)	02_2	-1,0,0
/* Now: */
-	script	TurboTrap#tt_main	FAKE_NPC,{
	// ...
in_moc_16,65,162,0	duplicate(SinTrap)	02_2	FAKE_NPC,0,0
Merge Date:
Thu, 31 Dec 2015 23:40:48 +0100

Related Pull Requests:
- #1000 - - define FAKE_NPC as -1 in const.txt [AnnieRuru]

Related Commits:
- ef171a8 - - Mon, 21 Dec 2015 19:59:38 +0800 define FAKE_NPC as -1 in const.txt [AnnieRuru]
- efaaf84 - - Mon, 21 Dec 2015 20:12:45 +0800 Replace -1,{ with FAKE_NPC,{ replace using Notepad++ [AnnieRuru]
- b4c99db - - Tue, 29 Dec 2015 02:16:49 +0100 Replaced leftover -1 view IDs with FAKE_NPC [Haru]
- 32a42ee - - Tue, 29 Dec 2015 02:17:26 +0100 Extended the numeric view ID deprecation to '-1' (FAKE_NPC) [Haru]
- 0e99004 - - Thu, 31 Dec 2015 23:40:48 +0100 Merge branch 'AnnieRuru-request_29' into hercules [Haru]

Commit efaaf84 was done with a find and replace in Notepad++, to globally replace '-1' view IDs with 'FAKE_NPC' (as described in the commit notes).
Commit b4c99db caught the leftovers (less common cases where the -1 is not followed by ',{'), and was powered by vim macros and grep (and vimgrep). It also features manual clean up of trailing whitespace or extra tabs in a small subset of the affected lines.

View the full article

Share this post

Link to post
Share on other sites