Spell Dialog::SelectSpell(u8 cur)
{
    Display & display = Display::Get();
    Cursor & cursor = Cursor::Get();
    LocalEvent & le = LocalEvent::Get();

    std::vector<int> spells(static_cast<int>(Spell::STONE - 1), Spell::NONE);

    cursor.Hide();
    cursor.SetThemes(cursor.POINTER);

    for(size_t ii = 0; ii < spells.size(); ++ii) spells[ii] = ii + 1;

    const u16 window_w = 340;
    const u16 window_h = 280;

    Dialog::FrameBorder frameborder;
    frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH,
			    (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h);
    frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0));

    const Rect & area = frameborder.GetArea();

    SelectEnumSpell listbox(area);

    listbox.SetListContent(spells);
    if(cur != Spell::NONE)
	listbox.SetCurrent(static_cast<int>(cur));
    listbox.Redraw();

    ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL);
    btnGroups.Draw();

    cursor.Show();
    display.Flip();

    u16 result = Dialog::ZERO;

    while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents())
    {
        result = btnGroups.QueueEventProcessing();
        listbox.QueueEventProcessing();

        if(!cursor.isVisible())
        {
            listbox.Redraw();
            cursor.Show();
            display.Flip();
        }
    }

    return result == Dialog::OK || listbox.ok ?
	Spell(listbox.GetCurrent()) : Spell(Spell::NONE);
}
示例#2
0
void Vehicle::AddPassengerToSeat( Unit *passenger, uint32 seatid ){
	if( seats[ seatid ]->HasPassenger() )
		return;

	if( !seats[ seatid ]->Usable() )
		return;

	passenger->RemoveAllAuraType( SPELL_AURA_MOUNTED );

	if( passenger->IsPlayer() )
		static_cast< Player* >( passenger )->DismissActivePets();

	if( passenger->GetCurrentVehicle() != NULL )
		passenger->GetCurrentVehicle()->EjectPassenger( passenger );

	// set moveflags
	// set movement info
	
	// root passenger
	passenger->Root();

	WorldPacket ack( 0x049D );
	passenger->SendPacket( &ack );

	passenger->SendHopOnVehicle( owner, seatid );

	LocationVector v( owner->GetPosition() );
	v.x += seats[ seatid ]->GetSeatInfo()->attachmentOffsetX;
	v.y += seats[ seatid ]->GetSeatInfo()->attachmentOffsetY;
	v.z += seats[ seatid ]->GetSeatInfo()->attachmentOffsetZ;

	passenger->SetPosition( v, false );

	// Player's client sets these
	if( passenger->IsCreature() ){
		passenger->transporter_info.guid = owner->GetGUID();
		passenger->transporter_info.seat = seatid;
	}

	if( passenger->IsPlayer() ){
		WorldPacket ack( SMSG_CONTROL_VEHICLE, 0);
		passenger->SendPacket( &ack );

		passenger->SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE );

		static_cast< Player* >( passenger )->SetFarsightTarget( owner->GetGUID() );

		if( seats[ seatid ]->Controller() ){
			ack.Initialize( SMSG_CLIENT_CONTROL_UPDATE );
			ack << owner->GetNewGUID() << uint8(1);
			passenger->SendPacket(&ack);

			passenger->SetCharmedUnitGUID( owner->GetGUID() );
			owner->SetCharmedByGUID( passenger->GetGUID() );
			owner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED_CREATURE );

			WorldPacket spells( SMSG_PET_SPELLS, 100 );
			owner->BuildPetSpellList( spells );
			passenger->SendPacket( &spells );
		}		
	}

	seats[ seatid ]->AddPassenger( passenger->GetGUID() );
	passenger->SetCurrentVehicle( this );

	if( seats[ seatid ]->HidesPassenger() )
		passenger->SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NOT_ATTACKABLE_2 );

	passengercount++;
	freeseats--;

	// remove spellclick flag if full
	if( !HasEmptySeat() ){
		owner->RemoveFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK );
		owner->RemoveFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE );

	}

	if( passenger->IsCreature() ){
		Creature *c = static_cast< Creature* >( passenger );
		
		if( c->GetScript() != NULL ){
			c->GetScript()->OnEnterVehicle();
		}
	}

	if( owner->IsCreature() ){
		Creature *c = static_cast< Creature* >( owner );

		if( c->GetScript() != NULL ){
			if( passengercount == 1 )
				c->GetScript()->OnFirstPassengerEntered( passenger );

			if( !HasEmptySeat() )
				c->GetScript()->OnVehicleFull();
		}
	}
}
示例#3
0
文件: camp.c 项目: hialmar/tyrann3
void inspect(void)
{
	char a, i, j;
	char titre[32];
	
	printTitle(8,4, A_BGRED, "INSPECTER QUEL HEROS ? ", 23);
	while(1) {
		a = get();
		if (a<'1' || a>'6')
			ping(); // ping si pas correct
		else
			break; // correct : on sort
	}
	cls();
	printFrame(23);
	i = a - '1';
	// construction du nom/titre
	strcpy(titre, " < ");
	strcat(titre, characters[i].nom);
	if(characters[i].mp != 1) {
		strcat(titre, " ");
		strcat(titre, maisons[characters[i].mp-2]);
	}
	strcat(titre, " > ");
	j = strlen(titre);
	a = (31-j)/2 + 4;
	// affichage du titre
	printTitle(a,2, A_BGRED, titre, j);
	// affichage classe, niv, xp
	printAtXY(5,  4, "Carr :");
	printAtXY(11, 4, classe[characters[i].cp-1]);
	printAtXY(22, 4, "Niv:");
	printAtXY(27, 4, itoa(characters[i].ni));
	printAtXY(29, 4, "EXP:");
	printAtXY(33, 4, itoa(characters[i].xp));
	
	// affichage santé, pv
	printAtXY(5,  6, "Sant{:");
	printAtXY(11, 6, etat[characters[i].ok-1]);
	printAtXY(22, 6, "PV :");
	printAtXY(27, 6, itoa(characters[i].et));
	printAtXY(30, 6, "/");
	printAtXY(32, 6, itoa(characters[i].pv));
	// affichage bourse
	printAtXY(5,  8, "Bourse:");
	printAtXY(13, 8, itoa(characters[i].ri*10));
	printAtXY(21, 8, "Cerfs d'Argent");
	
	// affichage de l'équipement porté
	printAtXY(5,  10, "Arme D:");
	if (characters[i].wr != 0)
		printAtXY(13, 10, textesItems[characters[i].wr-1]);

	printAtXY(5,  11, "Arme G:");
	if (characters[i].wl != 0)
		printAtXY(13, 11, textesItems[characters[i].wl-1]);
	
	printAtXY(5,  12, "Animal:");
	if (characters[i].bt != 0)
		printAtXY(13, 12, textesItems[characters[i].bt-1]);

	printAtXY(5,  13, "Armure:");
	if (characters[i].pt != 0)
		printAtXY(13, 13, textesItems[characters[i].pt-1]);
	printAtXY(29, 13, "CA:");
	printAtXY(33, 13, itoa(characters[i].ca));
	
	// affiche les caracs
	printTitle(4,15, A_BGRED, "CC  CT  Fo  Ag  In  FM ", 23);
	printAtXY(7,16, itoa(characters[i].cc));
	printAtXY(11,16, itoa(characters[i].ct));
	printAtXY(15,16, itoa(characters[i].fo));
	printAtXY(19,16, itoa(characters[i].ag));
	printAtXY(23,16, itoa(characters[i].in));
	printAtXY(27,16, itoa(characters[i].fm));
	// affichage du sac à dos
	for(j=0;j<6;j++) {
		printAtXY(5,18+j, itoa(j+1));
		if (characters[i].sad[j]!=0) {
			if (characters[i].sad[j]-1<nbTextes)
			    printAtXY(8,18+j, textesItems[characters[i].sad[j]-1]);
			else
				printAtXY(8,18+j, "objet bugge");
		} else {
			printAtXY(8,18+j, "..............");
		}
	}
	// les morts et les paralysés ne peuvent pas lancer de sorts!
	if (characters[i].cp>3 && characters[i].ok<3)
		printTitle(10,25, A_BGRED, " <ESPACE> : SORTS ", 18);
	else
		printTitle(10,25, A_BGRED, " <ESPACE> : RETOUR", 18);
	printTitle(4,26, A_BGBLUE, " DONNER :  ", 11);
	printTitle(16,26, A_BGRED, " A)rgent O)bjet ? ", 17);
	while(1) {
		a = get();
		if (a=='A') {
			money(i);
			break;
		} else if (a=='O') {
			items(i);
			break;
		} else if (a==' ') {
			if (characters[i].cp>3 && characters[i].ok<3)
				spells(i);
			break;
		} else
			ping();
	}
}