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:
parent
26e12fa733
commit
70a5fd4db3
@ -591,7 +591,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
"advanced_defenses": self.advanced_defenses_checkBox.isChecked(),
|
||||
"red_cap": self.scenario.getConfigValue("red_cap", default=True),
|
||||
"blue_cap": self.scenario.getConfigValue("blue_cap", default=True),
|
||||
"rotorops_server": self.scenario.getConfigValue("rotorops_server", default=False),
|
||||
"rotorops_server": self.rotorops_server_checkBox.isChecked(),
|
||||
"perks": self.perks_checkBox.isChecked(),
|
||||
"easy_comms": self.scenario.getConfigValue("easy_comms", default=True)
|
||||
}
|
||||
|
||||
@ -465,9 +465,18 @@ class Ui_MainWindow(object):
|
||||
self.perks_checkBox.setFont(font)
|
||||
self.perks_checkBox.setChecked(True)
|
||||
self.perks_checkBox.setObjectName("perks_checkBox")
|
||||
self.rotorops_server_checkBox = QtWidgets.QCheckBox(self.centralwidget)
|
||||
self.rotorops_server_checkBox.setEnabled(True)
|
||||
self.rotorops_server_checkBox.setGeometry(QtCore.QRect(1020, 650, 121, 21))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(7)
|
||||
font.setBold(False)
|
||||
self.rotorops_server_checkBox.setFont(font)
|
||||
self.rotorops_server_checkBox.setChecked(False)
|
||||
self.rotorops_server_checkBox.setObjectName("rotorops_server_checkBox")
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.menubar = QtWidgets.QMenuBar(MainWindow)
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 29))
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 24))
|
||||
self.menubar.setObjectName("menubar")
|
||||
self.menuMap = QtWidgets.QMenu(self.menubar)
|
||||
self.menuMap.setObjectName("menuMap")
|
||||
@ -664,6 +673,8 @@ class Ui_MainWindow(object):
|
||||
self.farp_spawn_checkBox.setText(_translate("MainWindow", "Spawns at zone FARPs"))
|
||||
self.perks_checkBox.setStatusTip(_translate("MainWindow", "Adds a rewards system with points for kills, troop drops, etc. See the F10 menu to use Perks."))
|
||||
self.perks_checkBox.setText(_translate("MainWindow", "Perks"))
|
||||
self.rotorops_server_checkBox.setStatusTip(_translate("MainWindow", "Generate missions for RotorOps public servers."))
|
||||
self.rotorops_server_checkBox.setText(_translate("MainWindow", "RotorOps Server Mission"))
|
||||
self.menuMap.setTitle(_translate("MainWindow", "Map"))
|
||||
self.menuFilter.setTitle(_translate("MainWindow", "Filter"))
|
||||
self.menuPreferences.setTitle(_translate("MainWindow", "Preferences"))
|
||||
|
||||
@ -1341,6 +1341,34 @@ p, li { white-space: pre-wrap; }
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="rotorops_server_checkBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1020</x>
|
||||
<y>650</y>
|
||||
<width>121</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>7</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Generate missions for RotorOps public servers.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>RotorOps Server Mission</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
@ -1348,7 +1376,7 @@ p, li { white-space: pre-wrap; }
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1280</width>
|
||||
<height>29</height>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuMap">
|
||||
|
||||
@ -414,7 +414,10 @@ class RotorOpsMission:
|
||||
else:
|
||||
output_dir = directories.output # default dir
|
||||
os.chdir(output_dir)
|
||||
output_filename = options["scenario_name"] + " " + time.strftime('%a%H%M%S') + '.miz'
|
||||
prefix = ""
|
||||
if options["rotorops_server"]:
|
||||
prefix = "DS_" # prefix for dedicated server missions
|
||||
output_filename = prefix + options["scenario_name"] + " " + time.strftime('%a%H%M%S') + '.miz'
|
||||
|
||||
# dcs.mission.save will use the bypassed trig, trigrules, and triggers. Our goal is to leave the trigrules and
|
||||
# trig from the source mission untouched. See comments in self.m.load_file above
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user