feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39
@ -3979,21 +3979,21 @@ export class GameRuntime {
|
||||
return;
|
||||
}
|
||||
if (cmd === 'playerSet' && payload) {
|
||||
// Из Lua-runtime: humanoid.Health = 0 → шлёт {prop:'health', value:N}.
|
||||
// Применяем к реальному игроку BabylonScene.
|
||||
// Из Lua-runtime: humanoid.Health = N → {prop:'health', value:N}.
|
||||
// Используем PlayerController.takeDamage, который запускает полный
|
||||
// death-flow: distance debris, _onDeath callback (respawn), звук.
|
||||
// Сбрасываем _lastDamageTime чтобы invulnerability не блокировал.
|
||||
const player = this.scene3d?.player;
|
||||
if (!player) return;
|
||||
if (payload.prop === 'health') {
|
||||
const v = Math.max(0, Number(payload.value) || 0);
|
||||
player.hp = v;
|
||||
if (v === 0) {
|
||||
try { this.routeGlobalEvent('playerDied', {}); } catch (_) {}
|
||||
// Перезагружаем игру (как при смерти)
|
||||
try {
|
||||
if (this.scene3d?.respawnPlayer) this.scene3d.respawnPlayer();
|
||||
} catch (_) {}
|
||||
const target = Math.max(0, Number(payload.value) || 0);
|
||||
const damage = Math.max(0, (player.hp || 0) - target);
|
||||
if (damage > 0 && typeof player.takeDamage === 'function') {
|
||||
player._lastDamageTime = 0;
|
||||
player.takeDamage(damage, 'lua');
|
||||
} else {
|
||||
player.hp = target;
|
||||
}
|
||||
try { this.routeGlobalEvent('hpChange', { hp: v }); } catch (_) {}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user