36 #include "Core-Level-JR.h"
40 laFightingCreature::laFightingCreature(
rpgSheet* pSheet):
45 _bAttack = _bAttack_Quick = M_FALSE;
48 _ttDeath.parameters(M_DEATHFX_DURATION);
50 _ttDeath.enable(M_FALSE);
52 _ttHitImmunity.parameters(0.5);
53 _ttHitImmunity.enable();
54 _ttHitImmunity.force();
66 fxParticleSystem_params param;
68 sprintf(strFilePath,
"%s%s",
M_DIR_FX,
"creature_blood.fx");
69 fxp.fileOpen(strFilePath);
70 fxp.readObj(¶m, M_FALSE);
73 _fxBlood.create(param);
74 _fxBlood.enable(M_TRUE);
75 _fxBlood.enableGeneration(M_TRUE);
80 laFightingCreature::~laFightingCreature(
void)
92 laMovingCreature::load(fp);
95 getObject()->getModel(M_STATE_DIE)->cycle(M_FALSE);
98 _ttAttackCharge.enable(M_FALSE);
100 _ttAttack.parameters( getObject()->getModel(M_STATE_ATTACK)->duration() );
101 _ttAttack.enable(M_FALSE);
108 void laFightingCreature::respawn()
110 laMovingCreature::respawn();
114 _bAttack = _bAttack_Quick = M_FALSE;
117 _ttDeath.enable(M_FALSE);
119 _color[3]= _outline.
color[3]= 255;
122 void laFightingCreature::attackInitiate(M_BOOL bQuick)
124 if(!isControlEnabled())
return;
125 if(attackIsCharged())
return;
127 if( (!_ttAttackCharge.isEnabled()) )
130 _bAttack_Quick = bQuick;
133 _ttAttackCharge.parameters( selectedAttack().dChargeTime );
134 _ttAttackCharge.enable();
135 _ttAttackCharge.reset();
138 if(!_bAttack_Quick)
fxMessages.add(0.8, laColor(255,255,0),
"Haste!");
142 if(_pAttackSound) _pAttackSound->play();
148 void laFightingCreature::attackStop()
152 _bAttack = _bAttack_Quick = M_FALSE;
154 _ttAttackCharge.reset();
155 _ttAttackCharge.enable(M_FALSE);
158 _ttAttack.enable(M_FALSE);
164 void laFightingCreature::attack(
unsigned nAttackIndex,
laFightingCreature* pTarget ) {
165 ASSERT(pTarget,
"Nil target object");
166 ASSERT(nAttackIndex < ((rpgSheet_Fighter*)_pSheet)->properties()->vAttacks.size(),
"Attack %d not registered", nAttackIndex);
168 pTarget->hit( ((rpgSheet_Fighter*)_pSheet)->modAttack( nAttackIndex ) );
179 void laFightingCreature::hit(
rpgAttack attack)
183 if( (!isAlive()) || isImmune() || getLevelObject()->isCompleted() )
return;
187 unsigned nDamage = ((rpgSheet_Fighter*)_pSheet)->hit( attack );
191 _hit_actions(nDamage);
196 void laFightingCreature::_hit_actions(
unsigned nDamage)
200 fxMessages.add(0.8, laColor(255,255,0),
"Resist");
205 if( ! ((rpgSheet_Fighter*)_pSheet)->isAlive() )
209 if(_pDieSound) _pDieSound->play();
212 else if(_pSufferSound) _pSufferSound->play();
218 fxMessages.add(1, laColor(255,0,0),
"-%d", (
int)nDamage);
221 _ttHitImmunity.reset();
228 void laFightingCreature::animate(laTimer &t)
232 _ttAttackCharge.animate(t);
233 _ttAttack.animate(t);
235 _ttHitImmunity.animate(t);
248 laMovingCreature::animate(t);
252 void laFightingCreature::_animate_attacks()
260 if( _ttAttackCharge.isElapsed() && (!_bAttack) )
268 getObject()->getModel(M_STATE_QATTACK)->frameIndex(0);
269 getObject()->getModel(M_STATE_QATTACK)->toggleTraceFx(M_TRUE);
272 getObject()->getModel(M_STATE_ATTACK)->frameIndex(0);
275 if( _ttAttack.isElapsed() )
281 unsigned laFightingCreature::_next_state(
unsigned nCurrentState )
285 if( (!isAlive()) && (!_ttDeath.isEnabled()) )
287 _ttDeath.enable(M_TRUE);
299 if(_bAttack_Quick)
return M_STATE_QATTACK;
300 else return M_STATE_ATTACK;
309 return laMovingCreature::_next_state( nCurrentState );
315 void laFightingCreature::_draw_positioned_rotated(
laRenderer *r)
319 if(_ttDeath.isEnabled())
323 laStateObject::_draw_positioned_rotated(r);
326 else laMovingCreature::_draw_positioned_rotated(r);
331 void laFightingCreature::_trans_deathfx(
laRenderer *r)
333 _color[3]= _outline.
color[3]= _ttDeath.reminder() * 250;
337 if(_ptPivot.bOnGround) r->transTranslate(laPoint3(0, -1*_ttDeath.progress()*M_DEATHFX_OFFSET, 0));
338 r->transRotate(_ttDeath.progress()*M_DEATHFX_ROTATION, laPoint3(0,1,0));
343 void laFightingCreature::_drawFx_positioned(
laRenderer *r)
347 if(_ttDeath.isEnabled())
348 _ptPivot.dShadowY = _ptPivot.y() + _ttDeath.progress()*M_DEATHFX_OFFSET;
350 if(_ptPivot.y() <
M_UNIT * (M_SEGH - 1))
351 laMovingCreature::_drawFx_positioned(r);
#define M_UNIT
Unit of 1 meter.
laColor color
Outline color.
#define M_DIR_FX
Visual effects directory.
Abstract RPG Properties Sheet.
virtual void modeOutline(const laOutline &outline)
Set outline parameters.
Virtual interface for the Engine graphics renderer.