| 1502 | } |
| 1503 | |
| 1504 | void PlayerController::importObject(const json& j, bool noTransform) |
| 1505 | { |
| 1506 | if (!noTransform) |
| 1507 | { |
| 1508 | Controller::importObject(j); |
| 1509 | |
| 1510 | // Teleport to position |
| 1511 | { |
| 1512 | // need to copy since changing position sets the direction of the transform matrix |
| 1513 | auto forward = getEntityTransform().Forward(); |
| 1514 | teleportToPosition(getEntityTransform().Translation()); |
| 1515 | setDirection(-1.0f * forward); |
| 1516 | } |
| 1517 | } |
| 1518 | |
| 1519 | // Set script values |
| 1520 | { |
| 1521 | auto& scriptObj = getScriptInstance(); |
| 1522 | |
| 1523 | scriptObj.instanceSymbol = j["scriptObj"]["instanceSymbol"]; |
| 1524 | scriptObj.id = j["scriptObj"]["id"]; |
| 1525 | |
| 1526 | Utils::putArray(scriptObj.name, j["scriptObj"]["name"]); |
| 1527 | |
| 1528 | // Need this in iso8859-1 again |
| 1529 | //for(std::string& s : scriptObj.name) |
| 1530 | // s = Utils::utf8_to_iso8859_1(s.c_str()); |
| 1531 | |
| 1532 | scriptObj.slot = j["scriptObj"]["slot"]; |
| 1533 | scriptObj.npcType = j["scriptObj"]["npcType"]; |
| 1534 | scriptObj.flags = (Daedalus::GEngineClasses::C_Npc::ENPCFlag)((int)j["scriptObj"]["flags"]); |
| 1535 | |
| 1536 | Utils::putArray(scriptObj.attribute, j["scriptObj"]["attribute"]); |
| 1537 | Utils::putArray(scriptObj.protection, j["scriptObj"]["protection"]); |
| 1538 | Utils::putArray(scriptObj.damage, j["scriptObj"]["damage"]); |
| 1539 | |
| 1540 | scriptObj.damagetype = j["scriptObj"]["damagetype"]; |
| 1541 | scriptObj.guild = j["scriptObj"]["guild"]; |
| 1542 | scriptObj.level = j["scriptObj"]["level"]; |
| 1543 | Utils::putArray(scriptObj.mission, j["scriptObj"]["mission"]); |
| 1544 | scriptObj.fight_tactic = j["scriptObj"]["fight_tactic"]; |
| 1545 | scriptObj.weapon = j["scriptObj"]["weapon"]; |
| 1546 | scriptObj.voice = j["scriptObj"]["voice"]; |
| 1547 | scriptObj.voicePitch = j["scriptObj"]["voicePitch"]; |
| 1548 | scriptObj.bodymass = j["scriptObj"]["bodymass"]; |
| 1549 | scriptObj.daily_routine = j["scriptObj"]["daily_routine"]; |
| 1550 | scriptObj.start_aistate = j["scriptObj"]["start_aistate"]; |
| 1551 | scriptObj.spawnPoint = j["scriptObj"]["spawnPoint"]; |
| 1552 | scriptObj.spawnDelay = j["scriptObj"]["spawnDelay"]; |
| 1553 | scriptObj.senses = j["scriptObj"]["senses"]; |
| 1554 | scriptObj.senses_range = j["scriptObj"]["senses_range"]; |
| 1555 | Utils::putArray(scriptObj.aivar, j["scriptObj"]["aivar"]); |
| 1556 | scriptObj.wp = j["scriptObj"]["wp"]; |
| 1557 | scriptObj.exp = j["scriptObj"]["exp"]; |
| 1558 | scriptObj.exp_next = j["scriptObj"]["exp_next"]; |
| 1559 | scriptObj.lp = j["scriptObj"]["lp"]; |
| 1560 | } |
| 1561 |
no test coverage detected