All Traps

Got any custom JavaScript additions/tweaks you think other people would like to see? Post 'em here!
Post Reply
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

All Traps

Post by dragon slayer »

I have scripted this traps for any shard like to use them when walked across the trap fires and does damage to your Char.

I will have more so watch this post.

Saw Trap
function onCollide( srcSock, pUser, iUsed )
{
        //Change the motionless trap to a moving trap!
        if( iUsed.id == 0x1103 )
            iUsed.id++;
        else if( iUsed.id == 0x1116 )
            iUsed.id++;

        //Start a timer so the trap doesn't keep going forever
        iUsed.StartTimer( 3000, 1, false );
                pUser.DoAction( 0x20 );
                SubtractHealth( pUser, 4, 8 );
                pUser.SoundEffect( 0x23a, true );

                srcSock.SysMessage("You take damage on your legs!");
                return;
}

function SubtractHealth( mChar, health, mSpell )
{
    if( mChar.noNeedMana || mSpell.health == 0 )
        return;

    if( mSpell.health <0> mChar.health )
            mChar.health = 0;
        else
            mChar.health += ( mSpell.health * health );
    }
    else
    {
        mChar.health -= health;
    }
}

function onTimer( iUsed, timerID )
{
    //If timer is 1, stop the trap
    if( timerID == 1 )
    {
        stopSawTrap( iUsed );
    }  
}

function stopSawTrap( iUsed )
{
    if( iUsed )
    {
        if( iUsed.id == 0x1104 || iUsed.id == 0x1105 || iUsed.id == 0x1106 || iUsed.id == 0x1107 )
            iUsed.id = 0x1103;
        else if( iUsed.id == 0x1117 || iUsed.id == 0x1118 || iUsed.id == 0x1119 || iUsed.id == 0x111A )
            iUsed.id = 0x1116;
    }
}
Axe Trap
function onCollide( srcSock, pUser, iUsed )
{
        //Change the motionless trap to a moving trap!
        if( iUsed.id == 0x1133 )
            iUsed.id++;

        //Start a timer so the trap doesn't keep going forever
        iUsed.StartTimer( 3000, 1, false );
                pUser.DoAction( 0x18 );
                SubtractHealth( pUser, 6, 12 );
                pUser.SoundEffect( 0x23c, true );

                srcSock.SysMessage("You take damage on your legs!");
                return;
}

function SubtractHealth( mChar, health, mSpell )
{
    if( mChar.noNeedMana || mSpell.health == 0 )
        return;

    if( mSpell.health <0> mChar.health )
            mChar.health = 0;
        else
            mChar.health += ( mSpell.health * health );
    }
    else
    {
        mChar.health -= health;
    }
}

function onTimer( iUsed, timerID )
{
    //If timer is 1, stop the trap
    if( timerID == 1 )
    {
        stopAxeTrap( iUsed );
    }  
}

function stopAxeTrap( iUsed )
{
    if( iUsed )
    {
        if( iUsed.id == 0x1134 || iUsed.id == 0x1135 || iUsed.id == 0x1136 || iUsed.id == 0x1137 || iUsed.id == 0x1138 || iUsed.id == 0x1139  )
            iUsed.id = 0x1133;
    }
}
Axe Trap 2
function onCollide( srcSock, pUser, iUsed )
{
        //Change the motionless trap to a moving trap!
        if( iUsed.id == 0x1140 )
            iUsed.id++;
        else if( iUsed.id == 0x114B )
            iUsed.id++;

        //Start a timer so the trap doesn't keep going forever
        iUsed.StartTimer( 3000, 1, false );
                pUser.DoAction( 0x14 );
                SubtractHealth( pUser, 6, 12 );
                pUser.SoundEffect( 0x23c, true );

                srcSock.SysMessage("You take damage from the axe!");
                return;
}

function SubtractHealth( mChar, health, mSpell )
{
    if( mChar.noNeedMana || mSpell.health == 0 )
        return;

    if( mSpell.health <0> mChar.health )
            mChar.health = 0;
        else
            mChar.health += ( mSpell.health * health );
    }
    else
    {
        mChar.health -= health;
    }
}

function onTimer( iUsed, timerID )
{
    //If timer is 1, stop the trap
    if( timerID == 1 )
    {
        stopAxeTrapTwo( iUsed );
    }  
}

function stopAxeTrapTwo( iUsed )
{
    if( iUsed )
    {
        if( iUsed.id == 0x1141 || iUsed.id == 0x1142 || iUsed.id == 0x1143 || iUsed.id == 0x1144 )
            iUsed.id = 0x1140;
        else if( iUsed.id == 0x114C || iUsed.id == 0x114D || iUsed.id == 0x114E || iUsed.id == 0x114F )
            iUsed.id = 0x114B;
    }
}
Spike Trap
function onCollide( srcSock, pUser, iUsed )
{
        //Change the motionless trap to a moving trap!
        if( iUsed.id == 0x1108 )
            iUsed.id++;
        else if( iUsed.id == 0x111B )
            iUsed.id++;

        //Start a timer so the trap doesn't keep going forever
        iUsed.StartTimer( 3000, 1, false );
                pUser.DoAction( 0x14 );
                SubtractHealth( pUser, 8, 14 );
                pUser.SoundEffect( 0x23a, true );

                srcSock.SysMessage("You take damage by the spikes!");
                return;
}

function SubtractHealth( mChar, health, mSpell )
{
    if( mChar.noNeedMana || mSpell.health == 0 )
        return;

    if( mSpell.health <0> mChar.health )
            mChar.health = 0;
        else
            mChar.health += ( mSpell.health * health );
    }
    else
    {
        mChar.health -= health;
    }
}

function onTimer( iUsed, timerID )
{
    //If timer is 1, stop the trap
    if( timerID == 1 )
    {
        stopSpikeTrap( iUsed );
    }  
}

function stopSpikeTrap( iUsed )
{
    if( iUsed )
    {
        if( iUsed.id == 0x1109 || iUsed.id == 0x110A || iUsed.id == 0x110B || iUsed.id == 0x110C || iUsed.id == 0x110D || iUsed.id == 0x110E )
            iUsed.id = 0x1108;
        else if( iUsed.id == 0x111C || iUsed.id == 0x111D || iUsed.id == 0x111E || iUsed.id == 0x111F || iUsed.id == 0x1120 || iUsed.id == 0x1121 )
            iUsed.id = 0x111B;
    }
}
Post Reply