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.obj: findAreaPlayers(player.x + clientr.hbox[player.dir][0], player.y + clientr.hbox[player.dir][1], clientr.hbox[player.dir][2], clientr.hbox[player.dir][3], player.account)) {
temp.objlist.add(temp.obj);
}
for (temp.obj: findAreaNpcs(player.x + clientr.hbox[player.dir][0], player.y + 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.obj: params[1]) {
temp.obj.chat="hit";
temp.obj.hurt(clientr.sweapon.damage, player.account, player.dir , clientr.sweapon.typus, clientr.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...".