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 05-25-2011, 12:55 AM
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
You might also want to move some of that code to functions. I.e:

PHP Code:
function sendTrigger(pl) {
  
triggeraction(pl.x+0.5pl.y+0.5"Damage"this.effectsplayer.account, {temp.damagetemp.criton}, temp.accuracy"Physical"100temp.armorpiercetemp.attackerlevelaxayazad); 
  if (
client.showhits){ 
    
triggerserver("gui"this.name"putnpc""testblock",pl.x+0.5pl.y+0.5); 
  }

Other functions may include:

PHP Code:
function inHittingRange(plmaxdist) {
  if (
pl == player) {
    return 
false;
  }
  if (
dist(player.1player.1.5pl.1pl.1.5) <= maxdist) {
    if (
player.dir == 0) {
      if (
pl.player.0.5) {
        return 
true;
      }
    }
    else if (
player.dir == 1) {
      if (
pl.player.0.5) {
        return 
true;
      }
    }
    else if (
player.dir == 2) {
      if (
pl.player.0.5) {
        return 
true;
      }
    }
    else if (
player.dir == 3) {
      if (
pl.player.0.5) {
        return 
true;
      }
    }
    return 
false;
  } else {
    return 
false;
  }
}

function 
inParty(pl) {
  return (
pl.account in clientr.party);

Also I would store the tokens in it's own variable, for clarity reasons and it's slightly more efficient.

Your code can then be re-factored to:

PHP Code:
temp.weapondata wdata[5].tokenize(",");
temp.weapontype temp.weapondata[1];
temp.weapondist temp.weapondata[2];
if (
temp.weapontype == "arc") {
  for (
temp.plfindNearestPlayers(player.xplayer.y)) {
    if (!
inParty(temp.pl)) {
      if (
inHittingRange(temp.pltemp.weapondist)) {
        
sendTrigger(temp.pl);
      }
    }
  }

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 05:30 PM.


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