void Actor::ExamineUnit(ui::Gui &table, const Point &start, const Point &range) const { Point nameplate = start.Moved(Point(1, 0)); Point hp = start.Moved(Point(1, 2)); Point mp = start.Moved(Point(1, 4)); Point effect_position = start.Moved(Point(1, 6)); // name Name name = GetName(); if (name.length() > 0) { table.SetTextColor(Color(1, 1, 1)); table.Write(nameplate, name); } // bars int bar_length = range.X - 2; int current_health = GetCurrentHealth(); int max_health = GetMaximumHealth(); int current_energy = GetCurrentEnergy(); int max_energy = GetMaximumEnergy(); max_health = (max_health == 0) ? 1 : max_health; max_energy = (max_energy == 0) ? 1 : max_energy; int green = bar_length * current_health / max_health; green = (green == 0 && current_health > 0) ? 1 : green; green = (green < 0) ? 0 : green; int blue = bar_length * current_energy / max_energy; blue = (blue == 0 && current_energy > 0) ? 1 : blue; blue = (blue < 0) ? 0 : blue; table.Rectangle(hp, Point(green, 1), 0x085200); table.Rectangle(hp.Moved(Point(green, 0)), Point(bar_length - green, 1), 0x642800); table.Rectangle(mp, Point(blue, 1), 0x6b839c); table.Rectangle(mp.Moved(Point(blue, 0)), Point(bar_length - blue, 1), 0xf0bf9f); table.SetTextColor(0x1f0c00); table.WriteInteger(hp.Moved(Point(bar_length - 1, 0)), current_health); table.WriteInteger(mp.Moved(Point(bar_length - 1, 0)), current_energy); table.Write(hp.Moved(Point(1, 0)), "HP"); table.Write(mp.Moved(Point(1, 0)), "EP"); // effects table.SetTextColor(Color(1, 1, 1)); for (auto i = _effects.cbegin(); i != _effects.cend(); ++i) { table.Write(effect_position, i->GetName()); effect_position.Y += 2; } }
Ability::Ability(AbilityID id, const Name &name, const DescriptionText &desc, ScriptInterface &scriptIF) :m_scriptIF(scriptIF) { //Verify input parameters assert(id > 0); assert(name.length() > 0); assert(desc.length() > 0); m_ID = id; m_name.assign(name); m_description.assign(desc); char file[64], moduleName[64]; sprintf(file, "data/scripts/afx/0x%03x.as", id); sprintf(moduleName, "afx:0x%03x", id); m_scriptModuleID = scriptIF.createModuleFromFile(Name(moduleName), Filename(file)); m_scriptContextID = scriptIF.createContext(); }