- added bloodlust

This commit is contained in:
cade 2000-07-01 23:54:46 +00:00
parent 0524cdb99c
commit 382af1c13f
3 changed files with 35 additions and 31 deletions

View file

@ -92,11 +92,7 @@ typedef struct _missile_ {
int Wait; /// delay
Unit* SourceUnit; /// unit that fires (could be killed)
UnitType* SourceType; /// type of unit that fires
UnitStats* SourceStats; /// stats of unit that fires
Player* SourcePlayer; /// player of unit that fires
Unit* TargetUnit; /// target unit, used for spells
Unit* TargetUnit; /// target unit, used for spells
int Damage; /// direct damage that missile applies

View file

@ -569,9 +569,6 @@ found:
missile->Wait=1;
missile->SourceUnit=NULL;
missile->SourceType=NULL;
missile->SourceStats=NULL;
missile->SourcePlayer=NULL;
missile->Damage = 0;
missile->TargetUnit = NULL;
@ -596,16 +593,25 @@ found:
**
** @param attack_stats Attacker attributes.
** @param goal_stats Goal attributes.
** @param bloodlust If attacker has bloodlust
**
** @returns damage produces on goal.
*/
local int CalculateDamageStats(const UnitStats* attacker_stats
,const UnitStats* goal_stats)
local int CalculateDamageStats( const UnitStats* attacker_stats,
const UnitStats* goal_stats,
int bloodlust )
{
int damage;
int basic_damage = attacker_stats->BasicDamage;
int piercing_damage = attacker_stats->PiercingDamage;
if (bloodlust)
{
basic_damage *= 2;
piercing_damage *= 2;
printf("bloodlust\n");
}
damage=-goal_stats->Armor;
damage+= basic_damage;
if( damage<0 ) {
@ -624,11 +630,14 @@ local int CalculateDamageStats(const UnitStats* attacker_stats
**
** @param attack_stats Attacker attributes.
** @param goal Goal unit.
** @param bloodlust If attacker has bloodlust
** @returns damage produces on goal.
*/
local int CalculateDamage(const UnitStats* attacker_stats,const Unit* goal)
local int CalculateDamage( const UnitStats* attacker_stats,
const Unit* goal,
int bloodlust )
{
return CalculateDamageStats(attacker_stats,goal->Stats);
return CalculateDamageStats(attacker_stats,goal->Stats,bloodlust);
}
/**
@ -658,11 +667,11 @@ global void FireMissile(Unit* unit)
if( HumanWallOnMap(dx,dy) ) {
// FIXME: don't use UnitTypeByIdent here, this is slow!
HitWall(dx,dy,CalculateDamageStats(unit->Stats,
UnitTypeByIdent("unit-human-wall")->Stats));
UnitTypeByIdent("unit-human-wall")->Stats,0));
} else {
// FIXME: don't use UnitTypeByIdent here, this is slow!
HitWall(dx,dy,CalculateDamageStats(unit->Stats,
UnitTypeByIdent("unit-orc-wall")->Stats));
UnitTypeByIdent("unit-orc-wall")->Stats,0));
}
return;
}
@ -701,7 +710,7 @@ global void FireMissile(Unit* unit)
return;
}
HitUnit(goal,CalculateDamage(unit->Stats,goal));
HitUnit(goal,CalculateDamage(unit->Stats,goal,unit->Bloodlust));
return;
}
@ -748,10 +757,7 @@ global void FireMissile(Unit* unit)
// Damage of missile
//
missile->SourceUnit=unit;
// unit->Refs++; Reference currently not used.
missile->SourceType=unit->Type;
missile->SourceStats=unit->Stats;
missile->SourcePlayer=unit->Player;
unit->Refs++;
}
/**
@ -819,8 +825,8 @@ global void DrawMissiles(void)
x=missile->X-MapX*TileSizeX+TheUI.MapX;
y=missile->Y-MapY*TileSizeY+TheUI.MapY;
// FIXME: I should copy SourcePlayer for second level missiles.
if( missile->SourcePlayer ) {
GraphicPlayerPixels(missile->SourcePlayer
if( missile->SourceUnit && missile->SourceUnit->Player ) {
GraphicPlayerPixels(missile->SourceUnit->Player
,missile->Type->Sprite);
}
DrawMissile(missile->Type,missile->Frame,x,y);
@ -1008,7 +1014,8 @@ global void MissileHit(const Missile* missile)
mis->Damage = missile->Damage; // direct damage, spells mostly
mis->SourceUnit = missile->SourceUnit;
}
if( !missile->SourceType ) { // no target
if( !missile->SourceUnit ) { // no target
//FIXME: should be removed?
return;
}
@ -1027,14 +1034,14 @@ global void MissileHit(const Missile* missile)
if ( missile->Damage )
HitWall(x,y,missile->Damage); // direct damage, spells mostly
else
HitWall(x,y,CalculateDamageStats(missile->SourceStats,
UnitTypeByIdent("unit-human-wall")->Stats));
HitWall(x,y,CalculateDamageStats(missile->SourceUnit->Stats,
UnitTypeByIdent("unit-human-wall")->Stats,0));
} else {
if ( missile->Damage )
HitWall(x,y,missile->Damage); // direct damage, spells mostly
else
HitWall(x,y,CalculateDamageStats(missile->SourceStats,
UnitTypeByIdent("unit-orc-wall")->Stats));
HitWall(x,y,CalculateDamageStats(missile->SourceUnit->Stats,
UnitTypeByIdent("unit-orc-wall")->Stats,0));
}
return;
}
@ -1047,7 +1054,8 @@ global void MissileHit(const Missile* missile)
if ( missile->Damage )
HitUnit(goal,missile->Damage); // direct damage, spells mostly
else
HitUnit(goal,CalculateDamage(missile->SourceStats,goal));
HitUnit(goal,CalculateDamage(missile->SourceUnit->Stats,goal,
missile->SourceUnit->Bloodlust));
}
/**

View file

@ -609,8 +609,8 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
mis->Damage = BLIZZARD_DAMAGE;
//FIXME: not correct -- blizzard should continue even if mage is
// destroyed (though it will be quite short time...)
mis->SourceUnit = unit;
mis->SourceType = unit->Type;
mis->SourceUnit = unit;
mis->SourceUnit->Refs++;
}
unit->Mana -= spell->ManaCost;
@ -681,8 +681,8 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
dx*TileSizeX+TileSizeX/2,
dy*TileSizeX+TileSizeX/2 );
unit->Refs++;
mis->SourceUnit = unit;
mis->SourceUnit->Refs++;
if (target)
{
mis->TargetUnit = target;
@ -784,7 +784,7 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
//FIXME: not correct -- blizzard should continue even if mage is
// destroyed (though it will be quite short time...)
mis->SourceUnit = unit;
mis->SourceType = unit->Type;
mis->SourceUnit->Refs++;
}
unit->Mana -= spell->ManaCost;