Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-02-2009, 02:04 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
triggeraction vs player.trigger

Here's the thing - I really, really hate the triggeraction(targetx+1.5,targety+1.5,hit,2); technique. What happens if the target's lagging? What happens if he moves between the point that you had him lined up in your sites and took the shot and the point that the action triggers on his spot?

And yet I find myself with a script that's almost finished - except that the previous scripter used triggeraction. I've got a whole beautiful (not elegant, I don't do elegant) subroutine for detecting which players are about to get hit and storing their names, and I've got a whole beautiful loop for picking each one and hitting them...but because I'm not writing (guessing) it Exactly Right, it doesn't do a damn thing.

Here's what I got:

PHP Code:
//#CLIENTSIDE

function onActionMelee() {
  
player.chat=("Hit! "@params[0SPC params[1]);
  
setAni("hurt""");
  if(
this.cooldown<1){
    
triggerserver("gui"this.name"hurt"params[0], params[1]);
    
findWeapon("GUIInventory").trigger("showHUD""");
    
this.cooldown=60;
  }

which works fine (but only for triggeraction x y), and
PHP Code:
          with(findplayer(plr)){
            
//            echo("Found "@plr SPC ani);
            
setAni("hurt""");
            
triggerserver("gui""#HP""hurt""other"temp.dmg);
            
this.findWeapon("#HP").trigger("Melee""other""3");
            
this.findWeapon("#HP").trigger("ActionMelee""other""3");
            
this.findWeapon("#HP").trigger("OnActionMelee""other""3");
            
this.findWeapon("#HP").melee("other""3");
            
this.findWeapon("#HP").Melee("other""3");
            
this.findWeapon("#HP").ActionMelee("other""3");
            
this.findWeapon("#HP").actionmelee("other""3");
            
this.findWeapon("#HP").onactionmelee("other""3");
            
this.findWeapon("#HP").OnActionMelee("other""3");
          } 
(also clientside); to reiterate, isn't there some sort of player.trigger(wossname)?
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #2  
Old 03-02-2009, 02:35 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Why are you naming your weapons with a # in front of them, anyway?

Have you debugged and made sure that you're actually reaching the player? It looks like those should work.

Are you getting any errors in NC (e.g. can't access private function)?

If you want I can get on Testbed or wherever you're doing this and try to help you out.
__________________
Reply With Quote
  #3  
Old 03-03-2009, 03:54 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
I inherited the # signs. Not a lot I can do about it. Got sure I can find it (I forgot some little subroutine to make sure the player was getting called), then the guy I was testing with got quietly kicked offline. Right now I got
PHP Code:
            triggerserver("weapon",this.name,0,temp.sinx,temp.siny,temp.targets,temp.ptargets);
            
temp.ptt=ptargets.tokenize();
            
player.chat=("PTT:"@ptt);
            for(
temp.plrn:ptt){
              
temp.plr=findplayer(plrn);
              
player.chat=("PLR:"@plr SPC this.damage);
              
plr.chat="Fix me";
              
triggeraction(plr.x+1.5plr.y+1.5"melee""other"this.damage);
              
triggeraction(plr.x+1.5plr.y+1.5"tyhm""other"this.damage);
              
triggeraction(plr.x+1.5plr.y+1.5"Tyhm""other"this.damage);
            } 
And it Used to work, but spontaneously stopped. -_-. Curiously, if I comment out the other two triggeractions it works fine...but only out to a certain distance, about 6 tiles. And actionmelee looks like this:
PHP Code:
function onActionMelee() {
  
player.chat=("Hit! "@params[0SPC params[1]);
  
setAni("hurt""");
  if(
this.cooldown<1){
    
triggerserver("gui"this.name"hurt"params[0], params[1]);
    
findWeapon("GUIInventory").trigger("showHUD""");
    
this.cooldown=60;
  }

__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233

Last edited by Tyhm; 03-03-2009 at 04:04 AM..
Reply With Quote
  #4  
Old 03-03-2009, 05:07 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Clientside to clientside triggeractions only work for a certain distance.

If you're trying to make a sort of long range hit detection you may want to change your methods (such as storing the data in attr or anis).
Reply With Quote
  #5  
Old 03-03-2009, 05:19 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Quote:
Originally Posted by WhiteDragon View Post
Clientside to clientside triggeractions only work for a certain distance.

If you're trying to make a sort of long range hit detection you may want to change your methods (such as storing the data in attr or anis).
...
...
...
...
Thanks, that's great. Hooray Wiki. -_-

Does the old trick of setting a weapon's x and y work? Or is it a fixed distance from the player? Or is a weapon's x and y static?
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #6  
Old 03-03-2009, 05:33 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Tyhm View Post
Does the old trick of setting a weapon's x and y work? Or is it a fixed distance from the player? Or is a weapon's x and y static?
I believe Stefan said it was a fixed distance, but you could always try that since he didn't explicitly say what the engine was determining the distance from.
Reply With Quote
  #7  
Old 03-03-2009, 06:05 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Suggestion: Join the player to a class, then you can call a public function.

PHP Code:
findPlayer("cbk1994").doDamage(1); 
Let me know if you need a better explanation.
__________________
Reply With Quote
  #8  
Old 03-03-2009, 07:28 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Might do that, the players already join a class; would that trigger function on doDamage(){, function onDoDamage(){, function doDamage(){, ? The "on"s always throw me.
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #9  
Old 03-03-2009, 08:22 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by Tyhm View Post
Might do that, the players already join a class; would that trigger function on doDamage(){, function onDoDamage(){, function doDamage(){, ? The "on"s always throw me.
it's just calling
PHP Code:
public function doDamage() {
  ...

Reply With Quote
  #10  
Old 03-03-2009, 09:13 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
kkthxz. :-D
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #11  
Old 03-03-2009, 07:50 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by WhiteDragon View Post
If you're trying to make a sort of long range hit detection you may want to change your methods (such as storing the data in attr or anis).
Thankyou for this suggestion!
Reply With Quote
  #12  
Old 03-03-2009, 10:54 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Tyhm View Post
Might do that, the players already join a class; would that trigger function on doDamage(){, function onDoDamage(){, function doDamage(){, ? The "on"s always throw me.
"on" is used when you use a trigger.

PHP Code:
npc.trigger("PlayerAttack"player.accountdmg); // calls "onPlayerAttack"
npc.playerAttack(player.accountdmg); // calls "playerAttack" 
The main benefits of using triggers are:
  • They don't interrupt your code (your code continues without waiting for the function to finish)
  • You can trigger any NPC for any function, and even if it doesn't exist, it won't give an error, unlike directly calling the function.
__________________
Reply With Quote
  #13  
Old 03-03-2009, 11:00 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by cbk1994 View Post
"on" is used when you use a trigger.

PHP Code:
npc.trigger("PlayerAttack"player.accountdmg); // calls "onPlayerAttack"
npc.playerAttack(player.accountdmg); // calls "playerAttack" 
The main benefits of using triggers are:
  • They don't interrupt your code (your code continues without waiting for the function to finish)
  • You can trigger any NPC for any function, and even if it doesn't exist, it won't give an error, unlike directly calling the function.
I, personally, would have liked a trigger to be used for this situation but unfortunately, it didn't work. I don't know if I did something wrong though. However, what I've done to work around the situation works almost as well
Reply With Quote
  #14  
Old 03-03-2009, 11:23 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Event function names are prefixed with "on" and trigger() is triggering an event, same with scheduleevent().

I also find "doDamage" a silly function name, "damage" works fine.
__________________
Reply With Quote
  #15  
Old 03-04-2009, 12:06 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Keep in mind that triggers are considerably slower than direct public function calls. However if you do not need quick response time, triggers/events are much more useful, especially because of the interface they provide with functions such as catchevent.
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:32 PM.


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