mirror of
https://github.com/weyne85/DML.git
synced 2025-10-29 16:57:49 +00:00
0.9991
unGrief
This commit is contained in:
parent
964a00dbbd
commit
82f59f5728
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
cfxGroundTroops = {}
|
||||
cfxGroundTroops.version = "1.7.5"
|
||||
cfxGroundTroops.version = "1.7.6"
|
||||
cfxGroundTroops.ups = 1
|
||||
cfxGroundTroops.verbose = false
|
||||
cfxGroundTroops.requiredLibs = {
|
||||
@ -60,6 +60,7 @@ cfxGroundTroops.deployedTroops = {}
|
||||
-- 1.7.3 - callbacks for lase:tracking and lase:stop
|
||||
-- 1.7.4 - verbose flag, warnings suppressed
|
||||
-- 1.7.5 - some troop.group hardening with isExist()
|
||||
-- 1.7.6 - fixed switchToOffroad
|
||||
|
||||
|
||||
-- an entry into the deployed troop has the following attributes
|
||||
@ -259,7 +260,7 @@ function cfxGroundTroops.switchToOffroad(troops)
|
||||
-- on their route for longer than allowed
|
||||
-- we now force a direct approach
|
||||
local group = troops.group
|
||||
if not group.isExist() then
|
||||
if not group:isExist() then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
unGrief = {}
|
||||
unGrief.version = "1.0.0"
|
||||
unGrief.version = "1.1.0"
|
||||
unGrief.verbose = false
|
||||
unGrief.requiredLibs = {
|
||||
"dcsCommon", -- always
|
||||
@ -13,14 +13,67 @@ unGrief.disabledFlagValue = unGrief.enabledFlagValue + 100 -- DO NOT CHANGE
|
||||
|
||||
Version History
|
||||
1.0.0 - initial release
|
||||
1.1.0 - wrathful option
|
||||
- pve option
|
||||
- ignoreAI option
|
||||
|
||||
--]]--
|
||||
|
||||
unGrief.griefers = {} -- offenders are stored here
|
||||
|
||||
-- vengeance: if player killed before, they are no longer welcome
|
||||
function unGrief.exactVengance(theEvent)
|
||||
if theEvent.id == 20 then -- S_EVENT_PLAYER_ENTER_UNIT
|
||||
if not theEvent.initiator then return end
|
||||
local theUnit = theEvent.initiator
|
||||
if not theUnit.getPlayerName then return end -- wierd stuff happening here
|
||||
local playerName = theUnit:getPlayerName()
|
||||
if not playerName then return end
|
||||
local unitName = theUnit:getName()
|
||||
if unGrief.verbose then
|
||||
trigger.action.outText("+++uGrf: player <" .. playerName .. "> entered <" .. unitName .. ">", 30)
|
||||
end
|
||||
|
||||
local causedGrief = unGrief.griefers[playerName]
|
||||
if not causedGrief then
|
||||
if unGrief.verbose then
|
||||
trigger.action.outText("+++uGrf: player <" .. playerName .. "> is welcome here", 30)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if causedGrief < unGrief.graceKills + 2 then
|
||||
trigger.action.outText("Player <" .. playerName .. "> in <" .. unitName .. "> is on probation", 30)
|
||||
return
|
||||
end
|
||||
|
||||
-- you are done here, buster!
|
||||
if unGrief.retaliation == "ssb" then
|
||||
-- use ssb to kick/block the entire group
|
||||
local theGroup = theUnit:getGroup()
|
||||
if not theGroup then return end -- you got lucky!
|
||||
local groupName = theGroup:getName()
|
||||
-- tell ssb to kick now:
|
||||
trigger.action.setUserFlag(groupName, unGrief.disabledFlagValue)
|
||||
trigger.action.outText("Player <" .. playerName .. "> is not welcome here. Shoo! Shoo!", 30)
|
||||
return
|
||||
end
|
||||
|
||||
-- add some weight for good measure
|
||||
-- set them up the bomb
|
||||
-- tell them off
|
||||
trigger.action.outText("Player <" .. playerName .. "> is not welcome here. Shoo! Shoo!", 30)
|
||||
trigger.action.setUnitInternalCargo(unitName, 100000 ) -- 100 tons
|
||||
local p = theUnit:getPoint()
|
||||
trigger.action.explosion(p, 10)
|
||||
end
|
||||
end
|
||||
|
||||
-- event proccer
|
||||
function unGrief:onEvent(theEvent)
|
||||
if not theEvent then return end
|
||||
if unGrief.wrathful then unGrief.exactVengance(theEvent) end
|
||||
|
||||
if theEvent.id ~= 28 then return end -- only S_EVENT_KILL events allowed
|
||||
if not theEvent.initiator then return end -- no initiator, no interest
|
||||
if not theEvent.target then return end -- wtf happened here? begone!
|
||||
@ -34,11 +87,21 @@ function unGrief:onEvent(theEvent)
|
||||
-- map (scenery) objects don't have coalition, so check this first
|
||||
if not stiff.getCoalition then return end
|
||||
|
||||
local pvpTransgression = false
|
||||
if unGrief.pve and stiff.getPlayerName and stiff:getPlayerName() then
|
||||
pvpTransgression = true
|
||||
end
|
||||
|
||||
if unGrief.ignoreAI then
|
||||
if not stiff.getPlayerName then return end -- killed AI, don't care
|
||||
if not stiff:getPlayerName() then return end -- killed AI, don't care
|
||||
end
|
||||
|
||||
-- get the two coalitions involved
|
||||
local killSide = killer:getCoalition()
|
||||
local stiffSide = stiff:getCoalition()
|
||||
|
||||
if killSide ~= stiffSide then return end -- fair & square
|
||||
if (not pvpTransgression) and (killSide ~= stiffSide) then return end -- fair & square
|
||||
|
||||
-- if we get here, we have a problem.
|
||||
local previousKills = unGrief.griefers[playerName]
|
||||
@ -49,12 +112,20 @@ function unGrief:onEvent(theEvent)
|
||||
|
||||
if previousKills <= unGrief.graceKills then
|
||||
-- ok, let them off with a warning
|
||||
trigger.action.outText(playerName .. " has killed one of their own. YOU ARE ON NOTICE!", 30)
|
||||
if not pvpTransgression then
|
||||
trigger.action.outText(playerName .. " has killed one of their own. YOU ARE ON NOTICE!", 30)
|
||||
else
|
||||
trigger.action.outText(playerName .. " has killed a fellow Player. YOU ARE ON NOTICE!", 30)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- ok, time to get serious
|
||||
trigger.action.outText(playerName .. " is killing their own. ".. previousKills .. " kills recorded so far. We disaprove", 30)
|
||||
if not pvpTransgression then
|
||||
trigger.action.outText(playerName .. " is killing their own. ".. previousKills .. " illegal kills recorded so far. We disaprove", 30)
|
||||
else
|
||||
trigger.action.outText(playerName .. " is killing other players. ".. previousKills .. " illegal kills recorded so far. We disaprove", 30)
|
||||
end
|
||||
|
||||
-- lets set them up the bomb
|
||||
local p = killer:getPoint()
|
||||
@ -80,13 +151,25 @@ function unGrief.readConfigZone()
|
||||
if unGrief.verbose then
|
||||
trigger.action.outText("+++uGrf: NO config zone!", 30)
|
||||
end
|
||||
return
|
||||
theZone = cfxZone.createSimpleZone("unGriefConfig")
|
||||
end
|
||||
|
||||
unGrief.verbose = cfxZones.getBoolFromZoneProperty(theZone, "verbose", false)
|
||||
|
||||
unGrief.graceKills = cfxZones.getNumberFromZoneProperty(theZone, "graceKills", 1)
|
||||
unGrief.retaliation = cfxZones.getStringFromZoneProperty(theZone, "retaliation", "boom") -- other possible methods: ssb
|
||||
unGrief.retaliation = dcsCommon.trim(unGrief.retaliation:lower())
|
||||
|
||||
|
||||
unGrief.wrathful = cfxZones.getBoolFromZoneProperty(theZone, "wrathful", false)
|
||||
|
||||
unGrief.pve = cfxZones.getBoolFromZoneProperty(theZone, "pve", false)
|
||||
if cfxZones.hasProperty(theZone, "pveOnly") then
|
||||
unGrief.pve = cfxZones.getBoolFromZoneProperty(theZone, "pveOnly", false)
|
||||
end
|
||||
|
||||
unGrief.ignoreAI = cfxZones.getBoolFromZoneProperty(theZone, "ignoreAI", false)
|
||||
|
||||
if unGrief.verbose then
|
||||
trigger.action.outText("+++uGrf: read config", 30)
|
||||
end
|
||||
@ -95,10 +178,10 @@ end
|
||||
function unGrief.start()
|
||||
-- lib check
|
||||
if not dcsCommon.libCheck then
|
||||
trigger.action.outText("cfx unGrief requires dcsCommon", 30)
|
||||
trigger.action.outText("cf/x unGrief requires dcsCommon", 30)
|
||||
return false
|
||||
end
|
||||
if not dcsCommon.libCheck("cfx unGrief", unGrief.requiredLibs) then
|
||||
if not dcsCommon.libCheck("cf/x unGrief", unGrief.requiredLibs) then
|
||||
return false
|
||||
end
|
||||
|
||||
@ -108,12 +191,16 @@ function unGrief.start()
|
||||
-- connect event proccer
|
||||
world.addEventHandler(unGrief)
|
||||
|
||||
trigger.action.outText("cfx unGrief v" .. unGrief.version .. " started.", 30)
|
||||
trigger.action.outText("cf/x unGrief v" .. unGrief.version .. " started.", 30)
|
||||
return true
|
||||
end
|
||||
|
||||
-- let's go!
|
||||
if not unGrief.start() then
|
||||
trigger.action.outText("cfx unGrief aborted: missing libraries", 30)
|
||||
trigger.action.outText("cf/x unGrief aborted: missing libraries", 30)
|
||||
unGrief = nil
|
||||
end
|
||||
|
||||
-- to be developed:
|
||||
-- ungrief on and off flags
|
||||
-- pvp and pve zones in addition to global attributes
|
||||
BIN
tutorial & demo missions/demo - good grief.miz
Normal file
BIN
tutorial & demo missions/demo - good grief.miz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user