diff --git a/2001/ze_lotr_minas_tirith/global_hud.js b/2001/ze_lotr_minas_tirith/global_hud.js new file mode 100644 index 0000000..a736bf7 --- /dev/null +++ b/2001/ze_lotr_minas_tirith/global_hud.js @@ -0,0 +1,49 @@ +import { Instance } from "cs_script/point_script"; + +let remaining = 0; // 总时间 +let delay = 0; // 每次触发的延迟 +let isCounting = false; // 添加一个标志来控制倒计时,防止重复启动 + +function tickCountdown() { + if (!isCounting) return; + + if (remaining < 0) { + Instance.Msg("Countdown finished!"); + isCounting = false; + return; + } + + const text = "TIME UNTIL GHOST ARMY ARRIVAL:" + remaining + " SECONDS"; + Instance.EntFireAtName({ + name: "counter", + input: "SetMessage", + value: text, + delay: 0 + }); + + Instance.EntFireAtName({ + name: "countdown", + input: "CountPlayersInZone", + delay: 0.1 + }); + + remaining--; + + Instance.Msg("Countdown " + remaining); + + Instance.SetNextThink(Instance.GetGameTime() + 1.0); +} + +Instance.OnScriptInput("globalHUD", () => { + if (isCounting) { + Instance.Msg("Countdown is already running."); + return; + } + + remaining = 150; + isCounting = true; + + Instance.SetThink(tickCountdown); + tickCountdown(); // 立即显示首帧 + Instance.SetNextThink(Instance.GetGameTime() + 1.0); +}); \ No newline at end of file diff --git a/2001/ze_lotr_minas_tirith/item_nazgul.js b/2001/ze_lotr_minas_tirith/item_nazgul.js new file mode 100644 index 0000000..0415734 --- /dev/null +++ b/2001/ze_lotr_minas_tirith/item_nazgul.js @@ -0,0 +1,77 @@ +import { Instance } from "cs_script/point_script"; + +// @ts-ignore +// 数组存储多个玩家 +let markedPlayers = []; + +// 输入:标记玩家(范围在1-6人) +Instance.OnScriptInput("LaunchNAZGUL", (inputData) => { + let player = inputData.activator; + + if (!player || !player.IsValid()) return; + + // @ts-ignore + // 查重:如果数组里已经有这个人,就不再重复添加 + if (markedPlayers.includes(player)) { + Instance.Msg("LaunchNAZGUL: 玩家已在列表 -> " + player.GetEntityName()); + return; + } + + // @ts-ignore + // 如果数组里没有这个人,添加到数组 + markedPlayers.push(player); + Instance.Msg("LaunchNAZGUL: 新增标记玩家 -> " + player.GetEntityName() + " (当前总数: " + markedPlayers.length + ")"); +}); + +Instance.OnPlayerDamage((event) => { + // 获取被攻击者 + let victim = event.player; + + // @ts-ignore + // 1. 检查被攻击者是否在我们的标记名单里 + // 如果名单为空,或者被攻击者不在名单里,直接跳过 + if (markedPlayers.length === 0 || !markedPlayers.includes(victim)) { + return; + } + + // 2. 获取攻击者 + let attacker = event.attacker; + if (!attacker || !attacker.IsValid()) return; + + // 3. 计算击退向量 + let attackerPos = attacker.GetAbsOrigin(); + let playerPos = victim.GetAbsOrigin(); + + let dirX = playerPos.x - attackerPos.x; + let dirY = playerPos.y - attackerPos.y; + let dirZ = playerPos.z - attackerPos.z; + + let len = Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ); + + if (len > 0) { + const force = 110; + + let pushX = (dirX / len) * force; + let pushY = (dirY / len) * force; + let pushZ = (dirZ / len) * force + 5; + + // 优化2:动量保留 (当前速度 + 击退速度) + let currentVel = victim.GetAbsVelocity(); + + let finalVelocity = { + x: currentVel.x + pushX, + y: currentVel.y + pushY, + z: currentVel.z + pushZ + 10 // 额外提升Z轴速度 + }; + + // 应用速度 + victim.Teleport({ velocity: finalVelocity }); + } +}); + +// 回合开始时清空名单 +Instance.OnRoundStart(() => { + // @ts-ignore + markedPlayers = []; + Instance.Msg("LaunchNAZGUL: 回合开始,清空标记名单。"); +}); \ No newline at end of file diff --git a/2001/ze_lotr_minas_tirith/item_tnt_push.js b/2001/ze_lotr_minas_tirith/item_tnt_push.js new file mode 100644 index 0000000..2e89612 --- /dev/null +++ b/2001/ze_lotr_minas_tirith/item_tnt_push.js @@ -0,0 +1,76 @@ +import { Instance } from "cs_script/point_script"; + +// @ts-ignore +let TNT_Phys = null; + +function Get_TNT_Phys() { + // @ts-ignore + if (!TNT_Phys || !TNT_Phys.IsValid()) { + TNT_Phys = Instance.FindEntityByName("item_tnt_s1"); + } + return TNT_Phys; +} + +//计算发射方向向量 +// @ts-ignore +function calculateLaunchDirection(AbsAngles, pitchOffset) { + let yawRad = AbsAngles.yaw * Math.PI / 180; + let pitchRad = (AbsAngles.pitch + pitchOffset) * Math.PI / 180; + + let x = Math.cos(pitchRad) * Math.cos(yawRad); + let y = Math.cos(pitchRad) * Math.sin(yawRad); + let z = Math.sin(pitchRad); + + return { x, y, z }; +} + +Instance.OnScriptInput("LaunchTNT", (inputData) => { + Instance.Msg("LaunchTNT is running."); + + // 获取玩家 (Entity) + let player = inputData.activator; + + if (!player || !player.IsValid()) { + return; + } + + // 注意:在CS2中,玩家Pawn的classname通常是 "cs_player_pawn" 而不是 "player" + // 为了兼容性,这里主要检查 IsValid 和 IsAlive + if (player.IsAlive && !player.IsAlive()) { + Instance.Msg("LaunchTNT: Player not alive."); + return; + } + + let tnt = Get_TNT_Phys(); + if (!tnt || !tnt.IsValid()) { + Instance.Msg("LaunchTNT: TNT entity not found or invalid."); + return; + } + + let AbsAngles = player.GetAbsAngles(); + // 获取角度 + let launchDirection = calculateLaunchDirection(AbsAngles, 60); + // 设置速度 + let launchSpeed = 720; + // 设置跳投的额外速度 + let launchBoost = 530; + + // 获取玩家当前的绝对速度向量 {x, y, z} + let playerVel = player.GetAbsVelocity(); // + + // 检查 Z 轴速度。使用 Math.abs 处理向上(正)或向下(负)的速度 + if (playerVel && Math.abs(playerVel.z) > 10) { + launchSpeed += launchBoost; + Instance.Msg("Boost applied! Z-Speed: " + playerVel.z); + } + // --- 修改结束 --- + + let launchVelocity = { + x: launchDirection.x * launchSpeed, + y: launchDirection.y * launchSpeed, + z: launchDirection.z * launchSpeed + }; + + // 设置TNT速度 + tnt.Teleport({ velocity: launchVelocity }); +}); \ No newline at end of file