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 04-02-2010, 07:22 AM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Question involving custom damage scripts.

Okay, so I have a weapon that uses triggeraction and whatnot clientside, but in my class, where it calculates the damage to be taken, its only using the variables of the person hit. What kind of function or w/e would I use to find the variable of another player? findplayer? and how would i go about telling it what player to find?
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #2  
Old 04-02-2010, 07:38 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
findplayer(str) - returns object
findplayerbycommunityname(str) - returns object
findplayerbyid(int) - returns object
You'd need to use testplayer(x, y) or something similar to see which player you want to get. testplayer() returns an integer so you'd need to use findplayerbyid() if you want to use it.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #3  
Old 04-02-2010, 03:46 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Send the attacker as a parameter with the triggeraction?
Reply With Quote
  #4  
Old 04-02-2010, 04:22 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by DrakilorP2P View Post
Send the attacker as a parameter with the triggeraction?
Ideal way to do it, testplayer is a jerk and doesn't play nice around NPC decorations.

In your melee weapon system:

triggeraction(x, y, "damage", damageAmount, player.account);

Then in your damage system that catches the damage triggers:

PHP Code:
//#CLIENTSIDE

function onActionDamage(damageattacker) {
  
// Find attacker
  
temp.obj findplayer(attacker);
  
// Check if in same guild (Example)
  
if (temp.obj.guild == player.guild && player.guild.length() > 0) return;
  
// Other damage system code

It's important to note that you won't be able to access other player's client/clientr variables on the clientside, so you'll have to process those checks on the serverside.
__________________
Quote:
Reply With Quote
  #5  
Old 04-02-2010, 08:40 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
Usually it's best to just send the account of the attacker and the weapon they're using if you're using a clientside melee system since they can change the damage to whatever they want. For example,

PHP Code:
function onActionServerSide(cmdaccountweapon) {
  if (
cmd == "attack") {
    
temp.pl findPlayer(account);
    if (
pl == null) {
      return; 
// attacker is offline
    
}
    if (! 
pl.hasWeapon(weapon)) { // replace this to match your server's item/weapon structure
      
return; // they don't have the weapon
    
}
    
    
temp.damage DB_Damage.getDamage(weapon);
    
player.hit(damage);
  }
}

//#CLIENTSIDE
function onActionPlayerHit(accountweapon) {
  
triggerServer("gui"this.name"attack"accountweapon);

__________________
Reply With Quote
  #6  
Old 06-03-2010, 01:11 AM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
urg. i tried this today. i cant even get it to to hit the player that has it.
What am i doing wrong in this?

PHP Code:
//#CLIENTSIDE
function onCreated(){
  
setTimer(0.05);
}

function 
onTimeout(){
  
triggeraction(player.xplayer.y"Test");
  
setTimer(0.05);
}

function 
onActionTest(){
  
player.chat "It works!";

__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #7  
Old 06-03-2010, 01:18 AM
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 Jiroxys7 View Post
urg. i tried this today. i cant even get it to to hit the player that has it.
What am i doing wrong in this?

PHP Code:
//#CLIENTSIDE
function onCreated(){
  
setTimer(0.05);
}

function 
onTimeout(){
  
triggeraction(player.xplayer.y"Test");
  
setTimer(0.05);
}

function 
onActionTest(){
  
player.chat "It works!";

The Triggeraction function requires an extra Parameter even if you do not intend one to be sent (so just use "" or NULL), this is also intended to be something received by other players on the given coordinate, not sure if it can be picked up by yourself.

Also probably not the best idea to be doing this on a constant timeout beyond testing.
Reply With Quote
  #8  
Old 06-03-2010, 01:25 AM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Yeah the timeout is purely for testing. I'll try your suggestion.
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #9  
Old 06-03-2010, 02:51 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Also, I don't think it'll work at the players x,y because that location doesn't actually touch a player. Try x+1.5, y+1.5
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #10  
Old 06-03-2010, 03:24 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
I don't know what exactly you're trying to do but I think this might be it
PHP Code:
function onActionServerside(hitx,hity){
  for (
temp.plfindNearestPlayers(hitx,hity)){
    
temp.playercenter = {temp.pl.1.5temp.pl.2};
      if (
hitx in |temp.playercenter[0]-1.5temp.playercenter[0]+1.5|){
       if (
hity in |temp.playercenter[1]-1.5temp.playercenter[1]+1.5){
        
//do damage
      
}
    }
  }

Also, I'm assuming if he is doing something that would cause damage that the player would be either in the 8 surrounding levels so findNearestPlayers would be best in my opinion rather than findplayer as everyone else was saying. If I'm wrong then correct me but that's what I have always just assumed.
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 04:43 PM.


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