Can Anybody port SM Plugin to Source Python?

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
Painkiller
Senior Member
Posts: 205
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Can Anybody port SM Plugin to Source Python?

Postby Painkiller » Thu Feb 23, 2017 5:10 pm

It is a Thunder Plugin.

Its make:
- Rain/Snow + Sound
- Fog
- Wind + Sound (Moves physics through the area)
- Flash and Lightning + Sound
- Sky

I have only the SMX but i uploaded it.
http://hlsw.rocks-clan.de/~akooh/fastDL/config/thunder.smx

I will make a Video for better understanding.

Thanks in Advance

Edit: join on this server 176.9.155.153:28040 HL2DM and type vote in chat for map: dm_h4f_overwocht_r1.
The problem is it does not work on any map. Maybe it will be better with SP;)
decompile
Senior Member
Posts: 287
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: Can Anybody port SM Plugin to Source Python?

Postby decompile » Thu Feb 23, 2017 7:21 pm

first of all we cant do anything without .sp
User avatar
La Muerte
Administrator
Posts: 173
Joined: Sun Jul 15, 2012 1:48 pm
Location: Belgium
Contact:

Re: Can Anybody port SM Plugin to Source Python?

Postby La Muerte » Thu Feb 23, 2017 7:48 pm

decompile wrote:first of all we cant do anything without .sp

I remembered hearing about a SM plugin decompiler a while back so thought I'd gave it a try and ended up using Lysis by PeaceMaker.

Code: Select all

public PlVers:__version =
{
   version = 5,
   filevers = "1.6.1",
   date = "09/15/2014",
   time = "03:13:37"
};
new Float:NULL_VECTOR[3];
new String:NULL_STRING[4];
public Extension:__ext_core =
{
   name = "Core",
   file = "core",
   autoload = 0,
   required = 0,
};
new MaxClients;
public Extension:__ext_sdktools =
{
   name = "SDKTools",
   file = "sdktools.ext",
   autoload = 1,
   required = 1,
};
new Handle:H_enabled;
new Handle:H_enabled_snow;
new Handle:H_enabled_fog;
new Handle:H_density;
new Handle:H_color;
new Handle:H_windspeed;
new Handle:H_flash_min;
new Handle:H_flash_max;
new Handle:H_flash_density;
new Handle:H_delay_min;
new Handle:H_delay_max;
new Handle:H_wind_delay_min;
new Handle:H_wind_delay_max;
new Handle:H_skybox;
new Handle:H_lightstyle;
new rain = -1;
new snow = -1;
public Plugin:myinfo =
{
   name = "SM Thunder",
   description = "thunder",
   author = "Franc1sco's snowfall edited by Alienmario",
   version = "1.1",
   url = ""
};
public __ext_core_SetNTVOptional()
{
   MarkNativeAsOptional("GetFeatureStatus");
   MarkNativeAsOptional("RequireFeature");
   MarkNativeAsOptional("AddCommandListener");
   MarkNativeAsOptional("RemoveCommandListener");
   MarkNativeAsOptional("BfWriteBool");
   MarkNativeAsOptional("BfWriteByte");
   MarkNativeAsOptional("BfWriteChar");
   MarkNativeAsOptional("BfWriteShort");
   MarkNativeAsOptional("BfWriteWord");
   MarkNativeAsOptional("BfWriteNum");
   MarkNativeAsOptional("BfWriteFloat");
   MarkNativeAsOptional("BfWriteString");
   MarkNativeAsOptional("BfWriteEntity");
   MarkNativeAsOptional("BfWriteAngle");
   MarkNativeAsOptional("BfWriteCoord");
   MarkNativeAsOptional("BfWriteVecCoord");
   MarkNativeAsOptional("BfWriteVecNormal");
   MarkNativeAsOptional("BfWriteAngles");
   MarkNativeAsOptional("BfReadBool");
   MarkNativeAsOptional("BfReadByte");
   MarkNativeAsOptional("BfReadChar");
   MarkNativeAsOptional("BfReadShort");
   MarkNativeAsOptional("BfReadWord");
   MarkNativeAsOptional("BfReadNum");
   MarkNativeAsOptional("BfReadFloat");
   MarkNativeAsOptional("BfReadString");
   MarkNativeAsOptional("BfReadEntity");
   MarkNativeAsOptional("BfReadAngle");
   MarkNativeAsOptional("BfReadCoord");
   MarkNativeAsOptional("BfReadVecCoord");
   MarkNativeAsOptional("BfReadVecNormal");
   MarkNativeAsOptional("BfReadAngles");
   MarkNativeAsOptional("BfGetNumBytesLeft");
   MarkNativeAsOptional("PbReadInt");
   MarkNativeAsOptional("PbReadFloat");
   MarkNativeAsOptional("PbReadBool");
   MarkNativeAsOptional("PbReadString");
   MarkNativeAsOptional("PbReadColor");
   MarkNativeAsOptional("PbReadAngle");
   MarkNativeAsOptional("PbReadVector");
   MarkNativeAsOptional("PbReadVector2D");
   MarkNativeAsOptional("PbGetRepeatedFieldCount");
   MarkNativeAsOptional("PbSetInt");
   MarkNativeAsOptional("PbSetFloat");
   MarkNativeAsOptional("PbSetBool");
   MarkNativeAsOptional("PbSetString");
   MarkNativeAsOptional("PbSetColor");
   MarkNativeAsOptional("PbSetAngle");
   MarkNativeAsOptional("PbSetVector");
   MarkNativeAsOptional("PbSetVector2D");
   MarkNativeAsOptional("PbAddInt");
   MarkNativeAsOptional("PbAddFloat");
   MarkNativeAsOptional("PbAddBool");
   MarkNativeAsOptional("PbAddString");
   MarkNativeAsOptional("PbAddColor");
   MarkNativeAsOptional("PbAddAngle");
   MarkNativeAsOptional("PbAddVector");
   MarkNativeAsOptional("PbAddVector2D");
   MarkNativeAsOptional("PbRemoveRepeatedFieldValue");
   MarkNativeAsOptional("PbReadMessage");
   MarkNativeAsOptional("PbReadRepeatedMessage");
   MarkNativeAsOptional("PbAddMessage");
   VerifyCoreVersion();
   return 0;
}

Float:operator/(Float:,_:)(Float:oper1, oper2)
{
   return oper1 / float(oper2);
}

Float:operator+(Float:,_:)(Float:oper1, oper2)
{
   return oper1 + float(oper2);
}

bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
{
   return strcmp(str1, str2, caseSensitive) == 0;
}

Handle:StartMessageOne(String:msgname[], client, flags)
{
   new players[1];
   players[0] = client;
   return StartMessage(msgname, players, 1, flags);
}

EmitSoundToAll(String:sample[], entity, channel, level, flags, Float:volume, pitch, speakerentity, Float:origin[3], Float:dir[3], bool:updatePos, Float:soundtime)
{
   new clients[MaxClients];
   new total;
   new i = 1;
   while (i <= MaxClients)
   {
      if (IsClientInGame(i))
      {
         total++;
         clients[total] = i;
      }
      i++;
   }
   if (!total)
   {
      return 0;
   }
   EmitSound(clients, total, sample, entity, channel, level, flags, volume, pitch, speakerentity, origin, dir, updatePos, soundtime);
   return 0;
}

public OnPluginStart()
{
   CreateConVar("sm_thunder_version", "1.1", "version", 270656, false, 0.0, false, 0.0);
   H_enabled = CreateConVar("sm_thunder_enabled", "0", "Enable thunderstorm", 0, true, 0.0, true, 1.0);
   H_enabled_snow = CreateConVar("sm_snow_enabled", "0", "Enable snow", 0, true, 0.0, true, 1.0);
   H_enabled_fog = CreateConVar("sm_fog_enabled", "1", "Enable fog", 0, true, 0.0, true, 1.0);
   H_density = CreateConVar("sm_rain_density", "999", "Density of the precipitation", 0, false, 0.0, false, 0.0);
   H_color = CreateConVar("sm_rain_color", "255 255 255", "Color of the precipitation", 0, false, 0.0, false, 0.0);
   H_delay_min = CreateConVar("sm_thunder_delay_min", "1", "Delay of thunder sound after lighting min", 0, false, 0.0, false, 0.0);
   H_delay_max = CreateConVar("sm_thunder_delay_max", "4", "Delay of thunder sound after lighting max", 0, false, 0.0, false, 0.0);
   H_flash_min = CreateConVar("sm_flash_delay_min", "1", "min delay between flashes", 0, false, 0.0, false, 0.0);
   H_flash_max = CreateConVar("sm_flash_delay_max", "25", "max delay between flashes", 0, false, 0.0, false, 0.0);
   H_flash_density = CreateConVar("sm_flash_density", "6", "number of flashes", 0, false, 0.0, false, 0.0);
   H_wind_delay_min = CreateConVar("sm_wind_delay_min", "5", "min delay between wind blows", 0, false, 0.0, false, 0.0);
   H_wind_delay_max = CreateConVar("sm_wind_delay_max", "20", "max delay between wind blows", 0, false, 0.0, false, 0.0);
   H_windspeed = CreateConVar("sm_wind_speed", "100.0", "speed of wind", 0, false, 0.0, false, 0.0);
   H_skybox = CreateConVar("sm_skybox", "-1", "skybox override", 0, false, 0.0, false, 0.0);
   H_lightstyle = CreateConVar("sm_lightstyle", "-1", "light style override", 0, false, 0.0, false, 0.0);
   HookConVarChange(H_enabled, EnableThunderChanged);
   HookConVarChange(H_enabled_snow, EnableSnowChanged);
   HookConVarChange(H_enabled_fog, EnableFogChanged);
   HookConVarChange(H_skybox, SkyboxChanged);
   HookConVarChange(H_lightstyle, LightStyleChanged);
   return 0;
}

public OnMapStart()
{
   PrecacheSound("ambient/atmosphere/thunder1.wav", true);
   PrecacheSound("ambient/atmosphere/thunder2.wav", true);
   PrecacheSound("ambient/atmosphere/thunder3.wav", true);
   PrecacheSound("ambient/atmosphere/thunder4.wav", true);
   PrecacheSound("ambient/wind/wind_hit3.wav", true);
   PrecacheSound("ambient/wind/wind_hit2.wav", true);
   PrecacheSound("ambient/wind/wind_hit1.wav", true);
   PrecacheModel("models/error.mdl", true);
   if (GetConVarBool(H_enabled))
   {
      rain = makeIt("1");
   }
   if (GetConVarBool(H_enabled_snow))
   {
      snow = makeIt("3");
   }
   if (!(GetConVarInt(H_enabled_fog)))
   {
      new entity = -1;
      while ((entity = FindEntityByClassname(entity, "env_fog_controller")) != -1)
      {
         AcceptEntityInput(entity, "TurnOff", -1, -1, 0);
      }
   }
   new String:buffer[64];
   GetConVarString(H_skybox, buffer, 64);
   if (!StrEqual(buffer, "-1", true))
   {
      DispatchKeyValue(0, "skyname", buffer);
   }
   GetConVarString(H_lightstyle, buffer, 64);
   if (!StrEqual(buffer, "-1", true))
   {
      SetLightStyle(0, buffer);
   }
   CreateTimer(5.0, Flash, any:0, 2);
   CreateTimer(8.0, Wind, any:0, 2);
   return 0;
}

public EnableFogChanged(Handle:cvar, String:oldVal[], String:newVal[])
{
   new entity = -1;
   if (GetConVarInt(cvar) == 1)
   {
      while ((entity = FindEntityByClassname(entity, "env_fog_controller")) != -1)
      {
         AcceptEntityInput(entity, "TurnOn", -1, -1, 0);
      }
   }
   return 0;
}

public EnableThunderChanged(Handle:cvar, String:oldVal[], String:newVal[])
{
   new var1;
   if (GetConVarInt(cvar) == 1 && !IsValidEdict(rain))
   {
      rain = makeIt("1");
   }
   else
   {
      if (IsValidEdict(rain))
      {
         AcceptEntityInput(rain, "kill", -1, -1, 0);
         rain = -1;
      }
   }
   return 0;
}

public EnableSnowChanged(Handle:cvar, String:oldVal[], String:newVal[])
{
   new var1;
   if (GetConVarInt(cvar) == 1 && !IsValidEdict(snow))
   {
      snow = makeIt("3");
   }
   else
   {
      if (IsValidEdict(snow))
      {
         AcceptEntityInput(snow, "kill", -1, -1, 0);
         snow = -1;
      }
   }
   return 0;
}

public SkyboxChanged(Handle:cvar, String:oldVal[], String:newVal[])
{
   if (!StrEqual(newVal, "-1", true))
   {
      DispatchKeyValue(0, "skyname", newVal);
   }
   return 0;
}

public LightStyleChanged(Handle:cvar, String:oldVal[], String:newVal[])
{
   if (!StrEqual(newVal, "-1", true))
   {
      SetLightStyle(0, newVal);
   }
   return 0;
}

makeIt(String:what[])
{
   decl String:MapName[128];
   decl String:buffer[128];
   decl String:den[128];
   decl String:col[128];
   GetConVarString(H_density, den, 128);
   GetConVarString(H_color, col, 128);
   GetCurrentMap(MapName, 128);
   Format(buffer, 128, "maps/%s.bsp", MapName);
   new ent = CreateEntityByName("func_precipitation", -1);
   DispatchKeyValue(ent, "model", buffer);
   DispatchKeyValue(ent, "preciptype", what);
   DispatchKeyValue(ent, "renderamt", den);
   DispatchKeyValue(ent, "rendercolor", col);
   DispatchSpawn(ent);
   ActivateEntity(ent);
   new Float:minbounds[3] = 0.0;
   GetEntPropVector(0, PropType:1, "m_WorldMins", minbounds, 0);
   new Float:maxbounds[3] = 0.0;
   GetEntPropVector(0, PropType:1, "m_WorldMaxs", maxbounds, 0);
   SetEntPropVector(ent, PropType:0, "m_vecMins", minbounds, 0);
   SetEntPropVector(ent, PropType:0, "m_vecMaxs", maxbounds, 0);
   new Float:m_vecOrigin[3] = 0.0;
   m_vecOrigin[0] = minbounds[0] + maxbounds[0] / 2;
   m_vecOrigin[1] = minbounds[1] + maxbounds[1] / 2;
   m_vecOrigin[2] = minbounds[2] + maxbounds[2] / 2;
   TeleportEntity(ent, m_vecOrigin, NULL_VECTOR, NULL_VECTOR);
   return EntIndexToEntRef(ent);
}

public Action:Flash(Handle:timer, any:data)
{
   if (GetConVarBool(H_enabled))
   {
      new i = 1;
      while (i <= MaxClients)
      {
         if (IsClientInGame(i))
         {
            ScreenFade(i, 255, 255, 255, 200, 15, 1);
         }
         i++;
      }
      CreateTimer(Math_GetRandomFloat(GetConVarFloat(H_delay_min), GetConVarFloat(H_delay_max)), Thunder, any:0, 2);
      new clients[MaxClients];
      new size = GetClients(clients);
      if (0 < size)
      {
         new Float:origin[3] = 0.0;
         GetClientAbsOrigin(clients[Math_GetRandomInt(0, size + -1)], origin);
         new density = GetConVarInt(H_flash_density);
         new i;
         while (i < density)
         {
            decl Float:flashOrigin[3];
            flashOrigin[0] = origin[0] + Math_GetRandomFloat(-3000.0, 3000.0);
            flashOrigin[1] = origin[1] + Math_GetRandomFloat(-3000.0, 3000.0);
            flashOrigin[2] = origin[2] + Math_GetRandomFloat(50.0, 500.0);
            new ent = CreateEntityByName("point_tesla", -1);
            if (IsValidEdict(ent))
            {
               DispatchKeyValue(ent, "texture", "sprites/laserbeam.vmt");
               DispatchKeyValue(ent, "m_Color", "255 255 255");
               DispatchKeyValue(ent, "m_flRadius", "1500");
               DispatchKeyValue(ent, "beamcount_max", "10");
               DispatchKeyValue(ent, "beamcount_min", "1");
               DispatchKeyValue(ent, "thick_min", "4");
               DispatchKeyValue(ent, "thick_max", "80");
               DispatchKeyValue(ent, "lifetime_max", "0.4");
               DispatchKeyValue(ent, "lifetime_min", "0.1");
               DispatchKeyValue(ent, "interval_max", "0.1");
               DispatchKeyValue(ent, "interval_min", "0.0");
               DispatchSpawn(ent);
               ActivateEntity(ent);
               TeleportEntity(ent, flashOrigin, NULL_VECTOR, NULL_VECTOR);
               AcceptEntityInput(ent, "TurnOn", -1, -1, 0);
               CreateTimer(0.3, KillMeLater, EntIndexToEntRef(ent), 2);
            }
            i++;
         }
      }
   }
   CreateTimer(Math_GetRandomFloat(GetConVarFloat(H_flash_min), GetConVarFloat(H_flash_max)), Flash, any:0, 2);
   return Action:4;
}

GetClients(clients[])
{
   new size;
   new i = 1;
   while (i <= MaxClients)
   {
      new var1;
      if (IsClientInGame(i) && !IsFakeClient(i) && IsPlayerAlive(i))
      {
         size++;
         clients[size] = i;
      }
      i++;
   }
   return size;
}

public Action:Thunder(Handle:timer, any:data)
{
   new r = Math_GetRandomInt(1, 4);
   switch (r)
   {
      case 1:
      {
         EmitSoundToAll("ambient/atmosphere/thunder1.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
      }
      case 2:
      {
         EmitSoundToAll("ambient/atmosphere/thunder2.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
      }
      case 3:
      {
         EmitSoundToAll("ambient/atmosphere/thunder3.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
      }
      case 4:
      {
         EmitSoundToAll("ambient/atmosphere/thunder4.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
      }
      default:
      {
      }
   }
   return Action:4;
}

public Action:Wind(Handle:timer, any:data)
{
   if (GetConVarBool(H_enabled))
   {
      new r = Math_GetRandomInt(1, 3);
      switch (r)
      {
         case 1:
         {
            EmitSoundToAll("ambient/wind/wind_hit1.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
         }
         case 2:
         {
            EmitSoundToAll("ambient/wind/wind_hit2.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
         }
         case 3:
         {
            EmitSoundToAll("ambient/wind/wind_hit3.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
         }
         default:
         {
         }
      }
      new ent = CreateEntityByName("trigger_push", -1);
      new Float:angles[3] = 0.0;
      angles[1] = Math_GetRandomFloat(0.0, 359.0);
      DispatchKeyValueVector(ent, "pushdir", angles);
      DispatchKeyValueFloat(ent, "Speed", GetConVarFloat(H_windspeed));
      DispatchKeyValue(ent, "spawnflags", "1038");
      DispatchKeyValue(ent, "StartDisabled", "1");
      DispatchSpawn(ent);
      ActivateEntity(ent);
      TeleportEntity(ent, 3016, NULL_VECTOR, NULL_VECTOR);
      SetEntityModel(ent, "models/error.mdl");
      decl Float:minbounds[3];
      decl Float:maxbounds[3];
      SetEntPropVector(ent, PropType:0, "m_vecMins", minbounds, 0);
      SetEntPropVector(ent, PropType:0, "m_vecMaxs", maxbounds, 0);
      SetEntProp(ent, PropType:0, "m_nSolidType", any:2, 4, 0);
      new enteffects = GetEntProp(ent, PropType:0, "m_fEffects", 4, 0);
      enteffects |= 32;
      SetEntProp(ent, PropType:0, "m_fEffects", enteffects, 4, 0);
      AcceptEntityInput(ent, "enable", -1, -1, 0);
      CreateTimer(Math_GetRandomFloat(2.0, 3.5), KillMeLater, EntIndexToEntRef(ent), 2);
   }
   CreateTimer(Math_GetRandomFloat(GetConVarFloat(H_wind_delay_min), GetConVarFloat(H_wind_delay_max)), Wind, any:0, 2);
   return Action:4;
}

public Action:KillMeLater(Handle:timer, any:data)
{
   AcceptEntityInput(data, "kill", -1, -1, 0);
   return Action:4;
}

Float:Math_GetRandomFloat(Float:min, Float:max)
{
   return GetURandomFloat() * max - min + min;
}

Math_GetRandomInt(min, max)
{
   new random = GetURandomInt();
   if (!random)
   {
      random++;
   }
   return RoundToCeil(float(random) / float(2147483647) / float(max - min + 1)) + min + -1;
}

public ScreenFade(client, red, green, blue, alpha, delay, type)
{
   new Handle:msg = StartMessageOne("Fade", client, 0);
   BfWriteShort(msg, 500);
   BfWriteShort(msg, delay);
   BfWriteShort(msg, type);
   BfWriteByte(msg, red);
   BfWriteByte(msg, green);
   BfWriteByte(msg, blue);
   BfWriteByte(msg, alpha);
   EndMessage();
   return 0;
}
User avatar
Kill
Member
Posts: 73
Joined: Wed Aug 31, 2016 10:05 pm

Re: Can Anybody port SM Plugin to Source Python?

Postby Kill » Thu Feb 23, 2017 11:30 pm

decompile wrote:first of all we cant do anything without .sp

Off topic:
I understand having the source code would help, but why can't You do anything without it?
decompile
Senior Member
Posts: 287
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: Can Anybody port SM Plugin to Source Python?

Postby decompile » Fri Feb 24, 2017 1:22 am

Since OP specifically wants the SM Plugin ported.

Havent even thought thats its possible, can just remember that I was once googling it, and it wasnt possible at that time.
User avatar
Painkiller
Senior Member
Posts: 205
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: Can Anybody port SM Plugin to Source Python?

Postby Painkiller » Fri Feb 24, 2017 9:13 am

Oh yes thanks for Decompile.

Now it would be great if someone finds to write it in SP.
User avatar
La Muerte
Administrator
Posts: 173
Joined: Sun Jul 15, 2012 1:48 pm
Location: Belgium
Contact:

Re: Can Anybody port SM Plugin to Source Python?

Postby La Muerte » Sun Feb 26, 2017 9:16 am

decompile wrote:Since OP specifically wants the SM Plugin ported.

Havent even thought thats its possible, can just remember that I was once googling it, and it wasnt possible at that time.

Haha Decompile, the ironic part is that probably the main reason I remembered it was because of your name.
User avatar
Painkiller
Senior Member
Posts: 205
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: Can Anybody port SM Plugin to Source Python?

Postby Painkiller » Sat Mar 04, 2017 2:48 am

Have anybody new insights?
User avatar
Painkiller
Senior Member
Posts: 205
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: Can Anybody port SM Plugin to Source Python?

Postby Painkiller » Fri Mar 17, 2017 3:23 pm

Nobody who can help?
User avatar
Painkiller
Senior Member
Posts: 205
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: Can Anybody port SM Plugin to Source Python?

Postby Painkiller » Wed Mar 22, 2017 7:24 pm

Can nobody held with this?

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 1 guest