Skip to content

Commit

Permalink
Merge branch 'dev' into feature/BigWaterCanon
Browse files Browse the repository at this point in the history
  • Loading branch information
Z1Meme authored Nov 5, 2024
2 parents ee98de6 + 5ce3e1e commit 8f152ed
Show file tree
Hide file tree
Showing 17 changed files with 245 additions and 157 deletions.
9 changes: 9 additions & 0 deletions data/defaultDatabase/shared/admins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"name": "Your name",
"permissionLevel": 2,
"commentOnLevel": "1=moderator,2=admin,3=dev",
"sessionId": "Your sessionId that you get using /me in game"
}
]

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "h1z1-server",
"version": "0.40.3-8",
"version": "0.40.3-9",
"description": "Library for emulating h1z1 servers",
"author": "Quentin Gruber <[email protected]> (https://github.com/quentingruber)",
"license": "GPL-3.0-only",
Expand Down
2 changes: 1 addition & 1 deletion src/packets/ClientProtocol/ClientProtocol_1080/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const basePackets: PacketStructures = [
0x02,
{
fields: [
{ name: "unknownBoolean1", type: "boolean", defaultValue: false } // This value is first set to false, the second time its sent its set to true
{ name: "characterReleased", type: "boolean", defaultValue: false } // This value is first set to false, the second time its sent its set to true
]
}
],
Expand Down
5 changes: 2 additions & 3 deletions src/servers/ZoneServer2016/classes/zoneclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export class ZoneClient2016 {
guid?: string;
character: Character2016;
currentPOI?: number;
firstLoading: boolean = false;
firstLoading: boolean = true;
isLoading: boolean = true;
characterReleased: boolean = false;
firstCharacterReleased: boolean = true;
isSynced: boolean = false;
isInteracting: boolean = false;
isAdmin: boolean = false;
Expand Down Expand Up @@ -121,8 +122,6 @@ export class ZoneClient2016 {
this.sessionId = sessionId;
this.soeClientId = soeClientId;

this.isLoading = true;
this.firstLoading = true;
this.loginSessionId = loginSessionId;
this.spawnedEntities = new Set();
this.managedObjects = [];
Expand Down
173 changes: 103 additions & 70 deletions src/servers/ZoneServer2016/entities/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1653,71 +1653,11 @@ export class Character2016 extends BaseFullCharacter {
}
}

OnProjectileHit(server: ZoneServer2016, damageInfo: DamageInfo) {
if (!this.isAlive) return;

const itemDefinition = server.getItemDefinition(damageInfo.weapon);
if (!itemDefinition) return;
const weaponDefinitionId = itemDefinition.PARAM1;

const client = server.getClientByCharId(damageInfo.entity), // source
c = server.getClientByCharId(this.characterId); // target
if (!client || !c || !damageInfo.hitReport) {
return;
}

server.fairPlayManager.hitMissFairPlayCheck(
server,
client,
true,
damageInfo.hitReport?.hitLocation || ""
);

if (server.isHeadshotOnly && damageInfo.hitReport?.hitLocation != "HEAD")
return;
if (server.isPvE) return;

const hasHelmetBefore = this.hasHelmet(server);
const hasArmorBefore = this.hasArmor(server);

let damage = damageInfo.damage,
canStopBleed,
armorDmgModifier;
armorDmgModifier =
weaponDefinitionId == WeaponDefinitionIds.WEAPON_SHOTGUN ? 10 : 4;
if (weaponDefinitionId == WeaponDefinitionIds.WEAPON_308)
armorDmgModifier = 2;
switch (damageInfo.hitReport?.hitLocation) {
case "HEAD":
case "GLASSES":
case "NECK":
damage =
weaponDefinitionId == WeaponDefinitionIds.WEAPON_SHOTGUN
? (damage *= 2)
: (damage *= 4);
damage =
weaponDefinitionId == WeaponDefinitionIds.WEAPON_308
? (damage *= 2)
: damage;
damage = server.checkHelmet(this.characterId, damage, 1);
break;
default:
damage = server.checkArmor(this.characterId, damage, armorDmgModifier);
canStopBleed = true;
break;
}

if (this.isAlive) {
server.sendHitmarker(
client,
damageInfo.hitReport?.hitLocation,
this.hasHelmet(server),
this.hasArmor(server),
hasHelmetBefore,
hasArmorBefore
);
}

applySpecialWeaponEffect(
server: ZoneServer2016,
client: ZoneClient2016,
weaponDefinitionId: WeaponDefinitionIds
) {
/* eslint-disable @typescript-eslint/no-unused-vars */
switch (weaponDefinitionId) {
case WeaponDefinitionIds.WEAPON_BLAZE:
Expand Down Expand Up @@ -1756,7 +1696,7 @@ export class Character2016 extends BaseFullCharacter {
case WeaponDefinitionIds.WEAPON_FROSTBITE:
if (!this._characterEffects[Effects.PFX_Seasonal_Holiday_Snow_skel]) {
server.sendData<ClientUpdateModifyMovementSpeed>(
c,
client,
"ClientUpdate.ModifyMovementSpeed",
{
speed: 0.5
Expand All @@ -1771,7 +1711,7 @@ export class Character2016 extends BaseFullCharacter {
character: Character2016
) {
server.sendData<ClientUpdateModifyMovementSpeed>(
c,
client,
"ClientUpdate.ModifyMovementSpeed",
{
speed: 2
Expand All @@ -1790,7 +1730,100 @@ export class Character2016 extends BaseFullCharacter {
);
break;
}
/* eslint-enable @typescript-eslint/no-unused-vars */
}

OnProjectileHit(server: ZoneServer2016, damageInfo: DamageInfo) {
if (!this.isAlive || server.isPvE) return;

if (server.isHeadshotOnly) {
switch (damageInfo.hitReport?.hitLocation) {
case "HEAD":
case "GLASSES":
case "NECK":
break;
default:
return;
}
}

const itemDefinition = server.getItemDefinition(damageInfo.weapon);
if (!itemDefinition) return;
const weaponDefinitionId = itemDefinition.PARAM1;

const sourceClient = server.getClientByCharId(damageInfo.entity), // source
targetClient = server.getClientByCharId(this.characterId); // target
if (!sourceClient || !targetClient || !damageInfo.hitReport) {
return;
}

server.fairPlayManager.hitMissFairPlayCheck(
server,
sourceClient,
true,
damageInfo.hitReport?.hitLocation || ""
);

const hasHelmetBefore = this.hasHelmet(server);
const hasArmorBefore = this.hasArmor(server);

let damage = damageInfo.damage,
canStopBleed,
weaponDmgModifier,
headshotDmgMultiplier;

// these should be configurable
const weaponDmgModifierDefault = 4,
weaponDmgModifierShotgun = 10,
weaponDmgModifierSniper = 1,
headshotDmgMultiplierDefault = 4,
headshotDmgMultiplierShotgun = 1,
headshotDmgMultiplierSniper = 6;

switch (weaponDefinitionId) {
case WeaponDefinitionIds.WEAPON_SHOTGUN:
weaponDmgModifier = weaponDmgModifierShotgun;
headshotDmgMultiplier = headshotDmgMultiplierShotgun;
break;
case WeaponDefinitionIds.WEAPON_308:
weaponDmgModifier = weaponDmgModifierSniper;
headshotDmgMultiplier = headshotDmgMultiplierSniper;
break;
default:
weaponDmgModifier = weaponDmgModifierDefault;
headshotDmgMultiplier = headshotDmgMultiplierDefault;
break;
}

switch (damageInfo.hitReport?.hitLocation) {
case "HEAD":
case "GLASSES":
case "NECK":
damage = damage *= headshotDmgMultiplier;
damage = server.applyHelmetDamageReduction(this, damage, 1);
break;
default:
damage = server.applyArmorDamageReduction(
this,
damage,
weaponDmgModifier
);
canStopBleed = true;
break;
}

if (this.isAlive) {
server.sendHitmarker(
sourceClient,
damageInfo.hitReport?.hitLocation,
this.hasHelmet(server),
this.hasArmor(server),
hasHelmetBefore,
hasArmorBefore
);
}

this.applySpecialWeaponEffect(server, targetClient, weaponDefinitionId);

this.damage(server, {
...damageInfo,
damage: damage,
Expand Down Expand Up @@ -1823,10 +1856,10 @@ export class Character2016 extends BaseFullCharacter {
case "HEAD":
case "GLASSES":
case "NECK":
damage = server.checkHelmet(this.characterId, damage, 1);
damage = server.applyHelmetDamageReduction(this, damage, 1);
break;
default:
damage = server.checkArmor(this.characterId, damage, 4);
damage = server.applyArmorDamageReduction(this, damage, 4);
break;
}

Expand Down
3 changes: 2 additions & 1 deletion src/servers/ZoneServer2016/entities/lootableprop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ export class LootableProp extends BaseLootableEntity {
() => {
super.OnPlayerSelect(server, client);
client.searchedProps.push(this);
server.lootCrateWithChance(client, 5);
}
);
} else {
Expand Down Expand Up @@ -428,6 +429,6 @@ export class LootableProp extends BaseLootableEntity {
client.character.lootItem(server, server.generateItem(Items.METAL_SCRAP));
}

server.damageItem(client, weapon, server.crowbarHitDamage);
server.damageItem(client.character, weapon, server.crowbarHitDamage);
}
}
2 changes: 1 addition & 1 deletion src/servers/ZoneServer2016/entities/npc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ export class Npc extends BaseFullCharacter {
case ModelIds.ZOMBIE_SCREAMER:
this.triggerAwards(server, client, this.rewardItems, true);
}
server.damageItem(client, skinningKnife, 200);
server.damageItem(client.character, skinningKnife, 200);
server.deleteEntity(this.characterId, server._npcs);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/servers/ZoneServer2016/entities/trapentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export class TrapEntity extends BaseSimpleNpc {

const damage = damageInfo.damage * 3;
this.damage(server, { ...damageInfo, damage });
server.damageItem(client, weapon, 50);
server.damageItem(client.character, weapon, 50);
}

damage(server: ZoneServer2016, damageInfo: DamageInfo) {
Expand Down
2 changes: 1 addition & 1 deletion src/servers/ZoneServer2016/entities/treasurechest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class TreasureChest extends LootableProp {
);
const rewards = server.rewardManager.rewards;
for (const reward of rewards) {
if (chance(50)) {
if (chance(100)) {
const item = server.generateItem(reward.itemId, 1, true);
if (!item) return;
this.lootContainerItem(server, item, item?.stackCount, false);
Expand Down
2 changes: 1 addition & 1 deletion src/servers/ZoneServer2016/entities/vehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ export class Vehicle2016 extends BaseLootableEntity {

if (this._resources[ResourceIds.CONDITION] < 100000) {
this.damage(server, { ...damageInfo, damage: -2000 });
server.damageItem(client, weapon, 100);
server.damageItem(client.character, weapon, 100);
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/servers/ZoneServer2016/managers/constructionmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2451,7 +2451,7 @@ export class ConstructionManager {
entity: "Server.DemoHammer",
damage: entity.maxHealth / 3 + 10
});
server.damageItem(client, weaponItem, 50);
server.damageItem(client.character, weaponItem, 50);
}

hammerConstructionEntity(
Expand Down Expand Up @@ -2499,7 +2499,11 @@ export class ConstructionManager {
this.repairConstruction(server, entity, entity.maxHealth / 10);
accumulatedItemDamage += 15;
}
server.damageItem(client, weaponItem, Math.ceil(accumulatedItemDamage / 4));
server.damageItem(
client.character,
weaponItem,
Math.ceil(accumulatedItemDamage / 4)
);
client.character.lastMeleeHitTime = Date.now();
client.character.lastRepairTime = Date.now();
}
Expand Down
2 changes: 1 addition & 1 deletion src/servers/ZoneServer2016/managers/speedtreemanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class SpeedTreeManager {
return;
}

server.damageItem(client, wep, 5);
server.damageItem(client.character, wep, 5);

if (!this._speedTreesCounter[objectId]) {
this._speedTreesCounter[objectId] = {
Expand Down
Loading

0 comments on commit 8f152ed

Please sign in to comment.