Automaton or native to disable forward & OT discussion about detecting ground touch
Hello, I came across an interesting question that I'm having a hard time trying to answer. Which of the following snippets contains more efficient code? Is there a better way to enable / disable the hook?
Code:
Code:
Code:
|
Re: Automaton or fakemeta?
Automaton will always be more or equally efficient. If you have a good reason to use it (such as yours), do it.
|
Re: Automaton or fakemeta?
It could depend on what you want to do.
Also, pay attention to if(!forward_PreThink & something), should be && ;) |
Re: Automaton or fakemeta?
Thank you for your answers. :) You're right about the &&, I don't know what happend there. :D
Anyway, in which case is fakemeta way more efficient than the first one? I would like to know whether changing state and calling empty client_PreThink(id) <> {} has any negative impact on performance. |
Re: Automaton or fakemeta?
I'm not familiar with automatons, just feel better to disable such a forward when you don't need, would use Ham_Player_PreThink.
About pure theory, i don't know if someone can answer you. Can see http://forums.alliedmods.net/showthread.php?p=958497. Anyway, what are you hooking PreThink for ? |
Re: Automaton or fakemeta?
I'm mostly interested in automatons as I don't know much about them and I'd like to learn new stuff, so this was a general example but hey, I've found use for this in one of my plugins. I'm blocking any damage dealt to player before they touch ground after spawn (for example maps where players spawn in air and fall down to start with less than 100hp but I don't want to block damage after then).
|
Re: Automaton or fakemeta?
There are often alternative to PreThink hook.
In the example you gave it is not even an alternative, because PreThink shouldn't be hooked for that. All you have to do is to hook Ham_TakeDamage and to check if last bit param contains bit DMG_FALL. So before to worry about what it the best between automaton with prethink and disabling prethink forward, you should first ask yourself if there could be better ways to achieve what you want to do. You can also ask on forum when you have such a question and you don't find an answer by yourself ;) |
Re: Automaton or fakemeta?
I'm sorry but I don't really see the way how do it your way. If hooked Ham_TakeDamage and the player had fallen from just a few units after spawn Ham_TakeDamage would not be called and if they had fallen from some high place afterwards the damage would be blocked then which in many cases could mess things up. Say I have three maps: first one with spawnpoints high up in the air, second one with trigger_hurt or whatever is it called with spawnpoints nearly on the ground and third one with none of these. I would like do enable damage right after the player touches ground in every of these maps. I don't want to customize my plugin for each map I add to my server.
Edit: I don't mean to be offensive, I'm sorry if it looks like that, my English is terrible. |
Re: Automaton or fakemeta?
Hook Ham_TakeDamage at new round and disable it at start round.
|
Re: Automaton or fakemeta?
I would need to adjust mp_freezetime for each map to fit the time before players reach the ground which is something I am not looking for because I have team of admins that change the maplist quite often but are not allowed to change server CVars. I could even use a set_task for that, I've already considered these options but it's unbearably time-consuming to maintain the individual settings for each map…
Edit: I've added Ham version to the first post. I'm interested in the answer to the detecting player touch ground "event", but also in the pure theory, but I'm not sure whether joaquimandrade reads Scripting Help. :D Edit2: Following are not solutions to my problem:
|
| All times are GMT -4. The time now is 10:45. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.