Drafted backend handling of melee attack.

This commit is contained in:
genxium
2022-11-24 17:48:07 +08:00
parent fdc296531a
commit 24d5ad9dc8
9 changed files with 2197 additions and 2008 deletions

View File

@@ -4,36 +4,6 @@ option go_package = "battle_srv/protos"; // here "./" corresponds to the "--go_o
package protos;
import "geometry.proto"; // The import path here is only w.r.t. the proto file, not the Go package.
message BattleColliderInfo {
string stageName = 1;
map<string, sharedprotos.Vec2DList> strToVec2DListMap = 2;
map<string, sharedprotos.Polygon2DList> strToPolygon2DListMap = 3;
int32 stageDiscreteW = 4;
int32 stageDiscreteH = 5;
int32 stageTileW = 6;
int32 stageTileH = 7;
int32 intervalToPing = 8;
int32 willKickIfInactiveFor = 9;
int32 boundRoomId = 10;
int64 battleDurationNanos = 11;
int32 serverFps = 12;
int32 inputDelayFrames = 13;
uint32 inputScaleFrames = 14;
int32 nstDelayFrames = 15;
int32 inputFrameUpsyncDelayTolerance = 16;
int32 maxChasingRenderFramesPerUpdate = 17;
int32 playerBattleState = 18;
double rollbackEstimatedDtMillis = 19;
int64 rollbackEstimatedDtNanos = 20;
double worldToVirtualGridRatio = 21;
double virtualGridToWorldRatio = 22;
int32 spAtkLookupFrames = 23;
int32 renderCacheSize = 24;
}
message PlayerDownsync {
int32 id = 1;
int32 virtualGridX = 2;
@@ -126,6 +96,38 @@ message MeleeBullet {
int32 offenderPlayerId = 17;
}
message BattleColliderInfo {
string stageName = 1;
map<string, sharedprotos.Vec2DList> strToVec2DListMap = 2;
map<string, sharedprotos.Polygon2DList> strToPolygon2DListMap = 3;
int32 stageDiscreteW = 4;
int32 stageDiscreteH = 5;
int32 stageTileW = 6;
int32 stageTileH = 7;
int32 intervalToPing = 8;
int32 willKickIfInactiveFor = 9;
int32 boundRoomId = 10;
int64 battleDurationNanos = 11;
int32 serverFps = 12;
int32 inputDelayFrames = 13;
uint32 inputScaleFrames = 14;
int32 nstDelayFrames = 15;
int32 inputFrameUpsyncDelayTolerance = 16;
int32 maxChasingRenderFramesPerUpdate = 17;
int32 playerBattleState = 18;
double rollbackEstimatedDtMillis = 19;
int64 rollbackEstimatedDtNanos = 20;
double worldToVirtualGridRatio = 21;
double virtualGridToWorldRatio = 22;
int32 spAtkLookupFrames = 23;
int32 renderCacheSize = 24;
map<int32, MeleeBullet> meleeSkillConfig = 25; // skillId -> skill
}
message RoomDownsyncFrame {
int32 id = 1;
map<int32, PlayerDownsync> players = 2;

View File

@@ -343,6 +343,7 @@
"forceBigEndianFloatingNumDecoding": false,
"renderFrameIdLagTolerance": 4,
"jigglingEps1D": 0.001,
"bulletTriggerEnabled": true,
"_id": "d12gkAmppNlIzqcRDELa91"
},
{
@@ -522,7 +523,7 @@
"array": [
0,
0,
239.32248305180272,
210.23252687912068,
0,
0,
0,
@@ -1482,7 +1483,6 @@
"zoomingListenerNode": {
"__id__": 5
},
"actionBtnListenerNode": null,
"stickhead": {
"__id__": 25
},

View File

@@ -440,7 +440,7 @@
"array": [
0,
0,
210.4441731196186,
210.23252687912068,
0,
0,
0,

View File

@@ -454,7 +454,7 @@
"array": [
0,
0,
210.4441731196186,
210.23252687912068,
0,
0,
0,

View File

@@ -1085,18 +1085,23 @@ cc.Class({
bulletColliders.forEach((bulletCollider, collisionBulletIndex) => {
const potentials = bulletCollider.potentials();
const offender = currRenderFrame.players[bulletCollider.data.offenderPlayerId];
let shouldRemove = false;
for (const potential of potentials) {
if (null != potential.data && potential.data.joinIndex == bulletCollider.data.offenderJoinIndex) continue;
if (!bulletCollider.collides(potential, result1)) continue;
if (null != potential.data && null !== potential.data.joinIndex) {
const joinIndex = potential.data.joinIndex;
bulletPushbacks[joinIndex - 1][0] += bulletCollider.data.pushback; // Only for straight punch, there's no y-pushback
let xfac = 1;
if (0 > offender.dirX) {
xfac = -1;
}
bulletPushbacks[joinIndex - 1][0] += xfac * bulletCollider.data.pushback; // Only for straight punch, there's no y-pushback
bulletPushbacks[joinIndex - 1][1] += 0;
const thatAckedPlayerInNextFrame = nextRenderFramePlayers[potential.data.id];
thatAckedPlayerInNextFrame.characterState = window.ATK_CHARACTER_STATE.Atked1[0];
const oldFrameToRecover = thatAckedPlayerInNextFrame.framesToRecover;
thatAckedPlayerInNextFrame.framesToRecover = (oldFrameToRecover > bulletCollider.data.hitStunFrames ? oldFrameToRecover : bulletCollider.data.hitStunFrames); // In case the hit player is already stun, we extend it
const oldFramesToRecover = thatAckedPlayerInNextFrame.framesToRecover;
thatAckedPlayerInNextFrame.framesToRecover = (oldFramesToRecover > bulletCollider.data.hitStunFrames ? oldFramesToRecover : bulletCollider.data.hitStunFrames); // In case the hit player is already stun, we extend it
}
shouldRemove = true;
}
@@ -1156,14 +1161,14 @@ cc.Class({
punch.offenderPlayerId = playerId;
punch.originatedRenderFrameId = currRenderFrame.id;
toRet.meleeBullets.push(punch);
console.log(`A rising-edge of meleeBullet is created at renderFrame.id=${currRenderFrame.id}, delayedInputFrame.id=${delayedInputFrame.inputFrameId}: ${JSON.stringify(punch)}`);
console.log(`A rising-edge of meleeBullet is created at renderFrame.id=${currRenderFrame.id}, delayedInputFrame.id=${delayedInputFrame.inputFrameId}: ${self._stringifyRecentInputCache(true)}`);
thatPlayerInNextFrame.characterState = window.ATK_CHARACTER_STATE.Atk1[0];
}
} else if (0 == decodedInput.btnALevel && 1 == prevBtnALevel) {
// console.log(`playerId=${playerId} triggered a falling-edge of btnA at renderFrame.id=${currRenderFrame.id}, delayedInputFrame.id=${delayedInputFrame.inputFrameId}`);
} else {
// No trigger, process movement inputs
// No bullet trigger, process movement inputs
if (0 != decodedInput.dx || 0 != decodedInput.dy) {
// Update directions and thus would eventually update moving animation accordingly
thatPlayerInNextFrame.dirX = decodedInput.dx;