Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-31-2011, 08:59 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Baddy Script

I know some members may dislike me, but for those who don't continue reading
Anyway I am scripting a Baddy and am wondering how I could make it swing its sword at players when it's movement is done via a timeout.
Maybe increase an index variable and if it starts with lets say 2 for instance or an even number it would swing it's sword.
Here is what I have so far.
PHP Code:
function onCreated() {
  
this.attackzone 10//Tiles before it attacks
  
this.speed 0.5//Speed in tiles
  
this.lastplayer null;
  
CreateCharacter(); //Creates the character
  
this.orx this.x;
  
this.ory this.y;
  
this.sayings = { 
  
"It's time to die ",
  
"The time has come ",
  
"It's you're turn ",
  
"I will get you ",
  
"I won't miss this time ",
  
"You will die ",
  
"My sword never misses "
  
};
  
onTimeout();
}

function 
onTimeout() {
  for (
temp.plplayers) {
    if (
pl.x in this.this.attackzonethis.this.attackzone | && pl.y in this.this.attackzonethis.this.attackzone | ) {
      if (
this.lastplayer == null) {
        
this.lastplayer pl;
        
this.saying randomstring(this.sayings)@pl.nick.substring(0pl.nick.pos("(").trim());
      }
      if (
this.pl.x) {
        
this.+= this.speed;
        
this.ani "walk";
      }
      if (
this.pl.x) {
        
this.-= this.speed;
        
this.ani "walk";
      }
      if (
this.pl.y) {
        
this.+= this.speed;
        
this.ani "walk";
      }
      if (
this.pl.y) {
        
this.-= this.speed;
        
this.ani "walk";
      }
      
this.chat this.saying;
      
this.dir getdir(pl.this.xpl.this.y);
    } else {
      if (
pl == this.lastplayer) {
        
this.lastplayer null;
      }
    }
  }
  if (
this.lastplayer == null) {
    
this.ani "idle";
    if (
this.this.orx) {
      
this.-= this.speed;
      
this.ani "walk";
    }
    if (
this.this.orx) {
      
this.+= this.speed;
      
this.ani "walk";
    }
    if (
this.this.ory) {
      
this.-= this.speed;
      
this.ani "walk";
    }
    if (
this.this.ory) {
      
this.+= this.speed;
      
this.ani "walk";
    }
    
this.chat "";
    
this.dir getdir(this.orx this.xthis.ory this.y);
  }
  
settimer(0.05);
}

function 
CreateCharacter() {
  
showcharacter();
  
this.head "head25.png";
  
this.nick "Baddy";
  
this.ap 25;
  
this.colors[0] = "orange"//hands
  
this.colors[1] = "red"//body
  
this.colors[2] = "blue"//sleeves
  
this.colors[3] = "white"//shoes
  
this.colors[4] = "blue"//belt

__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
 


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 +2. The time now is 07:55 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.