PDA

View Full Version : New Special Attack - Immune to Ranged


trevius
11-17-2008, 11:49 PM
I don't think there is anything to make NPCs immune to ranged damage yet, but I do think it would be useful for creating some more diverse types of encounters. It would basically be to make NPCs immune to ranged (bow/arrow) and throwing/throwingV2 damage. I am not sure what it would take to code this yet, but I may look into it if I get some time.

trevius
11-18-2008, 12:21 AM
After checking into it a bit, it looks like it may be easier than I thought. I am pretty sure that I have the new special attack setting added properly to npc.cpp and mob.h, but I am still not exactly sure on where to put the part for attack.cpp or even if it is correct.

The code in red is the code that would be getting added to the existing code:

attack.cpp - Not sure if this is right yet, or exactly where to put it
if(skillinuse == ARCHERY || skillinuse == THROWING) {
if(against->SpecAttacks[IMMUNE_RANGED]) {
return 0;
}
}

mob.h
enum {
SPECATK_NONE = 0,
SPECATK_SUMMON, //S
SPECATK_ENRAGE, //E
SPECATK_RAMPAGE, //R
SPECATK_FLURRY, //F
SPECATK_TRIPLE, //T
SPECATK_QUAD, //Q
UNSLOWABLE, //U
UNMEZABLE, //M
UNCHARMABLE, //C
UNSTUNABLE, //N
UNSNAREABLE, //I
UNFEARABLE, //D
IMMUNE_MELEE, //A
IMMUNE_MAGIC, //B
IMMUNE_FLEEING, //f
IMMUNE_MELEE_EXCEPT_BANE, //O
IMMUNE_MELEE_NONMAGICAL, //W
IMMUNE_AGGRO, //H, wont aggro, ever.
IMMUNE_RANGED, //P - Projectile
SPECATK_MAXNUM
//X,Y,Z are old interactive NPC codes
};


npc.cpp - Slightly modified the format, since it was kinda sloppy and hard to read
void Mob::NPCSpecialAttacks(const char* parse, int permtag) {
for(int i = 0; i < SPECATK_MAXNUM; i++)
{
SpecAttacks[i] = false;
SpecAttackTimers[i] = NULL;
}

const char* orig_parse = parse;
while (*parse)
{
switch(*parse)
{
case 'E':
SpecAttacks[SPECATK_ENRAGE] = true;
break;
case 'F':
SpecAttacks[SPECATK_FLURRY] = true;
break;
case 'R':
SpecAttacks[SPECATK_RAMPAGE] = true;
break;
case 'S':
SpecAttacks[SPECATK_SUMMON] = true;
SpecAttackTimers[SPECATK_SUMMON] = new Timer(6000);
SpecAttackTimers[SPECATK_SUMMON]->Start();
break;
case 'T':
SpecAttacks[SPECATK_TRIPLE] = true;
break;
case 'Q':
//quad requires triple to work properly
SpecAttacks[SPECATK_TRIPLE] = true;
SpecAttacks[SPECATK_QUAD] = true;
break;
case 'U':
SpecAttacks[UNSLOWABLE] = true;
break;
case 'M':
SpecAttacks[UNMEZABLE] = true;
break;
case 'C':
SpecAttacks[UNCHARMABLE] = true;
break;
case 'N':
SpecAttacks[UNSTUNABLE] = true;
break;
case 'I':
SpecAttacks[UNSNAREABLE] = true;
break;
case 'D':
SpecAttacks[UNFEARABLE] = true;
break;
case 'A':
SpecAttacks[IMMUNE_MELEE] = true;
break;
case 'B':
SpecAttacks[IMMUNE_MAGIC] = true;
break;
case 'f':
SpecAttacks[IMMUNE_FLEEING] = true;
break;
case 'O':
SpecAttacks[IMMUNE_MELEE_EXCEPT_BANE] = true;
break;
case 'W':
SpecAttacks[IMMUNE_MELEE_NONMAGICAL] = true;
break;
case 'H':
SpecAttacks[IMMUNE_AGGRO] = true;
break;
case 'P':
SpecAttacks[IMMUNE_RANGED] = true;
break;
default:
break;
}
parse++;
}

if(permtag == 1 && this->GetNPCTypeID() > 0){
if(database.SetSpecialAttkFlag(this->GetNPCTypeID(), orig_parse)) {
LogFile->write(EQEMuLog::Normal, "NPCTypeID: %i flagged to '%s' for Special Attacks.\n",this->GetNPCTypeID(),orig_parse);
}
}
}