AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Questions about preThink and entity thinking (https://forums.alliedmods.net/showthread.php?t=17700)

KCE 09-07-2005 03:20

Questions about preThink and entity thinking
 
Is prethink called in the engine like normal think?

LynX 09-07-2005 07:37

No.

KCE 09-07-2005 17:40

Few more questions:

1. Are fakemeta hooks to FM_Think called in the engine also?

2. Would doing this make the entity think instantly?
Code:
entity_set_float( id , EV_FL_nextthink, halflife_time() )

And would it be faster than doing this:

Code:
entity_set_float( id , EV_FL_nextthink, halflife_time() + 0.0001 )

3. Is it okay to hook a think function to a player?
Code:
register_think( "player", "think_player" )

knekter 09-07-2005 19:11

for #3 use:
Code:
register_touch("*", "player", "player_touch"); public player_touch(ent, id) {   // ect. }

XxAvalanchexX 09-07-2005 22:57

1. Dunno

2. Dunno to the first part, but as to the second part I think 0.1 is the lowest you can make it, just like set_task

3. Yes, that's fine

knekter: start reading.

KCE 09-17-2005 14:48

Please
 
I reallly need to know the answer to these questions please. I know one of you devs know it :lol:

Basically I'm trying to detect an entity being created and replacing that entity with another one, when a player fires their weapon (its a grenade launcher). I want the fastest but most efficient method, so their's less delay when they're grenade is switched. I tried to check when entity's are spawned so I hooked FM_CreateEntity, which was able to catch the grenade being created but all the values I got with entity_get_int were 0 so I couldn't find out who fired it.

I'm deciding whether to use player think (not prethink), or prethink. I want to know which one is more efficient to use. Currently I'm using the player think since its called in engine so its less laggy then prethink. Though If I were to hook FM_PlayerPreThink, it would be like PrePlayerPreThink, since the hook is executed before the real thing, which could probably be the fastest check.
  • 1. Are fakemeta hooks to FM_Think and the engine forward pfn_think, called in the engine?

    2. Lynx, are you sure prethink is not called in the engine? Doesn't seem to make sense that the player think (not prethink) is called in engine but the prethink is not, unless the prethink method was made by amxmodx and its not an engine native like normal thinks are. Likewise for postthink also I guess.

    3. BTW, the FL_ALWAYSTHINK flag does not seem to work, I tried everything including setting other flags. I registered a think to the entity and it was never called. Maybe it can only use generic think like FM_Think or pfn_think? Does this have something to do with the ltime being set?

Correct me if I'm wrong.

XxAvalanchexX 09-17-2005 16:07

FL_ALWAYSTHINK is only for brush entities, so it's funny whenever people try to incorporate it into their plugins.
The only thing that uses it by default are trains.

Quote:

Originally Posted by const.h
#define FL_ALWAYSTHINK (1<<21) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path)

Try catching FM_SetModel to see when the grenade entity receives its model.

KCE 09-18-2005 00:32

Okay, FM_SetMode worked, now to see whether it's more efficient than the think method.


All times are GMT -4. The time now is 14:24.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.