Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Baddy Script (https://forums.graalonline.com/forums/showthread.php?t=134265474)

Gunderak 12-31-2011 08:59 AM

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



DustyPorViva 12-31-2011 09:01 AM

I think baddies should have a cone of vision instead of just attacking whoever is near them. Also, you should probably do a raycast check between the baddy and player for a wall. Why go after a player it might not even be able to get to(on the other side of a row of trees, for example)?

Gunderak 12-31-2011 09:06 AM

Yes, I am yet to script wall check's, Mainly I just want to get the attacking bit right, then I'll work on the not walking on walls and not targeting a player if it can't get to them. (No idea how I'll do that yet lol)

DustyPorViva 12-31-2011 09:15 AM

You also need to familiarize yourself with finding the distance between the player and baddy, and working with deltas.

callimuc 12-31-2011 03:41 PM

Things which might help you
Generally a baddy
Going around walls

Gunderak 12-31-2011 04:13 PM

Thanks for the links, I will read them and try to understand how I could make a good movement system.


All times are GMT +2. The time now is 01:53 PM.

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