用户:
打酱油的企鹅呀查看:38 回复:16 评论:38 创建时间:2020-06-20T15:51:40
打酱油的企鹅呀给未入门的程序员的代码:
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true;
entity.player.onPress(({ button, raycast:{ hitEntity, direction } }) => {
if (button !== 'action0' || !hitEntity) {
return;
}
hitEntity.velocity.x += direction.x;
hitEntity.velocity.y += 0.5;
hitEntity.velocity.z += direction.z;
hitEntity.hurt(2 * Math.random() + 1, {
attacker: entity,
});
});
});
world.onDie(({ entity, attacker }) => {
if (attacker) {
world.say(attacker.player.name + ' 击杀了 ' + entity.player.name)
}
entity.player.forceRespawn();
});
undefined;
world.onPlayerJoin(({entity})=>{
entity.position.set(54, 8, 69);//玩家进来的时候,将ta传送到指定的坐标
entity.player.spawnPoint.copy(entity.position);//将玩家复活点复制为上面的坐标
})
/*SJS Tool version 0.1.5-beta, Copyright 2020 By Shyfcka, All right reserved. Code is Open Source. */const $ = {Position: (x, y, z) => {return new Box3Vector3(x, y, z);},GetEntityByPlayerName: (n) => {g = {e: null};world.querySelectorAll('player').forEach((e) => {if (e.player.name == n) {g.e = e}});return g.e;},PracticalFunctions: {},Gamerule: {Init: {CanFly: false,SpawnPoint: new Box3Vector3(喵, 15, 喵),CanByAttack: false,ShowHpBar: false,JumpPower: 1,DoubleJumpPower: 1,WalkSpeed: 0.2,RunSpeed: 0.3,MaxHp: 10.01,Hp: 10,},Running: {RespawnY: 0}},};(($) => {$.SendMessage = (e, m) => {e.player.directMessage(m);};$.SendMessageByName = (name, m) => {$.GetEntityByPlayerName(name).player.directMessage(m)};$.EntitySay = (e, m) => {e.say(m);};$.EntitySayByPlayerName = (name, m) => {$.GetEntityByPlayerName(name).say(m)};$.SetSpawnPoint = (e, x, y, z) => {e.player.spawnPoint = new Box3Vector3(x, y, z);};$.PracticalFunctions.Portal = (from, to, func = (e) => {}) => {world.querySelector(`.${from}`).onEntityContact(({other}, t = world.querySelector(`.${to}`).position, ds = func) => {other.position.x = t.x;other.position.y = t.y + 1;other.position.z = t.z;ds(other);})};$.PracticalFunctions.SavePoint = (tag, tips = '存档成功', func = (e) => {}) => {world.querySelector(`.${tag}`).onEntityContact(({entity,other}, ps = tips, fun = func) => {if (!other.isPlayer) {return;};other.player.spawnPoint = new Box3Vector3(entity.position.x, entity.position.y, entity.position.z);other.player.directMessage(ps);fun(other);});};$.AttackEntity = (e, conut) => {e.hurt(conut);};$.ForEachAllPlayer = (func) => {world.querySelectorAll('player').forEach((e) => {func(e)})};$.Start =() => {console.clear();console.log('程序开始运行\n已导入SJS v0.1\n--------------------------------------------------\n\n');world.onPlayerJoin(({entity}) => {gr = $.Gamerule.Init;entity.player.CanFly = gr.CanFly;entity.player.spawnPoint = gr.SpawnPoint;entity.enableDamage = gr.CanByAttack;entity.showHealthBar = gr.ShowHpBar;entity.maxHp = gr.MaxHp;entity.hp = gr.Hp;entity.player.spawnPoint = gr.SpawnPoint;entity.player.jumpPower = gr.JumpPower;entity.player.doubleJumpPower = gr.DoubleJumpPower;entity.player.walkSpeed = gr.WalkSpeed;entity.player.runSpeed = gr.RunSpeed;});world.onTick((evt) => {world.querySelectorAll('player').forEach((i) => {if (i.position.y < $.Gamerule.Running.RespawnY) {i.hurt(i.hp);i.position.y = -999;};});});};})($);world.$ = $;'enableDamage enable ';;
(async function(){
world.onPlayerJoin(async ({entity})=>{
entity.player.spawnPoint=new Box3Vector3(123,8,2);
world.say('欢迎来到迷雾PVP!');
entity.player.scale=0.5;
world.querySelector("."+'回血').onEntityContact(async ({entitiy,other})=>{
entity.hp=entity.hp + 3;
});
});
})();点赞0
评论