mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-19 22:41:52 +00:00
Added PVP
This commit is contained in:
parent
b11fb30ad6
commit
d1cfcc7367
3 changed files with 26 additions and 1 deletions
|
|
@ -4,5 +4,5 @@
|
|||
"maxPlayers": 10,
|
||||
"onlineMode": true,
|
||||
"logging": false,
|
||||
"gameMode":1
|
||||
"gameMode": 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ function inject(serv,player)
|
|||
serv.entityMaxId++;
|
||||
player.entity=new Entity(serv.entityMaxId);
|
||||
serv.entities[player.entity.id]=player.entity;
|
||||
player.entity.player=player;
|
||||
player.entity.health = 20;
|
||||
player.entity.food = 20;
|
||||
player.username=player._client.username;
|
||||
serv.players.push(player);
|
||||
serv.uuidToPlayer[player._client.uuid] = player;
|
||||
|
|
|
|||
22
lib/playerPlugins/pvp.js
Normal file
22
lib/playerPlugins/pvp.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
module.exports=inject;
|
||||
|
||||
function inject(serv, player)
|
||||
{
|
||||
function attackEntity(entityId)
|
||||
{
|
||||
var attackedPlayer = serv.entities[entityId].player;
|
||||
attackedPlayer.entity.health -= 1;
|
||||
attackedPlayer._client.write('update_health', {
|
||||
food: attackedPlayer.entity.food,
|
||||
foodSaturation: 0.0,
|
||||
health: attackedPlayer.entity.health
|
||||
});
|
||||
}
|
||||
|
||||
player._client.on("use_entity", function(packet) {
|
||||
if(packet.mouse == 1) {
|
||||
attackEntity(packet.target);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue