Here's a little tip for understanding the options part of
move(), showstats(), enablefeatures() etc and how it works:
If these functions are known to you, you might have noticed the build up of the options going like this
1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 ETC ETC
Basically you can create any numbers using the numbers given above
31 = 1 + 2 + 4 + 8 + 16
30 = 2 + 4 + 8 + 16
29 = 1 + 4 + 8 + 16
Following? Now, why are those functions using numbers like that? Why not use normal numbers from 1 to 10 for example? To answer that, let me set an example up:
PHP Code:
/*
createNPC(x, y, type, options)
options:
1 = randomized look?
2 = roam around
3 = hunt and hurt players
*/
function onCreated() {
createNPC(x, y, "baddy", 1 + 2); // randomized look + roam around
createNPC(x, y, "baddy", 3); // function as enemy to the player, hunt & kill
}
function createNPC(npcx, npcy, npctype, options) {
// how to tell the difference between 1+2 (randomized look + roam around)
// and 3 (hunt players and hurt them
temp.npc = putnpc2(npcx, npcy, "");
if (options == 1+2) {
// just give up here and start over., ok?
//the script can't tell the difference between 1+2 and 3
}
Now, how can it be done instead? Well, yeah, you use the numbers given further up this post and do like this:
PHP Code:
/*
createNPC(x, y, type, options)
options:
1 = randomized look?
2 = roam around
4 = function as enemy to the player
*/
function onCreated() {
createNPC(x, y, "baddy", 1 + 2); // randomized look + roam around
createNPC(x, y, "baddy", 4); // function as enemy to the player, hunt & kill
}
function createNPC(npcx, npcy, npctype, options) {
temp.npc = putnpc2(npcx, npcy, "");
temp.npc.join("npc_"@ npctype); // would join npc_baddy
temp.npc.type = npctype;
if (options&1) temp.npc.join("npc_module_randomizedlook");
if (options&2) temp.npc.join("npc_module_roam");
if (options&4) temp.npc.join("npc_module_enemyai");
}
By using the & operator you can simply check if a bit value exists within the specified bit value given.
so instead of doing something like
createNPC(x, y, type, true, true, false);, or set up predefined options, use this method instead!