void ezQtEngineViewWidget::mouseMoveEvent(QMouseEvent* e) { s_InteractionContext.m_pLastHoveredViewWidget = this; s_InteractionContext.m_pLastPickingResult = &m_LastPickingResult; // kick off the picking PickObject(e->pos().x(), e->pos().y()); // if a context is active, it gets exclusive access to the input data if (ezEditorInputContext::IsAnyInputContextActive()) { if (ezEditorInputContext::GetActiveInputContext()->MouseMoveEvent(e) == ezEditorInput::WasExclusivelyHandled) { e->accept(); return; } } if (ezEditorInputContext::IsAnyInputContextActive()) { e->accept(); return; } // Override context { ezEditorInputContext* pOverride = GetDocumentWindow()->GetDocument()->GetEditorInputContextOverride(); if (pOverride != nullptr) { if (pOverride->MouseMoveEvent(e) == ezEditorInput::WasExclusivelyHandled || ezEditorInputContext::IsAnyInputContextActive()) return; } } // if no context is active, pass the input through in a certain order, until someone handles it for (auto pContext : m_InputContexts) { if (pContext->MouseMoveEvent(e) == ezEditorInput::WasExclusivelyHandled || ezEditorInputContext::IsAnyInputContextActive()) { e->accept(); return; } } QWidget::mouseMoveEvent(e); }
static void EndRubberBand ( Widget w, XtPointer clientData, XEvent *event, Boolean *flag ) { /* * Finalize the operation begun with StartRubberBand(). If there * a current drawing function, clear the last XOR image and draw * the final figure. */ if ( currentFunction && event->xbutton.button == Button1 ) { /* * Erase the XOR image. */ ( * ( currentFunction ) ) ( XtWindow ( w ), xorGC, startX, startY, lastX, lastY ); /* * Draw the figure using the normal GC. */ ( * ( currentFunction ) ) ( XtWindow ( w ), currentGC, startX, startY, event->xbutton.x, event->xbutton.y ); /* * Update the data, and store the object in * the display list. */ lastX = event->xbutton.x; lastY = event->xbutton.y; StoreObject(); currentObject = PickObject ( event->xbutton.x, event->xbutton.y ); } else if ( currentObject && !currentFunction && event->xbutton.button == Button1 ) { /* * If the operation was a drag, move the figure * to its final position. */ MoveObject ( currentObject, event->xbutton.x - lastX, event->xbutton.y - lastY ); /* * Force a complete redraw. */ XClearArea ( display, XtWindow ( w ), 0, 0, 0, 0, TRUE ); } }
static void StartRubberBand ( Widget w, XtPointer clientData, XEvent *event, Boolean *flag ) { /* * Ignore any events other than a button press for * mouse button one. */ if ( event->xbutton.button != Button1 ) return; if ( currentFunction ) { /* * If there is a current drawing function, call it to * start positioning the new figure. */ XGCValues values; /* * Get a GC for the current colors */ values.foreground = currentForeground; values.background = background; currentGC = XtGetGC ( w, GCBackground | GCForeground, &values ); /* * Store the starting point and draw the initial figure. */ lastX = startX = event->xbutton.x; lastY = startY = event->xbutton.y; ( * ( currentFunction ) ) ( XtWindow ( w ), xorGC, startX, startY, lastX, lastY ); } else if ( !currentFunction && event->xbutton.button == Button1 ) { /* * If there is no current function, treat Button1 * as a pointer and find the graphics object the mouse * cursor is pointing to. */ lastX = startX = event->xbutton.x; lastY = startY = event->xbutton.y; currentObject = PickObject ( event->xbutton.x, event->xbutton.y ); if ( currentObject ) { /* * If an object was found, any mouse motion will move * the object. Get a new graphics context whose colors * match the colors of the current object. */ XGCValues values; XtReleaseGC ( w, xorGC ); values.foreground = currentObject->foreground ^ background; values.function = GXxor; /* * Change the color of the rubber band gc */ xorGC = XtGetGC ( w, GCForeground | GCFunction, &values ); } } }
void Object::DynamicInit1() { // Dwarven mine const char* names[] = {"An Entrance to a Large Mining Tunnel", "A Large Mining Tunnel", "A Large Mining Tunnel with a Small Tunnel to One Side", "A Large Mining Tunnel", "A Large Open Chamber", "A Small Mining Tunnel", "A Bend in a Small Mining Tunnel", "A Fork in a Small Mining Tunnel", "A Small Alcove"}; const char* descs[] = { "This tunnel looks to have been carved centuries ago. It is so well " "crafted\n" "that you think it will stand as-is for another millenia.\n", "This tunnel looks to have been carved centuries ago. It is so well " "crafted\n" "that you think it will stand as-is for another millenia.\n", "This tunnel looks to have been carved centuries ago. It is so well " "crafted\n" "that you think it will stand as-is for another millenia. Another less\n" "well-supported tunnel leads off in another direction.\n", "This tunnel looks to have been carved centuries ago. It is so well " "crafted\n" "that you think it will stand as-is for another millenia.\n", "This is a large natural-looking opening. Perhaps this is where some of " "the\n" "miners removed a large vein of ore, or maybe this cavern was just here " "due\n" "to natural forces before they even got here. It seems the dwarves have " "used\n" "this tunnel for more than just mining work - a large cage here looks " "well\n" "used.\n", "This tunnel looks to have been carved quickly. It looks like it might\n" "collapse at any moment.\n", "This bend in the tunnel looks to have been carved quickly. It looks " "like it\n" "might collapse at any moment.\n", "This tunnel fork looks to have been carved quickly. It looks like it\n" "might collapse at any moment.\n", "The tunnel comes to an end in a rough opening here.\n"}; static MOBType* dwarf_miner; static MOBType* dwarf_engineer; static MOBType* dwarf_guard; static MOBType* dwarf_explorer; static MOBType* elf_prisoner; if (!dwarf_miner) { WeaponType* weap; ArmorType* arm; dwarf_miner = new MOBType( "a dwarf miner", "{He} looks pissed.", "", "M", 7, 7, 4, 5, 6, 7, 2, 2, 4, 3, 8, 7, 500, 2001); dwarf_miner->Skill("Two-Handed Cleaves", 100, 4); weap = new WeaponType( "a dwarven mining pickaxe", "A super-strong, super-sharp, super-heavy pickaxe.", "", "Two-Handed Cleaves", 2, 2, 7, 3, 3, 20000, 50, 2000); dwarf_miner->Arm(weap); arm = new ArmorType( "a dwarven leather jerkin", "A heavy dwarven leather jerkin. It'll probably stop an arrow.", "", 3, 2, 2, 2, 0, 0, 1, 0, 10000, 10, 150, ACT_WEAR_CHEST, ACT_WEAR_BACK); dwarf_miner->Armor(arm); dwarf_engineer = new MOBType( "a dwarf engineer", "She looks pissed.", "", "F", 5, 7, 4, 5, 5, 7, 3, 2, 5, 3, 8, 7, 2000, 8001); dwarf_engineer->Skill("Long Cleaves", 100, 2); weap = new WeaponType( "a dwarven combat axe", "A super-strong, super-sharp combat axe.", "", "Long Cleaves", 1, 2, 7, 2, 2, 4000, 10, 1000); dwarf_engineer->Arm(weap); arm = new ArmorType( "a dwarven leather jerkin", "A heavy dwarven leather jerkin. It'll probably stop an arrow.", "", 3, 2, 2, 2, 0, 0, 1, 0, 10000, 10, 150, ACT_WEAR_CHEST, ACT_WEAR_BACK); dwarf_engineer->Armor(arm); dwarf_guard = new MOBType( "a dwarf guard", "{He} looks pissed.", "", "MF", 9, 4, 6, 4, 9, 4, 1, 3, 5, 4, 9, 4, 100, 401); dwarf_guard->Skill("Two-Handed Cleaves", 100, 4); weap = new WeaponType( "a dwarven war axe", "A super-strong, super-sharp, super-heavy, high-quality war axe.", "", "Two-Handed Cleaves", 2, 4, 6, 4, 2, 20000, 40, 5000); dwarf_guard->Arm(weap); arm = new ArmorType( "a dwarven heavy breastplate", "A heavy dwarven breastplate. It'll probably stop a warhammer.", "", 8, 4, 6, 2, 4, 2, 10, 5, 200000, 100, 15000, ACT_WEAR_CHEST, ACT_WEAR_BACK); dwarf_guard->Armor(arm); arm = new ArmorType( "a dwarven great helm", "A heavy dwarven great helm. It'll probably stop a warhammer.", "", 8, 4, 6, 2, 4, 2, 10, 5, 50000, 70, 5000, ACT_WEAR_HEAD); dwarf_guard->Armor(arm); arm = new ArmorType( "a dwarven arm plate (right)", "A heavy dwarven arm plate. It'll probably stop a warhammer.", "", 8, 4, 6, 2, 4, 2, 10, 5, 50000, 60, 5000, ACT_WEAR_RARM); dwarf_guard->Armor(arm); arm = new ArmorType( "a dwarven arm plate (left)", "A heavy dwarven arm plate. It'll probably stop a warhammer.", "", 8, 4, 6, 2, 4, 2, 10, 5, 50000, 60, 5000, ACT_WEAR_LARM); dwarf_guard->Armor(arm); arm = new ArmorType( "a dwarven battle skirt", "A heavy dwarven battle skirt. It'll probably stop a warhammer.", "", 8, 4, 6, 2, 4, 2, 10, 5, 100000, 80, 10000, ACT_WEAR_RLEG, ACT_WEAR_LLEG); dwarf_guard->Armor(arm); dwarf_explorer = new MOBType( "a dwarf explorer", "{He} looks pissed.", "", "MF", 5, 4, 5, 4, 6, 4, 3, 2, 6, 4, 9, 5, 1000, 4001); dwarf_explorer->Skill("Long Cleaves", 100, 4); weap = new WeaponType( "a dwarven climbing pick", "A super-sharp, lightweight pick.", "", "Long Cleaves", 1, 1, 3, 3, 1, 2000, 10, 500); dwarf_explorer->Arm(weap); arm = new ArmorType( "a dwarven leather jerkin", "A heavy dwarven leather jerkin. It'll probably stop an arrow.", "", 3, 2, 2, 2, 0, 0, 1, 0, 10000, 10, 150, ACT_WEAR_CHEST, ACT_WEAR_BACK); dwarf_explorer->Armor(arm); elf_prisoner = new MOBType( "an elf slave", "This elf looks like {he}'s been a " "prisoner longer than you've been alive.", "", "MF", 4, 2, 8, 4, 5, 2, 8, 2, 7, 4, 4, 4, 0, 0); elf_prisoner->Skill("Carromeleg - Tier I", 2); elf_prisoner->Skill("Carromeleg - Tier II", 2); elf_prisoner->Skill("Carromeleg - Tier III", 2); elf_prisoner->Skill("Carromeleg - Tier IV", 2); elf_prisoner->Skill("Carromeleg - Tier V", 2); elf_prisoner->Skill("Carromeleg - Tier VI", 2); } int mojo = Skill("DynamicMojo"); SetSkill("DynamicMojo", 0); // Tree structure, start with one door - dir of travel is opposite it. const char* dirb = "south"; const char* dir = "north"; const char* dir2 = "west"; const char* dir3 = "east"; if (PickObject("north", LOC_INTERNAL) != NULL) { dirb = "north"; dir = "south"; dir2 = "east"; dir3 = "west"; } else if (PickObject("east", LOC_INTERNAL) != NULL) { dirb = "east"; dir = "west"; dir2 = "south"; dir3 = "north"; } else if (PickObject("west", LOC_INTERNAL) != NULL) { dirb = "west"; dir = "east"; dir2 = "north"; dir3 = "south"; } // Up and Down shafts are handled specially. switch (Skill("DynamicPhase")) { case (0): { // Entrance if (mojo == 0) mojo = 100000; Object* next = new Object(parent); next->SetShortDesc(names[1]); next->SetDesc(descs[1]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", 1); // Major Shaft next->SetSkill("DynamicMojo", mojo - 1000); Object* door1 = new Object(this); Object* door2 = new Object(next); door1->SetShortDesc(dir); door2->SetShortDesc(dirb); door1->SetDesc((string("You see a solid passage leading ") + dir + ".\n").c_str()); door2->SetDesc((string("You see a solid passage leading ") + dirb + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); } break; case (1): { // Major Shaft if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 10) { mojo -= 500; AddMOB(dwarf_engineer); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } if (mojo <= 0) break; // End of Tunnel int ntypes[] = {1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 4}; int ntype = ntypes[rand() % (sizeof(ntypes) / sizeof(int))]; Object* next = new Object(parent); next->SetShortDesc(names[ntype]); next->SetDesc(descs[ntype]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", ntype); next->SetSkill("DynamicMojo", mojo - 1000); Object* door1 = new Object(this); Object* door2 = new Object(next); door1->SetShortDesc(dir); door2->SetShortDesc(dirb); door1->SetDesc((string("You see a solid passage leading ") + dir + ".\n").c_str()); door2->SetDesc((string("You see a solid passage leading ") + dirb + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); } break; case (2): { // Major Shaft w/ Minor Offshoot if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 10) { mojo -= 500; AddMOB(dwarf_engineer); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } if (mojo <= 0) break; // End of Tunnel int ntypes[] = {1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 4}; int ntype = ntypes[rand() % (sizeof(ntypes) / sizeof(int))]; Object* next = new Object(parent); next->SetShortDesc(names[ntype]); next->SetDesc(descs[ntype]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", ntype); next->SetSkill("DynamicMojo", (mojo - 1000) * 9 / 10); Object* door1 = new Object(this); Object* door2 = new Object(next); door1->SetShortDesc(dir); door2->SetShortDesc(dirb); door1->SetDesc((string("You see a solid passage leading ") + dir + ".\n").c_str()); door2->SetDesc((string("You see a solid passage leading ") + dirb + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); if (rand() % 2) swap(dir2, dir3); // Half left, half right next = new Object(parent); next->SetShortDesc(names[5]); next->SetDesc(descs[5]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", 5); // Minor Shaft next->SetSkill("DynamicMojo", (mojo - 1000) / 10); door1 = new Object(this); door2 = new Object(next); door1->SetShortDesc(dir2); door2->SetShortDesc(dir3); door1->SetDesc((string("You see a crumbling passage leading ") + dir2 + ".\n").c_str()); door2->SetDesc((string("You see a crumbling passage leading ") + dir3 + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); } break; case (3): { // Major Shaft w/ Secret Minor Offshoot if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 10) { mojo -= 500; AddMOB(dwarf_engineer); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } if (mojo <= 0) break; // End of Tunnel int ntypes[] = {1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 4}; int ntype = ntypes[rand() % (sizeof(ntypes) / sizeof(int))]; Object* next = new Object(parent); next->SetShortDesc(names[ntype]); next->SetDesc(descs[ntype]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", ntype); next->SetSkill("DynamicMojo", (mojo - 1000) * 3 / 4); Object* door1 = new Object(this); Object* door2 = new Object(next); door1->SetShortDesc(dir); door2->SetShortDesc(dirb); door1->SetDesc((string("You see a solid passage leading ") + dir + ".\n").c_str()); door2->SetDesc((string("You see a solid passage leading ") + dirb + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); if (rand() % 2) swap(dir2, dir3); // Half left, half right next = new Object(parent); next->SetShortDesc(names[5]); next->SetDesc(descs[5]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", 5); // Minor Shaft next->SetSkill("DynamicMojo", (mojo - 1000) / 4); door1 = new Object(this); door2 = new Object(next); door1->SetShortDesc(dir2); door2->SetShortDesc(dir3); door1->SetDesc((string("You see a crumbling passage leading ") + dir2 + ".\n").c_str()); door2->SetDesc((string("You see a crumbling passage leading ") + dir3 + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); door1->SetSkill("Hidden", 4 + rand() % 13); } break; case (4): { // Major Chamber if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 10) { mojo -= 500; AddMOB(dwarf_engineer); } if ((rand() % 100) < 10) { mojo -= 500; AddMOB(dwarf_engineer); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_guard); } Object* cage = new Object(this); cage->SetShortDesc("an old strong cage"); cage->SetDesc( "This is a very old, large, rugged cage - probably built by " "dwarves.\n"); cage->SetSkill("Transparent", 900); cage->SetSkill("Container", 100000); cage->SetSkill("Locked", 1); cage->SetSkill("Closeable", 1); if ((rand() % 100) < 20) { mojo -= 500; cage->AddMOB(elf_prisoner); } if ((rand() % 100) < 20) { mojo -= 500; cage->AddMOB(elf_prisoner); } if (mojo <= 0) break; // End of Tunnel int ntypes[] = {1, 1, 1, 1, 1, 1, 1, 2, 2, 3}; int ntype = ntypes[rand() % (sizeof(ntypes) / sizeof(int))]; Object* next = new Object(parent); next->SetShortDesc(names[ntype]); next->SetDesc(descs[ntype]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", ntype); next->SetSkill("DynamicMojo", mojo - 1000); Object* door1 = new Object(this); Object* door2 = new Object(next); door1->SetShortDesc(dir); door2->SetShortDesc(dirb); door1->SetDesc((string("You see a solid passage leading ") + dir + ".\n").c_str()); door2->SetDesc((string("You see a solid passage leading ") + dirb + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); } break; case (5): { // Minor Shaft if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 10) { mojo -= 500; AddMOB(dwarf_engineer); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_explorer); } if (mojo <= 0) break; // End of Tunnel // int ntypes[] = { 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9 }; int ntypes[] = {5, 5, 5, 5, 5, 6, 6, 7, 7, 8}; int ntype = ntypes[rand() % (sizeof(ntypes) / sizeof(int))]; Object* next = new Object(parent); next->SetShortDesc(names[ntype]); next->SetDesc(descs[ntype]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", ntype); next->SetSkill("DynamicMojo", mojo - 100); Object* door1 = new Object(this); Object* door2 = new Object(next); door1->SetShortDesc(dir); door2->SetShortDesc(dirb); door1->SetDesc((string("You see a crumbling passage leading ") + dir + ".\n").c_str()); door2->SetDesc((string("You see a crumbling passage leading ") + dirb + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); } break; case (6): { // Minor Shaft (Bend) if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 10) { mojo -= 500; AddMOB(dwarf_engineer); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_explorer); } // int ntypes[] = { 5, 5, 5, 5, 5, 6, 6, 7, 7, 8, 9 }; int ntypes[] = {5, 5, 5, 5, 5, 6, 6, 7, 7, 8}; int ntype = ntypes[rand() % (sizeof(ntypes) / sizeof(int))]; if (rand() % 2) swap(dir2, dir3); // Half left, half right Object* next = new Object(parent); next->SetShortDesc(names[ntype]); next->SetDesc(descs[ntype]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", ntype); next->SetSkill("DynamicMojo", mojo - 100); Object* door1 = new Object(this); Object* door2 = new Object(next); door1->SetShortDesc(dir2); door2->SetShortDesc(dir3); door1->SetDesc((string("You see a crumbling passage leading ") + dir2 + ".\n").c_str()); door2->SetDesc((string("You see a crumbling passage leading ") + dir3 + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); } break; case (7): { // Minor Shaft Fork if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 10) { mojo -= 500; AddMOB(dwarf_engineer); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_explorer); } // int ntypes[] = { 5, 5, 5, 5, 5, 6, 6, 7, 7, 8, 9 }; int ntypes[] = {5, 5, 5, 5, 5, 6, 6, 7, 7, 8}; int ntype = ntypes[rand() % (sizeof(ntypes) / sizeof(int))]; Object* next = new Object(parent); next->SetShortDesc(names[ntype]); next->SetDesc(descs[ntype]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", ntype); next->SetSkill("DynamicMojo", (mojo - 100) / 2); Object* door1 = new Object(this); Object* door2 = new Object(next); door1->SetShortDesc(dir2); door2->SetShortDesc(dir3); door1->SetDesc((string("You see a crumbling passage leading ") + dir2 + ".\n").c_str()); door2->SetDesc((string("You see a crumbling passage leading ") + dir3 + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); ntype = ntypes[rand() % (sizeof(ntypes) / sizeof(int))]; swap(dir2, dir3); // Same code, opposite dir. next = new Object(parent); next->SetShortDesc(names[ntype]); next->SetDesc(descs[ntype]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", ntype); next->SetSkill("DynamicMojo", (mojo - 100) / 2); door1 = new Object(this); door2 = new Object(next); door1->SetShortDesc(dir2); door2->SetShortDesc(dir3); door1->SetDesc((string("You see a crumbling passage leading ") + dir2 + ".\n").c_str()); door2->SetDesc((string("You see a crumbling passage leading ") + dir3 + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); } break; case (8): { // Minor Shaft Alcove if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 30) { mojo -= 500; AddMOB(dwarf_miner); } if ((rand() % 100) < 10) { mojo -= 500; AddMOB(dwarf_engineer); } if ((rand() % 100) < 20) { mojo -= 500; AddMOB(dwarf_explorer); } if (mojo <= 0) break; // End of Tunnel if (mojo > 10000 && (rand() % 100) < 20) { mojo -= 5000; int option = rand() % 100; if (option >= 70) { swap(dir, dir2); swap(dirb, dir3); } else if (option >= 70) { swap(dir, dir3); swap(dirb, dir2); } } else { // No secret tunnels here! break; } int ntype = 5; Object* next = new Object(parent); next->SetShortDesc(names[ntype]); next->SetDesc(descs[ntype]); next->SetSkill("DynamicInit", 1); next->SetSkill("DynamicPhase", ntype); next->SetSkill("DynamicMojo", mojo - 500); Object* door1 = new Object(this); Object* door2 = new Object(next); door1->SetShortDesc(dir); door2->SetShortDesc(dirb); door1->SetDesc((string("You see a crumbling passage leading ") + dir + ".\n").c_str()); door2->SetDesc((string("You see a crumbling passage leading ") + dirb + ".\n").c_str()); door1->AddAct(ACT_SPECIAL_LINKED, door2); door1->AddAct(ACT_SPECIAL_MASTER, door2); door1->SetSkill("Open", 1000); door1->SetSkill("Enterable", 1); door2->AddAct(ACT_SPECIAL_LINKED, door1); door2->AddAct(ACT_SPECIAL_MASTER, door1); door2->SetSkill("Open", 1000); door2->SetSkill("Enterable", 1); door1->SetSkill("Hidden", 4 + rand() % 13); } break; default: { fprintf( stderr, "Unknown dynamic-phase-type (%d-%d) init requested!\n", Skill("DynamicInit"), Skill("DynamicPhase")); } break; } SetSkill("DynamicPhase", 0); }
void Editor::Update(void){ float movement_speed = time->GetFrameTime() * 2.0f; if (input->IsKeyDown(EG::Input::v)) { movement_speed /= 100.0f; } if (pick_object) { PickObject(input->GetMousePosition()); pick_object = false; } if (input->IsMouseDown(EG::Input::mouse_right)){ scene->GetCurrentCamera()->RotateByMouse(input->GetMouseDelta()); } if (input->IsKeyDown(EG::Input::q)){ scene->GetCurrentCamera()->Rotate(glm::vec3(0.0f, 0.0f, -movement_speed)); } if (input->IsKeyDown(EG::Input::e)){ scene->GetCurrentCamera()->Rotate(glm::vec3(0.0f, 0.0f, movement_speed)); } if (input->IsKeyDown(EG::Input::w)){ scene->GetCurrentCamera()->Move(glm::vec3(0.0f, 0.0f, -movement_speed)); } if (input->IsKeyDown(EG::Input::s)){ scene->GetCurrentCamera()->Move(glm::vec3(0.0f, 0.0f, movement_speed)); } if (input->IsKeyDown(EG::Input::a)){ scene->GetCurrentCamera()->Move(glm::vec3(-movement_speed, 0.0f, 0.0f)); } if (input->IsKeyDown(EG::Input::d)){ scene->GetCurrentCamera()->Move(glm::vec3(movement_speed, 0.0f, 0.0f)); } if (input->IsKeyDown(EG::Input::space)){ scene->GetCurrentCamera()->Move(glm::vec3(0.0f, movement_speed, 0.0f)); } if (input->IsKeyDown(EG::Input::c)){ scene->GetCurrentCamera()->Move(glm::vec3(0.0f, -movement_speed, 0.0f)); } if (input->IsKeyPressed(EG::Input::t)){ if (rendering_method == RENDERER_DEFERRED){ (static_cast<EG::Graphics::RendererDeferred *>(renderer))->CycleOutputType(); } } if (input->IsKeyPressed(EG::Input::b)){ if (rendering_method == RENDERER_DEFERRED){ (static_cast<EG::Graphics::RendererDeferred *>(renderer))->ToggleBloom(); } } if (input->IsKeyPressed(EG::Input::o)){ if (rendering_method == RENDERER_DEFERRED){ (static_cast<EG::Graphics::RendererDeferred *>(renderer))->ToggleSSAO(); } } if (input->IsKeyPressed(EG::Input::n)){ if (rendering_method == RENDERER_DEFERRED){ (static_cast<EG::Graphics::RendererDeferred *>(renderer))->ToggleNormalMapping(); } } if (input->IsKeyPressed(EG::Input::m)){ if (rendering_method == RENDERER_DEFERRED){ (static_cast<EG::Graphics::RendererDeferred *>(renderer))->ToggleShadowMapping(); } } if (input->IsKeyPressed(EG::Input::f)){ if (rendering_method == RENDERER_DEFERRED){ (static_cast<EG::Graphics::RendererDeferred *>(renderer))->ToggleDOF(); } } physics->Update(time->GetFrameTime()); }