Guest User

Untitled

a guest
Mar 27th, 2025
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.03 KB | None | 0 0
  1. if MinigameSnowball == nil then
  2.     MinigameSnowball = class({})
  3. end
  4.  
  5. SNOWBALL_FALL_HEIGHT = 0
  6. SNOWBALL_SIZE = 100
  7. SNOWBALL_MODEL_RADIUS = 128
  8. SNOWBALL_KILL_INTERVAL = 0.2
  9.  
  10. SNOWBALL_BEGIN_TIME = 80
  11. SNOWBALL_BONUS_TIME = 10
  12.  
  13. function MinigameSnowball:InitMinigame()
  14.  
  15.     print("[OMNIPARTY] Run Maiden, Run!")
  16.  
  17.     -- Set scoring method
  18.     OmniParty:AutoScoreReverse()
  19.  
  20.     -- Initialize areas
  21.     self._PlayerSpawn = GetArea("snowball_player_spawn")
  22.     self._CheckPoint = {
  23.         [0] = self._PlayerSpawn,
  24.         [1] = GetArea("real_snowball_checkpoint_1"),
  25.         [2] = GetArea("real_snowball_checkpoint_2"),
  26.         -- [3] = GetArea("snowball_checkpoint_3")
  27.     }
  28.  
  29.     self._WardPosition = Entities:FindAllByName("snowball_vision")
  30.  
  31.     for i, v in pairs(self._WardPosition) do
  32.         self._WardPosition[i] = self._WardPosition[i]:GetAbsOrigin()
  33.     end
  34.  
  35.     -- Show the remaining time
  36.     Scoreboard:ShowExtraColumn("#time")
  37.    
  38.     -- Initialize Maidens
  39.     self._SnowMaiden = {}
  40.     self._SnowMaidenCount = 0
  41.     self._LastCheckPoint = {}
  42.     self._TimeCheckPoint = {}
  43.     self._Countdown = {}
  44.  
  45.     for i, player in pairs(GetPlayers()) do
  46.         self._SnowMaiden[i] = SpawnUnitForPlayer("npc_snow_maiden", player, self._PlayerSpawn, 0, true, false, 80, true)
  47.  
  48.         ApplyCustomModifier(self._SnowMaiden[i], "item_modifier", "no_collision")
  49.  
  50.         self._SnowMaidenCount = self._SnowMaidenCount + 1
  51.  
  52.         self._LastCheckPoint[i] = 0
  53.         self._TimeCheckPoint[i] = 0
  54.         self._Countdown[i] = SNOWBALL_BEGIN_TIME
  55.  
  56.         Scoreboard:SetPlayerExtra(i, self._Countdown[i])
  57.  
  58.         PlayerResource:SetCameraTarget(i, self._SnowMaiden[i])
  59.     end
  60.  
  61.     -- Initialize Snowballs
  62.     local Snowball_param = self:GetSnowballParam()
  63.  
  64.     -- Get the starting and destination points for all the snowballs
  65.     local _max_s = {}
  66.     local _max_n = {}
  67.     local count = {}
  68.  
  69.     for k, group in pairs(Snowball_param) do
  70.         count[k] = 0
  71.  
  72.         for i, v in pairs(group) do
  73.             -- Get start and end positions for the snowballs
  74.             v.start = Entities:FindByName(nil, "snowball_start_" .. i):GetAbsOrigin()
  75.             v.dest = Entities:FindByName(nil, "snowball_dest_" .. i):GetAbsOrigin()
  76.             v.start[3]=128
  77.             v.dest[3]=128
  78.             -- Precalculate number and size of series
  79.             if _max_s[k] == nil then
  80.                 _max_s[k] = #v.velocity
  81.             end
  82.  
  83.             _max_n[i] = {}
  84.  
  85.             for j, series in pairs(v.velocity) do
  86.                 _max_n[i][j] = #series
  87.             end
  88.  
  89.             count[k] = count[k] + 1
  90.         end
  91.     end
  92.  
  93.     -- Create Snowball spawners
  94.     self._SnowballTimer = {}
  95.  
  96.     for k, group in pairs(Snowball_param) do
  97.         local max_s = _max_s[k]
  98.         local s = RandomInt(1, max_s)
  99.         local flag = count[k]
  100.  
  101.         for i, v in pairs(group) do
  102.             local max_n = _max_n[i][s]
  103.             local n = 0
  104.  
  105.             self._SnowballTimer[i] = Timers:CreateTimer({
  106.                 callback = function()
  107.                     n = n + 1
  108.  
  109.                     if n > max_n then
  110.                         if flag == count[k] then
  111.                             s = RandomInt(1, max_s)
  112.                             flag = 1
  113.                         else
  114.                             flag = flag + 1
  115.                         end
  116.  
  117.                         max_n = _max_n[i][s]
  118.                         n = 1
  119.                     end
  120.  
  121.                     if v.velocity[s][n] ~= 0 then
  122.                         self:CreateSnowball(SNOWBALL_SIZE, v.start, v.velocity[s][n] * (v.dest - v.start):Normalized(),
  123.                             (v.dest - v.start):Length())
  124.                     end
  125.  
  126.                     return v.interval[s][n]
  127.                 end
  128.             })
  129.         end
  130.     end
  131.  
  132. end
  133.  
  134. function MinigameSnowball:Intro()
  135.     Scoreboard:ShowHelp("#snowball")
  136. end
  137.  
  138. function MinigameSnowball:OnUnitDeath(keys)
  139.  
  140.     local unit = EntIndexToHScript(keys.entindex_killed)
  141.     local name = unit:GetUnitName()
  142.  
  143.     if name == "npc_snow_maiden" then
  144.         local killer = EntIndexToHScript(keys.entindex_attacker)
  145.         local player = unit:GetPlayerOwner()
  146.         local id = unit:GetPlayerOwnerID()
  147.  
  148.         -- If the player died to a snowball respawn
  149.         if player and killer:GetUnitName() == "npc_dummy" and IsPhysicsUnit(killer) then
  150.             local posspawn = RandomVectorInArea(self._CheckPoint[self._LastCheckPoint[id]],50,50)
  151.             self._SnowMaiden[id] = SpawnUnitForPlayer("npc_snow_maiden", player,
  152.             posspawn, 0, false, false, 80, true)
  153.         end
  154.     end
  155.  
  156. end
  157.  
  158. function SetCheckPoint(trigger)
  159.     OmniParty._Minigame:SetCheckPoint(trigger.activator, trigger.caller)
  160. end
  161.  
  162. function MinigameSnowball:SetCheckPoint(unit, area)
  163.  
  164.     if unit:GetUnitName() == "npc_snow_maiden" then
  165.         local areaName = area:GetName()
  166.         local n = string.gsub(area:GetName(), "%D", "")
  167.         n = tonumber(n)
  168.  
  169.         local id = unit:GetPlayerOwnerID()
  170.  
  171.         if self._LastCheckPoint[id] < n then
  172.             self._LastCheckPoint[id] = n
  173.             self._TimeCheckPoint[id] = self._Countdown[id]
  174.             self._Countdown[id] = self._Countdown[id] + SNOWBALL_BONUS_TIME
  175.  
  176.             Announcement:Player(id, "Checkpoint reached!", 3)
  177.         end
  178.     end
  179.  
  180. end
  181.  
  182. function PlayerFinished(trigger)
  183.     OmniParty._Minigame:PlayerFinished(trigger.activator)
  184. end
  185.  
  186. function MinigameSnowball:PlayerFinished(unit)
  187.  
  188.     if unit:GetUnitName() == "npc_snow_maiden" then
  189.         local id = unit:GetPlayerOwnerID()
  190.  
  191.         RemoveWinner(unit)
  192.         OmniParty:AutoScore(id)
  193.  
  194.         self._LastCheckPoint[id] = -1
  195.         self._Countdown[id] = -1
  196.         local player = unit:GetPlayerOwner()
  197.         local id = unit:GetPlayerOwnerID()
  198.  
  199.         if player then
  200.             for i, position in pairs(self._WardPosition) do
  201.                 CreateWard(WARD_GROUND, position, player)
  202.             end
  203.         end
  204.  
  205.         Scoreboard:SetPlayerExtra(id, nil)
  206.  
  207.         self._SnowMaiden[id] = nil
  208.         self._SnowMaidenCount = self._SnowMaidenCount - 1
  209.     end
  210.  
  211. end
  212.  
  213. function MinigameSnowball:CreateSnowball(r_kill, position, velocity, distance)
  214.     -- print(position)
  215.     local Snowball = CreateUnitByName("npc_dummy", position, true, nil, nil, DOTA_TEAM_NEUTRALS)
  216.  
  217.     -- Calculate the model scale according to the kill radius it should have
  218.     local scale = r_kill / SNOWBALL_MODEL_RADIUS * 2
  219.  
  220.     -- Roll radius so that the snowball rolls a bit submerged in the ground
  221.     local r_roll = scale * (SNOWBALL_MODEL_RADIUS - 100)
  222.  
  223.     -- Initialize physics properties
  224.     Physics:Unit(Snowball)
  225.  
  226.     Snowball:Hibernate(false)
  227.     Snowball:SetPhysicsFriction(0)
  228.  
  229.     -- Make the ball fall before starting the intended movement
  230.     Snowball:SetAbsOrigin(GetGroundPosition(position, Snowball) + Vector(0, 0, SNOWBALL_FALL_HEIGHT))
  231.  
  232.     Snowball:SetPhysicsVelocity(Vector(0, 0, -1 * velocity:Length()))
  233.  
  234.     -- local pindex = ParticleManager:CreateParticle("particles/basic_rope/basic_rope.vpcf",
  235.     --  PATTACH_ABSORIGIN, unit)
  236.     -- Create the actual snowball model
  237.     -- model = "models/props_gameplay/soccer_ball.vmdl",
  238.    
  239.     local SnowballModel = SpawnEntityFromTableSynchronous("prop_dynamic", {
  240.         model = "models/props_consumables/balloons/donkey_dire_2022/donkey_dire_2022.vmdl",
  241.         origin = Snowball:GetAbsOrigin() + Vector(0, 0, r_roll)
  242.     })
  243.  
  244.     SnowballModel:SetModelScale(scale)
  245.  
  246.     -- Start with a random rotation
  247.     SnowballModel:SetAngles(0, 180, 0)
  248.  
  249.     -- Snowball movement logic
  250.     Snowball:OnPhysicsFrame(function(unit)
  251.         local velocity = Snowball:GetPhysicsVelocity()
  252.         local vel2D = Vector(velocity.x, velocity.y, 0)
  253.         local speed = vel2D:Length()
  254.        
  255.         if speed > 1 then
  256.             -- Calculate rotation angle based on velocity direction
  257.             local rollAngle = speed * FrameTime() * 360 / (2 * math.pi * r_roll)
  258.            
  259.             local currentAngles = SnowballModel:GetAngles()
  260.            
  261.             local yawAngle = math.atan2(velocity.y, velocity.x) * 180 / math.pi
  262.            
  263.             SnowballModel:SetAngles(0,
  264.                                   yawAngle,
  265.                                   0)
  266.         end
  267.    
  268.         SnowballModel:SetAbsOrigin(Snowball:GetAbsOrigin() + Vector(0, 0, r_roll))
  269.    
  270.         if Snowball:GetPhysicsVelocity():Length() < 1 then
  271.             Snowball:Destroy()
  272.             SnowballModel:Destroy()
  273.         end
  274.     end)
  275.  
  276.     -- Snowball kill logic
  277.     Timers:CreateTimer({
  278.         callback = function()
  279.             if IsValidEntity(Snowball) then
  280.                 -- DebugDrawCircle(Snowball:GetAbsOrigin(), Vector(255,0,0), 5.0, r_kill, true, 0.1)
  281.                 local squash = FindUnitsInRadius(DOTA_TEAM_NEUTRALS, Snowball:GetAbsOrigin(), nil, r_kill,
  282.                     DOTA_UNIT_TARGET_TEAM_ENEMY, DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_FLAG_NONE, FIND_ANY_ORDER,
  283.                     false)
  284.  
  285.                 for i, unit in pairs(squash) do
  286.                     unit:Kill(nil, Snowball)
  287.                 end
  288.  
  289.                 return SNOWBALL_KILL_INTERVAL
  290.             end
  291.         end
  292.     })
  293.  
  294.     -- Stop the snowball when it hits the ground and start the desired movement
  295.     Timers:CreateTimer({
  296.         endTime = SNOWBALL_FALL_HEIGHT / velocity:Length(),
  297.         callback = function()
  298.             -- Set intended direction
  299.             Snowball:SetPhysicsVelocity(velocity)
  300.  
  301.             -- Stop the snowball after it has traveled the intended distance, which kills it
  302.             Timers:CreateTimer({
  303.                 endTime = distance / velocity:Length(),
  304.                 callback = function()
  305.                     Snowball:SetPhysicsVelocity(Vector(0, 0, 0))
  306.                 end
  307.             })
  308.         end
  309.     })
  310.  
  311. end
  312.  
  313. function MinigameSnowball:Destroy()
  314.  
  315.     -- Stop the snowball spawners
  316.     for i, timer in pairs(self._SnowballTimer) do
  317.         Timers:RemoveTimer(timer)
  318.     end
  319.  
  320.     KillUnitList({"npc_ward_ground"})
  321.  
  322.     -- Score the players who didn't finish
  323.     local score = {}
  324.  
  325.     for i, checkpoint in pairs(self._LastCheckPoint) do
  326.         if checkpoint >= 0 then
  327.             -- The score information can be combined
  328.             score[i] = 1000 * checkpoint + self._TimeCheckPoint[i]
  329.         end
  330.     end
  331.  
  332.     OmniParty:AutoScoreFromArray(score, true)
  333.  
  334. end
  335.  
  336. function MinigameSnowball:MinigameThink()
  337.  
  338.     -- Check if the minigame is over
  339.     if self._SnowMaidenCount == 0 then
  340.         return
  341.     end
  342.     local allzero = true
  343.     -- Display coundown
  344.     for i, time in pairs(self._Countdown) do
  345.         if time >= 0 then
  346.             if time == 0 then
  347.                 self._SnowMaiden[i]:ForceKill(true)
  348.             else
  349.                 Scoreboard:SetPlayerExtra(i, self._Countdown[i])
  350.             end
  351.  
  352.             self._Countdown[i] = self._Countdown[i] - 1
  353.             if self._Countdown[i] > 0 then
  354.                 allzero = false
  355.             end
  356.         end
  357.     end
  358.     if allzero then
  359.         KillUnitList({"npc_snow_maiden"})
  360.         return
  361.     end
  362.  
  363.     return 1
  364.  
  365. end
  366.  
  367. function MinigameSnowball:GetSnowballParam()
  368.  
  369.     return {{
  370.         [1] = {
  371.             velocity = {{100}},
  372.             interval = {{5.5}}
  373.         }
  374.    
  375.     }, {
  376.         [2] = {
  377.             velocity = {{600, 900, 900}},
  378.             interval = {{2, 1.5, 1.5}}
  379.         }
  380.     }, {
  381.         [3] = {
  382.             velocity = {{600}},
  383.             interval = {{2.5}}
  384.         },
  385.         [4] = {
  386.             velocity = {{600}},
  387.             interval = {{2.5}}
  388.         }
  389.     }, {
  390.         [5] = {
  391.             velocity = {
  392.                 {600, 400, 400, 400},
  393.                 {600, 400, 400, 600}
  394.             },
  395.             interval = {
  396.                 {1, 1, 1, 2},
  397.                 {4, 4,4, 4}
  398.             }
  399.         }
  400.     },
  401.     {
  402.         [6] = {
  403.             velocity = {
  404.                 {0, 280, 280},
  405.                 {0, 280, 280, 280},
  406.                 {0, 280, 280, 280},
  407.                 {0, 280, 280}
  408.             },
  409.             interval = {
  410.                 {4*0.857, 0.857, 0.857},
  411.                 {0.857, 0.857, 4*0.857, 0.857},
  412.                 {0.857, 0.857, 4*0.857, 3*0.857},
  413.                 {3*0.857, 0.857, 3*0.857}
  414.             }
  415.         },
  416.         [7] = {
  417.             velocity = {
  418.                 {0, 280, 280},
  419.                 {0, 280},
  420.                 {0, 280, 280},
  421.                 {0, 280, 280}
  422.             },
  423.             interval = {
  424.                 {0.857, 0.857, 4*0.857},
  425.                 {4*0.857, 3*0.857},
  426.                 {4*0.857, 4*0.857, 0.857},
  427.                 {0.857, 5*0.857, 0.857}
  428.             }
  429.         },
  430.         [8] = {
  431.             velocity = {
  432.                 {280, 280},
  433.                 {280, 280, 280},
  434.                 {280, 280, 280, 280},
  435.                 {280, 280}
  436.             },
  437.             interval = {
  438.                 {4*0.857, 2*0.857},
  439.                 {0.857, 4*0.857, 2*0.857},
  440.                 {0.857, 2*0.857, 3*0.857, 3*0.857},
  441.                 {4*0.857, 3*0.857}
  442.             }
  443.         },
  444.         [9] = {
  445.             velocity = {
  446.                 {0, 280, 280},
  447.                 {0, 280, 280, 280},
  448.                 {0, 280, 280, 280},
  449.                 {0, 280, 280, 280}
  450.             },
  451.             interval = {
  452.                 {2*0.857, 2*0.857, 2*0.857},
  453.                 {2*0.857, 0.857, 3*0.857, 0.857},
  454.                 {3*0.857, 4*0.857, 0.857, 0.857},
  455.                 {2*0.857, 0.857, 2*0.857, 2*0.857}
  456.             }
  457.         }
  458.     },
  459.     {
  460.         -- Right to left
  461.         [10] = {
  462.             velocity = {{600, 600, 600}},
  463.             interval = {{2.5, 2.5, 7}}
  464.         },
  465.         [11] = {
  466.             velocity = {{0}},
  467.             interval = {{12}}
  468.         },
  469.         [12] = {
  470.             velocity = {{0, 600, 600}},
  471.             interval = {{1.25, 2.5, 8.25}}
  472.         },
  473.         [13] = {
  474.             velocity = {{0}},
  475.             interval = {{12}}
  476.         },
  477.         -- Left to right
  478.         [14] = {
  479.             velocity = {{0}},
  480.             interval = {{12}}
  481.         },
  482.         [15] = {
  483.             velocity = {{0, 600, 600}},
  484.             interval = {{1.25, 2.5, 8.25}}
  485.         },
  486.         [16] = {
  487.             velocity = {{0}},
  488.             interval = {{12}}
  489.         },
  490.         [17] = {
  491.             velocity = {{600, 600, 600}},
  492.             interval = {{2.5, 2.5, 7}}
  493.         },
  494.         -- Top to bottom
  495.         [18] = {
  496.             velocity = {{0}},
  497.             interval = {{12}}
  498.         },
  499.         [19] = {
  500.             velocity = {{0, 300}},
  501.             interval = {{9, 3}}
  502.         }
  503.     }
  504.     --  [20] = {
  505.     --      velocity = {{0}},
  506.     --      interval = {{12}}
  507.     --  },
  508.     --  [21] = {
  509.     --      velocity = {{0, 300}},
  510.     --      interval = {{9, 3}}
  511.     --  },
  512.     --  -- Bottom to top
  513.     --  [22] = {
  514.     --      velocity = {{0, 300}},
  515.     --      interval = {{9, 3}}
  516.     --  },
  517.     --  [23] = {
  518.     --      velocity = {{0}},
  519.     --      interval = {{11}}
  520.     --  },
  521.     --  [24] = {
  522.     --      velocity = {{0, 300}},
  523.     --      interval = {{9, 3}}
  524.     --  },
  525.     --  [25] = {
  526.     --      velocity = {{0}},
  527.     --      interval = {{12}}
  528.     --  }
  529.     -- },
  530.     -- {
  531.     --  -- Top to bottom
  532.     --  [26] = {
  533.     --      velocity = {{0, 400}},
  534.     --      interval = {{0.75, 3.75}}
  535.     --  },
  536.     --  [27] = {
  537.     --      velocity = {{0, 400}},
  538.     --      interval = {{1.5, 3}}
  539.     --  },
  540.     --  [28] = {
  541.     --      velocity = {{400}},
  542.     --      interval = {{4.5}}
  543.     --  },
  544.     --  -- Bottom to top
  545.     --  [29] = {
  546.     --      velocity = {{0, 400}},
  547.     --      interval = {{3, 1.50}}
  548.     --  },
  549.     --  [30] = {
  550.     --      velocity = {{0, 400}},
  551.     --      interval = {{3.75, 0.75}}
  552.     --  },
  553.     --  [31] = {
  554.     --      velocity = {{0, 400}},
  555.     --      interval = {{2.25, 2.25}}
  556.     --  }
  557.     -- },
  558.     -- {
  559.     --  -- Top to bottom
  560.     --  [32] = {
  561.     --      velocity = {{0, 300}},
  562.     --      interval = {{0.75, 5.25}}
  563.     --  },
  564.     --  [33] = {
  565.     --      velocity = {{0}},
  566.     --      interval = {{6}}
  567.     --  },
  568.     --  -- Bottom to top
  569.     --  [34] = {
  570.     --      velocity = {{0, 300}},
  571.     --      interval = {{3.75, 2.25}}
  572.     --  },
  573.     --  [35] = {
  574.     --      velocity = {{300, 300, 300, 300}},
  575.     --      interval = {{1.5, 1.5, 1.5, 1.5}}
  576.     --  }
  577.     -- }
  578.     }
  579. end
  580.  
  581. function printDebug(t, indent, done)
  582.     -- Set default parameters
  583.     done = done or {}
  584.     indent = indent or 0
  585.     local indentStr = string.rep("  ", indent)
  586.  
  587.     if type(t) ~= "table" then
  588.         print(indentStr .. tostring(t))
  589.         return
  590.     end
  591.  
  592.     -- Avoid infinite recursion
  593.     if done[t] then
  594.         print(indentStr .. "TABLE *recursive*")
  595.         return
  596.     end
  597.     done[t] = true
  598.  
  599.     -- Print each field with proper indentation
  600.     for key, value in pairs(t) do
  601.         if type(key) ~= "number" then
  602.             key = '"' .. tostring(key) .. '"'
  603.         end
  604.  
  605.         if type(value) == "table" and not done[value] then
  606.             print(indentStr .. "[" .. key .. "] = {")
  607.             printDebug(value, indent + 1, done)
  608.             print(indentStr .. "}")
  609.         elseif type(value) == "userdata" then
  610.             print(indentStr .. "[" .. key .. "] = userdata")
  611.         else
  612.             print(indentStr .. "[" .. key .. "] = " .. tostring(value))
  613.         end
  614.     end
  615. end
  616.  
  617. function InspectEntity(entity)
  618.     print("[ENTITY INSPECTOR] Beginning entity inspection")
  619.  
  620.     -- Basic entity information
  621.     print("[ENTITY INSPECTOR] Entity exists: " .. tostring(entity ~= nil))
  622.     if not entity then
  623.         return
  624.     end
  625.  
  626.     -- Try common entity methods
  627.     local methods = {"GetClassname", "GetName", "GetEntityName", "GetEntityIndex", "entindex", "GetEntityHandle",
  628.                      "GetAbsOrigin", "GetOrigin", "GetCenter", "GetAngles", "GetBoundingMaxs", "GetBoundingMins",
  629.                      "GetTargetName", "GetDebugName", "GetModelName", "IsValid"}
  630.  
  631.     for _, method in ipairs(methods) do
  632.         if entity[method] then
  633.             local success, result = pcall(function()
  634.                 return entity[method](entity)
  635.             end)
  636.             if success then
  637.                 if type(result) == "userdata" and result.x and result.y and result.z then
  638.                     -- Handle Vector objects
  639.                     print("[ENTITY INSPECTOR] " .. method .. "(): Vector(" .. result.x .. ", " .. result.y .. ", " ..
  640.                               result.z .. ")")
  641.                 else
  642.                     print("[ENTITY INSPECTOR] " .. method .. "(): " .. tostring(result))
  643.                 end
  644.             else
  645.                 print("[ENTITY INSPECTOR] " .. method .. "(): Error - " .. tostring(result))
  646.             end
  647.         else
  648.             print("[ENTITY INSPECTOR] " .. method .. ": Not available")
  649.         end
  650.     end
  651.  
  652.     -- Try to get all key values if available
  653.     print("[ENTITY INSPECTOR] Trying to get all key values:")
  654.     local commonKeys = {"targetname", "classname", "model", "origin", "name", "hammerid", "checkpoint_number"}
  655.  
  656.     for _, key in ipairs(commonKeys) do
  657.         local success, result = pcall(function()
  658.             if entity.GetKeyValue then
  659.                 return entity:GetKeyValue(key)
  660.             else
  661.                 return nil
  662.             end
  663.         end)
  664.  
  665.         if success and result then
  666.             print("[ENTITY INSPECTOR] KeyValue " .. key .. ": " .. tostring(result))
  667.         end
  668.     end
  669.  
  670.     -- Look for custom properties that might contain checkpoint info
  671.     print("[ENTITY INSPECTOR] Looking for custom properties:")
  672.     local customProps = {"m_checkpoint", "checkpoint", "checkpoint_id", "checkpoint_number", "cp_number"}
  673.  
  674.     for _, prop in ipairs(customProps) do
  675.         local success, result = pcall(function()
  676.             return entity[prop]
  677.         end)
  678.         if success and result then
  679.             print("[ENTITY INSPECTOR] Custom property " .. prop .. ": " .. tostring(result))
  680.         end
  681.     end
  682.  
  683.     -- Try to get script scope if available
  684.     if entity.GetScriptScope then
  685.         local scope = entity:GetScriptScope()
  686.         if scope then
  687.             print("[ENTITY INSPECTOR] Script scope found, printing keys:")
  688.             for k, v in pairs(scope) do
  689.                 print("[ENTITY INSPECTOR] Script scope key: " .. k .. " = " .. tostring(v))
  690.             end
  691.         else
  692.             print("[ENTITY INSPECTOR] No script scope found")
  693.         end
  694.     end
  695.  
  696.     -- Check if we can use the entity index to determine the checkpoint number
  697.     if entity.entindex then
  698.         local entIndex = entity:entindex()
  699.         print("[ENTITY INSPECTOR] Entity index: " .. entIndex)
  700.         print("[ENTITY INSPECTOR] This might be useful to map to a checkpoint number")
  701.     end
  702.  
  703.     print("[ENTITY INSPECTOR] Entity inspection complete")
  704. end
  705.  
Advertisement
Add Comment
Please, Sign In to add comment