Skip to content

Commit

Permalink
Add vbIsUndead boolean to monsters.
Browse files Browse the repository at this point in the history
The @IsUndead message is called a lot for its relative importance
(various calls to this in the top 50 calls) and as it returns a boolean
that isn't changed, checking a classvar is quicker.
  • Loading branch information
skittles1 committed Apr 29, 2015
1 parent 5ca2d72 commit 4f96442
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 46 deletions.
13 changes: 8 additions & 5 deletions kod/object/active/holder/nomoveon/battler/monster.kod
Expand Up @@ -253,6 +253,9 @@ classvars:
viOccupation = 0
viKarma = 0

% If the monster is undead, set this to TRUE.
vbIsUndead = FALSE

% viLevel ranges from 25 to 200 (150 and above is for "boss" mobs)
% determines hit points.
viLevel = 25
Expand Down Expand Up @@ -1162,7 +1165,7 @@ messages:
AND NOT (IsClass(self,&EvilTwin)
AND (NOT Send(self,@IsEnchanted,#byClass=&Seduce))))
OR IsClass(self,&Reflection) % Flecs follow.
OR Send(self,@IsUndead) % So do undead (Animate).
OR vbIsUndead % So do undead (Animate).
{
Post(self,@GotoMaster);
}
Expand Down Expand Up @@ -6467,13 +6470,13 @@ messages:

IsFrightenedOf(target = $)
{
if Send(self,@IsUndead)
if vbIsUndead
AND (poHolySymbolCaster <> $)
AND (poHolySymbolCaster = target)
{
return TRUE;
}

return FALSE;
}

Expand Down Expand Up @@ -6856,7 +6859,7 @@ messages:

IsUndead()
{
return FALSE;
return vbIsUndead;
}

TurnedBy(who = $)
Expand All @@ -6868,7 +6871,7 @@ messages:
return;
}

if not Send(self,@IsUndead)
if NOT vbIsUndead
{
Debug("Somehow turned a monster that isn't undead.");

Expand Down
6 changes: 1 addition & 5 deletions kod/object/active/holder/nomoveon/battler/monster/ghost.kod
Expand Up @@ -60,6 +60,7 @@ classvars:
% Attack range of 192, or 3 row/col.
viAttackRange = 192
viKarma = -100
vbIsUndead = TRUE
viCashmin = 1000
viCashmax = 5500
vrSound_hit = ghost_sound_hit
Expand Down Expand Up @@ -192,11 +193,6 @@ messages:
propagate;
}

IsUndead()
{
return TRUE;
}

SendLightingInformation()
{
AddPacket(2,(LIGHT_FLAG_ON | LIGHT_FLAG_DYNAMIC));
Expand Down
6 changes: 1 addition & 5 deletions kod/object/active/holder/nomoveon/battler/monster/lich.kod
Expand Up @@ -136,6 +136,7 @@ classvars:
% Attack range of 192, or 3 row/col.
viAttackRange = 192
viKarma = -100
vbIsUndead = TRUE
viDefault_behavior = \
AI_FIGHT_AGGRESSIVE | AI_FIGHT_WIZARD_KILLER | AI_FIGHT_HYPERAGGRESSIVE \
| AI_MOVE_FLEE_FRIGHTENERS | AI_FIGHT_THROUGH_WALLS | AI_FIGHT_SWITCHALOT
Expand Down Expand Up @@ -982,11 +983,6 @@ messages:
return oBody;
}

IsUndead()
{
return TRUE;
}

DMCanArmageddon()
{
return FALSE;
Expand Down
6 changes: 1 addition & 5 deletions kod/object/active/holder/nomoveon/battler/monster/mummy.kod
Expand Up @@ -51,6 +51,7 @@ classvars:
% Larger distance since we want them to seek out the newbies.
viVisionDistance = 16
viKarma = 0
vbIsUndead = TRUE
viDefault_behavior = AI_FIGHT_AGGRESSIVE | AI_MOVE_FLEE_FRIGHTENERS
viCashmin = 1
viCashmax = 20
Expand Down Expand Up @@ -109,10 +110,5 @@ messages:
propagate;
}

IsUndead()
{
return TRUE;
}

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 changes: 1 addition & 5 deletions kod/object/active/holder/nomoveon/battler/monster/skel.kod
Expand Up @@ -51,6 +51,7 @@ classvars:
viDifficulty = 5
viVisionDistance = 10
viKarma = -50
vbIsUndead = TRUE
viDefault_behavior = AI_FIGHT_AGGRESSIVE | AI_FIGHT_SWITCHALOT \
| AI_MOVE_FLEE_FRIGHTENERS

Expand Down Expand Up @@ -190,10 +191,5 @@ messages:
return oBody;
}

IsUndead()
{
return TRUE;
}

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Up @@ -52,6 +52,7 @@ classvars:
viDifficulty = 5
viVisionDistance = 8
viKarma = -35
vbIsUndead = TRUE
viDefault_behavior = AI_FIGHT_AGGRESSIVE | AI_MOVE_FLEE_FRIGHTENERS
viCashmin = 120
viCashmax = 320
Expand Down Expand Up @@ -114,11 +115,6 @@ messages:
propagate;
}

IsUndead()
{
return TRUE;
}

SendLightingInformation()
{
AddPacket(2,(LIGHT_FLAG_ON | LIGHT_FLAG_DYNAMIC));
Expand Down
Expand Up @@ -67,6 +67,7 @@ classvars:
viAttackRange = 192
viAttributes = 0
viKarma = -75
vbIsUndead = TRUE
viDefault_behavior = AI_FIGHT_AGGRESSIVE | AI_FIGHT_HYPERAGGRESSIVE \
| AI_FIGHT_LASHOUT | AI_MOVE_FLEE_FRIGHTENERS

Expand Down Expand Up @@ -503,12 +504,6 @@ messages:
return;
}

IsUndead()
{
% Let's see... walking pile o' body parts...
return TRUE;
}

Delete()
{
if ptSecondAttack <> $
Expand Down
Expand Up @@ -40,6 +40,7 @@ classvars:
viSpeed = SPEED_AVERAGE
viAttack_type = ATCK_WEAP_SLASH
viAttributes = 0
vbIsUndead = TRUE
viDefault_behavior = AI_FIGHT_NEWBIESAFE | AI_MOVE_REGROUP
viVisionDistance = 18
viCashmin = 100
Expand Down Expand Up @@ -90,10 +91,5 @@ messages:
return;
}

IsUndead()
{
return TRUE;
}

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 changes: 1 addition & 5 deletions kod/object/active/holder/nomoveon/battler/monster/zombie.kod
Expand Up @@ -46,6 +46,7 @@ classvars:
viAttack_type = ATCK_WEAP_SLASH
viDefault_behavior = AI_FIGHT_KARMA_AGGRESSIVE | AI_MOVE_FLEE_FRIGHTENERS

vbIsUndead = TRUE
viDifficulty = 4
viVisionDistance = 10
viKarma = -45
Expand Down Expand Up @@ -133,11 +134,6 @@ messages:
propagate;
}

IsUndead()
{
return TRUE;
}

SetMaster(oMaster=$,DurationSecs=1)
{
if (oMaster <> $) AND IsClass(oMaster,&User)
Expand Down

0 comments on commit 4f96442

Please sign in to comment.