Purpose: To make NPCS attack with mage, and do animations!
Difficulty: 4/10
Server base: Any
Classes modified: NPCHandler
NOTE: BACKUP YOUR SERVER!!!!
Step 1: Open NPCHandler ..
Step 2: Find..
Code:
AttackPlayerMage(i)
You should see something like...
Code:
if(npcs[i].npcType == 1645 || npcs[i].npcType == 1913 || npcs[i].npcType == 1241 || npcs[i].npcType == 1246 || npcs[i].npcType == 1977 || npcs[i].npcType == 1914 || npcs[i].npcType == 1975)
AttackPlayerMage(i);
Step 3:
On the end of that number, 1975.. Add this
Code:
|| npcs[i].npcType == XXXX)
So it would look like..
Code:
if(npcs[i].npcType == 1645 || npcs[i].npcType == 1913 || npcs[i].npcType == 1241 || npcs[i].npcType == 1246 || npcs[i].npcType == 1977 || npcs[i].npcType == 1914 || npcs[i].npcType == 1975 || npcs[i].npcType == XXXX)
AttackPlayerMage(i);
Ok basically, the XXXX means the npc ID.. So lets use Jad as an example..
Code:
if(npcs[i].npcType == 1645 || npcs[i].npcType == 1913 || npcs[i].npcType == 1241 || npcs[i].npcType == 1246 || npcs[i].npcType == 1977 || npcs[i].npcType == 1914 || npcs[i].npcType == 1975 || npcs[i].npcType == 2745)
AttackPlayerMage(i);
Ok now you have added Jad to attack with mage, now to set his spell GFX and his animation when attacking..
Step 4:
(Now this is where it varies alot.. Depending on which sevrer source you have...)
Ok right, if you look above, where you just added jad to attack with mage. You will see (the first NPC) is..
Code:
if(npcs[i].npcType == 1645
Now your will be different, depending on what source your using.. Anyways.. Your first NPC, search it in NPCHandler, untill you come to something like this...
Code:
if(npcs[NPCID].npcType == XXXX) {
p.stillgfx(YYY, p.absY, p.absX);
hitDiff = 6 + misc.random(PP);
}
Ok now, add this with your others... Change the XXXX, to the NPC ID...
The YYY means GFX that the npc attacks with..
And PP means the hit.. So if you put, hitDiff 6 + misc.random(50);
It will do a random hit below 56...
Step 5:
Now to add the animation of what the NPC does... underneath
Code:
if(npcs[NPCID].npcType == XXXX) {
Add this..
Code:
npcs[NPCID].animNumber = MMM; // mage attack
MMM = The animation that the npc does... (Change it)..
Alright now, small example of what it should be like, again, i will use jad..
Code:
if(npcs[NPCID].npcType == 2745) {
npcs[NPCID].animNumber = 2565; // mage attack
p.stillgfx(451, p.absY, p.absX);
hitDiff = 6 + misc.random(70);
}
Okay, thats how jad hits in real rs, the GFX and the animation.. I think i might have got the animation wrong, if its not 2565, its 2656..
Step 6:
This is how to make your npc hit with double gfx... Really simple..
Code:
if(npcs[NPCID].npcType == 2745) {
npcs[NPCID].animNumber = 2565; // mage attack
p.stillgfx(451, p.absY, p.absX);
p.stillgfx(452, p.absY, p.absX);
hitDiff = 6 + misc.random(70);
}
That will hit with GFX 451, and 452..
Step 7:
NOTE: This is only for some sources.. WILL NOT work on others...
Okay, this part is to like, make prayer effect work...
Replace what you added with.
Code:
if(npcs[NPCID].npcType == 2745) { //Jad
if (misc.random(2)==1) {
npcs[NPCID].animNumber = 2656; // mage attack
p.stillgfx(451, p.absY, p.absX);
p.EntangleDelay = 10;
if (server.playerHandler.players[Player].MagicProtect == false) {
hitDiff = 0 + misc.random(70);
}
if (server.playerHandler.players[Player].MagicProtect == true) {
hitDiff = misc.random(120/2);
}
} else {
if (GoodDistance(npcs[NPCID].absX, npcs[NPCID].absY, EnemyX, EnemyY, 2) == true) {
if (server.playerHandler.players[Player].MeleeProtect == false) {
hitDiff = 0 + misc.random(70);
}
if (server.playerHandler.players[Player].MeleeProtect == true) {
hitDiff = misc.random(120/2);
}
npcs[NPCID].animNumber = 451; // mage attack
} else {
npcs[NPCID].animNumber = 2656; // mage attack
p.stillgfx(451, p.absY, p.absX);
p.EntangleDelay = 10;
if (server.playerHandler.players[Player].MagicProtect == false) {
hitDiff = 0 + misc.random(70);
}
if (server.playerHandler.players[Player].MagicProtect == true) {
hitDiff = misc.random(120/2);
}
}
}
}
Okay this is pretty simple, if your not using Magic Protect/Melee Protect, jad will hit 70..
If you are using using Magic/Melee protect, he will only hit 120/2..
Again, if you havent got these methods/ints. It will not work, so i suggest not to use the one above.. If your server has an entirely different one, what you can do, is copy it.. paste it underneath and edit it.. so it will work.
Credits: 100% me
-- Post all errors, ill be happy to help! Hope you liked
P.S - Really sorry this is kinda long, yes it could have been shorter, but i wanted to explain it fully and not word it wrong.. If i have worded something wrong, please tell me what you dont understand
Thanks
- NOTE: I r X J K X off mopar, dont say i leeched. This is found in many sources, but this explains how to add new ones.