ItsMods

Full Version: Improved 3D icons
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

This is another code I found out while I was exploring my zombie mod folder, it is meant to be used on boxes, it spawns a shader over it that only appears when you are close and looking at it, it fades in and out to give a better effect.

Code:
iShader( shader )
{
    trigger = Spawn( "trigger_radius", self.origin, 0, 150, 72 );
    icon = NewHudElem( );
    icon SetShader( shader, 150, 150 );
    icon.alpha = 0;
    icon.color = ( 1, 1, 1 );
    icon.x = self.origin[ 0 ];
    icon.y = self.origin[ 1 ];
    icon.z = self.origin[ 2 ] + 55;
    icon SetWayPoint( true, true );
    wait ( 0.05 );
    while( 1 )
    {
        trigger waittill( "trigger", player );
        if( !isplayer( player ) )
            continue;
        while( player IsTouching( trigger ) )
        {
            if( VectorDot( anglesToForward( player.angles ), VectorNormalize( trigger.origin - player.origin ) ) > 0.766 )
                FadeIcon( icon, "in" );
        else
                FadeIcon( icon, "out" );
        wait ( 0.25 );
        }
        FadeIcon( icon, "out" );
    }
}

FadeIcon( icon, what )
{
    if( what == "in" )
    {
        icon FadeOverTime( 0.2 );
        icon.alpha = 1;
        wait ( 0.2 );
    }
    else if( what == "out" )
    {
        icon FadeOverTime( 0.2 );
        icon.alpha = 0;
        wait ( 0.2 );
    }
    else
    {
        if( icon.alpha == 0 )
        {
            icon FadeOverTime( 0.2 );
            icon.alpha = 1;
            wait ( 0.2 );
        }
        else
        {
            icon FadeOverTime( 0.2 );
            icon.alpha = 0;
            wait ( 0.2 );
        }
    }
}

Example of use:

Code:
block = spawn( "script_model", ( 100, 30, -1000 ) );
block setModel( "com_plasticcase_beige_big" );
block thread iShader( "hudicon_neutral" );

Thanks for reading
nice, also you can do it by using simple line. (i used it in mw2rotu)
I will post it there if i will find it.
How can I invert it to be if you're farther from it, the shader shows. But the closer you are it, the less it shows?

Edit: Never mind I got it, just had to replace the fadeicon( icon, "in" ); and so with the opposites.

Edit 2: I'm going to use this in AIZombies eXtreme 2.0, just a heads up. Credits obviously given.
(06-18-2013, 20:01)DidUknowiPwn Wrote: [ -> ]How can I invert it to be if you're farther from it, the shader shows. But the closer you are it, the less it shows?

Edit: Never mind I got it, just had to replace the fadeicon( icon, "in" ); and so with the opposites.

Edit 2: I'm going to use this in AIZombies eXtreme 2.0, just a heads up. Credits obviously given.

Could you post 1-2 picture about how does it look w/ the added shader and w/o?
(06-18-2013, 21:41)TheRaZ Wrote: [ -> ]
(06-18-2013, 20:01)DidUknowiPwn Wrote: [ -> ]How can I invert it to be if you're farther from it, the shader shows. But the closer you are it, the less it shows?

Edit: Never mind I got it, just had to replace the fadeicon( icon, "in" ); and so with the opposites.

Edit 2: I'm going to use this in AIZombies eXtreme 2.0, just a heads up. Credits obviously given.

Could you post 1-2 picture about how does it look w/ the added shader and w/o?

Okay so they're basically the same thing but it just hides the icon when you're looking at it (using a transition, in my version at least).
Original it's hidden until you look at it.
Video coming.
Edit:
There is a bug where if let's say the area it was threaded from i.e. box location in point A in the map. And the box moved to point B the waypoint will still be at A. Any idea on how to fix it?
(06-20-2013, 01:58)DidUknowiPwn Wrote: [ -> ]There is a bug where if let's say the area it was threaded from i.e. box location in point A in the map. And the box moved to point B the waypoint will still be at A. Any idea on how to fix it?

Create wp1, if box moved Destroy wp1 and if destroyed create new waypoint?
Or put this inside a while, so it keeps changing its position according to the box.

Code:
trigger setOrigin( (x,y,z ) );
    icon.x = trigger.origin[ 0 ];
    icon.y = trigger.origin[ 1 ];
    icon.z = trigger.origin[ 2 ] + 55;
Code:
Error: uninitialised variable 'z' at file maps/mp/gametypes/mapedit.gsc, line 2161:
  trigger SetOrigin( (x,y,z) );

Edit 3: Now it's working ;P
Code:
    while( 1 )
    {
        trigger SetOrigin( (icon.x,icon.y,icon.z) );
        icon.x = self.origin[ 0 ];
        icon.y = self.origin[ 1 ];
        icon.z = self.origin[ 2 ] + 55;
        wait (0.01);
    }