Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   this.wont work... (https://forums.graalonline.com/forums/showthread.php?t=74311)

theHAWKER 05-31-2007 04:20 PM

this.wont work...
 
I am making a agent who walks across the level then i want it to look like another agent walks across when the first is done, so i used this script:

PHP Code:

if (this.63){
this.-= 60;


yet it wont work, anyone want to help me out?

xAndrewx 05-31-2007 04:28 PM

Well, you need to check it when the npc is moving... Here's how!
HTML Code:

function onMove()
{
  this.x++;
  if (this.x > 63)
  {
    this.x = 0;
  }
  schedulevent(0.05, "Move, "");
}


theHAWKER 05-31-2007 04:31 PM

Quote:

Originally Posted by xAndrewx (Post 1313772)
Well, you need to check it when the npc is moving... Here's how!
HTML Code:

function onMove()
{
  this.x++;
  if (this.x > 63)
  {
    this.x = 0;
  }
  schedulevent(0.05, "Move, "");
}


he still just walks into the wall :(
this is my whole script:
PHP Code:

// Graal2002 NPC by Stefan Knorr
if (created) {x+=.5;
  
// Initialize the attributes
  
showcharacter;
  
setcharprop #3,head9.png;
  
setcharprop #C0,white;
  
setcharprop #C1,black;
  
setcharprop #C2,black;
  
setcharprop #C3,black;
  
setcharprop #C4,black;
  
setcharprop #n,Agent;
  
setcharprop #2,no-shield.gif;
  
shieldpower 1;
  
dir 0;
}
if (
playertouchsme) {
message FBI only!;
player.26;
player.41;
player.chat "Busted.";
sleep 1.5;
message ;
}
if (
created || movementfinished) {
setcharani walk,;
radangle random(1*3.14);
dx cos(radangle);
dy = -sin(radangle);
move dx*5,dy*5,.5,4+8+16;
}
if (
this.63){
this.-= 60;
}
function 
onMove()
{
  
this.x++;
  if (
this.63)
  {
    
this.0;
  }
  
schedulevent(0.05"Move""");



JkWhoSaysNi 05-31-2007 04:34 PM

Haven't tried it, but showcharacter NPCs are about 2 tiles wide and x/y are from the top-left corner. So it's probably 2 tiles further along x than you think.

Try if (this.x > 61){ }

theHAWKER 05-31-2007 04:36 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1313774)
Haven't tried it, but showcharacter NPCs are about 2 tiles wide and x/y are from the top-left corner. So it's probably 2 tiles further along x than you think.

Try if (this.x > 61){ }

It sends him back but he stops moving :(

xAndrewx 05-31-2007 04:38 PM

PHP Code:

function onCreated() 

  
this.showcharacter(); 
  
this.headImg "head9.png"
  
temp.colorNames = { {{0}, "white"}, {{1234}, "black"} }; 
  for (
temp.currentTypetemp.colorNames
  { 
    for (
temp.currentIndextemp.currentType[0]) 
    { 
      
this.colors[temp.currentIndex] = temp.currentType[1]; 
    } 
  } 
  
this.nick "Agent"
  
this.shieldImg "no-shield.png"
  
this.bodyImg "body3.png";
  
  
this.ani "walk"
  
this.dir 3;
  
  
this.onMovement();  //Call it 

  
function 
onPlayerTouchsMe() 

  
this.chat "FBI only!"
  
setlevel2(this.level.name2641); 
  
player.chat "Busted"
  
this.removeChat 3


function 
onMovement() 

  if (
playerscount <= 0
  { 
    return 
false
  } 
  if (
this.removeChat 0
  { 
    
this.removeChat -= 0.05
    if (
this.removeChat <= 0
    { 
      
this.chat ""
    } 
  } 
  
this.x++; 
  if (
this.63
  { 
    
this.0
  } 
  
scheduleevent(0.05"Movement"""); 



theHAWKER 05-31-2007 04:42 PM

Quote:

Originally Posted by xAndrewx (Post 1313776)
PHP Code:

function onCreated()
{
  
this.showcharacter();
  
this.headImg "head9.png";
  
temp.colorNames = { {{0}, "white"}, {1234}, "black"} };
  for (
temp.currentTypetemp.colorNames)
  {
    for (
temp.currentIndextemp.currentType[0])
    {
      
this.colors[temp.currentIndex] = temp.currentType[1];
    }
  }
  
this.nick "Agent";
  
this.shieldimg "no-shield.png";
  
this.ani "walk";

  
this.onMove();  //Call it
}
function 
onPlayerTouchsMe()
{
  
this.chat "FBI only!";
  
setlevel2(this.name2641);
  
player.chat "Busted";
  
this.removeChat 3;
}
function 
onMove()
{
  if (
playerscount <= 0)
  {
    return 
false;
  }
  if (
this.removeChat 0)
  {
    
this.removeChat -= 0.05;
    if (
this.removeChat <= 0)
    {
      
this.chat "";
    }
  }
  
this.x++;
  if (
this.63)
  {
    
this.0;
  }
  
schedulevent(0.05"Move""");



xD nice conversion, but it dosen't work lol

DustyPorViva 05-31-2007 04:45 PM

I guess redo the move after he's warped to the otherside of the level?

xAndrewx 05-31-2007 04:48 PM

Fixed, just missed out a bracket and didn't spell scheduleevent correctly!

killerogue 05-31-2007 05:38 PM

What's stopping you people from just using move()? And setting a temp ran for x and keeping him at the same y?

xAndrewx 05-31-2007 05:47 PM

what?


All times are GMT +2. The time now is 09:55 PM.

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