![]() |
Baddie Script Review
1 Attachment(s)
I have attached my server's baddie script, and as discussed in the playerworld forums, I had questions about IOS scripts involving baddies.
I want to know how well/poor, organized, etc. this is coded in the goal of putting it in a mobile server. Original Question Post: http://forums.graalonline.com/forums...hp?t=134268621 What needs to be changed? Or does it totally need to be re-done. I am not an expert GS2 coder as I switched from GML (Gamemaker language) Constructive criticism would be nice :) |
The whole thing seems to be a mess of different scheduled events. You should clean that up a lot. Also, the minimum timeout/scheduleEvent time on serverside is 0.1, not 0.05. You seem to be scheduling events even in areas where you don't need to wait (e.g. when adding experience, why not just call the function instead of scheduling it for 0.1 seconds in the future?)
I don't understand why you need a timeout checking if the baddy is dead every 0.1 seconds. Just check if it's dead when it gets attacked and handle it then. There are also a lot of random errors like in onAttack where you loop through the players (with temp.p) but then use the player variable, which is going to either be unset or set to an arbitrary player. I also noticed some typos like this.aggressive / this.agressive. I didn't look very closely but there are a lot of big problems. |
Quote:
I understand.. Now that I look it over it is pretty unacceptable. |
also try to get familiar with the move() function, will help you a lot
|
Quote:
|
Quote:
TServerNPC.move(float, float, float, int) - moves the npc smoothly, parameters are delta x, delta y, time and options: cache type (0, 1-cache, 2-append) + blockcheck(4) + eventwhendone(8) + applydir(16) example: PHP Code:
Ps: This move example replaced something like this which does lag more on the server PHP Code:
|
On an unrelated note you may want to create some getter and setter functions instead of doing things such as
PHP Code:
join the player to a class called player_functions or whatever you want to call it doing player.join("player_functions"); Then within that class do something similar to the following PHP Code:
PHP Code:
PHP Code:
|
Quote:
|
whoops and fixed
|
To answer your question, it has to be completely redone. The code is terrible, and your abusing schduleevent as if it was a timeout :/. I might release delterias Baddie system on the forums soon. You could probably at least learn from it.
PHP Code:
|
Quote:
I really am trying. Fact of the matter is I am not a good programmer haha. But I appreciate all the tips. Perhaps I just need to re-learn GS2 from scratch, and broadin my knowledge of different functions. |
Quote:
|
For the baddie being hit, could I just use the default onwas.Hit() function as long as the player's ani is something_sword. Or trigger in manually?
Also, does the default onwas.Hit() work when a player hits a player? |
| All times are GMT +2. The time now is 05:51 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.