Commit b3c028fa authored by Gerstrong's avatar Gerstrong

PoisonSlug Update

parent 85e82b3a
......@@ -26,7 +26,7 @@ struct ActionFormatType {
int16_t Movement_parameter; // 0-3
int16_t Change_h; // 0/1
int16_t Change_v; // 0/1
int16_t Delay; // (Anim speed) 0-8000
int16_t Delay; // (Anim speed) 0-8000
int16_t H_anim_move_amount; // +- any value
int16_t V_anim_move_amount; // +- any value
int16_t Behavior; // [Start of behavior codes only]
......@@ -34,7 +34,7 @@ struct ActionFormatType {
int16_t Check_sprites; // [Start of check sprite codes only]
int16_t Check_segment; // [Segment values only]
int16_t Check_tiles; // [Start of check tile code only]
int16_t Check_segment2; // [Segment values only]
int16_t Check_segment2; // [Segment values only]
int16_t Next_action; // [Valid actions only]
/**
......
......@@ -485,15 +485,31 @@ void CObject::processActionRoutine()
{
setActionSprite();
if(m_hDir == LEFT)
moveLeft(m_Action.H_anim_move_amount<<1);
else if(m_hDir == RIGHT)
moveRight(m_Action.H_anim_move_amount<<1);
if(m_vDir == UP)
moveUp( m_Action.V_anim_move_amount<<1 );
else if(m_vDir == DOWN)
moveDown( m_Action.V_anim_move_amount<<1 );
// Check the Movement Parameter
/*
* This is how the game handles the sprite's movement;
* and is important only with sprites that have movement
* not associated with animation (See below.)The variable
* can have any value between 0-4; zero is used for
* sprites that don't move (Most common occurrence.),
* 1 for nonanimating sprites that may still need to move or hover in place,
* 2 is the stunned sprite value and is also used where smooth movement is needed
* 3 is used for 'fall' moves such as the Bounder or Mad Mushroom and
* 4 is used for sprites that must hit or land on the ground.
*/
if( m_Action.Movement_parameter )
{
if(m_hDir == LEFT )
moveLeft( m_Action.H_anim_move_amount<<1 );
else if(m_hDir == RIGHT )
moveRight( m_Action.H_anim_move_amount<<1 );
if(m_vDir == UP)
moveUp( m_Action.V_anim_move_amount<<1 );
else if(m_vDir == DOWN)
moveDown( m_Action.V_anim_move_amount<<1 );
}
if( m_ActionTicker > m_Action.Delay )
{
......@@ -507,7 +523,9 @@ void CObject::processActionRoutine()
m_ActionTicker = 0;
}
else
{
m_ActionTicker += 2;
}
}
////
......
......@@ -6,18 +6,75 @@
*/
#include "CPoisonSlug.h"
#include "misc.h"
namespace galaxy {
const int SLUG_MOVE_SPEED = 1;
const int SLUG_MOVE_TIMER = 10;
//const int SLUG_POO_TIME = 1000;
CPoisonSlug::CPoisonSlug(CMap *pmap, Uint32 x, Uint32 y) :
CObject(pmap, x, y, OBJ_NONE)
CObject(pmap, x, y, OBJ_NONE),
m_timer(0)
{
m_ActionBaseOffset = 0x2012;
m_hDir = LEFT;
setActionForce(A_SLUG_MOVE);
mp_processState = &CPoisonSlug::processCrawling;
processActionRoutine();
performCollisions();
}
void CPoisonSlug::processCrawling()
{
if( m_timer < SLUG_MOVE_TIMER )
{
m_timer++;
return;
}
else
{
m_timer = 0;
}
// Chance to poo
if( getProbability(50) )
{
m_timer = 0;
mp_processState = &CPoisonSlug::processPooing;
setAction(A_SLUG_POOING);
return;
}
// Move normally in the direction
if( m_hDir == RIGHT )
moveRight( m_Action.H_anim_move_amount<<1 );
else
moveLeft( m_Action.H_anim_move_amount<<1 );
}
void CPoisonSlug::processPooing()
{
if( getActionStatus(A_SLUG_MOVE) )
{
// TODO: Create that slime
setAction(A_SLUG_MOVE);
mp_processState = &CPoisonSlug::processCrawling;
}
}
void CPoisonSlug::process()
{
(this->*mp_processState)();
if( blockedl )
m_hDir = RIGHT;
else if(blockedr)
m_hDir = LEFT;
processActionRoutine();
}
......
......@@ -15,13 +15,22 @@
namespace galaxy {
#define A_SLUG_MOVE 0 /* Ordinary slug_move action */
#define A_SLUG_POOHING 2
#define A_SLUG_POOING 2
#define A_SLUG_STUNNED 3
#define A_SLUG_STUNNED_ALT 4
class CPoisonSlug : public CObject {
public:
CPoisonSlug(CMap *pmap, Uint32 x, Uint32 y);
void processCrawling();
void processPooing();
void process();
private:
int m_timer;
void (CPoisonSlug::*mp_processState)();
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment