AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Half model of ball is in floor. What to do? (https://forums.alliedmods.net/showthread.php?t=252176)

danonix 11-27-2014 11:46

Half model of ball is in floor. What to do?
 
Hello, I don't know why but half of my ball model is in floor. I have changed model to another one and that happened. Which line I should change, to make it fine? I was trying some stuff, but didn't work.

Thanks!

Code:

UpdateBall()
{
if(!pev_valid(g_ball))
        return
       
        set_pev(g_ball, pev_velocity, Float:{0.0, 0.0, 0.1});
        set_pev(g_ball, pev_mins, Float:{-15.0, -15.0, -15.0}); //////// MOZE TUTAJ
        set_pev(g_ball, pev_maxs, Float:{15.0, 15.0, 15.0}); //////// MOZE TUTAJ
       
        set_pev(g_ball, pev_solid, SOLID_TRIGGER);
        set_pev(g_ball, pev_frame, 0.0);
        set_pev(g_ball, pev_animtime, 0.0);
        set_pev(g_ball, pev_framerate, 0.0);
        set_pev(g_ball, pev_iuser1, 0);
        set_pev(g_ball, pev_sequence, 1);
        set_pev(g_ball, pev_origin, g_origin);
}

CreateBall(Float:origin[3])
{
g_ball = create_entity("info_target");

set_pev(g_ball, pev_classname, "ball");
engfunc(EngFunc_SetModel, g_ball, "models/pilkanew/ball.mdl");
set_pev(g_ball, pev_body, 0);
set_pev(g_ball, pev_skin, random(3))
set_pev(g_ball, pev_solid, SOLID_TRIGGER);
set_pev(g_ball, pev_movetype, MOVETYPE_BOUNCE);

set_pev(g_ball, pev_mins, Float:{-15.0, -15.0, -15.0}); //////// MOZE TUTAJ
set_pev(g_ball, pev_maxs, Float:{15.0, 15.0, 15.0}); /////////// MOZE TUTAJ

set_pev(g_ball, pev_sequence, 1);
set_pev(g_ball, pev_framerate, 0.0);
set_pev(g_ball, pev_frame, 0.0);

set_pev(g_ball, pev_origin, origin); //////// MOZE TUTAJ
set_pev(g_ball, pev_nextthink, get_gametime()+0.05);
g_CreateBall = true;
}

Code:

public FwdThinkBall(ent)
{
        if(!pev_valid(ent))
                return PLUGIN_HANDLED;
       
        set_pev(ent, pev_nextthink, halflife_time()+0.05);
       
        new Float:EntOrigin[3], Float:EntVelocity[3];
        pev(ent, pev_origin, EntOrigin);
        pev(ent, pev_velocity, EntVelocity);
       
        new owner = pev(ent, pev_iuser1);
        new solid = pev(ent, pev_solid);
       
        static Float:LastThink;
        if(LastThink < get_gametime())
        {
                if(floatround(vector_length(EntVelocity)) > 10)
                {
                        message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
                        write_byte(TE_KILLBEAM);
                        write_short(g_ball);
                        message_end();
                       
                        message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
                        write_byte(TE_BEAMFOLLOW);
                        write_short(g_ball);
                        write_short(g_trail);
                        write_byte(10);
                        write_byte(10);
                        write_byte(0);//r
                        write_byte(0);//g
                        write_byte(0);//b
                        write_byte(255);//alpha ?
                        message_end();
                }
                LastThink = get_gametime()+3.0;
        }
       
        if(owner)
        {
                new Float:OwnerOrigin[3];
                pev(owner, pev_origin, OwnerOrigin);
               
                if(!is_user_alive(owner))
                {
                        OwnerOrigin[2] += 5.0;
                       
                        set_pev(ent, pev_iuser1, 0);
                        set_pev(ent, pev_origin, OwnerOrigin);
                        set_pev(ent, pev_velocity, Float:{1.0, 1.0, 0.0});
                        return PLUGIN_CONTINUE;
                }
               
                if(solid != SOLID_NOT)
                        set_pev(ent, pev_solid, SOLID_NOT);
               
                set_pev(ent, pev_frame, pev(ent, pev_frame));
                set_pev(ent, pev_animtime, 0.0);
                set_pev(ent, pev_framerate, 0.0);
                set_pev(g_ball, pev_sequence, 1);
                new Float:Angles[3], Float:vReturn[3];
                pev(owner, pev_v_angle, Angles);
               
                vReturn[0] = (floatcos(Angles[1], degrees) * 25.0) + OwnerOrigin[0];
                vReturn[1] = (floatsin(Angles[1], degrees) * 55.0) + OwnerOrigin[1];
                vReturn[2] = OwnerOrigin[2] - ((pev(owner, pev_flags) & FL_DUCKING) ?10.0: 30.0);
               
                set_pev(ent, pev_origin, vReturn);
                set_pev(ent, pev_velocity, Float:{1.0, 1.0, 0.0});
        }
        else
        {
                if(solid != SOLID_TRIGGER)
                        set_pev(ent, pev_solid, SOLID_TRIGGER);
               
                static Float:VerticalOrigin;
                if(!EntVelocity[2])
                {
                        set_pev(ent, pev_frame, pev(ent, pev_frame));
                        set_pev(ent, pev_animtime, 0.0);
                        set_pev(ent, pev_framerate, 0.0);
                       
                        static iCounts;
                        if(VerticalOrigin > EntOrigin[2])
                        {
                                iCounts++;
                                if(iCounts > 10)
                                {
                                        iCounts = 0;
                                        UpdateBall();
                                }
                        }
                        else
                        {
                                iCounts = 0;
                                if(PointContents(EntOrigin) != CONTENTS_EMPTY)
                                        UpdateBall();
                        }
                        VerticalOrigin = EntOrigin[2];
                }
        }
        return PLUGIN_CONTINUE;
}


RateX 11-27-2014 21:49

Re: Half model of ball is in floor. What to do?
 
Was this happen when it spawn or after it think?

danonix 11-28-2014 12:59

Re: Half model of ball is in floor. What to do?
 
When player has ball, everything is fine
When ball bounes, and touches floor - it's in it.
When ball has no owner and it's immobility then it is in floor.

There is one function more, TouchWorld;

PHP Code:

public FwdTouchWorld(entworld)
{
    new 
Float:velocity[3];
    
pev(entpev_velocityvelocity); 
    
    if(
floatround(vector_length(velocity)) > 10)
    {
        
velocity[0] *= 0.85;
        
velocity[1] *= 0.85;
        
velocity[2] *= 0.85;
        
        if(
velocity[0] && velocity[1])
        {
            new 
Float:Angels[3];
            
vector_to_angle(velocityAngels);
            
Angels[0] = 0.0;
            
set_pev(entpev_anglesAngels);
        }
        
set_pev(entpev_velocityvelocity);
        
emit_sound(entCHAN_ITEM"jb/bounce.wav"1.0ATTN_NORM0PITCH_NORM);
    }
    return 
PLUGIN_CONTINUE;




All times are GMT -4. The time now is 17:43.

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