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 09-27-2006, 01:50 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Things that stop NPCs

Zodiac's inventory has a major bug.
It randomly stops. By stopping, I mean it doesn't carry out any functions or catch any events.
I have no idea what causes it. The only thing I can think of that stops an NPC like this is when a script exceeds the loop limit. The console log doesn't give a loop limit exceeded error.

I can't fully debug the problem, because I can't make the bug happen to myself. However, a majority of Zodiac has it. These bugged players all seem to have the Stealth skill, but I also have it and I'm not experiencing the bug.

PHP Code:
//Skill: Stealth
function onActionServerside() {
  if (
params[0] == "cast") {
    
player.TakeMP(25,"skill");
  }
}
//#CLIENTSIDE
function onCreated() {
  
join("systemfunctions");
  
join("mudfunctions");
  
this.spelltime .4;
  
this.spellpower 0;
  
this.manacost 25;
  
this.element "Dark";
  
this.description "Makes you invisible to|others for a while.";
  
this.castani "carrystill";
}

function 
onCast() {
  if (
clientr.stat.mp this.manacost) return;
  
setani("carrystill",NULL);
  
this.ftime .5;
  if (
clientr.cmp.shadowblanket 0this.ftime -= clientr.cmp.shadowblanket .1;
  
freezeplayer(this.ftime);
  
findweapon("+System").AddBuff(/*Params clipped*/);
  
sleep(this.ftime);
  
setani("y-animation-hidden",NULL);
  
player.chat " ";
  if (
clientr.element == "Dark") {
    
temp.stealthtime clientr.levels.Thief 1.5;
  }
  else if (
clientr.element == "Light") {
    
temp.stealthtime clientr.levels.Thief .5;
  }
  else {
    
temp.stealthtime clientr.levels.Thief 1.5;
  }
  
temp.modz clientr.mods;
  while (
temp.modz.index("stealthup") >= 0) {
    
temp.stealthtime += temp.modz[temp.modz.index("stealthup")+1];
    
temp.modz.delete(temp.modz.index("stealthup")+1);
    
temp.modz.delete(temp.modz.index("stealthup"));
  }
  
findweapon("+System").AddBuff(/*Params clipped*/);
  
triggerserver("gui",name,"cast");
}

public function 
CanCast() {
  if (
HasBuff("invisible")) return false;
  return 
true;

PHP Code:
//System: Stealth-related functions
public function AddBuff(/*Params clipped*/) {
  switch (
type) {
    case 
"invisible":
      
this.invisible.duration time;
      
replaceani("walk","y-animation-hidden");
      
replaceani("idle","y-animation-hidden");
      
player.attr[3] = "";
      
RemoveEffects();
      break;
  }
}

function 
RemoveEffects() {
  for (
728b++) {
    
player.attr[b] = "";
  }
}

function 
onTimeout() {
  for (
/*Buff stuff*/) {
    if (
a[3] == "invisible") {
      
this.invisible.duration -= .05;
      if (
player.ani != "y-animation-hidden") {
        
this.invisible.duration 0;
      }
      if (
this.invisible.duration <= 0) {
        
RemoveBuff("invisible");
      }
    }
  }
}

public function 
RemoveBuff(/*Params clipped*/) {
  
this.(@type).duration 0;

  switch (
type) {
    case 
"invisible":
      
replaceani("walk",client.gani.walk);
      
replaceani("idle",client.gani.idle);
      
replaceani("sit","sit");
      
this.updateicon 0;
      if (
player.ani == "y-animation-hidden"setani(client.gani.idle,player.attr[2]);
      
UpdateBuffs();
    break;
  }
}

function 
UpdateBuffs() {
  for (
728b++) {
    
player.attr[b] = "";
  }
  for (
/*Buff stuff*/) {
    
player.attr[7+a] = /*Buff effect var clipped*/;
  }

Clipped out not-so-important parts that people-shouldn't-be-seeing.
Reply With Quote
  #2  
Old 09-27-2006, 04:21 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
temp.modz = clientr.mods;
while (temp.modz.index("stealthup") >= 0) {
temp.stealthtime += temp.modz[temp.modz.index("stealthup")+1];
temp.modz.delete(temp.modz.index("stealthup")+1);
temp.modz.delete(temp.modz.index("stealthup"));
}

if the last member of temp.modz is "stealthup" and you do
temp.modz.delete(temp.modz.index("stealthup")+1);
why delete the member after "stealthup" if that was the last member?

correct me if I am wrong

and why you have two
temp.modz.delete(temp.modz.index("stealthup")+1);
temp.modz.delete(temp.modz.index("stealthup")); ?

or secret?

oh and also, if last member is "stealthup" (again)
why use
temp.stealthtime += temp.modz[temp.modz.index("stealthup")+1];?
(not sure if this would do something that I can't see in the script)

and again, correct me if I am wrong
__________________
Reply With Quote
  #3  
Old 09-27-2006, 05:06 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Quote:
Originally Posted by Chompy View Post
temp.modz = clientr.mods;
while (temp.modz.index("stealthup") >= 0) {
temp.stealthtime += temp.modz[temp.modz.index("stealthup")+1];
temp.modz.delete(temp.modz.index("stealthup")+1);
temp.modz.delete(temp.modz.index("stealthup"));
}

if the last member of temp.modz is "stealthup" and you do
temp.modz.delete(temp.modz.index("stealthup")+1);
why delete the member after "stealthup" if that was the last member?

correct me if I am wrong

and why you have two
temp.modz.delete(temp.modz.index("stealthup")+1);
temp.modz.delete(temp.modz.index("stealthup")); ?

or secret?

oh and also, if last member is "stealthup" (again)
why use
temp.stealthtime += temp.modz[temp.modz.index("stealthup")+1];?
(not sure if this would do something that I can't see in the script)

and again, correct me if I am wrong
You're very wrong.
The mod that increases stealth time takes the form of 'stealthup,time' so it deletes both the time and the stealthup
Reply With Quote
  #4  
Old 09-27-2006, 06:00 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
ah, just wondered

but I was thinking of something, doesn't temp. variables get deleted after the ending bracet?

if (clientr.element == "Dark") {
temp.stealthtime = clientr.levels.Thief * 1.5;
}
else if (clientr.element == "Light") {
temp.stealthtime = clientr.levels.Thief * .5;
}
else {


or..?

And again (and again xD) correct me if I am wrong

but, do the function onCast() check if it allready has the buff (can't see the ckecking stuff in the script) and is onCast() done outside the same script?
if so;
sleep(this.ftime); if you cast the function from outside the script while the script has sleep wouldn't it stop the script?
That happened too one of my scripts
(everytime it added an showani of players head and used sleep then hide it, but when player died (or have been hitted many times)
the script stopped and I have to update the script)
Well that problem is gone now, but
I dunno if you should use sleep there :O


Correct me if I am wrong,
but I am guessing its wrong but I am trying atleast
__________________
Reply With Quote
  #5  
Old 09-27-2006, 06:09 PM
contiga contiga is offline
Graal2001 Administration
contiga's Avatar
Join Date: Jul 2004
Location: Netherlands
Posts: 419
contiga is an unknown quantity at this point
Send a message via ICQ to contiga Send a message via AIM to contiga Send a message via MSN to contiga Send a message via Yahoo to contiga
Sleep sometimes breaks timeout.
__________________
AIM: Contiga122
MSN: [email protected]
Status:
Quote:
Originally Posted by unixmad View Post
I am also awake 3AM to help correct problems.
Quote:
Originally Posted by Bomy Island RC people
Daniel: HoudiniMan is a bad guy =p
*Bell: rofl. I first read that as houdini is a bad man. like the little kid that wants his mommy to keep her away from that boogie man
Daniel: xD
*Rufus: I wouldn't want my kids around him.
Reply With Quote
  #6  
Old 09-27-2006, 08:51 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by contiga View Post
Sleep sometimes breaks timeout.
Correct. Always re-initiate a timeout after a sleep have been carried out.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #7  
Old 09-27-2006, 06:20 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
ah
__________________
Reply With Quote
  #8  
Old 09-27-2006, 08:59 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
hmm, not weird my script stopped, well I made an count variable and when it went under 0 it hided the showani.. xD

oh well
__________________
Reply With Quote
  #9  
Old 09-28-2006, 12:14 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Where is the timer started? A common error in scripts is to start the timer in onCreated(), but the timer is stopped in various situations when switching levels, so you need to start the timer in onPlayerEnters, on clientside, always.
Reply With Quote
  #10  
Old 09-28-2006, 12:34 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I have experienced this error alot while scripting the Malorian baddy.

NOTE FOR SENSITIVE READERS: GS1





PHP Code:
if (created) {
  
// Stuff
  
timeout .1;
}

if (
timeout) {
  
// stuff...
  
Move();
  
timeout .1;
}

function 
Move() {
  
// stuff...
  
move dxdytime8;
}

if (
movementfinished) {
  
//STUFF
  
timeout .1;

And unless the timeout in the 'movementfinished' is there, it wont execute the timeout.

Another example:

PHP Code:
if (created) {
  
// Stuff
  
timeout .1;
}

if (
timeout) {
  
// stuff...
  
Attack();
  
timeout .1;
}

function 
Attack() {
  
//stuff..
  
sleep 3;
  
timeout .1;

Unless the timeout is there after the sleep, well, you get the point by now.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #11  
Old 09-28-2006, 12:44 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
I remember such problems with GS1 on serverside yes (sleep is using a timeout event internally), that's not happening with new scripting engine though.
Reply With Quote
  #12  
Old 09-28-2006, 02:10 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
It doesn't seem to be timer related. I don't see how the Stealth NPC can cause it to bug, either, because nothing Stealth does is related to the Inventory.

The +Inventory NPC stops responding, like when an NPC exceeds the loop limit.
It can't catch any events, such as onPlayerChats, and it can't do anything.
Reply With Quote
  #13  
Old 09-28-2006, 07:28 AM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
When I was first learning to script I realized that whenever I used a while() command without making it a continuous loop my script and game would freeze. Just on the off-chance that it does this maybe you'd want to try using something other than while()?
Reply With Quote
  #14  
Old 09-28-2006, 01:45 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
while () causes it to freeze when you don't have a limiter on it. In my case, it deletes each instance of 'stealthup' it finds, so it can't be go on forever.
A lot of other NPCs use while() as well, but only Stealth seems to cause the problem.
Reply With Quote
  #15  
Old 09-28-2006, 07:17 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Normally the only thing that can stop the script completely from running is to do "this.ispaused = true" (or destroy() of course).
An exceeded loop-limited is just ending the current script execution, but other events are still working.
Other than that, most of the time when a clientside script is not doing anything it is because of the timer is not set.
Reply With Quote
  #16  
Old 09-28-2006, 08:22 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Hmm, that's weird.
I can't see why the NPC would do this.. I had thought maybe it was breaking out of the timer or the on/off variable was getting stuck, but then I added a function to echo when the player chats. When the inventory broke, it stopped echoing.
Reply With Quote
  #17  
Old 09-28-2006, 09:10 PM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
*shrug*
Maybe its not the Stealth NPC that these players all have in common? If it is something relating to Stealth, maybe there's something in the Inventory NPC? If neither of those two then it has to be something else, if all of this stuff is wrong...

*puffs pipe and plays violin*
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 11:14 PM.


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