game/fight/main.c
2023-01-10 18:30:35 +02:00

173 lines
5.3 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
// only RAD param ↓↓↓
id = id + 1; // Територия янтаратя 200 метров RAD
pos = "2405 0 6541";
radius = 200.0;
AddZone(id, pos, radius, ZoneType.RAD);
// only PSI param ↓↓↓
id = id + 1; // Територия янтаратя 200 метров PSI
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) {
attachment = player.FindAttachmentBySlotName("Mask"); // Перечеь защиты РѕС СЂР°РґРёР°С†РёРё
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" ) ){
Param1<string> m_MessageParamRD = new Param1<string>( "Дозиметр : " + radiationcnt + "м3в" );
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)
{
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());
}
}
}
else if((vector.Distance(player_position, zone.pos)) < zone.radius && zone.type == ZoneType.PSI) {
attachment = player.FindAttachmentBySlotName("Mask");// Перечеь защиты РѕС PSI
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)
{
player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_VOMIT); // рвота // SNEEZE - чихать
}
Param1<string> m_MessageParamPSI = new Param1<string>("Воздействие PSI! Нужно бежать!");
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;
}
}
}
}
}