Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 12-31-2011, 09:01 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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)?
Reply With Quote
  #3  
Old 12-31-2011, 09:06 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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)
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #4  
Old 12-31-2011, 09:15 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
You also need to familiarize yourself with finding the distance between the player and baddy, and working with deltas.
Reply With Quote
  #5  
Old 12-31-2011, 03:41 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Things which might help you
Generally a baddy
Going around walls
__________________
MEEP!
Reply With Quote
  #6  
Old 12-31-2011, 04:13 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Thanks for the links, I will read them and try to understand how I could make a good movement system.
__________________

Gund for president.

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


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 10:08 AM.


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