diff --git a/Core/HuRocos-2024/play/their_Penalty.lua b/Core/HuRocos-2024/play/their_Penalty.lua index f4d11a3..a1c9cd5 100644 --- a/Core/HuRocos-2024/play/their_Penalty.lua +++ b/Core/HuRocos-2024/play/their_Penalty.lua @@ -21,8 +21,13 @@ local stopPos = function(role) end local getBallPos = function(role) + local enemyNum = enemy.closestBall() local rolePos = player.pos(role) + local enemyPos = enemy.pos(enemyNum) local tPos = Utils.GetBestInterPos(vision, rolePos, param.playerVel, 1, 1,param.V_DECAY_RATE) + if enemyPos:dist(tPos) < param.playerRadius then + tPos = tPos + Utils.Polar2Vector(param.playerRadius, (param.ourGoalPos-enemyPos):dir()) + end return tPos end @@ -32,7 +37,6 @@ local subScript = false return { __init__ = function(name, args) print("in __init__ func : ",name, args) - end, @@ -59,9 +63,14 @@ firstState = "Init", ["Defend"] = { switch = function() -- debugEngine:gui_debug_msg(CGeoPoint(0,0),ball.posX()) - if bufcnt(ball.pos():dist(enemy.pos(enemy.closestBall())) < param.playerRadius * 1.5, 20) then - return "Getball" - end + -- if bufcnt(ball.pos():dist(enemy.pos(enemy.closestBall())) < param.playerRadius * 1.5, 20) then + -- return "Getball" + -- end + return "Getball" + + -- if bufcnt(ball.pos():dist(enemy.pos(enemy.closestBall())) < param.playerRadius * 1.5, 20) then + -- return "Getball" + -- end end, Goalie = gSubPlay.roleTask("Goalie", "Goalie"), -- Leader = task.getball(function() return shoot_pos end,playerVel,getballMode), @@ -76,13 +85,24 @@ firstState = "Init", -- return "Defend" -- end if ball.posX() < player.posX("Goalie") then - return "Defend" + return "CatchBall" end end, Goalie = function() return task.goSimplePos(getBallPos, player.toBallDir("Goalie"), flag.dribbling) end, match = "{G}" }, + +["CatchBall"] = { + switch = function() + -- debugEngine:gui_debug_msg(CGeoPoint(0,0),ball.posX()) + -- if ball.pos():dist(enemy.pos(enemy.closestBall())) > param.playerRadius * 1.5 then + -- return "Defend" + -- end + end, + Goalie = function() return task.goalie_catchBall("Goalie") end, + match = "{G}" +}, name = "their_Penalty", applicable ={ exp = "a", diff --git a/Core/tactics/skill/CircleRun.cpp b/Core/tactics/skill/CircleRun.cpp index 6e30db7..fc41acb 100644 --- a/Core/tactics/skill/CircleRun.cpp +++ b/Core/tactics/skill/CircleRun.cpp @@ -53,7 +53,9 @@ CPlayerCommand* CCircleRun::execute(const CVisionModule* pVision){ GDebugEngine::instance()->gui_debug_line(me.RawPos(), me.RawPos() + targetVel.rotate(me.Dir()), COLOR_RED); GDebugEngine::instance()->gui_debug_line(me.RawPos(), me.RawPos() + localVel.rotate(me.Dir()), COLOR_BLUE); GDebugEngine::instance()->gui_debug_line(me.RawPos(), me.RawPos() + me2center.rotate(me.Dir()), COLOR_GREEN); - // GDebugEngine::instance()->gui_debug_x(me.RawPos() + me2center.rotate(me.Dir()), COLOR_GREEN); - // GDebugEngine::instance()->gui_debug_msg(me.RawPos() + me2center.rotate(me.Dir()), fmt::format("v:{:.1f},tv:{:.1f}",meVel.mod(),localVel.mod()),COLOR_GREEN); + + GDebugEngine::instance()->gui_debug_x(me.RawPos() + me2center.rotate(me.Dir()), COLOR_GREEN); + GDebugEngine::instance()->gui_debug_msg(me.RawPos() + me2center.rotate(me.Dir()), fmt::format("v:{:.1f},tv:{:.1f}",meVel.mod(),localVel.mod()),COLOR_GREEN); + return CmdFactory::Instance()->newCommand(CPlayerSpeedV2(vecNumber, localVel.x(), localVel.y(), rotVel, dribblePower)); } \ No newline at end of file diff --git a/ZBin/lua_scripts/worldmodel/task.lua b/ZBin/lua_scripts/worldmodel/task.lua index 145c91c..4de8b08 100644 --- a/ZBin/lua_scripts/worldmodel/task.lua +++ b/ZBin/lua_scripts/worldmodel/task.lua @@ -178,8 +178,6 @@ function getball(shootPos_,playerVel, inter_flag, permissions) end -- end - - local ishootpos if type(shootPos_) == "function" then ishootpos = shootPos_() @@ -391,6 +389,63 @@ function GetBallV2(role, p, dist1, speed1) -------dist开始减速的距离 sp end end +function TurnToPointV1(role, p, speed) + --参数说明 + -- role 使用这个函数的角色 + -- p 指向坐标 + -- speed 旋转速度 + local p1 = p + if type(p) == 'function' then + p1 = p() + else + p1 = p + end + if speed == nil then + speed = 800 + end + local playerPos = player.pos(role) + local playerDir = player.dir(role) + local playerToBallDist = player.toBallDist(role) + local playerToBallDir = (ball.pos() - player.pos(role)):dir() + local playerToTargetDir = (p1 - player.pos(role)):dir() + local ballPos = CGeoPoint:new_local (ball.posX(),ball.posY()) + local ballToTargetDir = (p1 - ball.pos()):dir() + local subPlayerBallToTargetDir = playerToTargetDir - ballToTargetDir + -- 逆时针旋转 + local idirLeft = (playerDir+param.PI/2)>param.PI and playerDir-(3/2)*param.PI or playerDir+param.PI/2 + -- 顺时针旋转 + local idirRight = (playerDir-param.PI/2)>param.PI and playerDir+(3/2)*param.PI or playerDir-param.PI/2 + + local Subdir = math.abs(Utils.angleDiff(playerToTargetDir,playerDir)) + + if Subdir > 0.14 then + if subPlayerBallToTargetDir > 0 then + -- 逆时针旋转 + -- debugEngine:gui_debug_msg(CGeoPoint(1000, 1000), "0") + local target_pos = playerPos+Utils.Polar2Vector(speed, idirLeft)+Utils.Polar2Vector(2*playerToBallDist, playerToBallDir) + debugEngine:gui_debug_x(target_pos) + local mexe, mpos = GoCmuRush { pos = target_pos, dir = playerToBallDir, acc = a, flag = 0x00000100, rec = r, vel = v } + return { mexe, mpos } + end + -- 顺时针旋转 + -- debugEngine:gui_debug_msg(CGeoPoint(1000, 1000), "1") + local target_pos = playerPos+Utils.Polar2Vector(speed, idirRight)+Utils.Polar2Vector(2*playerToBallDist, playerToBallDir) + debugEngine:gui_debug_x(target_pos) + local mexe, mpos = GoCmuRush { pos = target_pos, dir = playerToBallDir, acc = a, flag = 0x00000100, rec = r, vel = v } + return { mexe, mpos } + -- else + -- elseif playerToBallDist > 1 then + -- -- debugEngine:gui_debug_msg(CGeoPoint:new_local(1000, 1000), "2") + -- local mexe, mpos = GoCmuRush { pos = ballPos, dir = playerToTargetDir, acc = a, flag = 0x00000100, rec = r, vel = v } + -- return { mexe, mpos } + -- else + -- local idir = (p1 - player.pos(role)):dir() + -- local pp = player.pos(role) + Utils.Polar2Vector(0 + 10, idir) + -- local mexe, mpos = GoCmuRush { pos = pp, dir = idir, acc = 50, flag = 0x00000100 + 0x04000000, rec = 1, vel = v } + -- return { mexe, mpos } + end +end + function TurnToPointV2(role, p, speed) --参数说明 -- role 使用这个函数的角色 @@ -1157,7 +1212,24 @@ function goalie_kick(role) end --- 守门员skill +function goalie_catchBall(role) + local rolePos = player.pos(role) + local playerToBallDir = (ball.pos()-rolePos):dir() + local getBallPos = Utils.GetBestInterPos(vision, rolePos, param.playerVel, 1, 1,param.V_DECAY_RATE) + + + local DSS_FLAG = bit:_or(flag.allow_dss, flag.dodge_ball) + local iflag = DSS_FLAG + + + + local mexe, mpos = GoCmuRush { pos = getBallPos, dir = playerToBallDir, acc = a, flag = iflag, rec = r, vel = v } + return { mexe, mpos } +end + + + +-- 守门员skill(目前已弃用) -- 当球进禁区时要踢到的目标点 -- TODO: -- 这个mode的用法不对,在更换到新的goalie子脚本中会修复 @@ -1271,6 +1343,8 @@ end + + --[[ 盯防 ]] markingTable = {} markingTableLen = 0