Game Development Community

Statemachine problem.

by Toks · in Technical Issues · 08/12/2007 (11:08 pm) · 0 replies

Hey everyone:

what I wanted to do, is to modify the "altFire" or trigger[1] not to fire a second image, but to alternatively Fire the same image (so that you cant fire AND altfire at the same time for example). what i did was in player.cc i changed:

void Player::updateMove(const Move* move)
{
   delta.move = *move;

   // Trigger images
   if (mDamageState == Enabled) {
      setImageTriggerState(0,move->trigger[0]);
      setImageTriggerState(1,move->trigger[1]);
   }

   // Update current orientation

to:

void Player::updateMove(const Move* move)
{
   delta.move = *move;

   // Trigger images
   if (mDamageState == Enabled) {
      setImageTriggerState(0,move->trigger[0]);
      setImageAltTriggerState(0,move->trigger[1]);
   }

   // Update current orientation

then I added a setImageAltTriggerState function to shapeImage.cc, similar to the normal setImageTriggerState:

void ShapeBase::setImageAltTriggerState(U32 imageSlot,bool trigger)
{
   if (isGhost() || !mMountedImageList[imageSlot].dataBlock)
      return;
   MountedImage& image = mMountedImageList[imageSlot];

   if (trigger) {
      if (!image.altTriggerDown && image.dataBlock) {
         image.altTriggerDown = true;
         if (!isGhost()) {
            setMaskBits(ImageMaskN << imageSlot);
            updateImageState(imageSlot,0);
         }
      }
   }
   else
      if (image.altTriggerDown) {
         image.altTriggerDown = false;
         if (!isGhost()) {
            setMaskBits(ImageMaskN << imageSlot);
            updateImageState(imageSlot,0);
         }
      }
}

then I just did a global search through shapeImage.cc and shapebase.h duplicating the trigger related things into altTrigger things.

now this compiles correctly, then when i add to my statemachine

transitionOnTriggerDown[x] = "someState";

it indeed transitions into that state, it will launch stateScript, but when i add stateEmitter's nothing happens, and even when I exit this state into another state that SHOULD play a sound (which it does when you enter it through another state) it does not play.

why is this?