game/fight/main.c

173 lines
5.3 KiB
C
Raw Normal View History

2022-12-19 18:26:14 +00:00
class Zone {
int id;
int type;
vector pos;
float radius;
}
enum ZoneType {
SAFE,
PSI,
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;
2023-01-10 16:29:32 +00:00
// only RAD param ↓↓↓
id = id + 1; // Територия янтаратя 200 метров RAD
2022-12-19 18:26:14 +00:00
pos = "2405 0 6541";
radius = 200.0;
AddZone(id, pos, radius, ZoneType.RAD);
2023-01-10 16:29:32 +00:00
// only PSI param ↓↓↓
id = id + 1; // Територия янтаратя 200 метров PSI
2022-12-19 18:26:14 +00:00
pos = "2405 0 6541";
radius = 200.0;
AddZone(id, pos, radius, ZoneType.PSI);
GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckZones, 5000, true);
}
void ~ControllerZones() {
}
void AddZone(int id, vector pos, float radius, int type) {
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;
EntityAI attachment;
ItemBase item;
string className;
float biosafe = 0;
float psisafe = 0;
float damage_player;
float damage_zone = 0;
float damage_zonePSI = 8.0;
float rpu = 1.0;
if( (vector.Distance(player_position, zone.pos)) < zone.radius && zone.type == ZoneType.RAD) {
2023-01-10 16:29:32 +00:00
attachment = player.FindAttachmentBySlotName("Mask"); // Перечеь защиты РѕС СЂР°РґРёР°С†РёРё
2022-12-19 18:26:14 +00:00
if ( attachment && attachment.IsItemBase() )
{
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("dzrp_GasMask_GP1") )
{
biosafe = biosafe + 1.0;
}
}
attachment = player.FindAttachmentBySlotName("Body");
if ( attachment && attachment.IsItemBase() )
{
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("Top_Admin") )
{
biosafe = biosafe + 1.0;
}
}
if (((ga_zones.Get(j).radius - (vector.Distance(player_position, ga_zones.Get(j).pos)) ) * rpu) > 1 )
{
radiationcnt = ((ga_zones.Get(j).radius - (vector.Distance(player_position, ga_zones.Get(j).pos)) ) * rpu) + Math.RandomInt(1,10000)*0.00001;
if ( DayZRP_Static.IsItemInInventory( player, "DayZRP_Doz" ) ){
2023-01-10 16:29:32 +00:00
Param1<string> m_MessageParamRD = new Param1<string>( "Дозиметр : " + radiationcnt + "м3в" );
2022-12-19 18:26:14 +00:00
GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParamRD, true, player.GetIdentity());
}
}
if (biosafe<1)
{
damage_zone=((ga_zones.Get(j).radius - (vector.Distance(player_position, ga_zones.Get(j).pos)) ) * rpu)/50;
damage_player = player.GetHealth("GlobalHealth", "Health");
player.SetHealth("GlobalHealth", "Health", damage_player - (damage_zone - (damage_zone * biosafe)));
if (biosafe==0)
{
2023-01-10 16:29:32 +00:00
player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_COUGH); //Кашель
Param1<string> m_MessageParam = new Param1<string>("Воздействие Радиации! Одень противогаз!");
2022-12-19 18:26:14 +00:00
GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity());
}
}
}
else if((vector.Distance(player_position, zone.pos)) < zone.radius && zone.type == ZoneType.PSI) {
2023-01-10 16:29:32 +00:00
attachment = player.FindAttachmentBySlotName("Mask");// Перечеь защиты РѕС PSI
2022-12-19 18:26:14 +00:00
if ( attachment && attachment.IsItemBase() ) {
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("dzrp_GasMask_GP7") ) {
psisafe = psisafe + 1.0;
}
}
attachment = player.FindAttachmentBySlotName("Body");
if ( attachment && attachment.IsItemBase() ) {
item = Class.Cast(attachment);
className = item.GetType();
if ( className.Contains("Top_Admin") ) {
psisafe = psisafe + 1.0;
}
}
damage_player = player.GetHealth("GlobalHealth", "Health");
player.SetHealth("GlobalHealth", "Health", damage_player - (damage_zonePSI - (damage_zonePSI * psisafe)));
if (psisafe>=1)
{
return true;
}
if (psisafe==0)
{
if (psisafe<0.5)
{
2023-01-10 16:29:32 +00:00
player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_VOMIT); // рвота // SNEEZE - чихать
2022-12-19 18:26:14 +00:00
}
2023-01-10 16:29:32 +00:00
Param1<string> m_MessageParamPSI = new Param1<string>("Воздействие PSI! Нужно бежать!");
2022-12-19 18:26:14 +00:00
GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParamPSI, 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;
}
}
}
}
2022-06-06 21:30:34 +00:00
}