void UpdateAI(uint32 diff) override
        {
            if (BreakKeg_Timer)
            {
                if (BreakKeg_Timer <= diff)
                {
                    DoGo(DATA_GO_BAR_KEG, 0);
                    BreakKeg_Timer = 0;
                    BreakDoor_Timer = 1000;
                } else BreakKeg_Timer -= diff;
            }

            if (BreakDoor_Timer)
            {
                if (BreakDoor_Timer <= diff)
                {
                    DoGo(DATA_GO_BAR_DOOR, 2);
                    DoGo(DATA_GO_BAR_KEG_TRAP, 0);               //doesn't work very well, leaving code here for future
                    //spell by trap has effect61, this indicate the bar go hostile

                    if (Unit* tmp = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_PHALANX)))
                        tmp->setFaction(14);

                    //for later, this event(s) has alot more to it.
                    //optionally, DONE can trigger bar to go hostile.
                    instance->SetData(TYPE_BAR, DONE);

                    BreakDoor_Timer = 0;
                } else BreakDoor_Timer -= diff;
            }

            npc_escortAI::UpdateAI(diff);
        }
Beispiel #2
0
Datei: brain.c Projekt: jjh42/bif
static void UpdateBrainChaseEscape (BOOL DoChase, BOOL DoLight)
{
    if (BrainStatus == BRAIN_S_IDLE) // Need to choose a manouver
        switch (BrainStage) {
        case 0: // Turn 180 degrees
            DefaultDistance = 0;
            DefaultSpeed = MAX_SPEED;
            HeadlightIntensity = MAX_INTENSITY;
            setbase_intensity (HeadlightIntensity);
            MomentLength = 100; // 100 msec = 0.1 seconds
            DefaultAngle = 180;
        case 1: // and then 180 degrees again (complete circle)
            if (DoGo ())
                BrainStatus = BRAIN_S_WFC; // now Wait For Completion
            else // can't do it
                BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 2: // Tell them I give up
            switch (CurrentOutputLanguage) {
            case MATIGSALUG:
                sprintf (MakeupSpeakString, "Eg-engked ad e.");
                SayMakeupSpeakString (FALSE);
                break;
            default: // default to English
                sprintf (MakeupSpeakString, "I give up %s %s.", DoChase?"chasing":"escaping", DoLight?"light":"sound");
                SayMakeupSpeakString (FALSE);
                break;
            }
            BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 3: // Give up
            SetBrainMode (BRAIN_M_HALTED);
            break;
        }
}
Beispiel #3
0
void Go( struct TDebug *obj )
{
    if( obj->CurrentThread ) {
        RdosResetSignal( obj->UserSignal );
        DoGo( obj );
        RdosWaitForever( obj->UserWait );
    }
}
Beispiel #4
0
Datei: brain.c Projekt: jjh42/bif
static void UpdateBrainExplore (void)
{
    static BOOL TurnRight;
    if (BrainStatus == BRAIN_S_IDLE) // Need to choose a manouver
        switch (BrainStage) {
        case 0:
            DefaultDistance = MAX_DISTANCE;
            DefaultAngle = 0;
            DefaultSpeed = MAX_SPEED;
            HeadlightIntensity = MAX_INTENSITY;
            setbase_intensity (HeadlightIntensity);
            if (DoGo ())
                BrainStatus = BRAIN_S_WFC; // now Wait For Completion
            else // can't do it
                BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 1:
        case 3:
        case 5:
        case 7:
            DefaultDistance = 400; // Backup 0.4m
            if (DoReverse ())
                BrainStatus = BRAIN_S_WFC; // now Wait For Completion
            else // can't do it
                BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 2:
        case 4:
        case 6:
        case 8:
            DefaultDistance = MAX_DISTANCE;
            DefaultAngle = (U16)(TurnRight ? rndrange(85,95) : rndrange(265,275));
            if (DoGo ())
                BrainStatus = BRAIN_S_WFC; // now Wait For Completion
            else // can't do it
                BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        default:
            BrainStage = 1; // and now repeat some more (start by backing up)
            TurnRight = (BOOL)!TurnRight; // turning the other way
            break;
        }
}
    void UpdateEscortAI(const uint32 uiDiff) override
    {
        if (!m_pInstance)
            return;

        if (m_uiBreakKegTimer)
        {
            if (m_uiBreakKegTimer <= uiDiff)
            {
                DoGo(GO_BAR_KEG_SHOT, 0);
                m_uiBreakKegTimer = 0;
                m_uiBreakDoorTimer = 1000;
            }
            else
                m_uiBreakKegTimer -= uiDiff;
        }

        if (m_uiBreakDoorTimer)
        {
            if (m_uiBreakDoorTimer <= uiDiff)
            {
                DoGo(GO_BAR_DOOR, 2);
                DoGo(GO_BAR_KEG_TRAP, 0);                   // doesn't work very well, leaving code here for future
                // spell by trap has effect61, this indicate the bar go hostile

                if (Creature* pTmp = m_pInstance->GetSingleCreatureFromStorage(NPC_PHALANX))
                    pTmp->SetFactionTemporary(14, TEMPFACTION_NONE);

                // for later, this event(s) has alot more to it.
                // optionally, DONE can trigger bar to go hostile.
                m_pInstance->SetData(TYPE_BAR, DONE);

                m_uiBreakDoorTimer = 0;
            }
            else
                m_uiBreakDoorTimer -= uiDiff;
        }
    }
Beispiel #6
0
int AsyncGo( struct TDebug *obj, int ms )
{
    void *wait;
    
    if( obj->CurrentThread ) {
        RdosResetSignal( obj->UserSignal );
        DoGo( obj );

        wait = RdosWaitTimeout( obj->UserWait, ms );
        if ( wait ) {
            return( TRUE );
        }
        else
            return( FALSE );
    }
    return( TRUE );
}
Beispiel #7
0
Datei: brain.c Projekt: jjh42/bif
static void UpdateBrainRandom (void)
{
    U8 ThisRnd100;

    if (BrainStatus == BRAIN_S_IDLE) // Need to choose a manouver
    {
        DefaultDistance = rndrange (500,1500);
        DefaultAngle = rndrange (0,360);
        DefaultSpeed = (U8)rndrange (200,MAX_SPEED+1);
        HeadlightIntensity = (U8)rndrange (MIN_INTENSITY, MAX_INTENSITY+1);

        ThisRnd100 = rnd100 ();
        if (ThisRnd100 > 40) // go forward 60% of time
        {
            if (DoGo ())
                BrainStatus = BRAIN_S_WFC; // now Wait For Completion
            else
                BrainStatus = BRAIN_S_WAM; // Wait A Moment
        }
        else if (ThisRnd100 > 20) // go backwards 20% of time
        {
            if (DoReverse ())
                BrainStatus = BRAIN_S_WFC; // now Wait For Completion
            else
                BrainStatus = BRAIN_S_WAM; // Wait A Moment
        }
        else // do something else 20% of time
        {
            //printf ("Set lights randomly");
            setbase_intensity (HeadlightIntensity);
            if (ThisRnd100>15)
                setbase_lights (BASE_LIGHTS_LOW);
            else if (ThisRnd100>9)
                setbase_lights (BASE_LIGHTS_NORMAL);
            else if (ThisRnd100>3)
                setbase_lights (BASE_LIGHTS_FULL);
            else
                setbase_lights (BASE_LIGHTS_TEST);
            BrainStatus = BRAIN_S_WAM; // now Wait A Moment
        }
    }
}
Beispiel #8
0
Datei: brain.c Projekt: jjh42/bif
static void UpdateBrainGoHome (void)
{
    if (BrainStatus == BRAIN_S_IDLE) // Need to choose a manouver
        switch (BrainStage) {
        case 0: // Go forward
            setbase_lights (BASE_LIGHTS_NORMAL);
            DefaultDistance = 300; // 300mm = 0.3m
            DefaultAngle = 0;
            DefaultSpeed = MAX_SPEED;
            HeadlightIntensity = MAX_INTENSITY;
            setbase_intensity (HeadlightIntensity);
GHGo:
            if (DoGo ())
                BrainStatus = BRAIN_S_WFC; // now Wait For Completion
            else // can't do it
                BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 1: // Turn half around
        case 2: //  twice so a complete turn
            DefaultAngle = 180;
            DefaultDistance = 0;
            goto GHGo;
        case 3: // Tell them I'm lost
            switch (CurrentOutputLanguage) {
            case MATIGSALUG:
                sprintf (MakeupSpeakString, "Nalaag ad e.");
                SayMakeupSpeakString (FALSE);
                break;
            default: // default to English
                sprintf (MakeupSpeakString, "I'm lost.");
                SayMakeupSpeakString (FALSE);
                break;
            }
            BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 4: // Give up
            SetBrainMode (BRAIN_M_HALTED);
            break;
        }
}
Beispiel #9
0
Datei: brain.c Projekt: jjh42/bif
static void UpdateBrainShowOff (void)
{
    if (BrainStatus == BRAIN_S_IDLE) // Need to choose a manouver
        switch (BrainStage) {
        case 0: // Go forward
            setbase_lights (BASE_LIGHTS_NORMAL);
            DefaultDistance = 500; // 500mm = 0.5m
            DefaultSpeed = MAX_SPEED;
            HeadlightIntensity = MAX_INTENSITY;
            setbase_intensity (HeadlightIntensity);
SOGoStraight:
            DefaultAngle = 0;
SOGo:
            if (DoGo ())
                BrainStatus = BRAIN_S_WFC; // now Wait For Completion
            else // can't do it
                BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 1: // Reverse
SOReverse:
            if (DoReverse ())
                BrainStatus = BRAIN_S_WFC; // now Wait For Completion
            else // can't do it
                BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 2: // Turn left
            DefaultDistance = 0;
            DefaultAngle = 270;
            goto SOGo;
        case 3: // Turn right again
            DefaultAngle = 180;
            goto SOGo;
        case 4: // Turn back
            DefaultAngle = 270;
            goto SOGo;
        case 5: // Turn headlights on
            setbase_lights (BASE_LIGHTS_FULL);
            BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 6: // Turn half around
        case 7: //  twice so a complete turn
            DefaultAngle = 180;
            goto SOGo;
        case 8: // Show off lights
            setbase_lights (BASE_LIGHTS_TEST);
            BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        case 9: // Jiggle left
        case 11:
        case 13:
        case 16:
        case 18:
        case 20:
        case 23:
        case 25:
        case 27:
            DefaultDistance = 0;
            DefaultAngle = 350;
            goto SOGo;
        case 10: // Jiggle back right
        case 12:
        case 14:
        case 17:
        case 19:
        case 21:
        case 24:
        case 26:
        case 28:
            DefaultAngle = 10;
            goto SOGo;
        case 15: // Go forward 100mm
            DefaultDistance= 100;
            goto SOGoStraight;
        case 22: // Reverse 100mm
            DefaultDistance= 100;
            goto SOReverse;
        case 29:
            setbase_lights (BASE_LIGHTS_NORMAL);
            BrainStatus = BRAIN_S_WAM; // Just Wait A Moment
            break;
        default:
            BrainStage = 0; // and now repeat some more
            break;
        }
}