Spiders spitting webs

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

Spiders spitting webs

Post by dragon slayer »

If you attach this script to spiders they will randomly spit a web on a player doing combat. I call it a small spider ai or just spiders special attack.

spiders.js
// Gives the spider a chance to freeze player any time damage is done towards him just change the iNum > 700 to what ever number of chance you want to make it do more.
function onDefense( pAttacker, pDefender )
{
   var iNum = RandomNumber( 0, 1000 );
   if( iNum > 700 )
   {
      if( pDefender.health < pDefender.maxhp )
      {
          pAttacker.frozen = 1;
          pAttacker.StaticEffect( 0x10DD, 0, 20 );
          pAttacker.SoundEffect( 0x01f2, true );
          pAttacker.EmoteMessage("You are caught in the spiders web ");
          pAttacker.StartTimer(5000, 0, true);
      }
   }
}

function onTimer(pAttacker,timerID)
{
    var socket = pAttacker.socket;

    if(timerID == 0)
    {
             pAttacker.frozen = 0;
             pAttacker.EmoteMessage( "You break free of the web");
    }
}
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

here is a nother spider ai that clals forth baby spiders at random for help.
Might want to script some baby spiders in with lots of less health and damage or your char will come over ran LOL.

spiders.js
// Gives the spider a chance to freeze player any time damage is done towards him just change the iNum > 700 to what ever number of chance you want to make it do more.
function onDefense( pAttacker, pDefender )
{
   var iNum = RandomNumber( 0, 1000 );
   if( iNum > 700 )
   {
      if( pDefender.health < pDefender.maxhp )
      {
        var dice;
        dice = RollDice(1,20,0);

        if (dice < 3)
        {
          var nSpawned = SpawnNPC( "giantspider", pDefender.x, pDefender.y, pDefender.z, pDefender.worldnumber );
          pAttacker.EmoteMessage("You see baby spiders coming");
        }
        if (dice < 6)
        {
          var nSpawned = SpawnNPC( "giantspider", pDefender.x, pDefender.y, pDefender.z, pDefender.worldnumber );
          pAttacker.EmoteMessage("You see baby spiders coming");
        }
        if (dice < 16)
        {
          var nSpawned = SpawnNPC( "giantspider", pDefender.x, pDefender.y, pDefender.z, pDefender.worldnumber );
          pAttacker.EmoteMessage("You see baby spiders coming");
        }
        pAttacker.frozen = 1;
        pAttacker.StaticEffect( 0x10DD, 0, 20 );
        pAttacker.SoundEffect( 0x01f2, true );
        pAttacker.EmoteMessage("You are caught in the spiders web ");
        pAttacker.StartTimer(5000, 0, true);
      }
   }
}

function onTimer(pAttacker,timerID)
{
    var socket = pAttacker.socket;

    if(timerID == 0)
    {
             pAttacker.frozen = 0;
             pAttacker.EmoteMessage( "You break free of the web");
    }
}
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Post by Blue Dragon »

Hello Dragon Slayer,


Congratulations by the scripts, was very good! :D


I had not thought of something like was done in the second script, very cool! Now the spiders have their special attacks. Common spiders and spider boss + _ + :P

The scripts were great, but I will only take a few questions below and give some suggestions that could leave them even better, but if you find that the suggestions are impractical or even if you don't have the patience to try and do, quiet, okay, they are just suggestions, I really liked as has been done.

1- The spider web is spit in character only when he takes damage? For example, if the spider never hit a blow never settles the web in you?

2- If the answer above is Yes, would make it literally spitting the Web? For example, the player is running with her when she launched the attack appear a spider silk (0x0f8d) by going to the player (as the ball of canhao goes to the player), ai hitting it appear that the graph of the Web that you put...

3- Has as the graph of the Web remain on the character ai only when you see the phrase "You break free of the web" she disappear?

Already in the second script I modified speech "You see baby spiders coming" by "Aragog begin to reproduce" LOL, but even the sentence or this appear already exits the spiders with the sentence about them "giante spider is attacking you", leaving a flood on the screen.

4- Has as this second script the phrase "You see baby spiders coming" appear and only after a five seconds after the spiders arise? For example, spider holds you in the web, appears this sentence, ai five seconds after the spiders are born:

5- Where you can change the duration time of permanence of paralize the warp?

And an extra script question if you know. As it does for the spiders shoot you a venomous attacks?? I thought that was enough to use the tags "POISONING = 1000", "POISONSTRENGTH = 1", however they never poison ...


Again I wrote too much LOL :|

Thanks for the scripts.
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

Well after doing this script first night. I was looking in to what you was talking about. I'm going to advance this script even more post the advance version of it with some of your suggestions. keep my basic one i added. I also have been working on some new special attacks for Ettins, Like Boulder throwing at player. Even some nocking players off mounts. I have so many special attack ideas to give the players a run for there money and to make creatures so much more better then the basic ai.


Basicly basic AI is just our stepping stone we use it for the attack methods sine they are not in java we attach special attacks for our monsters to do.

One other thing is i try to make the scirpts as user friendly so you can change settings your self without having to redo it all. or even code.

so next couple scripts ill explain a little bit better for you and make some user friendly switchs
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

Here is a More advance version of the spider that will spit the web on a player from a distance.
var spiderWebDelay = 5000;// You can change the freeze time here.
var webSound = 0x01f2;// change the sound the web makes here
var webID = 0x10DD; //this is the static effect the char has around him when caught in web
var webmovingEffect = 0x0F8D;// this is the moving effect you see when the spider shoots at you.
var frozenMsg = "You are caught in the spiders web";
var unfrozenMsg = "You break free of the web";
var spawnMsg = "You see baby spiders coming";
var monsterSpawn = "giantspider";

function onCombatStart( pAttacker, pDefender )
{
        if( pDefender.frozen == 0)
        {
          pDefender.frozen = 1;
          DoMovingEffect( pAttacker, pDefender, webmovingEffect, 0x10, 0x00, false );
          pDefender.StaticEffect( webID, 0, 30 );
          pDefender.SoundEffect( webSound, true );
          pDefender.EmoteMessage( frozenMsg );
          pDefender.StartTimer(spiderWebDelay, 0, true);
        }
    return true;
}

// Gives the spider a chance to freeze player any time damage is done towards him just change the iNum > 700 to what ever number of chance you want to make it do more.
function onDefense( pAttacker, pDefender )
{
   var iNum = RandomNumber( 0, 1000 );
   if( iNum > 700 )
   {
      if( pDefender.health < pDefender.maxhp )
      {
        var dice;
        dice = RollDice(1,20,0);

        if (dice < 3)
        {
          var nSpawned = SpawnNPC( monsterSpawn, pDefender.x, pDefender.y, pDefender.z, pDefender.worldnumber );
          pAttacker.EmoteMessage( spawnMsg );
        }
        if (dice < 6)
        {
          var nSpawned = SpawnNPC( monsterSpawn, pDefender.x, pDefender.y, pDefender.z, pDefender.worldnumber );
          pAttacker.EmoteMessage( spawnMsg );
        }
        if (dice < 16)
        {
          var nSpawned = SpawnNPC( monsterSpawn, pDefender.x, pDefender.y, pDefender.z, pDefender.worldnumber );
          pAttacker.EmoteMessage( spawnMsg );
        }
        if( pAttacker.frozen == 0)
        {
          pAttacker.frozen = 1;
          DoMovingEffect( pDefender, pAttacker, webmovingEffect, 0x10, 0x00, false );
          pAttacker.StaticEffect( webID, 0, 30 );
          pAttacker.SoundEffect( webSound, true );
          pAttacker.EmoteMessage( frozenMsg );
          pAttacker.StartTimer(spiderWebDelay, 0, true);
        }
      }
   }
}

function onCombatEnd( pDefender, pAttacker )
{
        if( pAttacker.frozen == 0)
        {
          pAttacker.frozen = 1;
          DoMovingEffect( pDefender, pAttacker, webmovingEffect, 0x10, 0x00, false );
          pAttacker.StaticEffect( webID, 0, 30 );
          pAttacker.SoundEffect( webSound, true );
          pAttacker.EmoteMessage( frozenMsg );
          pAttacker.StartTimer(spiderWebDelay, 0, true);
        }
    return true;
}

function onTimer(pAttacker,timerID)
{
    var socket = pAttacker.socket;

    if(timerID == 0)
    {
             pAttacker.frozen = 0;
             pAttacker.EmoteMessage( unfrozenMsg );
    }
}
I added some checks in there to make sure he doesn't keep freezing a frozen player
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Post by Blue Dragon »

Great Dragon Slayer, each time improving the script, hehehe.

This was well understood and easy to edit.

Congratulations
Post Reply