Files

49 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MercanRey2.js — saveProfile() (satır 698)
[← MercanRey2.js](index.md) · [← Master](../../wiki.md)
```javascript
function saveProfile(c, caster, target, state)
{
var db = getKnowledgeDb();
var uuid = String(target.getUniqueId());
var old = db.people[uuid];
var oldKnowledge = old == null ? 0 : Number(old.knowledge || 0);
var pos = target.getPosition();
var plan = threatSentence(state.tags, { plan: state.basePlan });
db.people[uuid] = {
uuid: uuid,
name: String(target.getName()),
observedBy: String(caster.getUniqueId()),
knowledge: Math.min(100, oldKnowledge + 50),
observations: old == null ? 1 : Number(old.observations || 0) + 1,
className: state.className,
group: state.group,
will: state.will,
playerData: Boolean(state.playerData),
tags: state.tags,
fightStyle: plan,
habits: habitSentence(state),
fears: fearSentence(state),
decision: decisionSentence(state),
weakness: state.weakness,
itemWarnings: state.itemWarnings,
contacts: makeContactList(state.contacts),
enemies: state.enemies,
access: state.access,
hpRatio: Math.round(state.hpRatio * 100),
lastDimension: target.getDimension(),
lastX: Math.round(pos.x),
lastY: Math.round(pos.y),
lastZ: Math.round(pos.z),
lastSeenTick: c.getWorld().getTotalTime()
};
mappet.set(KNOWLEDGE_KEY, db);
mappet.set(OLD_KNOWLEDGE_KEY, db);
return db.people[uuid];
}
```