Esempio n. 1
0
void MenuTalker::nextDialog() {
	bool more = false;

	if (dialog_node != -1) {
		npc->processEvent(dialog_node, event_cursor);
		event_cursor++;
		more = npc->processDialog(dialog_node, event_cursor);
	}
	else {
		more = false;
	}

	if (more)
		createBuffer();
	else {
		if (dialog_node != -1) {
			// return to the topic selection
			int prev_node = dialog_node;
			chooseDialogNode(-1);

			// when returning to the topic selection, a topic is auto-selected if there is only one
			// in this case, we don't want to repeat the same topic, so we check for that here
			if (actions.empty() && dialog_node == prev_node)
				setNPC(NULL);
		}
		else
			setNPC(NULL); // end dialog
	}
}
Esempio n. 2
0
void MenuTalker::chooseDialogNode(int request_dialog_node) {
	event_cursor = 0;

	if(request_dialog_node == -1) {
		// display the topic list (or automatically select a topic if there's only one)
		dialog_node = -1;
		createActionBuffer();

		// need to set the portrait here since we don't call processDialog()
		if (!npc->portraits.empty())
			npc->npc_portrait = npc->portraits[0];

		if (actions.size() == 1 && (!actions[0].is_vendor || first_interaction)) {
			executeAction(0);
		}
		else if (actions.empty()) {
			setNPC(NULL); // end dialog
		}
	}
	else {
		dialog_node = request_dialog_node;
		npc->processEvent(dialog_node, event_cursor);
		if (npc->processDialog(dialog_node, event_cursor))
			createBuffer();
		else
			setNPC(NULL); // end dialog
	}

	first_interaction = false;
}
Esempio n. 3
0
Spawn::Spawn(Spawn& s, uint16_t id)
  : Item(tSpawn, id)
{
  setName(s.name());
  setLastName(s.lastName());
  Item::setPoint(s.x(), s.y(), s.z());
  setPetOwnerID(s.petOwnerID());
  setLight(s.light());
  setGender(s.gender());
  setDeity(s.deity());
  setRace(s.race());
  setClassVal(s.classVal());
  setHP(s.HP());
  setMaxHP(s.maxHP());
  setGuildID(s.GuildID());
  setLevel(s.level());
  for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s.equipment(i));
  setEquipment(tUnknown1, 0);
  setTypeflag(s.typeflag());
  setNPC(s.NPC());
  setAnimation(s.animation());
  setDeltas(s.deltaX(), s.deltaY(), s.deltaZ());
  setHeading(s.heading(), s.deltaHeading());
  setConsidered(s.considered());

  // the new copy will own the spawn track list
  m_spawnTrackList.setAutoDelete(false);
  m_spawnTrackList = s.m_spawnTrackList;
  s.m_spawnTrackList.setAutoDelete(false);
  m_spawnTrackList.setAutoDelete(true);
}
Esempio n. 4
0
Spawn::Spawn(uint16_t id, 
	     int16_t x, int16_t y, int16_t z,
	     int16_t deltaX, int16_t deltaY, int16_t deltaZ,
	     int8_t heading, int8_t deltaHeading,
	     uint8_t animation) 
  : Item(tSpawn, id)
{
  // apply the unknown mob values
  m_name = "unknown";
  setNPC(SPAWN_NPC_UNKNOWN);

  // set what is known
  setPos(x, y, z);
  setDeltas(deltaX, deltaY, deltaZ);
  setHeading(heading, deltaHeading);
  setAnimation(animation);
  
  // initialize what isn't to 0
  setPetOwnerID(0);
  setLight(0);
  setGender(0);
  setDeity(0);
  setRace(0);
  setClassVal(0);
  setHP(0);
  setMaxHP(0);
  setLevel(0);
  for (int i = 0; i < tNumWearSlots; i++)
    setEquipment(i, 0);
  setTypeflag(0);
  setConsidered(false);

  // turn on auto delete for the track list
  m_spawnTrackList.setAutoDelete(true);
}
Esempio n. 5
0
//----------------------------------------------------------------------
// Spawn
Spawn::Spawn()
  : Item(tSpawn, 0)
{
  m_name = "fake";
  setNPC(SPAWN_NPC_UNKNOWN);

  Item::setPos(0, 0, 0);
  setDeltas(0, 0, 0);
  setHeading(0, 0);
  setAnimation(0);
  setPetOwnerID(0);
  setLight(0);
  setGender(0);
  setDeity(0);
  setRace(0);
  setClassVal(0);
  setHP(0);
  setMaxHP(0);
  setGuildID(0xffff);
  setGuildTag(NULL);
  setLevel(0);
  setTypeflag(0);
  for (int i = 0; i < tNumWearSlots; i++)
    setEquipment(i, 0);

  // just clear the considred flag since data would be outdated
  setConsidered(false);

  // finally, note when this update occurred.
  updateLast();
}
Esempio n. 6
0
void MenuVendor::logic() {
	if (!visible) return;

	tablist.logic();

	if (TOUCHSCREEN && tablist.getCurrent() == -1) {
		stock[VENDOR_BUY].current_slot = NULL;
		stock[VENDOR_SELL].current_slot = NULL;
	}

	// make sure keyboard navigation leads us to correct tab
	for (unsigned i = 0; i < VENDOR_SLOTS; i++) {
		if (stock[VENDOR_BUY].slots[i]->in_focus) {
			tabControl->setActiveTab(VENDOR_BUY);
			activetab = VENDOR_BUY;
			break;
		}
		else if (stock[VENDOR_SELL].slots[i]->in_focus) {
			tabControl->setActiveTab(VENDOR_SELL);
			activetab = VENDOR_SELL;
			break;
		}
	}

	if (closeButton->checkClick()) {
		setNPC(NULL);
		snd->play(sfx_close);
	}
}
Esempio n. 7
0
Spawn::Spawn(Spawn* s, uint16_t id) : Item(tSpawn, id)
{
    setName(s->name());
    setLastName(s->lastName());
    Item::setPoint(s->x(), s->y(), s->z());
    setPetOwnerID(s->petOwnerID());
    setLight(s->light());
    setGender(s->gender());
    setDeity(s->deity());
    setRace(s->race());
    setClassVal(s->classVal());
    setHP(s->HP());
    setMaxHP(s->maxHP());
    setGuildID(s->guildID());
    setLevel(s->level());
    for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s->equipment(i));
    setEquipment(tUnknown1, SlotEmpty);
    setTypeflag(s->typeflag());
    setGM(s->gm());
    setNPC(s->NPC());
    setAnimation(s->animation());
    setDeltas(s->deltaX(), s->deltaY(), s->deltaZ());
    setHeading(s->heading(), s->deltaHeading());
    setConsidered(s->considered());

    // the new copy will own the spawn track list
    m_spawnTrackList.setAutoDelete(false);
    m_spawnTrackList = s->m_spawnTrackList;
    s->m_spawnTrackList.setAutoDelete(false);
    m_spawnTrackList.setAutoDelete(true);
}
Esempio n. 8
0
void MenuVendor::logic() {
	if (!visible) return;

	tablist.logic();
	tablist_buy.logic();
	tablist_sell.logic();

	tabControl->logic();
	if (TOUCHSCREEN && activetab != tabControl->getActiveTab()) {
		tablist_buy.defocus();
		tablist_sell.defocus();
	}
	activetab = tabControl->getActiveTab();

	if (activetab == VENDOR_BUY)
		tablist.setNextTabList(&tablist_buy);
	else if (activetab == VENDOR_SELL)
		tablist.setNextTabList(&tablist_sell);

	if (TOUCHSCREEN) {
		if (activetab == VENDOR_BUY && tablist_buy.getCurrent() == -1)
			stock[VENDOR_BUY].current_slot = NULL;
		else if (activetab == VENDOR_SELL && tablist_sell.getCurrent() == -1)
			stock[VENDOR_SELL].current_slot = NULL;
	}

	if (closeButton->checkClick()) {
		setNPC(NULL);
		snd->play(sfx_close);
	}
}
Esempio n. 9
0
int main(void){
	char* map = initMap();
	banner(map);
	int input = 0;
	int turn;
	for(turn=5; turn != 0; turn-- ){
		printf("Dein Zug: ");
		if(scanf("%d", &input) <= 0){
			printf("\nFehler bei der Eingabe!\n");
			while(getchar() != '\n');
			turn++;
			continue;
		}
		if(setMap(map, input) == 0){
			if(check(map) != 0) break;
			outMap(map);
			printf("Gegner ist am Zug:\n");
			setNPC(map);
			outMap(map);
			if(check(map) != 0) break;
		}
		else{
			turn++;
		}
	}
	printf("Der Sieger ist...\n");
	//Das kann man bestimmt auch besser machen..
	int result = check(map);
	if(result == 0) printf("Niemand\n");
	else if(result == 1) printf("Der Spieler\n");
	else if(result == 2) printf("Der Computer\n");
	free(map);
	writeRecord(result);
	return 0;
}
Esempio n. 10
0
void Spawn::update(const spawnStruct* s)
{
  if (m_name.find(Spawn_Corpse_Designator) == -1)
  {
    setName(s->name);
    setLastName(s->lastName);
  }

  setPos(s->x >> 3, s->y >> 3, s->z >> 3);
  setPetOwnerID(s->petOwnerId);
  setLight(s->light);
  setGender(s->gender);
  setDeity(s->deity);
  setRace(s->race);
  setClassVal(s->class_);
  setHP(s->curHp);
  //setMaxHP(s->maxHp);
  setMaxHP(s->curHp); //maxHp is no longer part of the struct
  setGuildID(s->guildID);
  setLevel(s->level);
  for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s->equipment[i]);
  setEquipment(tUnknown1, 0);

  setTypeflag(s->bodytype);
  setGM(s->gm);

  // If it is a corpse with Unknown (NPC) religion.
  if ((s->NPC == SPAWN_PC_CORPSE) && (s->deity == DEITY_UNKNOWN))
    setNPC(SPAWN_NPC_CORPSE); // it's a dead monster
  else
    setNPC(s->NPC); // otherwise it is what it is

  setAnimation(s->animation);

  // only non corpses and things with animation != 66 move
  if (!isCorpse() && (s->animation != 66))
  {
    setDeltas(s->deltaX >> 2, s->deltaY >> 2, s->deltaZ >> 2);
    setHeading(s->heading, s->deltaHeading);
  }
Esempio n. 11
0
/**
 * Menu interaction (enter/space/click to continue)
 */
void MenuTalker::logic() {

    if (!visible || npc==NULL) return;

    tablist.logic();

    advanceButton->enabled = false;
    closeButton->enabled = false;

    // determine active button
    if (static_cast<unsigned>(dialog_node) < npc->dialog.size() && !npc->dialog[dialog_node].empty() && event_cursor < npc->dialog[dialog_node].size()-1) {
        if (npc->dialog[dialog_node][event_cursor+1].type != EC_NONE) {
            advanceButton->enabled = true;
            tablist.remove(closeButton);
            tablist.add(advanceButton);
        }
        else {
            closeButton->enabled = true;
            tablist.remove(advanceButton);
            tablist.add(closeButton);
        }
    }
    else {
        closeButton->enabled = true;
        tablist.remove(advanceButton);
        tablist.add(closeButton);
    }

    bool more;
    if (advanceButton->checkClick() || closeButton->checkClick()) {
        // button was clicked
        npc->processEvent(dialog_node, event_cursor);
        event_cursor++;
        more = npc->processDialog(dialog_node, event_cursor);
    }
    else if	(inpt->pressing[ACCEPT] && !inpt->lock[ACCEPT]) {
        inpt->lock[ACCEPT] = true;
        // pressed next/more
        npc->processEvent(dialog_node, event_cursor);
        event_cursor++;
        more = npc->processDialog(dialog_node, event_cursor);
    }
    else {
        textbox->logic();
        return;
    }

    if (more) {
        createBuffer();
    }
    else {
        // show the NPC Action Menu
        menu->npc->setNPC(npc);

        if (!menu->npc->selection())
            menu->npc->visible = true;
        else
            menu->npc->setNPC(NULL);

        // end dialog
        setNPC(NULL);
    }
}