Маленько поправил... теперь если вещь уничтожена наноситься урон... (по гайду VIRrusR опубликовал тему в Помощь)
class Zone {
int id;
int type;
vector pos;
float radius;
}
enum ZoneType {
SAFE,
GAS,
RAD,
BIO
}
ref array<ref Zone> ga_zones = new array<ref Zone>;
ref ControllerZones ctrl_zones = new ControllerZones;
class ControllerZones {
void ControllerZones() {
int id = 0;
vector pos;
float radius;
int type = 0;
id = 1; //Swarog
pos = "5000 0 2100";
radius = 500.0;
AddZone(id, pos, radius);
id = 2; //Lembork
pos = "9000 0 6600";
radius = 300.0;
AddZone(id, pos, radius);
id = 3; //Borek
pos = "9800 0 8500";
radius = 300.0;
AddZone(id, pos, radius);
id = 4; //Nadbor
pos = "5600 0 3800";
radius = 150.0;
AddZone(id, pos, radius);
id = 5; //Nidek
pos = "6420 0 8170";
radius = 100.0;
AddZone(id, pos, radius);
id = 5; //Разлом
pos = "7400 0 2600";
radius = 300.0;
AddZone(id, pos, radius);
GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckZones, 5000, true);
}
void ~ControllerZones() {
}
void AddZone(int id, vector pos, float radius, int type = ZoneType.BIO) {
ref Zone zone = new ref Zone;
zone.id = id;
zone.pos = pos;
zone.radius = radius;
zone.type = type;
ga_zones.Insert(zone);
}
bool InZone(PlayerBase player, ref Zone zone) {
vector player_position = player.GetPosition();
player_position[1] = 0;
if( (vector.Distance(player_position, zone.pos)) < zone.radius ) {
EntityAI attachment;
ItemBase item;
string className;
float biosafe = 0;
//Противогазы
attachment = player.FindAttachmentBySlotName("Mask");
if ( attachment && attachment.IsItemBase() )
{
item = ItemBase.Cast(attachment);
if (( item.GetType().Contains("GP5GasMask") || ( item.GetType().Contains("GasMask")) && ((item.GetHealth()) > 0) )
{
biosafe = biosafe + 7.0;
}
}
attachment = player.FindAttachmentBySlotName("Mask");
if ( attachment && attachment.IsItemBase() ) {
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("GP5GasMask") ) {
item.SetHealth("","",item.GetHealth() - 0.2);
}
}
attachment = player.FindAttachmentBySlotName("Mask");
if ( attachment && attachment.IsItemBase() ) {
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("GasMask") ) {
item.SetHealth("","",item.GetHealth() - 0.2);
}
}
//Головной убор
attachment = player.FindAttachmentBySlotName("Headgear");
if ( attachment && attachment.IsItemBase() )
{
item = ItemBase.Cast(attachment);
if (( item.GetType().Contains("NBCHoodGray") ) && ((item.GetHealth()) > 0) )
{
biosafe = biosafe + 1.0;
}
}
attachment = player.FindAttachmentBySlotName("Headgear");
if ( attachment && attachment.IsItemBase() ) {
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("NBCHoodGray") ) {
item.SetHealth("","",item.GetHealth() - 0.2);
}
}
//Куртки
attachment = player.FindAttachmentBySlotName("Body");
if ( attachment && attachment.IsItemBase() )
{
item = ItemBase.Cast(attachment);
if (( item.GetType().Contains("NBCJacketGray") ) && ((item.GetHealth()) > 0) )
{
biosafe = biosafe + 1.0;
}
}
attachment = player.FindAttachmentBySlotName("Body");
if ( attachment && attachment.IsItemBase() ) {
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("NBCJacketGray") ) {
item.SetHealth("","",item.GetHealth() - 0.2);
}
}
//Штаны
attachment = player.FindAttachmentBySlotName("Legs");
if ( attachment && attachment.IsItemBase() )
{
item = ItemBase.Cast(attachment);
if (( item.GetType().Contains("NBCPantsGray") ) && ((item.GetHealth()) > 0) )
{
biosafe = biosafe + 1.0;
}
}
attachment = player.FindAttachmentBySlotName("Legs");
if ( attachment && attachment.IsItemBase() ) {
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("NBCPantsGray") ) {
item.SetHealth("","",item.GetHealth() - 0.2);
}
}
//Обувь
attachment = player.FindAttachmentBySlotName("Feet");
if ( attachment && attachment.IsItemBase() )
{
item = ItemBase.Cast(attachment);
if (( item.GetType().Contains("NBCBootsGray") ) && ((item.GetHealth()) > 0) )
{
biosafe = biosafe + 1.0;
}
}
attachment = player.FindAttachmentBySlotName("Feet");
if ( attachment && attachment.IsItemBase() ) {
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("NBCBootsGray") ) {
item.SetHealth("","",item.GetHealth() - 0.2);
}
}
//Перчатки
attachment = player.FindAttachmentBySlotName("Gloves");
if ( attachment && attachment.IsItemBase() )
{
item = ItemBase.Cast(attachment);
if (( item.GetType().Contains("NBCGlovesGray") ) && ((item.GetHealth()) > 0) )
{
biosafe = biosafe + 1.0;
}
}
attachment = player.FindAttachmentBySlotName("Gloves");
if ( attachment && attachment.IsItemBase() ) {
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("NBCGlovesGray") ) {
item.SetHealth("","",item.GetHealth() - 0.2);
}
}
if ( biosafe > 11.0 )
return true;
float damage_player;
float damage_zone = 12.0;
damage_player = player.GetHealth("GlobalHealth", "Health");
player.SetHealth("GlobalHealth", "Health", damage_player - (damage_zone - ((damage_zone / 12) * biosafe)));
player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_COUGH);
Param1<string> m_MessageParam = new Param1<string>("ОПАСНАЯ ЗОНА!!! Вам нужны химзащита и противогаз!");
GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity());
return true;
}
return false;
}
void CheckZones() {
ref array<Man> players = new array<Man>;
GetGame().GetPlayers( players );
for ( int i = 0; i < players.Count(); i++ )
{
PlayerBase player;
Class.CastTo(player, players.Get(i));
for ( int j = 0; j < ga_zones.Count(); j++ ) {
if(InZone(player, ga_zones.Get(j))) {
break;
}
}
}
}
}