11using namespace Tempest;
14 :pfx(std::move(pfx)), nodeSlot(node) {
19 :
Effect(vfx, owner, src.position(), key) {
35void Effect::setupLight(
World& owner) {
40 if(lightPresetName->empty()) {
45 Vec3 pos3 = {pos.at(3,0),pos.at(3,1),pos.at(3,2)};
46 light = owner.
addLight(*lightPresetName);
52void Effect::setupPfx(
World& owner) {
65 if(key!=
nullptr && key->
visName!=
nullptr)
79void Effect::setupSfx(
World& owner) {
80 auto sfxID = root->
sfxID;
82 if(key!=
nullptr && !key->
sfxID.empty()) {
88 Vec3 pos3 = {pos.at(3,0),pos.at(3,1),pos.at(3,2)};
110 selfRotation += (vel*float(dt)/1000.f);
112 syncAttachesSingle(pos);
137 syncAttachesSingle(pos);
142 next->setOrigin(npc);
144 syncAttachesSingle(pos);
145 setupCollision(npc->
world());
152void Effect::syncAttaches(
const Matrix4x4& inPos) {
154 next->syncAttaches(inPos);
155 syncAttachesSingle(inPos);
158void Effect::syncAttachesSingle(
const Matrix4x4& inPos) {
162 float emTrjTargetElev = 0;
181 p.translate(target->
mapBone(nodeSlot));
184 if(pose!=
nullptr && boneId<pose->boneCount())
185 p = pose->
bone(boneId);
186 else if(target!=
nullptr)
193 if(selfRotation!=Vec3() &&
false) {
196 m.rotateOX(selfRotation.x);
197 m.rotateOY(selfRotation.y);
198 m.rotateOZ(selfRotation.z);
202 p.set(3,1, p.at(3,1)+emTrjTargetElev);
203 Vec3 pos3 = {p.at(3,0),p.at(3,1),p.at(3,2)};
211 next->setKey(owner,k);
216 key = root->
key(k,keyLvl);
222 if(vfx!=
nullptr && !(next!=
nullptr && next->is(*vfx))) {
223 Vec3 pos3 = {pos.at(3,0),pos.at(3,1),pos.at(3,2)};
224 auto ex =
Effect(*vfx,owner,pos3,k);
225 ex.setActive(active);
226 ex.setLooped(looped);
227 if(pose!=
nullptr && skeleton!=
nullptr)
228 ex.bindAttaches(*pose,*skeleton);
229 next.reset(
new Effect(std::move(ex)));
231 else if(vfx==
nullptr) {
238 setupCollision(owner);
239 syncAttachesSingle(pos);
252 next->setBullet(b,owner);
254 setupCollision(owner);
259 next->setSpellId(s,owner);
261 setupCollision(owner);
265 uint64_t ret = next==
nullptr ? 0 : next->effectPrefferedTime();
278 return (next!=
nullptr && next->isAlive());
288 next->bindAttaches(p,to);
293 if(boneId==
size_t(-1)) {
311 const bool g2 = world.
version().game==2;
313 if(sender!=
nullptr && sender->sendAssessMagic && npc!=
nullptr) {
314 auto oth = other==
nullptr ? npc : other;
338void Effect::setupCollision(
World& owner) {
347 (void)emCheckCollision;
349 bool physics =
false;
357 if(!pfx.
isEmpty() && physics) {
364 auto src = (n!=
nullptr ? n : &npc);
void setMesh(const MeshObjects::Mesh *mesh)
void setTarget(const Npc *npc)
static void onCollide(World &owner, const VisualFx *root, const Tempest::Vec3 &pos, Npc *npc, Npc *other, int32_t splId)
void bindAttaches(const Pose &pose, const Skeleton &to)
bool is(const VisualFx &vfx) const
void setKey(World &owner, SpellFxKey key, int32_t keyLvl=0)
uint64_t effectPrefferedTime() const
void setObjMatrix(const Tempest::Matrix4x4 &mt)
void setBullet(Bullet *b, World &owner)
void setSpellId(int32_t splId, World &owner)
auto loadParticleFx(std::string_view name, bool relaxed=false) -> const ParticleFx *
void setPosition(float x, float y, float z)
auto mapBone(std::string_view bone) const -> Tempest::Vec3
void takeDamage(Npc &other, const Bullet *b)
auto transform() const -> Tempest::Matrix4x4
void runEffect(Effect &&e)
bool perceptionProcess(Npc &pl)
void setLooped(bool loop)
void setObjMatrix(const Tempest::Matrix4x4 &mt)
void setPhysicsEnable(World &physic, std::function< void(Npc &npc)> cb)
void setMesh(const MeshObjects::Mesh *mesh, const Pose *pose)
void setTarget(const Npc *tg)
auto bone(size_t id) const -> const Tempest::Matrix4x4 &
size_t findNode(std::string_view name, size_t def=size_t(-1)) const
size_t findRootNode() const
void setPosition(const Tempest::Vec3 &pos)
std::string lightPresetName
const VisualFx * emCreateFXID
const ParticleFx * visName
std::string userString[zenkit::IEffectBase::user_string_count]
const VisualFx * emFXCollDynPerc
Tempest::Vec3 emSelfRotVel
std::string lightPresetName
const VisualFx * emFXCreate
const VisualFx * emFXCollStat
bool isMeshEmmiter() const
std::string emTrjOriginNode
uint64_t effectPrefferedTime() const
const VisualFx * emFXCollDyn
const Key * key(SpellFxKey type, int32_t keyLvl=0) const
auto version() const -> const VersionInfo &
void runEffect(Effect &&e)
LightGroup::Light addLight(const zenkit::VLight &vob)
GlobalFx addGlobalEffect(std::string_view what, uint64_t len, const std::string *argv, size_t argc)