void game::generate_library() { m_library = std::make_shared<library>(); // buffs rl::person::status_t poison(10, [&](rl::person &c, rl::person::status_t &s) { c.health() = c.health() - 1; }); poison.register_apply([&](rl::person &target, rl::person::status_t &s) { m_broadcasts.emplace_back("* poisoned *", color(0, 1, 0), target.position(), 0.5); }); poison.appearance({ '-', 0xffff00 }); poison.name("Poison"); poison.tag("poison"); m_library->insert(poison); // skills rl::person::action_t::range_t bite_range(0, 1); rl::person::action_t bite(rl::person::action_t::target_fn([&](rl::person::caster_t *user, rl::person::target_t unit) { if (user && unit) { point start = user->position(); // status //unit->accept(rl::effect(m_library->prototype<rl::person::status_t>("poison"))); // popup m_broadcasts.emplace_back(std::to_string(-8), color(1, 0, 0), unit->position(), 0.75); // visual m_projectiles.push_back(projectile({ '>', 0xff0000 }, {}, [start, unit](projectile::timespan_t phase) { point fin = unit->position(); vector pos = fin + vector((fin - start).normalized()) * -0.25; vector up = pos + vector(0, 0.25); return up.lerp(pos, (std::min)(phase, 1.0)); }, 3.14 * -0.5, 0.25)); m_projectiles.push_back(projectile({ '>', 0xff0000 }, {}, [start, unit](projectile::timespan_t phase) { point fin = unit->position(); vector pos = fin + vector((fin - start).normalized()) * -0.25 + vector(0.15, 0); vector up = pos + vector(0, 0.25); return up.lerp(pos, (std::min)(phase, 1.0)); }, 3.14 * -0.5, 0.25)); m_projectiles.push_back(projectile({ '>', 0xff0000 }, {}, [start, unit](projectile::timespan_t phase) { point fin = unit->position(); vector pos = fin + vector((fin - start).normalized()) * -0.25 - vector(0.15, 0); vector up = pos + vector(0, 0.25); return up.lerp(pos, (std::min)(phase, 1.0)); }, 3.14 * -0.5, 0.25)); m_projectiles.push_back(projectile({ '>', 0xff0000 }, {}, [start, unit](projectile::timespan_t phase) { point fin = unit->position(); vector pos = fin + vector((fin - start).normalized()) * -0.25; vector down = pos - vector(0, 0.25); return down.lerp(pos, (std::min)(phase, 1.0)); }, 3.14 * 0.5, 0.25)); m_projectiles.push_back(projectile({ '>', 0xff0000 }, {}, [start, unit](projectile::timespan_t phase) { point fin = unit->position(); vector pos = fin + vector((fin - start).normalized()) * -0.25 + vector(0.15, 0); vector down = pos - vector(0, 0.25); return down.lerp(pos, (std::min)(phase, 1.0)); }, 3.14 * 0.5, 0.25)); m_projectiles.push_back(projectile({ '>', 0xff0000 }, {}, [start, unit](projectile::timespan_t phase) { point fin = unit->position(); vector pos = fin + vector((fin - start).normalized()) * -0.25 - vector(0.15, 0); vector down = pos - vector(0, 0.25); return down.lerp(pos, (std::min)(phase, 1.0)); }, 3.14 * 0.5, 0.25)); } }), rl::person::action_t::target_check_fn([&, bite_range](rl::person::caster_t *user, rl::person::target_t unit) { return user && unit && user != unit.get() && rl::person::action_t::in_range(bite_range, distance(user->position(), unit->position())); })); bite.name("Bite"); bite.range(bite_range); bite.tag("bite"); m_library->insert(bite); rl::person::action_t pyroblast(rl::person::action_t::target_fn([&](rl::person::caster_t *user, rl::person::target_t unit) { if (user) { //broadcast({ "puff!", 0xffffff, user->position() }); } if (user && unit) { vector start = user->position(); vector fin = unit->position(); //m_projectiles.push_back(projectile('*', 0xff0000, color(30, 10, 10), [=](projectile::timespan_t phase) { return start.lerp(fin, (std::min)(phase, 1.0)); })); } }), rl::person::action_t::target_check_fn([&](rl::person::caster_t *user, rl::person::target_t unit) { return true; })); pyroblast.tag("pyroblast"); m_library->insert(pyroblast); // heal rl::person::action_t::ground_fn h([&](rl::person::caster_t *user, const point &position) { user->health() = user->health() + 1; }); rl::person::action_t::ground_check_fn hc([&](rl::person::caster_t *user, const point &position) { return true; }); rl::person::action_t heal(h, hc); heal.tag("heal"); m_library->insert(heal); // teleport rl::person::action_t::ground_fn teleport_fn([&](rl::person::caster_t *user, const point &position) { m_scene->focus(position); m_scene->move(*user, position); }); rl::person::action_t::ground_check_fn teleport_check_fn([&](rl::person::caster_t *user, const point &position) { return true; }); rl::person::action_t teleport(teleport_fn, teleport_check_fn); teleport.tag("teleport"); m_library->insert(teleport); // npc rl::npc rat; rat.fraction(0); rat.appearance({ 'r', 0xff0000, 0.62f }); rat.health() = 100; rat.tag("mob_rat"); rat.name("Rat"); rat.add_skill(bite); m_library->insert(rat); // ore rl::item ore; ore.appearance('o'); ore.name("copper ore"); ore.tag("ore_copper"); ore.stackable(true); m_library->insert(ore); // placeables rl::unit lantern; lantern.appearance({ ' ', color(1, 1, 1) }); lantern.light({ { 3, 3, 3 }, true, true }); lantern.tag("lantern"); m_library->insert(lantern); rl::door door; door.appearance({ ' ', 0x333333 }, { '+', 0x333333 }); door.tag("door"); m_library->insert(door); // items { rl::item ff; ff.name("Firetail Mushroom"); ff.tag("f_red"); m_library->insert(ff); } { rl::item flora; flora.name("Glowing Moss"); flora.tag("f_green"); m_library->insert(flora); } { rl::item flora; flora.name("Cave Lily"); flora.tag("f_blue"); m_library->insert(flora); } // flora rl::deposit f1(m_library->make<rl::item>("f_red")); f1.tag("fireflower"); f1.name("Gribus Ognelisius"); f1.appearance({ '*', color(1, 0, 0), 0.75 }); f1.light({ { 3, 0, 0 }, true, true }); f1.invincible(true); m_library->insert(f1); rl::deposit f2(m_library->make<rl::item>("f_blue")); f2.tag("iceflower"); f2.appearance({ '*', color(0, 0, 1), 0.75 }); f2.light({ { 0, 0, 3 }, true, true }); f2.invincible(true); m_library->insert(f2); rl::deposit flower(m_library->make<rl::item>("f_green")); flower.tag("felflower"); flower.appearance({ '*', color(0, 1, 0), 0.75 }); flower.light({ { 0, 3, 0 }, true, true }); flower.invincible(true); m_library->insert(flower); }
int phTraceOption(String flags) { char phName[PH_NAME_MAXLEN], doPh[PH_LIMIT]; String phases; int i; /* Make "phases" point to string tail after separator. */ for (phases = flags; *phases != 0; phases++) if (*phases == PH_FLAG_SEP) { phases++; break; } if (*flags == PH_FLAG_SEP || *phases == 0) return -1; if (strAEqual(phases, "all")) for (i = PH_START; i < PH_LIMIT; i++) doPh[i] = true; else { for (i = PH_START; i < PH_LIMIT; i++) doPh[i] = false; while (*phases) { phases = bite(phName, phases, '+'); if ((i = phNumber(phName)) == PH_LIMIT) return -1; doPh[i] = true; } } for (i = PH_START; i < PH_LIMIT; i++) { String f; if (!doPh[i]) continue; for (f = flags; *f != 0 && *f != PH_FLAG_SEP; f++) switch (toupper(*f)) { case 'A': phInfo[i].flags |= PHX_Announce; break; case 'D': phInfo[i].flags |= PHX_Debug; break; case 'G': phInfo[i].flags |= PHX_GcAfter; break; case 'P': phInfo[i].flags |= PHX_Print; break; case 'R': phInfo[i].flags |= PHX_Report; break; case 'S': phInfo[i].flags |= PHX_StoAudit; break; case 'T': phInfo[i].flags |= PHX_Terminates; break; case '0': phInfo[i].flags = 0; break; default: return -1; } } return 0; }