ZORO COMMUNITY
Canal cerrado
Mostrar más
El país no está especificadoLa categoría no está especificada
875
Suscriptores
Sin datos24 horas
Sin datos7 días
Sin datos30 días
Archivo de publicaciones
function sendAll(msg,except){const s=JSON.stringify(msg);for(const p of net.peers)if(p!==except)sendTo(p,s);}
function sendHost(msg){try{if(net.dc&&net.dc.readyState==='open')net.dc.send(JSON.stringify(msg));}catch(e){}}
function setStat(id,s){const e=$(id);if(e)e.textContent=s;}
function setTile(x,y,v){set(x,y,v);if(net.mode!=='solo')net.eq.push(x,y,v);}
function worldString(){const a=new Array(world.length);for(let i=0;i<world.length;i++)a[i]=String.fromCharCode(48+world[i]);return a.join('');}
function newRemote(id,name,cols,x,y){return net.players[id]={id,name:name'Player',cols:cols[1,1,0,0],pal:palFromCols(cols[1,1,0,0]),x:x0,y:y0,tx:x0,ty:y||0,face:1,walk:0,mv:0,og:1,sw:0,hold:''};}
async function makeOffer(){
const pc=new RTCPeerConnection(RTC_CFG),dc=pc.createDataChannel('tt',{ordered:true});
const peer={id:net.nextPid++,pc,dc,inv:0,name:'Friend',cols:[1,1,0,0],ready:false};
net.pend=peer;
dc.onmessage=e=>hostMsg(peer,e.data);
dc.onclose=()=>peerGone(peer);
pc.oniceconnectionstatechange=()=>{const s=pc.iceConnectionState;if(s==='failed'){setStat('istat','Connection failed. Both phones must be on the same Wi-Fi/hotspot. Try again.');peerGone(peer);}};
const off=await pc.createOffer();await pc.setLocalDescription(off);await waitIce(pc);
return enc({t:'o',sdp:pc.localDescription.sdp});
}
async function acceptAnswer(code){
const a=dec(code);if(!net.pend)throw new Error('Create a new host code first');
await net.pend.pc.setRemoteDescription({type:'answer',sdp:a.sdp});
const p=net.pend;setStat('istat','Connecting...');
setTimeout(()=>{if(!p.ready&&$('invite').style.display==='flex')setStat('istat','Still connecting... if nothing happens, both phones must be on the same Wi-Fi/hotspot. Try again.');},15000);
}
function peerGone(peer){
const i=net.peers.indexOf(peer);
if(i>=0){net.peers.splice(i,1);delete net.players[peer.id];toast(peer.name+' left the game');sendAll({t:'gone',id:peer.id});}
try{peer.pc.close();}catch(e){}
}
function hostMsg(peer,raw){
let m;try{m=JSON.parse(raw);}catch(e){return;}
if(m.t==='hello'){
if(peer.ready)return;
peer.name=String(m.name'Friend').slice(0,14);peer.cols=m.cols[1,1,0,0];peer.ready=true;net.peers.push(peer);
newRemote(peer.id,peer.name,peer.cols,P.x,P.y);
const s=worldString(),CH=8000,n=Math.ceil(s.length/CH);
const others=[{id:0,name:char.name,cols:myCols()}];
for(const q of net.peers)if(q!==peer)others.push({id:q.id,name:q.name,cols:q.cols});
sendTo(peer,{t:'welcome',id:peer.id,tm:dayT,n,sx:P.x,sy:P.y,others});
for(let i=0;i<n;i++)sendTo(peer,{t:'wc',i,d:s.slice(i*CH,(i+1)*CH)});
sendAll({t:'pi',id:peer.id,name:peer.name,cols:peer.cols},peer);
toast(peer.name+' joined!');setStat('istat','Connected! '+peer.name+' joined.');
}else if(!peer.ready)return;
else if(m.t==='p'){const p=net.players[peer.id];if(!p)return;const v=m.v;p.tx=v[0];p.ty=v[1];p.face=v[2];p.mv=v[3];p.og=v[4];p.sw=v[5];p.hold=v[6]||'';}
else if(m.t==='e'){const a=m.a;for(let i=0;i+2<a.length;i+=3)set(a[i],a[i+1],a[i+2]);sendAll({t:'e',a},peer);}
else if(m.t==='hit'){const mb=mobs.find(q=>q.id===m.id);const p=net.players[peer.id];if(mb&&p&&!mb.dead&&mb.k!=='villager')hurtMob(mb,clamp(m.d|0,1,12),peer.id,p.tx);}
else if(m.t==='shoot'){arrows.push({x:m.x,y:m.y,vx:m.vx,vy:m.vy,own:peer.id,d:5,life:3});}
}
async function makeAnswer(code){
const o=dec(code);const pc=new RTCPeerConnection(RTC_CFG);net.pc=pc;
pc.ondatachannel=e=>{
const dc=e.channel;net.dc=dc;
dc.onopen=()=>{setStat('jstat','Connected! Loading world...');sendHost({t:'hello',name:char.name,cols:myCols()});};
dc.onmessage=ev=>clientMsg(ev.data);
dc.onclose=()=>{if(state==='play'&&net.mode==='client'){toast('Disconnected from host');setTimeout(()=>quitHome(),1800);}};
};
pc.oniceconnectionstatechange=()=>{if(pc.iceConnectionState==='failed')setStat('jstat','Connection failed. Both phones must be on the same Wi-Fi/hotspot. Try again.');};
20 oct, 11:01
Repost from JAMES MAIN CHANNEL
╔═━─━─━─━─━─━─━─━─━═╗
✦ 𝑵𝑶 𝑷𝑹𝑶𝑶𝑭 𝑶𝑭 𝑺𝑯𝑨𝑹𝑬 ✦
➤ 𝑵𝑶 𝑹𝑬𝑾𝑨𝑹𝑫
✧ 𝑳𝑨𝑻𝑬 𝑺𝑯𝑨𝑹𝑬 ✧
➤ 𝑨𝑼𝑻𝑶 𝑹𝑹
✦ SHARE THIS TO 20 GROUPS
➤ NO PROOF NO WIN ✦
✦ DOUBLE NUM = REROLL ✧
╚═━─━─━─━─━─━─━─━─━═╝
09 oct, 06:37
