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-09-2011, 08:46 AM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Npc Trigger

A while ago i posted a thread on How to set an "if" statement for a onPlayerTouchsMe and check the player gani to see if he is attacking.

Thread:
http://forums.graalonline.com/forums...t=blackbeltben

Thor told me i Should not do my collision like that so i changed it with the script he gave me but it doesnt seem to be working. I put it in a weapon added to the player.
I'm expecting it to trigger the action of "onWasDmg" of the baddie

PHP Code:
function onAttack()
{
  
temp.player.0.5 + (vecx(player.dir) * 2); 
  
temp.player.+ (vecy(player.dir) * 2); 
  
temp.tnpcs findareanpcs(temp.xtemp.y22); 
  for(
temp.temp.tnpcs){ 
    
temp.n.trigger("onWasDmg"player.clientr.power); 
  } 
Reply With Quote
  #2  
Old 09-09-2011, 12:07 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
I think you need to remove "on" from the trigger, otherwise it is invoking

ononWasDmg()
Reply With Quote
  #3  
Old 09-09-2011, 12:30 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
still not working
Reply With Quote
  #4  
Old 09-09-2011, 01:19 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 blackbeltben View Post
still not working
What have you done to try to make it work? Have you tried seeing what NPCs are being called with an echo?
__________________
Reply With Quote
  #5  
Old 09-09-2011, 01:42 PM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
Cbk, csn you explain that?
Reply With Quote
  #6  
Old 09-09-2011, 01:57 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Do the NPCs have a setshape or are they using showcharacter?
I believe they require such a shape in order to receive triggers.

If not you probably should include:

PHP Code:
this.setshape(13232); //32 pixels = 2 tiles in width and height 
You also need to make sure that the function is serverside/clientside according to where the area trigger was handled.
Reply With Quote
  #7  
Old 09-09-2011, 05:04 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
the shape was set.
and this line is under the weapon. which is CLIENTSIDE

PHP Code:
  temp.player.0.5 + (vecx(player.dir) * 2); 
  
temp.player.+ (vecy(player.dir) * 2); 
  
temp.tnpcs findareanpcs(temp.xtemp.y22); 
  for(
temp.temp.tnpcs){ 
    
temp.n.trigger("onWasDmg"player.clientr.dmg); 
  } 
And this is the baddie's which is SERVERSIDE

PHP Code:
function onWasDmg()
{
this.chat "hit"
Reply With Quote
  #8  
Old 09-09-2011, 05:45 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by blackbeltben View Post
the shape was set.
and this line is under the weapon. which is CLIENTSIDE

PHP Code:
  temp.player.0.5 + (vecx(player.dir) * 2); 
  
temp.player.+ (vecy(player.dir) * 2); 
  
temp.tnpcs findareanpcs(temp.xtemp.y22); 
  for(
temp.temp.tnpcs){ 
    
temp.n.trigger("onWasDmg"player.clientr.dmg); 
  } 
And this is the baddie's which is SERVERSIDE

PHP Code:
function onWasDmg()
{
this.chat "hit"
Here's the problem, trigger() does not communicate from Clientside to Serverside in the way that a triggeraction() does.

There are 3 different things you can do:

1. Move the onWasDmg() to Clientside, then specifically trigger to serverside within that NPC. This can be done by triggeraction() for a normal level NPC, otherwise for local NPCs (putnpc2) it's better to store npc.name as an attribute serverside, and use that name for triggerserver().

2. Pass the area trigger data to serverside within the weapon via triggerserver() and trigger area NPCs serverside.

3. As opposed to doing an area trigger, you can directly use triggeraction() within the weapon which can be received both Clientside and Serverside.

The 3 different methods have their advantages and disadvantages.

Method 1 will ensure the NPC receives damage if you see yourself hitting the baddy on your own client. However triggeraction can sometimes be unreliable, both for a moving target having different coordinates between clientside and serverside, and when it comes to there being multiple NPCs in the same position due to it triggering to one NPC on a single point. It would also be inefficient in the event of hitting several NPCs at once. I would only recommend this method if the baddies are local NPCs where you can then use triggerserver(); within the NPC itself.

Method 2 would be more efficient when it comes to hitting multiple NPCs in the same attack, and will avoid such issues as triggeraction() failing or having to make the baddies as local NPCs. The only downside is that with the area trigger occurring Serverside it may not be consistent with what you see on your own client. Players with a higher ping may have some difficulty with timing their hits on moving NPCs.

Method 3 is by far the easiest to implement but is also the most inefficient, not only would the trigger be sent to the server but also other nearby players if within a weapon script. Triggeraction() is a single-point trigger which means hits will be less sensitive than a box trigger. It would also have problem of not being able to damage multiple NPCs or triggering the wrong NPC if there are multiple on the coordinates.
Reply With Quote
  #9  
Old 09-09-2011, 09:49 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 ffcmike View Post
Do the NPCs have a setshape or are they using showcharacter?
I believe they require such a shape in order to receive triggers.

If not you probably should include:

PHP Code:
this.setshape(13232); //32 pixels = 2 tiles in width and height 
You also need to make sure that the function is serverside/clientside according to where the area trigger was handled.
Objects definitely don't need to have a shape to receive triggers via obj.trigger()
__________________
Reply With Quote
  #10  
Old 09-09-2011, 09:51 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by cbk1994 View Post
Objects definitely don't need to have a shape to receive triggers via obj.trigger()
This may well be the case now but I recall they did at some point, I think it was necessary for serverside NPCs.
Reply With Quote
  #11  
Old 09-09-2011, 09:53 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 ffcmike View Post
This may well be the case now but I recall they did at some point, I think it was necessary for serverside NPCs.
I highly doubt it. trigger doesn't use coordinates at all; you can trigger weapons, TStaticVars, players, or any other object.
__________________
Reply With Quote
  #12  
Old 09-09-2011, 09:55 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by cbk1994 View Post
I highly doubt it. trigger doesn't use coordinates at all; you can trigger weapons, TStaticVars, players, or any other object.
I'm referring to the ability to find an object via findareanpcs();.
Reply With Quote
  #13  
Old 09-10-2011, 01:02 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Alright, for the baddie, under //#CLIENTSIDE, it reconizes the attack. but it does not perform the trigger on the CLIENTSIDE function to properly decrease the baddie's HP
Reply With Quote
  #14  
Old 09-10-2011, 04:03 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by blackbeltben View Post
Alright, for the baddie, under //#CLIENTSIDE, it reconizes the attack. but it does not perform the trigger on the CLIENTSIDE function to properly decrease the baddie's HP
What are you doing to communicate serverside?
Reply With Quote
  #15  
Old 09-10-2011, 04:08 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Im using when it triggers serverside from the attack, i tried to use SetTimer(), scheduleEvent(), Trigger, all that stuff. I dont know what the proplem is. What would you use?
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 02:45 PM.


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