Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gadget:GetInfo()
- return {
- name = "DirectControl",
- desc = "Block direct control (FPS) for all units",
- author = "knorke",
- date = "Feb 2012",
- license = "GNU GPL, v2 or later",
- layer = 0,
- enabled = true -- loaded by default?
- }
- end
- local GetSpectatingState=Spring.GetSpectatingState
- local GetLocalTeamID=Spring.GetLocalTeamID
- local GetGameFrame=Spring.GetGameFrame
- local GetPlayerList=Spring.GetPlayerList
- local GetPlayerInfo=Spring.GetPlayerInfo
- local SendMessageToAllyTeam=Spring.SendMessageToAllyTeam
- local function Toggle(_,enable,playerId)
- if (playerId == Spring.GetMyPlayerID()) then
- if enable then
- enabled = true
- else
- enabled = false
- end
- end
- end
- local function checkWeapons (wd)
- for _,ud in pairs({weapons}) do
- -- add the custom weapons based parameters
- ud.hasShield = false
- ud.canParalyze = false
- ud.canStockpile = false
- ud.canAttackWater = false --workaround for mantis 2857
- for _,wt in ipairs(ud.weapons) do
- local wd = WeaponDefs[wt.weaponDef]
- Toggle (not enable, unitID)
- if (wd) then
- if (wd.isShield) then ud.hasShield = true end
- if (wd.paralyzer) then ud.canParalyze = true end
- if (wd.stockpile) then ud.canStockpile = true end
- if (wd.waterWeapon) then ud.canAttackWater = true end
- end
- end
- end
- return not wd
- end
- function gadget:AllowDirectUnitControl(unitID, unitDefID, unitTeam, playerID)
- return checkWeapons (true)
- end
- function SMerge(seq1, seq2)
- local head1, head2 = seq1.head, seq2.head
- local step
- if head1 < head2 then
- function step() return SMerge(seq1.tail, seq2) end
- elseif head2 < head1 then
- function step() return SMerge(seq1, seq2.tail) end
- head1 = head2
- else
- function step() return SMerge(seq1.tail, seq2.tail) end
- end
- return Seq(head1, step)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement