mirror of
https://github.com/spencershepard/RotorOps.git
synced 2025-11-10 15:45:30 +00:00
server prep
-adds checkbox for adding server scripts -server script adds perk to points conversion -drone invisibility #needs_testing
This commit is contained in:
committed by
Spencer Shepard
parent
26e12fa733
commit
70a5fd4db3
@@ -31,7 +31,7 @@ RotorOpsPerks.player_update_messages = true --set to false to disable messages w
|
||||
RotorOpsPerks.debug = false
|
||||
|
||||
RotorOpsPerks.points = {
|
||||
player_default=0, --how many points each player will start with
|
||||
player_default=1000, --how many points each player will start with
|
||||
kill=10,
|
||||
kill_inf=5,
|
||||
kill_heli=20,
|
||||
@@ -252,8 +252,16 @@ function RotorOpsPerks.spawnJtacDrone(dest_point, country, laser_code)
|
||||
end
|
||||
trigger.action.outText('JTAC DRONE IS ON STATION!', 10)
|
||||
|
||||
SetInvisible = {
|
||||
id = 'SetInvisible',
|
||||
params = {
|
||||
value = true
|
||||
}
|
||||
}
|
||||
|
||||
--set a timer for one minute
|
||||
timer.scheduleFunction(function()
|
||||
Group.getByName(new_group.name):getController():setTask(SetInvisible)
|
||||
Group.getByName(new_group.name):getController():setTask(orbit)
|
||||
Group.getByName(new_group.name):getController():setOption(AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.NO_REACTION)
|
||||
local _code = table.remove(ctld.jtacGeneratedLaserCodes, 1)
|
||||
@@ -480,6 +488,19 @@ function RotorOpsPerks.scorePoints(player_group_name, points, message)
|
||||
|
||||
end
|
||||
|
||||
function RotorOpsPerks.getPointsBalance(player_group_name)
|
||||
local players = RotorOpsPerks.playersByGroupName(player_group_name)
|
||||
if not players then
|
||||
return false
|
||||
end
|
||||
|
||||
local total_points = 0
|
||||
for _, player in pairs(players) do
|
||||
total_points = total_points + player.points
|
||||
end
|
||||
return total_points
|
||||
end
|
||||
|
||||
function RotorOpsPerks.checkPoints(player_group_name)
|
||||
local groupId = Group.getByName(player_group_name):getID()
|
||||
local players = RotorOpsPerks.playersByGroupName(player_group_name)
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
RotorOpsServer = {}
|
||||
RotorOpsServer.version = "0.3"
|
||||
RotorOpsServer.version = "0.4"
|
||||
trigger.action.outText("ROTOROPS SERVER SCRIPT: "..RotorOpsServer.version, 5)
|
||||
env.info("ROTOROPS SERVER SCRIPT STARTED: "..RotorOpsServer.version)
|
||||
|
||||
--For SpecialK's DCSServerBot
|
||||
RotorOpsServer.dcsbot = {}
|
||||
RotorOpsServer.dcsbot.enabled = true
|
||||
RotorOpsServer.dcsbot.points = {}
|
||||
RotorOpsServer.dcsbot.points.troop_drop = 6
|
||||
RotorOpsServer.dcsbot.points.unpack = 5
|
||||
RotorOpsServer.dcsbot.points.rearm_repair = 3
|
||||
|
||||
--Mission Ending
|
||||
RotorOpsServer.time_to_end = 600
|
||||
RotorOpsServer.time_to_end = 900
|
||||
|
||||
function RotorOpsServer.endMission(secs)
|
||||
if secs then
|
||||
@@ -36,33 +28,48 @@ function RotorOpsServer.endMission(secs)
|
||||
countdown()
|
||||
end
|
||||
|
||||
function RotorOpsServer.registerCtldCallbacks()
|
||||
ctld.addCallback(function(_args)
|
||||
local action = _args.action
|
||||
local unit = _args.unit
|
||||
local picked_troops = _args.onboard
|
||||
local dropped_troops = _args.unloaded
|
||||
--env.info("ctld callback: ".. mist.utils.tableShow(_args))
|
||||
|
||||
local playername = unit:getPlayerName()
|
||||
if RotorOpsServer.dcsbot.enabled and dcsbot and playername then
|
||||
if action == "unload_troops_zone" or action == "dropped_troops" then
|
||||
if RotorOps.isUnitInZone(unit, RotorOps.active_zone) then
|
||||
env.info('RotorOpsServer: adding points (unload troops in active zone) for ' ..playername)
|
||||
net.send_chat(playername .. " dropped troops into the active zone. [" .. RotorOpsServer.dcsbot.points.troop_drop .. " points]")
|
||||
dcsbot.addUserPoints(playername, RotorOpsServer.dcsbot.points.troop_drop)
|
||||
end
|
||||
elseif action == "rearm" or action == "repair" then
|
||||
env.info('RotorOpsServer: adding points (rearm/repair) for ' ..playername)
|
||||
net.send_chat(playername .. " repaired/rearmed our defenses. [" .. RotorOpsServer.dcsbot.points.rearm_repair .. " points]")
|
||||
dcsbot.addUserPoints(playername, RotorOpsServer.dcsbot.points.rearm_repair)
|
||||
elseif action == "unpack" then
|
||||
env.info('RotorOpsServer: adding points (unpack) for ' ..playername)
|
||||
net.send_chat(playername .. " unpacked ground units. [" .. RotorOpsServer.dcsbot.points.unpack .. " points]")
|
||||
dcsbot.addUserPoints(playername, RotorOpsServer.dcsbot.points.unpack)
|
||||
end
|
||||
end
|
||||
end)
|
||||
function RotorOpsServer.convertPointsToSpawnCredits(playerName, points)
|
||||
if dcsbot then
|
||||
env.info("RotorOpsServer: Converting "..points.." points to spawn credits for "..playerName)
|
||||
dcsbot.addUserPoints(playerName, points)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
RotorOpsServer.registerCtldCallbacks()
|
||||
function RotorOpsServer.addPerks()
|
||||
env.info("RotorOpsServer: Adding perks to RotorOpsPerks.")
|
||||
---- PERKS: Convert points to spawn credits ----
|
||||
|
||||
RotorOpsPerks.perks["spawnCredits"] = {
|
||||
perk_name='spawnCredits',
|
||||
display_name='Buy 10 Spawn Credits',
|
||||
cost=50,
|
||||
cooldown=0,
|
||||
max_per_player=1000,
|
||||
max_per_mission=1000,
|
||||
at_mark=false,
|
||||
at_position=true,
|
||||
enabled=true,
|
||||
sides={0,1,2},
|
||||
}
|
||||
|
||||
RotorOpsPerks.perks.spawnCredits["action_function"] = function(args)
|
||||
local playerName = Unit.getByName(args.player_unit_name):getPlayerName()
|
||||
return RotorOpsServer.convertPointsToSpawnCredits(playerName, 10)
|
||||
end
|
||||
|
||||
---- End of Spawn Credits Perk ----
|
||||
|
||||
end
|
||||
|
||||
if dcsbot then
|
||||
RotorOpsServer.addPerks()
|
||||
else
|
||||
env.warning("RotorOpsServer: DCSBot not found. Perks not added.")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user