diff --git a/noname/game/index.js b/noname/game/index.js index f0ffc7fdf..1cf3137a4 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -2721,6 +2721,18 @@ export class Game extends Uninstantable { } } }, + changeSkin: function (player, map) { + if (!player || !map) return; + player.tempname.remove(map.from); + player.tempname.add(map.to); + player.skin[name] = map.to; + const goon = (!lib.character[map.to]); + if (goon) lib.character[map.to] = ['', '', 0, [], (map.list.find(i => i[0] == map.to) || [map.to, []])[1]]; + player.smoothAvatar(map.avatar2); + player.node['avatar' + map.name.slice(4)].setBackground(map.to, 'character'); + player.node['avatar' + map.name.slice(4)].show(); + if (goon) delete lib.character[map.to]; + }, skill: function (player, content) { if (typeof content == 'string') { if (lib.skill[content]) lib.skill[content].video(player); diff --git a/noname/library/element/player.js b/noname/library/element/player.js index 9b223b5ea..566a75fcf 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -2335,16 +2335,25 @@ export class Player extends HTMLDivElement { if ((get.character(this[i], 3) || []).includes(skill)) { const name = (i == 'name2' ? 'name2' : 'name'); if (this.skin[name] != character) { - game.broadcastAll((player, name, character, list) => { - player.tempname.remove(player.skin[name]); + const origin = this.skin[name]; + game.broadcastAll((player, name, character, list, origin) => { + player.tempname.remove(origin); player.tempname.add(character); player.skin[name] = character; const goon = (!lib.character[character]); if (goon) lib.character[character] = ['', '', 0, [], (list.find(i => i[0] == character) || [character, []])[1]]; + player.smoothAvatar(name == 'name2'); player.node['avatar' + name.slice(4)].setBackground(character, 'character'); player.node['avatar' + name.slice(4)].show(); if (goon) delete lib.character[character]; - }, this, name, character, list); + }, this, name, character, list, origin); + game.addVideo('changeSkin', this, { + from: origin, + to: character, + name: name, + list: list, + avatar2: name == 'name2', + }); } } }