Raised This Month: $12 Target: $400
 3% 

RainySnowy (Enables CS weather) v2.0y


Post New Thread Reply   
 
Thread Tools Display Modes
juanjotoronja
Member
Join Date: Mar 2014
Old 04-10-2015 , 15:25   Re: RainySnowy (Enables CS weather) v2.0y
Reply With Quote #191

Hi... im using this two plugins Day/night https://forums.alliedmods.net/showthread.php?t=143313 and Rainy/snowy both have custom skys pictures so the "problem" i have is day/night plugin is taking priority over rain sky picture. Is there any chance to reverse this effect so whenever is raining it shows the cloudy sky picture over day/night sky? This is what i have...


Code:
#include <amxmodx>
#include <amxmisc>

/* Choose One */
//#include <engine>
#include <fakemeta>

#include "ojos.inc"

#define MAX_LIGHT_POINTS 3
#define max_suffix 6

new weather_ent
new Float:g_strikedelay
new g_suffix[max_suffix][3] = { "up", "dn", "ft", "bk", "lf", "rt" }
new g_lightpoints[MAX_LIGHT_POINTS]
new g_fxbeam;
new g_soundstate[33]
new g_maxplayers;
new g_stormintensity;

public plugin_precache() 
{
    register_plugin("RainySnowy", "2.0y", "OneEyed & teame06");
    register_cvar("rainysnowy", "2.0y", FCVAR_SERVER);
    register_cvar("weather_type", "3");
    register_cvar("weather_storm", "0");
    register_cvar("sv_customskyname", "rain")
    
    g_maxplayers = get_maxplayers();
    
    new type = get_cvar_num("weather_type");
    if(type == 3)
        type = random_num(0,2);
        
    switch(type) {
        case 1: 
        {    
            g_fxbeam = precache_model("sprites/laserbeam.spr");
            precache_model("models/chick.mdl");
            precache_sound("ambience/rain.wav");
            precache_sound("ambience/thunder_clap.wav");
            weather_ent = CREATE_ENTITY("env_rain")
            THINK("env_rain","WeatherSystem")
            NEXTTHINK(weather_ent,1.0)
            static cvar_skyname[32]
            get_cvar_string("sv_customskyname", cvar_skyname, 31)
            
            if(strlen(cvar_skyname) > 0)
                precache_sky(cvar_skyname)
        }
        case 2: 
        {
            weather_ent = CREATE_ENTITY("env_snow");
        }
    }    
}

public client_putinserver(id)
    client_cmd(id,"cl_weather 1");    

//This is only for rain.
public WeatherSystem(entid) {
    if(entid == weather_ent) 
    {
        //Is weather_storm activated? ( 0 = OFF ) -- ( 1-100 = INTENSITY )
        g_stormintensity = get_cvar_num("weather_storm");
        
        //Do our soundstate and picks random player.
        new victim = GetSomeoneUnworthy(); 
        
        if(g_stormintensity) 
        {
            //Is the delay up?
            if(g_strikedelay < get_gametime()) 
            {
                //We got player to create lightning from?
                if(victim)
                {
                    //Do our Lightning Technique.
                    CreateLightningPoints(victim);
                }
            }
        }
        NEXTTHINK(weather_ent,2.0)
    }
    return PLUGIN_CONTINUE
}

GetSomeoneUnworthy() {
    new cnt, id, total[33];
    for(id=1;id<g_maxplayers;id++)
        if(is_user_alive(id))
            if(is_user_outside(id)) 
            {
                total[cnt++] = id;    
                
                if(!g_soundstate[id]) {
                    g_soundstate[id] = 1;
                    client_cmd(id, "speak ambience/rain.wav");
                }    
            }
            else if(g_soundstate[id]) 
            {
                g_soundstate[id] = 0;
                client_cmd(id, "speak NULL")
            }
    
    if(cnt)
        return total[random_num(0, (cnt-1))];
    return 0;
}

CreateLightningPoints(victim) 
{
    if(IS_VALID_ENT(g_lightpoints[0]))
        return 0;
        
    new ent, x, Float:tVel[3];
    new Float:vOrig[3];
    new Float:mins[3] = { -1.0, -1.0, -1.0 };
    new Float:maxs[3] = { 1.0, 1.0, 1.0 };
    new Float:dist = is_user_outside(victim)-5; //Get distance to set ents at.
    
    GET_ORIGIN(victim,vOrig)
    if(dist > 700.0) { //cap distance.
        dist = 700.0;
    }
    vOrig[2] += dist;

    //Create lightning bolts by spreading X entities randomly with velocity
    for(x=0;x<MAX_LIGHT_POINTS;x++) 
    {
        ent = CREATE_ENTITY("env_sprite")
        SET_INT(ent,movetype,MOVETYPE_FLY)
        SET_INT(ent,solid,SOLID_TRIGGER)
        SET_FLOAT(ent,renderamt,0.0)
        SET_INT(ent,rendermode,kRenderTransAlpha)
        SET_MODEL(ent,"models/chick.mdl")
        
        SET_VECTOR(ent,mins,mins)
        SET_VECTOR(ent,maxs,maxs)
        tVel[0] = random_float(-500.0,500.0);
        tVel[1] = random_float(-500.0,500.0);
        tVel[2] = random_float((dist<=700.0?0.0:-100.0),(dist<=700.0?0.0:50.0));
        
        SET_VECTOR(ent,origin,vOrig)
        SET_VECTOR(ent,velocity,tVel)
        g_lightpoints[x] = ent;
    }
    emit_sound(ent, CHAN_STREAM, "ambience/thunder_clap.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    set_task(random_float(0.6,2.0),"Lightning",victim);
    return 1;
}

// Creating a beam at each entity consecutively.
// Player has 1 in 1000 chance of getting struck !
public Lightning(victim) 
{
    new x, a, b, rand;
    new endpoint = MAX_LIGHT_POINTS-1;
    while(x < endpoint) {
        a = g_lightpoints[x];
        b = g_lightpoints[x+1];
        x++
        if(x == endpoint) {
            rand = random_num(1,1000); //One unlucky son of a bish.
            if(rand == 1) {
                b = victim;
                FAKE_DAMAGE(victim,"Lightning",100.0,1);
            }
        }
        CreateBeam(a,b);
    }
    
    for(x=0;x<MAX_LIGHT_POINTS;x++)
        if(IS_VALID_ENT(g_lightpoints[x]))
            REMOVE_ENTITY(g_lightpoints[x])
    
    
    //Set up next lightning.
    if(g_stormintensity > 100) {
        set_cvar_num("weather_storm", 100);
        g_stormintensity = 100;    
    }
    new Float:mins = 50.0-float(g_stormintensity/2);
    new Float:maxs = 50.0-float(g_stormintensity/3);
    g_strikedelay = get_gametime() + random_float(mins, maxs);
}

public precache_sky(const skyname[])
{
    new bool:found = true
    static tgafile[35]
    
    for(new i = 0; i < max_suffix; ++i)
    {
        formatex(tgafile, 34, "gfx/env/%s%s.tga", skyname, g_suffix[i])
        if(file_exists(tgafile))
            precache_generic(tgafile)
        else
        {
            log_amx("Cannot locate file '%s'", tgafile)
            found = false
            break
        }
    }
    
    if(found)
        set_cvar_string("sv_skyname", skyname)
}

//return distance above us to sky
Float:is_user_outside(id) {
    new Float:origin[3], Float:dist;
    GET_ORIGIN(id, origin)
    
    dist = origin[2];
    
    while (POINTCONTENTS(origin) == -1)
        origin[2] += 5.0;

    if (POINTCONTENTS(origin) == -6) return (origin[2]-dist);
    return 0.0;
}

CreateBeam(entA, entB)
{
    message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
    write_byte( 8 );
    write_short( entA );
    write_short( entB );
    write_short( g_fxbeam );
    write_byte(0);      //start frame
    write_byte(10);     //framerate
    write_byte(5);         //life
    write_byte(8);      //width
    write_byte(100);     //noise
    write_byte(255);    //red
    write_byte(255);    //green
    write_byte(255);    //blue
    write_byte(255);    //brightness
    write_byte(10);        //scroll speed
    message_end();
}
juanjotoronja is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 04-10-2015 , 19:37   Re: RainySnowy (Enables CS weather) v2.0y
Reply With Quote #192

Does this works on Custom Maps? For example in Surf ones?
Syturi0 is offline
eduardolucioac
Member
Join Date: Jan 2016
Old 01-30-2016 , 17:57   Re: RainySnowy (Enables CS weather) v2.0y
Reply With Quote #193

Gentlemen,

Just a suggestion/solution!

One workaround the "problem"...

Quote:
NOTICE: The WEATHER can only be changed on mapchange, because its done before map loads! So change the map after changing the cvars or use weather_type 3 for randomness!!!
... is using "get_mapname" to get the proper configuration to map you want. The disadvantage of this: compile the plugin to configure it!

Quote:
new weather_storm;

public plugin_precache()
{
register_plugin("RainySnowy", "2.0y", "OneEyed & teame06");
register_cvar("rainysnowy", "2.0y", FCVAR_SERVER);

g_maxplayers = get_maxplayers();

new type = get_cvar_num("weather_type");
if(type == 3)
type = random_num(0,2);

new map[33];
get_mapname(map,32);
if(equali(map, "as_snowy2"))
{
type = 2;
weather_storm = 50;
}
else
{
type = 0;
weather_storm = 0;
}

switch(type){
case 1:
{
g_fxbeam = precache_model("sprites/laserbeam.spr");
precache_model("models/chick.mdl");
precache_sound("ambience/rain.wav");
precache_sound("ambience/thunder_clap.wav");
weather_ent = CREATE_ENTITY("env_rain")
THINK("env_rain","WeatherSystem")
NEXTTHINK(weather_ent,1.0)
}
case 2:
{
weather_ent = CREATE_ENTITY("env_snow");
}
}
}
[]'s
eduardolucioac is offline
ZEDD_Intensity
Senior Member
Join Date: Jun 2016
Old 11-18-2017 , 02:34   Re: RainySnowy (Enables CS weather) v2.0y
Reply With Quote #194

Hi there,

Would it be possible to edit Map Darkness? As I can see, the plugin makes the maps darker by about 60% and I'd like to change that and make it a bit lighter for Internal Deathrun Maps.

So, could you please help me with how to edit map darkness?

Regards,
ZEDD
ZEDD_Intensity is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-15-2018 , 12:09   Re: RainySnowy (Enables CS weather) v2.0y
Reply With Quote #195

Sorry for reviving,im really green into this,could someone point me on how to make the rain sound to loop constantly while player is alive or spectating??,problem is that the code as it is will only play the rain.wav( by speak command)which lasts 50 sec or so,then it suddenly stops and leave you with a silent rain ambient .
A easy fix i got to was editing the sound to last like 10 min by looping it on audacity,but then i ended up with two files of 30+ mb which randomly crashed server because of heap size hunk allocation.
If no one is able to help me i will proceed to make a formal request.

Thanks everybody

Eduardo,noob as ever hehe
chuttenjr is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-29-2018 , 17:21   Re: RainySnowy (Enables CS weather) v2.0y
Reply With Quote #196

Solved!*
chuttenjr is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:01.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode