Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-21-2011, 12:46 PM
AlexanderK AlexanderK is offline
Registered User
AlexanderK's Avatar
Join Date: Mar 2006
Location: Germany
Posts: 79
AlexanderK is on a distinguished road
Send a message via MSN to AlexanderK
Iteration on an array of objects

Up to now, I have been using a hitbox-based sword system, like explained in this thread by adam: http://forums.graalonline.com/forums...hp?t=134258416.
It was way too slow though, my bush classes didn't really react to being cut quickly enough, so I thought I'd try out what xXziroXx said.
Quote:
We've been using a system like this on Maloria for quite a while. We first do the box detection clientside, and if there's any eligble target(s), proceed to serverside where it will just make sure that said target(s) are still within the box and take action accordingly.
So that's what I'm trying to do now.

On the clientside, if the sword key is pressed, I display the gani and use the findThings() function:
PHP Code:
function findThings() {
  
temp.objlist = {};
  for (
temp.objfindAreaPlayers(player.clientr.hbox[player.dir][0], player.clientr.hbox[player.dir][1], clientr.hbox[player.dir][2], clientr.hbox[player.dir][3], player.account)) {
    
temp.objlist.add(temp.obj);
  }
  for (
temp.objfindAreaNpcs(player.clientr.hbox[player.dir][0], player.clientr.hbox[player.dir][1], clientr.hbox[player.dir][2], clientr.hbox[player.dir][3])) {
    
temp.objlist.add(temp.obj);
  }
  if (@
temp.objlist != null)
    
triggerServer("gui"this.name"hitthings"temp.objlist);

And this is what my ActionServerSide looks like:
PHP Code:
function onActionServerside() {
  if (
params[0] == "hitthings") {
    
player.chat "hit:"params[1];
    for (
temp.objparams[1]) {
      
temp.obj.chat="hit";
      
temp.obj.hurt(clientr.sweapon.damageplayer.accountplayer.dir clientr.sweapon.typusclientr.sweapon.typus2);
    }
  }

That doesn't work... Neither does the NPC chat anything, nor does the hurt functon hurt the NPC, like it did when I did everything serverside.
Also, when there are NPCs to be hit, the player chats something like " hit:"","", "

My guess is that I cant iterate over the array with for like that and expect the elements to be objects.

How can I fix this?

I also wouldn't mind some hints on how to get my sword system faster. Right now it seems like it takes the player about half a second to chat "hit...".
Reply With Quote
 


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 08:25 AM.


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