20#include <zenkit/addon/daedalus.hh>
81 void save(
Serialize& fout,
size_t id, std::string_view directory);
82 void load(
Serialize& fout,
size_t id, std::string_view directory);
92 auto transform() const -> Tempest::Matrix4x4;
93 auto
position() const -> Tempest::Vec3;
94 auto
cameraBone(
bool isFirstPerson = false) const -> Tempest::Vec3;
95 auto
cameraMatrix(
bool isFirstPerson = false) const -> Tempest::Matrix4x4;
114 void tick(uint64_t dt);
137 void setVisual (std::string_view visual);
141 void addOverlay (std::string_view sk, uint64_t time);
151 int32_t bodyVer, int32_t bodyColor,
152 std::string_view body, std::string_view head);
164 void setScale (
float x,
float y,
float z);
170 bool setAnimItem(std::string_view scheme,
int state);
171 void stopAnim(std::string_view ani);
172 void startFaceAnim(std::string_view anim,
float intensity, uint64_t duration);
174 bool hasAnim(std::string_view scheme) const;
213 uint32_t
guild() const;
219 int32_t
level() const;
312 bool testMove(const Tempest::Vec3& pos);
325 auto dialogChoices(
Npc &player,
const std::vector<uint32_t> &except,
bool includeImp) -> std::vector<GameScript::DlgChoice>;
328 const std::shared_ptr<zenkit::INpc>&
handlePtr()
const {
return hnpc; }
338 void delItem (
size_t id, uint32_t amount);
340 void useItem (
size_t item, uint8_t slotHint,
bool force);
344 void addItem (
size_t id,
Npc& from,
size_t count=1);
346 void sellItem (
size_t id,
Npc& to,
size_t count=1);
347 void buyItem (
size_t id,
Npc& from,
size_t count=1);
348 void dropItem (
size_t id,
size_t count=1);
356 auto
mapBone(std::string_view bone) const -> Tempest::Vec3;
358 bool turnTo (
float dx,
float dz,
bool noAnim, uint64_t dt);
360 bool whirlTo(
float dx,
float dz,
float step, uint64_t dt);
378 bool canSeeNpc(
const Tempest::Vec3 pos,
bool freeLos)
const;
381 bool canRayHitPoint(
const Tempest::Vec3 pos,
bool freeLos =
true,
float extRange=0.f)
const;
384 auto
canSenseNpc(const Tempest::Vec3 pos,
bool freeLos,
bool isNoisy,
float extRange=0.f) const ->
SensesBit;
404 void emitSoundEffect(std::string_view sound,
float range,
bool freeSlot);
405 void emitSoundGround(std::string_view sound,
float range,
bool freeSlot);
413 struct Routine final {
418 std::string fallbackName;
420 std::string_view wayPointName()
const;
423 enum TransformBit : uint8_t {
436 uint64_t loopNextTime=0;
448 Tempest::Vec3 pos = {};
452 Tempest::Vec3 target()
const;
453 bool isClose(
const Npc& self,
float dist)
const;
459 void set(
const Item* to);
460 void set(
const Tempest::Vec3& to);
464 void updateWeaponSkeleton();
466 void tickRegen(int32_t& v,
const int32_t max,
const int32_t chg,
const uint64_t dt);
467 void setViewPosition(
const Tempest::Vec3& pos);
468 bool tickCast(uint64_t dt);
470 int aiOutputOrderId()
const;
473 auto currentRoutine(
bool assertWp =
false) const -> const Routine&;
474 gtime endTime(const Routine& r) const;
476 bool implPointAt(const Tempest::Vec3& to);
477 bool implLookAtWp(uint64_t dt);
478 bool implLookAtNpc(uint64_t dt);
479 bool implLookAt (
float dx,
float dy,
float dz, uint64_t dt);
480 bool implTurnAway(const
Npc& oth, uint64_t dt);
481 bool implTurnTo (const
Npc& oth, uint64_t dt);
484 bool implTurnTo (
float dx,
float dz,
AnimationSolver::TurnType anim, uint64_t dt);
485 bool implWhirlTo(const
Npc& oth, uint64_t dt);
486 bool implGoTo (uint64_t dt);
487 bool implGoTo (uint64_t dt,
float destDist);
488 bool implAttack (uint64_t dt);
489 void adjustAttackRotation(uint64_t dt);
490 bool implAiTick (uint64_t dt);
491 void implAiWait (uint64_t dt);
492 void implAniWait(uint64_t dt);
493 void implFaiWait(uint64_t dt);
494 void implSetFightMode(const
Animation::EvCount& ev);
495 bool implAiFlee(uint64_t dt);
497 bool setGoToLadder();
499 bool isPlayerEnabledState(const ::
AiState& st) const;
501 void nextAiAction(
AiQueue& queue, uint64_t dt);
503 Npc* updateNearestEnemy();
504 Npc* updateNearestBody();
505 bool checkHealth(
bool onChange,
bool forceKill);
506 void onNoHealth(
bool death,
HitSound sndMask);
507 bool hasAutoroll() const;
509 void stopWalkAnimation();
511 void takeFallDamage(const Tempest::Vec3& fallSpeed);
512 void takeDrownDamage();
514 void dropTorch(
bool burnout = false);
521 static
float angleDir(
float x,
float z);
523 uint8_t calcAniComb() const;
524 uint64_t perceptionTimeClampt() const;
526 bool isAlignedToGround() const;
527 Tempest::Vec3 groundNormal() const;
528 Tempest::Matrix4x4 mkPositionMatrix() const;
532 std::shared_ptr<zenkit::INpc> hnpc={};
537 float sz[3]={1.f,1.f,1.f};
540 std::string body,head;
541 int32_t vHead = 0, vTeeth = 0, vColor = 0;
547 uint8_t durtyTranform=0;
548 Tempest::Vec3 lastGroundNormal;
556 uint64_t refuseTalkMilis =0;
563 uint64_t perceptionTime =0;
564 uint64_t perceptionNextTime=0;
569 bool invTorch =
false;
572 Npc* lastHit =
nullptr;
573 char lastHitType =
'A';
574 int32_t lastHitSpell = 0;
578 int32_t manaInvested = 0;
579 int32_t aiExpectedInvest = 1;
580 size_t currentSpellCast = size_t(-1);
581 uint64_t castNextTime = 0;
582 int32_t spellInfo = 0;
585 struct TransformBack;
586 std::unique_ptr<TransformBack> transformSpl;
589 uint64_t aniWaitTime=0;
591 uint64_t faiWaitTime=0;
592 uint64_t outWaitTime=0;
594 uint64_t aiOutputBarrier=0;
600 std::vector<Routine> routines;
603 Npc* currentOther =
nullptr;
604 Npc* currentVictim =
nullptr;
606 const WayPoint* currentLookAt=
nullptr;
607 Npc* currentLookAtNpc=
nullptr;
608 Npc* currentTarget =
nullptr;
609 Npc* nearestEnemy =
nullptr;
612 Tempest::Vec3 moveMobCacheKey={};
622 uint64_t lastEventTime=0;
auto mapHeadBone() const -> Tempest::Vec3
auto mapWeaponBone() const -> Tempest::Vec3
bool startState(ScriptFn id, std::string_view wp)
bool canSeeNpc(const Tempest::Vec3 pos, bool freeLos) const
auto canSenseNpc(const Npc &oth, bool freeLos, float extRange=0.f) const -> SensesBit
auto cameraBone(bool isFirstPerson=false) const -> Tempest::Vec3
void setToFightMode(const size_t item)
void startDialog(Npc &other)
void setTalentSkill(Talent t, int32_t lvl)
auto mapBone(std::string_view bone) const -> Tempest::Vec3
float qDistTo(const Tempest::Vec3 pos) const
bool hasOverlay(std::string_view sk) const
int32_t protection(Protection p) const
auto displayPosition() const -> Tempest::Vec3
auto weaponState() const -> WeaponState
bool canSeeSource() const
bool doAttack(Anim anim, BodyState bs)
bool startClimb(JumpStatus jump)
void stopAnim(std::string_view ani)
GoToHint moveHint() const
Attitude attitude() const
auto currentTaPoint() const -> const WayPoint *
void addRoutine(gtime s, gtime e, uint32_t callback, std::string_view point)
void setRangedWeapon(MeshObjects::Mesh &&bow)
const std::shared_ptr< zenkit::INpc > & handlePtr() const
void takeDamage(Npc &other, const Bullet *b)
auto currentWayPoint() const -> const WayPoint *
auto playAnimByName(std::string_view name, BodyState bs) -> const Animation::Sequence *
bool tryTranslate(const Tempest::Vec3 &to)
bool isInState(ScriptFn stateFn) const
void invalidateTalentOverlays()
bool canSeeNpc(const Npc &oth, bool freeLos) const
void setActiveSpellInfo(int32_t info)
bool drawMage(uint8_t slot)
int32_t experience() const
bool checkGoToNpcdistance(const Npc &other)
void setWalkMode(WalkBit m)
void setShield(MeshObjects::Mesh &&shield)
void emitSoundSVM(std::string_view sound)
Npc * lookAtTarget() const
bool wasInState(ScriptFn stateFn) const
void setVisualBody(int32_t headTexNr, int32_t teethTexNr, int32_t bodyVer, int32_t bodyColor, std::string_view body, std::string_view head)
void changeProtection(Protection p, int32_t val)
auto animMoveSpeed(uint64_t dt) const -> Tempest::Vec3
int32_t hitChance(Talent t) const
void aiPush(AiQueue::AiAction &&a)
size_t itemCount(size_t id) const
float rotationRad() const
void moveItem(size_t id, Interactive &to, size_t count=1)
void setRefuseTalk(uint64_t milis)
bool rotateTo(float dx, float dz, float speed, AnimationSolver::TurnType anim, uint64_t dt)
void setPerceptionDisable(PercType t)
MoveAlgo::JumpStatus JumpStatus
void setDirection(const Tempest::Vec3 &pos)
void setSlotItem(MeshObjects::Mesh &&itm, std::string_view slot)
auto transform() const -> Tempest::Matrix4x4
void updateAnimation(uint64_t dt, bool force=false)
void setAnimRotate(int rot)
void clearState(bool noFinalize)
bool isFallingDeep() const
int32_t talentSkill(Talent t) const
BodyState bodyState() const
bool isUsingTorch() const
bool shootBow(Interactive *focOverride=nullptr)
bool setPosition(float x, float y, float z)
bool hasAnim(std::string_view scheme) const
void setPerceptionEnable(PercType t, size_t fn)
void setProcessPolicy(NpcProcessPolicy t)
int32_t talentValue(Talent t) const
int32_t activeSpellLevel() const
bool hasState(BodyState s) const
int32_t attribute(Attribute a) const
auto detectedMob() const -> Interactive *
void onWldItemRemoved(const Item &itm)
void unequipItem(size_t item)
void processDefInvTorch()
void stopEffect(const VisualFx &vfx)
auto dialogChoices(Npc &player, const std::vector< uint32_t > &except, bool includeImp) -> std::vector< GameScript::DlgChoice >
int32_t experienceNext() const
bool testMove(const Tempest::Vec3 &pos)
auto setAnimAngGet(Anim a) -> const Animation::Sequence *
void setDirectionY(float rotation)
void setVisual(std::string_view visual)
auto inventory() const -> const Inventory &
auto interactive() const -> Interactive *
Item * currentMeleeWeapon()
void runEffect(Effect &&e)
void dropItem(size_t id, size_t count=1)
auto formerPortalName() -> std::string_view
bool closeWeapon(bool noAnim)
bool setAnimItem(std::string_view scheme, int state)
void endCastSpell(bool playerCtrl=false)
AnimationSolver::Anim Anim
auto centerPosition() const -> Tempest::Vec3
void setTalentValue(Talent t, int32_t lvl)
std::string_view displayName() const
void startFaceAnim(std::string_view anim, float intensity, uint64_t duration)
void setSword(MeshObjects::Mesh &&sword)
auto position() const -> Tempest::Vec3
bool isRotationAllowed() const
bool hasPerc(PercType perc) const
void buyItem(size_t id, Npc &from, size_t count=1)
void setRunAngle(float angle)
bool isUnconscious() const
void attachToPoint(const WayPoint *p)
bool perceptionProcess(Npc &pl)
int32_t learningPoints() const
bool isAttackAnim() const
void excRoutine(size_t callback)
void changeAttribute(Attribute a, int32_t val, bool allowUnconscious)
void useItem(size_t item)
void setStateItem(MeshObjects::Mesh &&itm, std::string_view slot)
int32_t magicCyrcle() const
int32_t mageCycle() const
void setStateTime(int64_t time)
bool turnTo(float dx, float dz, bool noAnim, uint64_t dt)
void setPhysic(DynamicWorld::NpcItem &&item)
bool drawSpell(int32_t spell)
void load(Serialize &fout, size_t id, std::string_view directory)
float rotationYRad() const
void sellItem(size_t id, Npc &to, size_t count=1)
bool whirlTo(float dx, float dz, float step, uint64_t dt)
uint32_t instanceSymbol() const
int32_t lastHitSpellId() const
bool setInteraction(Interactive *id, bool quick=false)
bool isAiQueueEmpty() const
void setAiOutputBarrier(uint64_t dt, bool overlay)
bool isRefuseTalk() const
bool hasSwimAnimations() const
bool hasAmmunition() const
void setAttitude(Attitude att)
void setCurrentItem(size_t item)
void delItem(size_t id, uint32_t amount)
bool tryMove(const Tempest::Vec3 &dp)
auto processPolicy() const -> NpcProcessPolicy
bool isTargetableBySpell(TargetType t) const
void save(Serialize &fout, size_t id, std::string_view directory)
auto cameraMatrix(bool isFirstPerson=false) const -> Tempest::Matrix4x4
void emitSoundEffect(std::string_view sound, float range, bool freeSlot)
void setTempAttitude(Attitude att)
Item * currentRangedWeapon()
Attitude tempAttitude() const
bool isInRoutine(ScriptFn stateFn) const
void setScale(float x, float y, float z)
void addOverlay(std::string_view sk, uint64_t time)
void setDetectedMob(Interactive *id)
uint64_t percNextTime() const
Item * addItem(size_t id, size_t amount)
uint64_t stateTime() const
Item * getItem(size_t id)
bool isEnemy(const Npc &other) const
void setTrueGuild(int32_t g)
bool canSeeItem(const Item &it, bool freeLos) const
bool hasCollision() const
BodyState bodyStateMasked() const
void delOverlay(std::string_view sk)
void emitSoundGround(std::string_view sound, float range, bool freeSlot)
void clearSlotItem(std::string_view slot)
bool canSwitchWeapon() const
void setMagicWeapon(Effect &&spell)
void setAmmoItem(MeshObjects::Mesh &&itm, std::string_view slot)
void startEffect(Npc &to, const VisualFx &vfx)
bool canRayHitPoint(const Tempest::Vec3 pos, bool freeLos=true, float extRange=0.f) const
bool hasStateFlag(BodyState flg) const
void setPerceptionTime(uint64_t time)
auto portalName() -> std::string_view
int32_t trueGuild() const
bool isFinishingMove() const
auto beginCastSpell() -> BeginCastResult
static const gtime endOfTime()
static CommandLine * instance
bool hasCollision() const