![]() |
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:
On the clientside, if the sword key is pressed, I display the gani and use the findThings() function: PHP Code:
PHP Code:
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...". |
What is your latency?
Half a second seems about normal for serverside hit detection. Doing the clientside check first doesn't seem like it would actually make it any faster, just more resource efficient for the server, I guess. |
You can't pass clientside objects to the server like this, what we do on Classic is a similar area NPCs trigger but on both clientside and serverside, this also creates the illusion of no lag.
|
Quote:
I guess making it more resource efficient for the server would be a good idea, too. In the thread I mentioned in the first post, someone said something about the script lagging the server. Quote:
If I used two checks like you described, I would need to hurt funcitons, one for Clientside and one for Serverside, right? And the bushes' hurt function would need to be clientside? There would still be some lag though as the bushes need to be hidden for everyone if they are slashed, which would need a trigger to the Serverside. Man, this is really confusing. >_< What about xXziroXx's quote? There surely must be some way to check for the objects clientside and then pass them to the serverside. |
It's much better to use the trigger function for this type of thing as opposed to public functions:
obj.trigger("Hit", param1); As this would automatically be making the check as to whether the function "onHit" actually exists. But yes you would need to do this both clientside (to make it appear instant to yourself), and serverside (for it to show to other players), for everyone else though this would be synced with your player, it's not a problem. What I meant regarding the clientside objects is simply that the object on your client is not the same as the object on the server, for this type of thing to work you'd have to try something such as passing the name of the npc (if it was a local npc) or the coordinates of the npc to use with testnpcs(x, y);, which isn't really reliable. |
Your latency is pretty high; you're in Germany and the servers are in Texas.
Here's how I would do it: PHP Code:
|
Thanks a lot you two! Very helpful.
I'll try doing it that way tomorrow. |
| All times are GMT +2. The time now is 10:39 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.