Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F134099
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/ButcherEntity.cpp b/src/ButcherEntity.cpp
index 6dd9c2c..e3fba45 100644
--- a/src/ButcherEntity.cpp
+++ b/src/ButcherEntity.cpp
@@ -1,171 +1,176 @@
#include "ButcherEntity.h"
#include "BoltEntity.h"
#include "PlayerEntity.h"
#include "SausageEntity.h"
#include "sfml_game/SpriteEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "Constants.h"
#include "WitchBlastGame.h"
#include "TextMapper.h"
ButcherEntity::ButcherEntity(float x, float y)
: EnemyEntity (ImageManager::getInstance().getImage(IMAGE_BUTCHER), x, y)
{
width = 80;
height = 160;
sprite.setOrigin(40, 115);
creatureSpeed = BUTCHER_VELOCITY;
velocity = Vector2D(creatureSpeed);
computeFacingDirection();
hp = BUTCHER_HP;
hpMax = BUTCHER_HP;
hpDisplay = BUTCHER_HP;
meleeDamages = BUTCHER_DAMAGES;
sausages = 0;
type = ENTITY_ENEMY_BOSS;
bloodColor = BloodRed;
shadowFrame = 4;
dyingFrame = 3;
deathFrame = FRAME_CORPSE_BUTCHER;
agonizingSound = SOUND_BUTCHER_DIE;
hurtingSound = SOUND_BUTCHER_HURT;
enemyType = EnemyTypeButcher;
timer = (rand() % 50) / 10.0f;
age = -1.5f;
frame = 1;
resistance[ResistanceFrozen] = ResistanceHigh;
resistance[ResistanceRecoil] = ResistanceHigh;
canExplode = false;
}
void ButcherEntity::animate(float delay)
{
if (age > 0.0f && !isAgonising)
{
sprite.setColor(sf::Color(255,255,255,255));
timer = timer - delay;
if (timer <= 0.0f)
{
creatureSpeed = BUTCHER_VELOCITY + (hpMax - hp) * 0.8f;
timer = (rand() % 50) / 10.0f;
setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), creatureSpeed ));
if (rand()%2 == 0)
SoundManager::getInstance().playSound(SOUND_BUTCHER_00);
else
SoundManager::getInstance().playSound(SOUND_BUTCHER_01);
}
frame = ((int)(age * creatureSpeed / 25)) % 4;
if (frame == 3) frame = 1;
if (velocity.x > 1.0f) isMirroring = true;
else if (velocity.x < -1.0f) isMirroring = false;
}
EnemyEntity::animate(delay);
z = y + 30;
}
void ButcherEntity::calculateBB()
{
boundingBox.left = (int)x - 22;
boundingBox.width = 44;
boundingBox.top = (int)y - 18;
boundingBox.height = 48;
}
void ButcherEntity::collideMapRight()
{
velocity.x = -velocity.x;
if (recoil.active) recoil.velocity.x = -recoil.velocity.x;
}
void ButcherEntity::collideMapLeft()
{
velocity.x = -velocity.x;
if (recoil.active) recoil.velocity.x = -recoil.velocity.x;
}
void ButcherEntity::collideMapTop()
{
velocity.y = -velocity.y;
if (recoil.active) recoil.velocity.y = -recoil.velocity.y;
}
void ButcherEntity::collideMapBottom()
{
velocity.y = -velocity.y;
if (recoil.active) recoil.velocity.y = -recoil.velocity.y;
}
void ButcherEntity::collideWithEnemy(EnemyEntity* entity)
{
if (recoil.active && recoil.stun) return;
if (entity->getMovingStyle() == movWalking && entity->getEnemyType() != EnemyTypeSausage_invocated)
{
Vector2D vel = Vector2D(entity->getX(), entity->getY()).vectorTo(Vector2D(x, y), 100.0f );
giveRecoil(false, vel, 0.3f);
}
}
void ButcherEntity::drop()
{
- ItemEntity* newItem = new ItemEntity(ItemSilverCoin, x, y);
- newItem->setMap(map, TILE_WIDTH, TILE_HEIGHT, 0, 0);
- newItem->setVelocity(Vector2D(100.0f + rand()% 250));
- newItem->setViscosity(0.96f);
+ //ItemEntity* itemCoin = new ItemEntity(ItemSilverCoin, x, y);
+ //itemCoin->setMap(map, TILE_WIDTH, TILE_HEIGHT, 0, 0);
+ //itemCoin->setVelocity(Vector2D(100.0f + rand()% 250));
+ //itemCoin->setViscosity(0.96f);
+
+ ItemEntity* itemScroll = new ItemEntity(ItemScrollRevelation, x, y);
+ itemScroll->setMap(map, TILE_WIDTH, TILE_HEIGHT, 0, 0);
+ itemScroll->setVelocity(Vector2D(100.0f + rand()% 250));
+ itemScroll->setViscosity(0.96f);
EntityManager::EntityList* entityList = EntityManager::getInstance().getList();
EntityManager::EntityList::iterator it;
for (it = entityList->begin (); it != entityList->end ();)
{
GameEntity *e = *it;
it++;
EnemyEntity* entity = dynamic_cast<EnemyEntity*>(e);
if (entity != NULL)
{
if (entity->getEnemyType()== EnemyTypeSausage_invocated)
{
entity->hurt(getHurtParams(entity->getHp(), ShotTypeStandard, 0, false, SourceTypeMelee, enemyType, false));
}
}
}
}
void ButcherEntity::render(sf::RenderTarget* app)
{
EnemyEntity::render(app);
renderLifeBar(app, tools::getLabel("enemy_butcher"));
}
int ButcherEntity::hurt(StructHurt hurtParam)
{
creatureSpeed = BUTCHER_VELOCITY + hpMax - hp;
setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), creatureSpeed ));
int result = EnemyEntity::hurt(hurtParam);
int totalDamages = hpMax - hp;
if (hp > 0 && totalDamages / 8 > sausages)
{
sausages++;
new SausageEntity(x, y, true);
}
return result;
}
bool ButcherEntity::isAttacking()
{
return true;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Jun 17, 9:17 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70045
Default Alt Text
(4 KB)
Attached To
Mode
R78 witchblast
Attached
Detach File
Event Timeline