载入中...
搜索中...
未找到
RPGActor.cpp
浏览该文件的文档.
1#include "rpg/RPGActor.h"
3#include "rpg/ClassSystem.h"
4#include "rpg/LevelSystem.h"
5#include "rpg/StatusSystem.h"
6#include "rpg/SkillSystem.h"
7#include "rpg/TraitSystem.h"
8#include "rpg/VitalsSystem.h"
9
10#include <algorithm>
11#include <utility>
12
13namespace eve::rpg {
14
15namespace {
16
17// 按 handle(id + generation)而非裸指针跟踪存活 actor:
18// ECS 的 entity 槽位在销毁后会被复用,复用后地址相同但其实是另一个实体,
19// 裸指针 + is_entity_visible 无法区分这种复用(复用后 flags 会被重置,
20// 旧的裸指针看起来又"活"了),必须连同 generation 一起校验才安全。
21std::vector<ecs::EntityHandle> &registryStorage() {
22 static std::vector<ecs::EntityHandle> v;
23 return v;
24}
25
26} // namespace
27
29 RPGActor *actor = RPGActor::create();
30 // Touch each component once so accessors are cheap/valid immediately.
31 actor->attributes();
32 actor->statuses();
33 actor->skills();
34 actor->progression();
35 actor->vitals();
36 actor->traits();
37 actor->classInfo();
38 registryStorage().push_back(ecs::handle_of(actor));
39 return actor;
40}
41
42const std::vector<RPGActor *> &RPGActor::liveActors() {
43 static std::vector<RPGActor *> resolved;
44 auto &handles = registryStorage();
45
46 handles.erase(std::remove_if(handles.begin(), handles.end(),
47 [](const ecs::EntityHandle &h) { return ecs::try_get(h) == nullptr; }),
48 handles.end());
49
50 resolved.clear();
51 resolved.reserve(handles.size());
52 for (const ecs::EntityHandle &h : handles)
53 resolved.push_back(static_cast<RPGActor *>(ecs::try_get(h)));
54 return resolved;
55}
56
57// ---- Attributes ----
58
59void RPGActor::setBaseAttribute(const std::string &attribute, double value) {
60 AttributeSystem::setBase(this, attribute, value);
61}
62
63double RPGActor::getBaseAttribute(const std::string &attribute) {
64 return AttributeSystem::getBase(this, attribute);
65}
66
67void RPGActor::modifyBaseAttribute(const std::string &attribute, double delta) {
68 AttributeSystem::modifyBase(this, attribute, delta);
69}
70
71bool RPGActor::hasAttribute(const std::string &attribute) {
72 return AttributeSystem::hasAttribute(this, attribute);
73}
74
78
79std::string RPGActor::addAttributeModifier(const std::string &attribute, const std::string &source,
80 const std::string &op, double value, int priority) {
81 return AttributeSystem::addModifier(this, attribute, source, op, value, priority);
82}
83
87
88bool RPGActor::removeAttributeModifier(const std::string &attribute, const std::string &modifierId) {
89 return AttributeSystem::removeModifier(this, attribute, modifierId);
90}
91
92int RPGActor::removeAttributeModifiersBySource(const std::string &attribute,
93 const std::string &source) {
94 auto result = AttributeSystem::removeModifiersBySource(this, attribute, source);
95 return result.ok() ? result.value() : 0;
96}
97
101
102double RPGActor::getFinalAttribute(const std::string &attribute) {
103 return AttributeSystem::getFinal(this, attribute);
104}
105
106// ---- Status ----
107
108int RPGActor::applyEffect(const std::string &effectId, const std::string &source) {
109 auto result = StatusSystem::apply(this, effectId, source);
110 return result.ok() ? std::move(result).takeValue() : -1;
111}
112
113bool RPGActor::removeStatus(int instanceId) { return StatusSystem::remove(this, instanceId).ok(); }
114
115int RPGActor::removeStatusByEffect(const std::string &effectId) {
116 return StatusSystem::removeByEffect(this, effectId);
117}
118
119int RPGActor::removeStatusBySource(const std::string &source) {
121}
122
123int RPGActor::removeStatusByTag(const std::string &tag) {
124 return StatusSystem::removeByTag(this, tag);
125}
126
127bool RPGActor::hasEffect(const std::string &effectId) { return StatusSystem::hasEffect(this, effectId); }
128
129bool RPGActor::hasStatusTag(const std::string &tag) { return StatusSystem::hasTag(this, tag); }
130
132
136
138
140
142
144
145std::string RPGActor::getStatusProp(int instanceId, const std::string &key,
146 const std::string &fallback) {
147 return StatusSystem::getProp(this, instanceId, key, fallback);
148}
149
150bool RPGActor::setStatusProp(int instanceId, const std::string &key, const std::string &value) {
151 return StatusSystem::setProp(this, instanceId, key, value);
152}
153
154int RPGActor::applyBuff(const std::string &effectId, const std::string &source) {
155 return applyEffect(effectId, source);
156}
157
158bool RPGActor::removeBuff(int instanceId) { return removeStatus(instanceId); }
159
160int RPGActor::removeBuffByEffect(const std::string &effectId) {
161 return removeStatusByEffect(effectId);
162}
163
164int RPGActor::removeBuffBySource(const std::string &source) {
166}
167
168int RPGActor::removeBuffByTag(const std::string &tag) { return removeStatusByTag(tag); }
169
170bool RPGActor::hasBuff(const std::string &effectId) { return hasEffect(effectId); }
171
172bool RPGActor::hasBuffTag(const std::string &tag) { return hasStatusTag(tag); }
173
175
177
179
181
183
185
186std::string RPGActor::getBuffProp(int instanceId, const std::string &key,
187 const std::string &fallback) {
188 return getStatusProp(instanceId, key, fallback);
189}
190
191bool RPGActor::setBuffProp(int instanceId, const std::string &key, const std::string &value) {
192 return setStatusProp(instanceId, key, value);
193}
194
195// ---- Skills ----
196
197void RPGActor::learnSkill(const std::string &skillId) { SkillSystem::learn(this, skillId); }
198
199bool RPGActor::knowsSkill(const std::string &skillId) { return SkillSystem::knows(this, skillId); }
200
201bool RPGActor::forgetSkill(const std::string &skillId) { return SkillSystem::forget(this, skillId); }
202
203float RPGActor::getSkillCooldown(const std::string &skillId) {
204 return SkillSystem::getCooldownRemaining(this, skillId);
205}
206
207void RPGActor::setSkillCooldown(const std::string &skillId, float seconds) {
208 SkillSystem::setCooldownRemaining(this, skillId, seconds);
209}
210
211bool RPGActor::canCastSkill(const std::string &skillId) {
212 return SkillSystem::canCast(this, skillId, nullptr);
213}
214
215std::string RPGActor::canCastSkillReason(const std::string &skillId) {
216 std::string reason;
217 SkillSystem::canCast(this, skillId, &reason);
218 return reason;
219}
220
221bool RPGActor::beginCastSkill(const std::string &skillId, RPGActor *target) {
222 return SkillSystem::beginCast(this, skillId, target, nullptr);
223}
224
226
228
230
232
234
235double RPGActor::getXp() { return LevelSystem::getXp(this); }
236
238
240
241eve::Result<void> RPGActor::restoreProgression(int level, double xp, double xpToNext) {
242 return LevelSystem::restoreProgression(this, level, xp, xpToNext);
243}
244
245bool RPGActor::gainXp(double amount) { return LevelSystem::gainXp(this, amount); }
246
247double RPGActor::getCurrent(const std::string &resource) {
249}
250
251double RPGActor::getMax(const std::string &resource) {
252 return VitalsSystem::getMax(this, resource);
253}
254
255void RPGActor::setCurrent(const std::string &resource, double value) {
257}
258
259double RPGActor::takeDamage(const std::string &resource, double amount,
260 const std::string &source) {
261 return VitalsSystem::takeDamage(this, resource, amount, source);
262}
263
264double RPGActor::heal(const std::string &resource, double amount) {
265 return VitalsSystem::heal(this, resource, amount);
266}
267
268void RPGActor::revive(const std::string &resource, double amount) {
269 VitalsSystem::revive(this, resource, amount);
270}
271
272bool RPGActor::isDead(const std::string &resource) {
273 return VitalsSystem::isDead(this, resource);
274}
275
276int RPGActor::applyTrait(const std::string &traitId, const std::string &source) {
277 return TraitSystem::apply(this, traitId, source);
278}
279
280bool RPGActor::removeTrait(int instanceId) { return TraitSystem::remove(this, instanceId); }
281
282int RPGActor::removeTraitsBySource(const std::string &source) {
284}
285
286int RPGActor::removeTraitsByTrait(const std::string &traitId) {
287 return TraitSystem::removeByTrait(this, traitId);
288}
289
290bool RPGActor::hasTrait(const std::string &traitId) { return TraitSystem::hasTrait(this, traitId); }
291
293
297
299
301 return TraitSystem::getSourceAt(this, index);
302}
303
304double RPGActor::getParamRate(const std::string &param) {
305 return TraitSystem::getParamRate(this, param);
306}
307
308double RPGActor::getElementRate(const std::string &element) {
310}
311
312double RPGActor::getStateRate(const std::string &stateId) {
313 return TraitSystem::getStateRate(this, stateId);
314}
315
316bool RPGActor::isStateResist(const std::string &stateId) {
317 return TraitSystem::isStateResist(this, stateId);
318}
319
320double RPGActor::getExParam(const std::string &exParam) {
321 return TraitSystem::getExParam(this, exParam);
322}
323
325
327
328std::vector<std::string> RPGActor::getAttackElements() {
330}
331
332std::vector<std::string> RPGActor::getAttackStates() {
333 return TraitSystem::getAttackStates(this);
334}
335
336bool RPGActor::setClass(const std::string &classId) { return ClassSystem::setClass(this, classId); }
337
338std::string RPGActor::getClassId() { return ClassSystem::getClassId(this); }
339
340bool RPGActor::hasClass(const std::string &classId) {
341 return ClassSystem::hasClass(this, classId);
342}
343
345
347
351
355
356} // namespace eve::rpg
LogicalId target
double value
RPG's thin compatibility facade over the attributes module.
int priority
职业系统:设定职业、施加职业基础特征、按等级自动学习技能。
std::uint32_t key
float v
int h
角色成长:等级 / 经验 / 升级。
int level
const std::string * tag
std::string resource
std::string element
特征系统:施加/移除运行时特征,并提供耐性/特殊参数/攻击附加等查询。
std::uint32_t classId
uint32_t index
const UnitySourceAsset & source
当前资源(hp/mana...)的受伤 / 治疗 / 复活 / 死亡。
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:480
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static void setBase(RPGActor *actor, const std::string &attribute, double value)
Set a base value; invalid actor or attribute is a compatibility no-op.
static bool hasAttribute(RPGActor *actor, const std::string &attribute)
Query whether an attribute exists on the actor.
static eve::Result< int > removeModifiersBySource(RPGActor *actor, const std::string &attribute, const std::string &source)
Remove source modifiers with a structured count result.
static void modifyBase(RPGActor *actor, const std::string &attribute, double delta)
Add a delta to a base value.
static double getBase(RPGActor *actor, const std::string &attribute)
Read a base value, returning zero for a missing actor/attribute.
static int removeAllModifiersBySource(RPGActor *actor, const std::string &source)
Compatibility all-attribute source removal facade.
static double getFinal(RPGActor *actor, const std::string &attribute)
Compute the final value through the canonical attributes engine.
static eve::Result< ModifierId > addModifier(RPGActor *actor, AttributeModifier modifier)
Add one canonical modifier to an actor.
static eve::Result< void > removeModifier(RPGActor *actor, const ModifierId &modifierId)
Remove by canonical modifier id with a structured result.
static int getLearnLevelAt(RPGActor *actor, int index)
Returns the learn level at.
static bool hasClass(RPGActor *actor, const std::string &classId)
是否已设定指定职业。
static std::string getClassId(RPGActor *actor)
当前职业 id(无则空)。
static std::string getLearnSkillIdAt(RPGActor *actor, int index)
Returns the learn skill id at.
static int getLearnCount(RPGActor *actor)
职业定义中可学技能总数。
static int checkLevelSkills(RPGActor *actor)
按当前等级补学尚未学过的升级技能。
static bool setClass(RPGActor *actor, const std::string &classId)
设定职业并施加职业基础特征(compatibility facade (脚本兼容门面);成功返回 true)。
static void setXpToNext(RPGActor *actor, double value)
设置当前等级的升级阈值。
static double getXpToNext(RPGActor *actor)
升级所需经验。
static double getXp(RPGActor *actor)
当前经验。
static eve::Result< void > restoreProgression(RPGActor *actor, int level, double xp, double xpToNext)
Atomically restore one validated progression checkpoint.
static bool gainXp(RPGActor *actor, double amount, double xpGrowth=1.2)
增加经验;每跨过阈值升一级并发出 LevelUpEvent(compatibility facade (脚本兼容门面))。
static int getLevel(RPGActor *actor)
当前等级(无 progression 时返回 1)。
属性 / 状态 / 技能三表合一的 ECS 实体。
Definition RPGActor.h:34
bool beginCastSkill(const std::string &skillId, RPGActor *target=nullptr)
开始读条释放;false 表示不满足条件。
Definition RPGActor.cpp:221
int removeTraitsByTrait(const std::string &traitId)
Definition RPGActor.cpp:286
std::string getCastingSkillId()
Definition RPGActor.cpp:229
bool isCastingSkill()
读条状态查询。
Definition RPGActor.cpp:227
double getBaseAttribute(const std::string &attribute)
Definition RPGActor.cpp:63
bool removeBuff(int instanceId)
Definition RPGActor.cpp:158
bool removeStatus(int instanceId)
Definition RPGActor.cpp:113
double heal(const std::string &resource, double amount)
Definition RPGActor.cpp:264
static const std::vector< RPGActor * > & liveActors()
返回所有通过 createActor() 创建、且当前仍存活的 actor。 StatusSystem::update / SkillSystem::update 用它遍历所有 actor 逐帧推进。 ...
Definition RPGActor.cpp:42
double getParamRate(const std::string &param)
Definition RPGActor.cpp:304
int getBuffStacks(int index)
Definition RPGActor.cpp:178
std::vector< std::string > getAttackElements()
Definition RPGActor.cpp:328
std::string canCastSkillReason(const std::string &skillId)
不能释放的原因("" = 可以)。
Definition RPGActor.cpp:215
std::string getClassId()
Definition RPGActor.cpp:338
int applyTrait(const std::string &traitId, const std::string &source="")
特征(TraitSystem 的薄转发)。
Definition RPGActor.cpp:276
double getElementRate(const std::string &element)
Definition RPGActor.cpp:308
std::string getStatusEffectId(int index)
Definition RPGActor.cpp:133
double takeDamage(const std::string &resource, double amount, const std::string &source="")
Definition RPGActor.cpp:259
double getCurrent(const std::string &resource)
生命等当前资源(VitalsSystem 的薄转发,max 取同名最终属性)。
Definition RPGActor.cpp:247
std::vector< std::string > getAttackStates()
Definition RPGActor.cpp:332
int getClassLearnLevelAt(int index)
Definition RPGActor.cpp:352
int removeAttributeModifiersBySource(const std::string &attribute, const std::string &source)
Definition RPGActor.cpp:92
void cancelCastSkill()
取消读条。
Definition RPGActor.cpp:225
eve::Result< void > restoreProgression(int level, double xp, double xpToNext)
Validate and atomically restore this actor's progression checkpoint.
Definition RPGActor.cpp:241
int removeAllAttributeModifiersBySource(const std::string &source)
Definition RPGActor.cpp:98
bool hasTrait(const std::string &traitId)
Definition RPGActor.cpp:290
void revive(const std::string &resource, double amount=-1.0)
Definition RPGActor.cpp:268
static RPGActor * createActor()
创建一个空白 actor(三张表均为空,按需惰性写入),并纳入 liveActors() 跟踪。
Definition RPGActor.cpp:28
int removeStatusByTag(const std::string &tag)
Definition RPGActor.cpp:123
void setSkillCooldown(const std::string &skillId, float seconds)
Definition RPGActor.cpp:207
int removeStatusBySource(const std::string &source)
Definition RPGActor.cpp:119
eve::Result< ModifierId > addAttributeModifier(AttributeModifier modifier)
Canonical modifier insertion backed by AttributeSet.
Definition RPGActor.cpp:75
bool isDead(const std::string &resource)
Definition RPGActor.cpp:272
std::string getBuffEffectId(int index)
Definition RPGActor.cpp:176
bool hasAttribute(const std::string &attribute)
Definition RPGActor.cpp:71
bool forgetSkill(const std::string &skillId)
Definition RPGActor.cpp:201
float getCastProgress()
Definition RPGActor.cpp:231
void learnSkill(const std::string &skillId)
技能:学习 / 查询 / 冷却。
Definition RPGActor.cpp:197
int getLevel()
成长进度(LevelSystem 的薄转发)。
Definition RPGActor.cpp:233
int getBuffInstanceId(int index)
Definition RPGActor.cpp:182
double getExParam(const std::string &exParam)
Definition RPGActor.cpp:320
std::string getBuffProp(int instanceId, const std::string &key, const std::string &fallback={})
Definition RPGActor.cpp:186
bool hasClass(const std::string &classId)
Definition RPGActor.cpp:340
double getMax(const std::string &resource)
Definition RPGActor.cpp:251
int applyBuff(const std::string &effectId, const std::string &source="")
Buff 别名(与 Status API 等价,便于游戏侧按习惯命名)。
Definition RPGActor.cpp:154
std::string getTraitSourceAt(int index)
Definition RPGActor.cpp:300
double getAttackSpeed()
Definition RPGActor.cpp:324
bool gainXp(double amount)
增加经验并可能升级(compatibility facade (脚本兼容门面);返回是否升级)。
Definition RPGActor.cpp:245
int removeTraitsBySource(const std::string &source)
Definition RPGActor.cpp:282
bool canCastSkill(const std::string &skillId)
Definition RPGActor.cpp:211
float getBuffRemaining(int index)
Definition RPGActor.cpp:180
void setBaseAttribute(const std::string &attribute, double value)
便捷成员方法(转发到 AttributeSystem / StatusSystem / SkillSystem)。 提供这一层薄封装主要是为了让脚本可以写 actor....
Definition RPGActor.cpp:59
int getStatusStacks(int index)
Definition RPGActor.cpp:137
std::string getTraitIdAt(int index)
Definition RPGActor.cpp:298
void modifyBaseAttribute(const std::string &attribute, double delta)
Definition RPGActor.cpp:67
int getTraitInstanceIdAt(int index)
Definition RPGActor.cpp:294
bool knowsSkill(const std::string &skillId)
Definition RPGActor.cpp:199
int removeBuffByEffect(const std::string &effectId)
Definition RPGActor.cpp:160
bool hasStatusTag(const std::string &tag)
Definition RPGActor.cpp:129
int removeStatusByEffect(const std::string &effectId)
Definition RPGActor.cpp:115
int removeBuffBySource(const std::string &source)
Definition RPGActor.cpp:164
double getStateRate(const std::string &stateId)
Definition RPGActor.cpp:312
std::string getClassLearnSkillIdAt(int index)
Definition RPGActor.cpp:348
bool setBuffProp(int instanceId, const std::string &key, const std::string &value)
Definition RPGActor.cpp:191
bool hasBuff(const std::string &effectId)
Definition RPGActor.cpp:170
int getStatusInstanceId(int index)
Definition RPGActor.cpp:141
bool setStatusProp(int instanceId, const std::string &key, const std::string &value)
Definition RPGActor.cpp:150
std::string getStatusSource(int index)
Definition RPGActor.cpp:143
bool isStateResist(const std::string &stateId)
Definition RPGActor.cpp:316
bool hasBuffTag(const std::string &tag)
Definition RPGActor.cpp:172
double getFinalAttribute(const std::string &attribute)
Definition RPGActor.cpp:102
bool removeTrait(int instanceId)
移除一个特征(compatibility facade (脚本兼容门面);成功返回 true)。
Definition RPGActor.cpp:280
std::string getStatusProp(int instanceId, const std::string &key, const std::string &fallback={})
Definition RPGActor.cpp:145
float getStatusRemaining(int index)
Definition RPGActor.cpp:139
int applyEffect(const std::string &effectId, const std::string &source="")
状态(buff/debuff)—— Statuses ECS 组件的薄封装。
Definition RPGActor.cpp:108
bool hasEffect(const std::string &effectId)
Definition RPGActor.cpp:127
int removeBuffByTag(const std::string &tag)
Definition RPGActor.cpp:168
bool setClass(const std::string &classId)
职业(ClassSystem 的薄转发)。
Definition RPGActor.cpp:336
std::string getBuffSource(int index)
Definition RPGActor.cpp:184
void setXpToNext(double value)
Definition RPGActor.cpp:239
float getSkillCooldown(const std::string &skillId)
Definition RPGActor.cpp:203
eve::Result< void > removeAttributeModifier(const ModifierId &modifierId)
Canonical modifier removal backed by AttributeSet.
Definition RPGActor.cpp:84
void setCurrent(const std::string &resource, double value)
Definition RPGActor.cpp:255
static bool forget(RPGActor *actor, const std::string &skillId)
Forget.
static void cancelCast(RPGActor *actor)
打断当前读条(不退还已扣除的消耗/冷却)。
static std::string getCastingSkillId(RPGActor *actor)
Returns the casting skill id.
static float getCastProgress(RPGActor *actor)
Returns the cast progress.
static void setCooldownRemaining(RPGActor *actor, const std::string &skillId, float seconds)
Sets the cooldown remaining.
static bool isCasting(RPGActor *actor)
True when casting.
static float getCooldownRemaining(RPGActor *actor, const std::string &skillId)
Returns the cooldown remaining.
static void learn(RPGActor *actor, const std::string &skillId)
Learn.
static bool knows(RPGActor *actor, const std::string &skillId)
Knows.
static bool canCast(RPGActor *actor, const std::string &skillId, std::string *reason=nullptr)
检查冷却/消耗/学会状态/自定义条件,不产生任何副作用。
static bool beginCast(RPGActor *actor, const std::string &skillId, RPGActor *target=nullptr, std::string *reason=nullptr)
尝试释放技能:通过 canCast 检查后立即扣除消耗并进入冷却; castTime<=0 时立即结算(授予效果 + 产生 SkillCastEvent), 否则进入读条状态,由 update() 在读...
static bool setProp(RPGActor *actor, int instanceId, const std::string &key, const std::string &value)
Sets the prop.
static std::string getActiveSource(RPGActor *actor, int index)
Returns the active source.
static eve::Result< void > remove(RPGActor *actor, int instanceId)
Removal of one status by its legacy adapter id.
static int getActiveStacks(RPGActor *actor, int index)
Returns the active stacks.
static int getActiveInstanceId(RPGActor *actor, int index)
Returns the active instance id.
static bool hasEffect(RPGActor *actor, const std::string &effectId)
True when effect.
static bool hasTag(RPGActor *actor, const std::string &tag)
是否存在任一效果定义带有该 tag 的活动实例。
static int removeBySource(RPGActor *actor, const std::string &source)
移除该 actor 身上所有 source 匹配的实例;返回移除数量。
static int getActiveCount(RPGActor *actor)
Returns the active count.
static std::string getProp(RPGActor *actor, int instanceId, const std::string &key, const std::string &fallback={})
按实例 id 读写 props;找不到实例时 get 返回 fallback,set 返回 false。
static int removeByEffect(RPGActor *actor, const std::string &effectId)
移除该 actor 身上所有 effectId 匹配的实例;返回移除数量。
static int removeByTag(RPGActor *actor, const std::string &tag)
移除该 actor 身上所有 tag 匹配(效果定义带该 tag)的实例;返回移除数量。
static std::string getActiveEffectId(RPGActor *actor, int index)
Returns the active effect id.
static eve::Result< int > apply(RPGActor *actor, const std::string &effectId, const std::string &source="")
Status application backed by the generic EffectContainer.
static float getActiveRemaining(RPGActor *actor, int index)
Returns the active remaining.
static int removeBySource(RPGActor *actor, const std::string &source)
移除该 actor 上所有来自 source 的特征;返回移除数。
static bool hasTrait(RPGActor *actor, const std::string &traitId)
是否已施加某特征。
static double getElementRate(RPGActor *actor, const std::string &element)
元素耐性乘积(1 = 无修正,0.5 = 减半)。
static int getAttackTimesAdd(RPGActor *actor)
攻击次数附加(整数加值)。
static double getExParam(RPGActor *actor, const std::string &exParam)
特殊参数加值(hit/evasion/critRate/critEvade/magicEvade/magicReflect/...)。
static double getAttackSpeed(RPGActor *actor)
攻击速度修正(加值)。
static std::string getSourceAt(RPGActor *actor, int index)
Returns the source at.
static std::string getTraitIdAt(RPGActor *actor, int index)
Returns the trait id at.
static bool remove(RPGActor *actor, int instanceId)
按实例 id 移除(compatibility facade (脚本兼容门面);成功返回 true)。
static std::vector< std::string > getAttackStates(RPGActor *actor)
攻击附加状态列表。
static double getParamRate(RPGActor *actor, const std::string &param)
参数倍率乘积(如 attack → 1.5 表示 +50)。
static bool isStateResist(RPGActor *actor, const std::string &stateId)
是否免疫某状态(stateResist 命中;target 空 = 全部免疫)。
static int apply(RPGActor *actor, const std::string &traitId, const std::string &source="")
施加一个特征。
static int getCount(RPGActor *actor)
Returns the count.
static std::vector< std::string > getAttackElements(RPGActor *actor)
攻击附加元素列表。
static int getInstanceIdAt(RPGActor *actor, int index)
Returns the instance id at.
static double getStateRate(RPGActor *actor, const std::string &stateId)
状态施加率乘积(1 = 正常)。
static int removeByTrait(RPGActor *actor, const std::string &traitId)
移除该 actor 上所有 traitId 匹配的特征;返回移除数。
static double getCurrent(RPGActor *actor, const std::string &resource)
当前值(无 vitals/资源时 0)。
static double takeDamage(RPGActor *actor, const std::string &resource, double amount, const std::string &source="")
造成伤害:current -= amount,下限 0;归零时发 death 事件。
static void revive(RPGActor *actor, const std::string &resource, double amount=-1.0)
复活:把资源设为 amount(默认当前上限),并清掉死亡状态。
static void setCurrent(RPGActor *actor, const std::string &resource, double value)
直接设定当前值,夹在 [0, max]。
static double heal(RPGActor *actor, const std::string &resource, double amount)
治疗:current += amount,上限 max。返回实际治疗量。
static double getMax(RPGActor *actor, const std::string &resource)
上限:取 actor 同名最终属性(getFinalAttribute),无则 0。
static bool isDead(RPGActor *actor, const std::string &resource)
是否死亡:max > 0 且 current <= 0。
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
::eve::attributes::ModifierId ModifierId
One canonical runtime modifier applied to one named attribute.