Exemplo n.º 1
0
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team)
{
    SetMapId(map->GetId());
    SetInstanceId(map->GetInstanceId());

    Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE);

    if(!InitEntry(Entry, team))
        return false;

    m_defaultMovementType = IDLE_MOTION_TYPE;

    AIM_Initialize();

    SetVehicleId(vehicleId);

    SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
    SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);

    CreatureInfo const *ci = GetCreatureInfo();
    setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H);
    SetMaxHealth(ci->maxhealth);
    SelectLevel(ci);
    SetHealth(GetMaxHealth());

	for( int i = 0; i < 4; ++i )
		this->m_spells[i] = this->GetCreatureInfo()->spells[i]; // So our vehicles can have spells on bar
	GetMotionMaster()->MovePoint(0, GetPositionX(), GetPositionY(), GetPositionZ()+2 ); // So we can fly with Dragon Vehicles

    return true;
}
Exemplo n.º 2
0
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team)
{
    SetMapId(map->GetId());
    SetInstanceId(map->GetInstanceId());

    Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE);

    if(!InitEntry(Entry, team))
        return false;

    m_defaultMovementType = IDLE_MOTION_TYPE;

    AIM_Initialize();

    SetVehicleId(vehicleId);

    SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
    SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);

    CreatureInfo const *ci = GetCreatureInfo();
    setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H);
    SetMaxHealth(ci->maxhealth);
    SelectLevel(ci);
    SetHealth(GetMaxHealth());

    return true;
}
Exemplo n.º 3
0
void Game::RemovePoint()
{
    points_ -= 1;

    if (points_ < 1 && level_ != Levels::INF)
    {
        SelectLevel(Levels::COUNT_);
    }
}
Exemplo n.º 4
0
void
NewGame(void)
{
    short l, c, p, max_opening_sequence;
#ifdef HAVE_GETTIMEOFDAY
    struct timeval tv;
#endif
    compptr = oppptr = 0;
    stage = 0;
    stage2 = -1;    /* the game is not yet started */
    flag.illegal = flag.mate = flag.post = flag.quit
        = flag.reverse = flag.bothsides = flag.onemove = flag.force
        = false;
    flag.material = flag.coords = flag.hash = flag.easy
        = flag.beep = flag.rcptr
        = true;
    flag.stars  = flag.shade = flag.back = flag.musttimeout = false;
    flag.gamein = false;
    flag.rv     = true;

    mycnt1 = mycnt2 = 0;
    GenCnt = NodeCnt = et0 = dither =  XCmore = 0;
    znodes = ZNODES;
    WAwindow = WAWNDW;
    WBwindow = WBWNDW;
    BAwindow = BAWNDW;
    BBwindow = BBWNDW;
    xwndw = BXWNDW;

    if (!MaxSearchDepth)
        MaxSearchDepth = MAXDEPTH - 1;

    contempt = 0;
    GameCnt = 0;
    Game50 = 1;
    CptrFlag[0] = TesujiFlag[0] = false;
    hint = OPENING_HINT;
    ZeroRPT();
    GameType[0] = GameType[1] = UNKNOWN;
    Pscore[0] = Tscore[0] = (SCORE_LIMIT + 3000);
    opponent = player = black;
    computer = white;

    for (l = 0; l < TREE; l++)
        Tree[l].f = Tree[l].t = 0;

    gsrand((unsigned int) 1);

    if (!InitFlag)
    {
        for (c = black; c <= white; c++)
        {
            for (p = pawn; p <= king; p++)
            {
                for (l = 0; l < NO_SQUARES; l++)
                {
                    (*hashcode)[c][p][l].key
                         = (((unsigned long) urand()));
                    (*hashcode)[c][p][l].key
                        += (((unsigned long) urand()) << 16);
                    (*hashcode)[c][p][l].bd
                         = (((unsigned long) urand()));
                    (*hashcode)[c][p][l].bd
                        += (((unsigned long) urand()) << 16);
#if SIZEOF_LONG == 8  /* 64-bit long i.e. 8 bytes */
                    (*hashcode)[c][p][l].key
                        += (((unsigned long) urand()) << 32);
                    (*hashcode)[c][p][l].key
                        += (((unsigned long) urand()) << 48);
                    (*hashcode)[c][p][l].bd
                        += (((unsigned long) urand()) << 32);
                    (*hashcode)[c][p][l].bd
                        += (((unsigned long) urand()) << 48);
#endif
                }
            }
        }

        for (c = black; c <= white; c++)
        {
            for (p = pawn; p <= king; p++)
            {
                for (l = 0; l < MAX_CAPTURED; l++)
                {
                    (*drop_hashcode)[c][p][l].key
                         = (((unsigned long) urand()));
                    (*drop_hashcode)[c][p][l].key
                        += (((unsigned long) urand()) << 16);
                    (*drop_hashcode)[c][p][l].bd
                         = (((unsigned long) urand()));
                    (*drop_hashcode)[c][p][l].bd
                        += (((unsigned long) urand()) << 16);
#if SIZEOF_LONG == 8  /* 64-bit long i.e. 8 bytes */
                    (*drop_hashcode)[c][p][l].key
                        += (((unsigned long) urand()) << 32);
                    (*drop_hashcode)[c][p][l].key
                        += (((unsigned long) urand()) << 48);
                    (*drop_hashcode)[c][p][l].bd
                        += (((unsigned long) urand()) << 32);
                    (*drop_hashcode)[c][p][l].bd
                        += (((unsigned long) urand()) << 48);
#endif
                }
            }
        }
    }

    for (l = 0; l < NO_SQUARES; l++)
    {
        board[l] = Stboard[l];
        color[l] = Stcolor[l];
        Mvboard[l] = 0;
    }

    ClearCaptured();
    ClearScreen();
    InitializeStats();

#ifdef HAVE_GETTIMEOFDAY
    gettimeofday(&tv, NULL);
    time0 = tv.tv_sec*100 + tv.tv_usec/10000;
#else
    time0 = time((long *) 0);
#endif

    /* resetting reference time */
    ElapsedTime(COMPUTE_AND_INIT_MODE);
    flag.regularstart = true;
    Book = BOOKFAIL;

    if (!InitFlag)
    {
        char sx[256];
        strcpy(sx, CP[169]);

        if (TCflag)
            SetTimeControl();
        else if (MaxResponseTime == 0)
            SelectLevel(sx);

        UpdateDisplay(0, 0, 1, 0);
        GetOpenings();
        GetOpeningPatterns(&max_opening_sequence);

        InitFlag = true;
    }

#if ttblsz
    if (TTadd)
    {
        ZeroTTable();
        TTadd = 0;
    }
#endif /* ttblsz */

    hashbd = hashkey = 0;
    return;
}
Exemplo n.º 5
0
bool Creature::CreateFromProto(uint32 guidlow,uint32 Entry)
{
    Object::_Create(guidlow, HIGHGUID_UNIT);

    m_DBTableGuid = guidlow;

    SetUInt32Value(OBJECT_FIELD_ENTRY,Entry);
    CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry);
    if(!cinfo)
    {
        sLog.outError("Error: creature entry %u does not exist.",Entry);
        return false;
    }
    uint32 rank = isPet()? 0 : cinfo->rank;
    float damagemod = _GetDamageMod(rank);;

    uint32 display_id = cinfo->randomDisplayID();

    SetUInt32Value(UNIT_FIELD_DISPLAYID,display_id );
    SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID,display_id );
    SetUInt32Value(UNIT_FIELD_BYTES_2,1);                   // let creature used equiped weapon in fight

    SetName(GetCreatureInfo()->Name);

    SelectLevel(cinfo);

    SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction);

    SetUInt32Value(UNIT_NPC_FLAGS,cinfo->npcflag);

    SetFloatValue(UNIT_FIELD_MINDAMAGE,cinfo->mindmg * damagemod);
    SetFloatValue(UNIT_FIELD_MAXDAMAGE,cinfo->maxdmg * damagemod);

    SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE,cinfo->minrangedmg * damagemod);
    SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE,cinfo->maxrangedmg * damagemod);

    SetAttackTime(BASE_ATTACK,  cinfo->baseattacktime);
    SetAttackTime(RANGED_ATTACK,cinfo->rangeattacktime);

    SetUInt32Value(UNIT_FIELD_FLAGS,cinfo->Flags);
    SetUInt32Value(UNIT_DYNAMIC_FLAGS,cinfo->dynamicflags);

    SetArmor(cinfo->armor);
    SetResistance(SPELL_SCHOOL_HOLY,cinfo->resistance1);
    SetResistance(SPELL_SCHOOL_FIRE,cinfo->resistance2);
    SetResistance(SPELL_SCHOOL_NATURE,cinfo->resistance3);
    SetResistance(SPELL_SCHOOL_FROST,cinfo->resistance4);
    SetResistance(SPELL_SCHOOL_SHADOW,cinfo->resistance5);
    SetResistance(SPELL_SCHOOL_ARCANE,cinfo->resistance6);

    //this is probably wrong
    SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, cinfo->equipmodel[0]);
    SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO , cinfo->equipinfo[0]);
    SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO  + 1, cinfo->equipslot[0]);

    SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, cinfo->equipmodel[1]);
    SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2, cinfo->equipinfo[1]);
    SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 2 + 1, cinfo->equipslot[1]);

    SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+2, cinfo->equipmodel[2]);
    SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 4, cinfo->equipinfo[2]);
    SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 4 + 1, cinfo->equipslot[2]);

    SetFloatValue(OBJECT_FIELD_SCALE_X, cinfo->size);

    SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS,cinfo->bounding_radius);
    SetFloatValue(UNIT_FIELD_COMBATREACH,cinfo->combat_reach );

    FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cinfo->faction);
    if (factionTemplate)
    {
        FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction);
        if (factionEntry)
            if (cinfo->civilian != 1 && (factionEntry->team == ALLIANCE || factionEntry->team == HORDE))
                SetPvP(true);
    } else
    sLog.outErrorDb("Error: invalid faction (%u) for creature (GUIDLow: %u Entry: %u)", cinfo->faction, GetGUIDLow(),Entry);

    if (cinfo->mount != 0)
        Mount(cinfo->mount);

    m_spells[0] = cinfo->spell1;
    m_spells[1] = cinfo->spell2;
    m_spells[2] = cinfo->spell3;
    m_spells[3] = cinfo->spell4;

    SetSpeed(MOVE_WALK,     cinfo->speed );
    SetSpeed(MOVE_RUN,      cinfo->speed );
    SetSpeed(MOVE_WALKBACK, cinfo->speed );
    SetSpeed(MOVE_SWIM,     cinfo->speed);
    SetSpeed(MOVE_SWIMBACK, cinfo->speed);

    if(cinfo->MovementType < MAX_DB_MOTION_TYPE)
        m_defaultMovementType = MovementGeneratorType(cinfo->MovementType);
    else
    {
        m_defaultMovementType = IDLE_MOTION_TYPE;
        sLog.outErrorDb("Creature template %u have wrong movement generator type value %u, ignore and set to IDLE.",Entry,cinfo->MovementType);
    }

    return true;
}
Exemplo n.º 6
0
void Creature::Update(uint32 diff)
{
    switch( m_deathState )
    {
        case JUST_DIED:
            // Dont must be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting.
            sLog.outError("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_DEAD (1)",GetGUIDLow(),GetEntry());
            break;
        case DEAD:
        {
            if( m_respawnTime <= time(NULL) )
            {
                DEBUG_LOG("Respawning...");
                m_respawnTime = 0;

                CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(this->GetEntry());

                SelectLevel(cinfo);
                SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
                RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);

                SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag);
                SetHealth(GetMaxHealth());
                setDeathState( ALIVE );
                clearUnitState(UNIT_STAT_ALL_STATE);
                i_motionMaster.Clear();
                MapManager::Instance().GetMap(GetMapId(), this)->Add(this);
            }
            break;
        }
        case CORPSE:
        {
            if( m_deathTimer <= diff )
            {
                m_deathTimer = 0;
                DEBUG_LOG("Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY));
                ObjectAccessor::Instance().RemoveCreatureCorpseFromPlayerView(this);
                lootForPickPocketed = false;
                lootForBody         = false;
                loot.clear();
                setDeathState(DEAD);
                m_respawnTime = time(NULL) + m_respawnDelay;

                float x,y,z;
                GetRespawnCoord(x, y, z);
                MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,GetOrientation());
            }
            else
            {
                m_deathTimer -= diff;
                if (m_groupLootTimer && lootingGroupLeaderGUID)
                {
                    if(diff <= m_groupLootTimer)
                    {
                        m_groupLootTimer -= diff;
                    }
                    else
                    {
                        Group* group = objmgr.GetGroupByLeader(lootingGroupLeaderGUID);
                        if (group)
                            group->EndRoll();
                        m_groupLootTimer = 0;
                        lootingGroupLeaderGUID = 0;
                    }
                }
            }

            break;
        }
        case ALIVE:
        {
            Unit::Update( diff );
            i_motionMaster.UpdateMotion(diff);
            i_AI->UpdateAI(diff);
            if(m_regenTimer > 0)
            {
                if(diff >= m_regenTimer)
                    m_regenTimer = 0;
                else
                    m_regenTimer -= diff;
            }
            if (m_regenTimer != 0)
                break;
            if (!isInCombat())
            {
                RegenerateHealth();
                RegenerateMana();
            }
            m_regenTimer = 2000;
            break;
        }
        default:
            break;
    }
}
Exemplo n.º 7
0
void DemoIntroduction(void)
{
	unsigned char i ;
	unsigned int w1, w2;
	unsigned char touchedNow;
	SCROLL_WHEEL_DIRECTION scrollDir;
	
    switch(DemoIntroState)
    {
        case 0:
            ResetDevice();  
        
            FillDisplay(0x00);
            oledPutROMString((ROM_STRING)" Labyrinth Demo v1.0 ",0,0);
            oledPutROMString((ROM_STRING)"   by Daniel Szot    ",1,0);
			oledPutROMString((ROM_STRING)"                     ",2,0);
			oledPutROMString((ROM_STRING)"  MB Turnkey Design  ",3,0);
			oledPutROMString((ROM_STRING)" mbturnkeydesign.com ",4,0);
            oledPutROMString((ROM_STRING)"Press Menu to proceed",6,0);

            DemoIntroState = 1;
            break;

        case 1:
            if(CheckButtonPressed() == TRUE)
            {
                DemoIntroState=4;
            }
            break;

        case 4:
            oledPutROMString((ROM_STRING)" 1. Use scroll to    ",0,0);
            oledPutROMString((ROM_STRING)" select menu items.  ",1,0);
            oledPutROMString((ROM_STRING)" 2. Tilt the board   ",2,0);
            oledPutROMString((ROM_STRING)" to move the ball.   ",3,0);
            oledPutROMString((ROM_STRING)" 3. Have a good time.",4,0);
            oledPutROMString((ROM_STRING)"                     ",5,0);
            oledPutROMString((ROM_STRING)"Press Menu to proceed",6,0);
            DemoIntroState = 5;
            break;

        case 5:
            if(CheckButtonPressed() == TRUE)
            {
                DemoIntroState++;
            }
            break;

        case 6:
			scrollDir = GetScrollDirection();

			if (scrollDir == SCROLL_UP)
			{
				if (g_menuSelected > 0)
					g_menuSelected --;
			}
			else if (scrollDir == SCROLL_DOWN)
			{
				if (g_menuSelected < 3)
					g_menuSelected ++;
			}		

            oledPutROMString((ROM_STRING)"   LABIRYNTH  MENU   ",0,0);
            oledPutROMString(empty_line,1,0);

			if (g_menuSelected == 0)
				oledPutROMNegString((ROM_STRING)"      NEW  GAME      ",2,0);	
			else
            	oledPutROMString((ROM_STRING)"      NEW  GAME      ",2,0);

            if (g_menuSelected == 1)
				oledPutROMNegString((ROM_STRING)"     SELECT LEVEL    ",3,0);
			else
				oledPutROMString((ROM_STRING)"     SELECT LEVEL    ",3,0);
		    
			if (g_menuSelected == 2)
            	oledPutROMNegString((ROM_STRING)"      CALIBRATE      ",4,0);
			else
				oledPutROMString((ROM_STRING)"      CALIBRATE      ",4,0);
			
			if (g_menuSelected == 3)
            	oledPutROMNegString((ROM_STRING)"      QUIT GAME      ",5,0);
			else
				oledPutROMString((ROM_STRING)"      QUIT GAME      ",5,0);

            oledPutROMString(empty_line,6,0);

			w1 = mTouchReadButton(0);
			if (w1 < 600)
			{
				switch(g_menuSelected)
				{
					case 0: DemoIntroState = 0xFF; g_level=0; loadLevel(g_level); break;
					case 1: DemoIntroState = 9; DelayMs(100); FillDisplay(0x00); g_menuSelected = 0; firstLevel = 0; break;
					case 2: DemoIntroState = 7; DelayMs(100); FillDisplay(0x00);  break;
					case 3: 
						_asm
						RESET
						_endasm
						 break;
				}
			}
            break;

        case 7:
			CalibrateAcc();
            break;

		case 8:
			FillDisplay(0xFF);
			oledPutROMNegString((ROM_STRING)"  CORNGRATULATIONS!  ",0,0);
			oledPutROMNegString((ROM_STRING)"   You won nothing   ",2,0);
			oledPutROMNegString((ROM_STRING)" You just waste your ",3,0);
			oledPutROMNegString((ROM_STRING)"   PRECIOUS time :)  ",4,0);
			DelayMs(2000);
			DemoIntroState = 6;
			FillDisplay(0x00);
			g_level = 0;
			g_ballGtt = 0;
			break;

		case 9:
			SelectLevel();
			break;

        default:
            break;
    }
}