mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Fixed Nuke And Base Damage
This commit is contained in:
47
Addons/Admin/base-damage.lua
Normal file
47
Addons/Admin/base-damage.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- alot of this is copied from redmew - but it has been reworked to use the ExpCore
|
||||
-- https://github.com/Valansch/RedMew/blob/develop/nuke_control.lua
|
||||
|
||||
local function _damage(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.damage = not reset and global.addons.damage or {}
|
||||
return global.addons.damage
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_entity_damaged,function(event)
|
||||
if event.force == nil or event.force ~= event.entity.force then return end
|
||||
if event.cause == nil or event.cause.name ~= 'player' then return end
|
||||
local player = Game.get_player(event.cause.player)
|
||||
if Ranking.get_rank(player):allowed('base-damage') then return end
|
||||
if not _damage()[player.index] then _damage()[player.index] = {0,0} end
|
||||
_damage()[player.index][1] = _damage()[player.index][1]+event.final_damage_amount
|
||||
if _damage()[player.index][2] < event.tick-300 then
|
||||
_damage()[player.index][2] = event.tick
|
||||
player_return({'base-damage.used'},defines.text_color.med,player)
|
||||
Admin.give_warning(player,'<server>','Damaged something inside the base. Total Delt: '.._damage()[player.index][1],4)
|
||||
end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_player_ammo_inventory_changed,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if Ranking.get_rank(player):allowed('nuke') then return end
|
||||
local found = player.remove_item({name='atomic-bomb',count=1000})
|
||||
if not _damage()[player.index] then _damage()[player.index] = {0,0} end
|
||||
if found > 0 then
|
||||
Admin.move_item_to_spawn({name='atomic-bomb',count=found},player.surface)
|
||||
player_return({'base-damage.nuke'},defines.text_color.med,player)
|
||||
if _damage()[player.index][2] < event.tick-300 then
|
||||
_damage()[player.index][2] = event.tick
|
||||
Admin.give_warning(player,'<server>','Nukes are not allowed for your rank.',4)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -1,53 +0,0 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- alot of this is copied from redmew - but it has been reworked to use the ExpCore
|
||||
-- https://github.com/Valansch/RedMew/blob/develop/nuke_control.lua
|
||||
|
||||
local const = 8 -- this is how many entites must be found in order to give a warning
|
||||
-- false means that it cant be used
|
||||
local capsules = {
|
||||
['artillery-targeting-remote']=false,
|
||||
['cliff-explosives']=true,
|
||||
['cluster-grenade']=false,
|
||||
['defender-capsule']=true,
|
||||
['destroyer-capsule']=true,
|
||||
['discharge-defense-remote']=true,
|
||||
['distractor-capsule']=true,
|
||||
['grenade']=false,
|
||||
['poison-capsule']=false,
|
||||
['raw-fish']=true,
|
||||
['slowdown-capsule']=true,
|
||||
}
|
||||
|
||||
Event.register(defines.events.on_player_used_capsule,function(event)
|
||||
local player = Game.get_player(event)
|
||||
local item = event.item
|
||||
if capsules[item.name] or Ranking.get_rank(player):allowed('capsules') then return end
|
||||
local x,y = event.position.x, event.position.y
|
||||
local player_entities = player.surface.count_entities_filtered{
|
||||
force=player.force,
|
||||
area={{x-5,y-5},{x+5,y+5}}
|
||||
}
|
||||
if player_entities < const then return end
|
||||
player_return({'capsules.used',item.name},defines.text_color.med,player)
|
||||
Admin.give_warning(player,'<server>','Using '..item.name..' inside the base.',4)
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_player_ammo_inventory_changed,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if Ranking.get_rank(player):allowed('nuke') then return end
|
||||
local found = player.remove_item({name='atomic-bomb',count=1000})
|
||||
if found > 0 then
|
||||
Admin.move_item_to_spawn({name='atomic-bomb',count=found},player.surface)
|
||||
player_return({'capsules.nuke'},defines.text_color.med,player)
|
||||
Admin.give_warning(player,'<server>','Nukes are not allowed for your rank.',4)
|
||||
end
|
||||
end)
|
||||
@@ -24,7 +24,7 @@ require('Admin/discord')
|
||||
require('Admin/auto-message')
|
||||
require('Admin/tree-decon')
|
||||
require('Admin/inventory-search')
|
||||
require('Admin/capsules')
|
||||
require('Admin/base-damage')
|
||||
|
||||
-- commands dir
|
||||
require('Commands/cheat-mode')
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
[capsules]
|
||||
used=You used __1__ and it hit some of your own buildings. Please be careful next time!
|
||||
[base-damage]
|
||||
used=You hit some of your own buildings. Please be careful next time!
|
||||
nukes=Nukes are not allowed in your rank. This is a preventive measure against grievers.
|
||||
Reference in New Issue
Block a user