Raised This Month: $12 Target: $400
 3% 

Optimization - Global variables vs natives


Post New Thread Reply   
 
Thread Tools Display Modes
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-12-2017 , 15:27   Re: Optimization - Global variables vs natives
Reply With Quote #11

Thanks you everyone!

Well currently I'm stuck with OnGameFrame(). I'm playing with custom entities and I would prefer to hook and use CPropDynamic::Think() but it looks like this function isn't called even if I set m_nNextThinkTick.
__________________
micapat is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-14-2017 , 17:19   Re: Optimization - Global variables vs natives
Reply With Quote #12

...did you try SDKHooks on those entities ?
__________________
Do not Private Message @me
Bacardi is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-15-2017 , 16:01   Re: Optimization - Global variables vs natives
Reply With Quote #13

Quote:
Originally Posted by Bacardi View Post
...did you try SDKHooks on those entities ?
Of course, and it doesn't work.
Attached Files
File Type: sp Get Plugin or Get Source (test_think.sp - 74 views - 1.7 KB)
__________________
micapat is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-15-2017 , 16:21   Re: Optimization - Global variables vs natives
Reply With Quote #14

there are many
PHP Code:
SDKHook_PreThinkPost    
SDKHook_PostThinkPost    
SDKHook_ThinkPost

SDKHook_PreThink    
SDKHook_Think
SDKHook_PostThink 
perhaps one hook type is not enough
set multiple type of hooks to same entity

*edit
You have Prop_Send, not Prop_Data
Code:
       
        SDKHook(gl_entity, SDKHook_Think, OnEntityThink);
        SetEntProp(gl_entity, Prop_Data, "m_nNextThinkTick", 10);
    }
    
    PrintToChatAll("CreateEntity (%d)", gl_entity);
    return Plugin_Handled;
}

public void OnEntityThink(int iEntity)
{
    SetEntProp(iEntity, Prop_Send, "m_nNextThinkTick", 10);
    
    PrintToChatAll("ThinkEntity (%d) (%f)", iEntity, GetGameTime());
}
__________________
Do not Private Message @me

Last edited by Bacardi; 09-15-2017 at 16:31.
Bacardi is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-15-2017 , 16:31   Re: Optimization - Global variables vs natives
Reply With Quote #15

If I'm not mistaken, PreThink / PostThink are for players.

Think / ThinkPost doesn't work.
__________________
micapat is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-15-2017 , 16:40   Re: Optimization - Global variables vs natives
Reply With Quote #16

yea, tested, can't use other hook types...
__________________
Do not Private Message @me
Bacardi is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-15-2017 , 16:46   Re: Optimization - Global variables vs natives
Reply With Quote #17

Yeah it's Prop_Data for m_nNextThinkTick.

I'm looking https://github.com/ValveSoftware/sou...hared.cpp#L733 to understand how Think() works.

It looks like I need to call CBaseEntity::RegisterThinkContext() then CBaseEntity::ThinkSet(), certainly with an extension..

It's weird that the default Think() isn't registered.
__________________
micapat is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-15-2017 , 17:03   Re: Optimization - Global variables vs natives
Reply With Quote #18

Prop_dynamic_override not do much, it can play model animations tough. Maybe that's why it not have any "think" progress.

What would you say about repeated timer ?
Spoiler


*edit
maybe you need use another entity type.
__________________
Do not Private Message @me

Last edited by Bacardi; 09-15-2017 at 17:05.
Bacardi is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-15-2017 , 18:08   Re: Optimization - Global variables vs natives
Reply With Quote #19

Well I'm looking for an entity which can:
- Be killed (TakeDamage / TraceAttack...).
- Animate.
- Be touched (StartTouch / Touch...).
- Think.

My goal is to create npc or similar stuff. The timers are not enough small (Min: 0.1s), and OnGameFrame is a little too much.

Currently prop_dynamic_override answers 3/4, I just need to make Think() works.
__________________
micapat is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-15-2017 , 18:37   Re: Optimization - Global variables vs natives
Reply With Quote #20

SetParent second entity to prop_dynamic_override...
__________________
Do not Private Message @me

Last edited by Bacardi; 09-15-2017 at 18:39.
Bacardi is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:52.


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