Raised This Month: $ Target: $400
 0% 

another system than looping task as thinking ent(s)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 05-16-2011 , 20:03   another system than looping task as thinking ent(s)
Reply With Quote #1

Not really sure what this means but the idea is

im using set_task with "b" flag to create a bleeding function in my plugin.

Conor told me
"Consider another system than looping task as thinking ent(s)"

I have no idea what he means but i have tried while loops. but that just happens really fast lol.. i need to be able to put a delay in set via cvar.

thats why i used

PHP Code:
set_task(get_pcvar_float(delay), "Function""id"__"b"); 
and if settask is all i can use then how can i copy "Floatirection" , to a global variable to put in

ExecuteHamB(Ham_TraceBleed, id, dmg, Floatirection, trace, dmgbits);
Doc-Holiday is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-16-2011 , 20:22   Re: another system than looping task as thinking ent(s)
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=43049
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 05-16-2011 , 20:52   Re: another system than looping task as thinking ent(s)
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
I always forget about the tut section THANKS!
Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-17-2011 , 02:01   Re: another system than looping task as thinking ent(s)
Reply With Quote #4

In a private plugin i've never finished so i've never released, i'm using 1 entity per player (so players don't beel at the same time as in gore plugin and next bleed time is randomized) :

But you could manage with only 1 thinking entity ;)

PHP Code:
UTIL_CreateFollowingEnt(id)
{
    static 
iEntHamHook:Think
    iEnt 
engfunc(EngFunc_CreateNamedEntityg_iInfoTarget)

    if(
pev_valid(iEnt))
    {
        
set_pev(iEntpev_aimentid)
        
set_pev(iEntpev_movetypeMOVETYPE_FOLLOW)

        
set_pev(iEntpev_ownerid)

        
set_pev(iEntpev_nextthinkget_gametime() + random_float(1.04.0))

        
g_iBleeding[id] = iEnt

        set_pev
(iEntpev_iuser1BLEED_ENT)

        if( !
Think )
        {
            
Think RegisterHamFromEntity(Ham_ThinkiEnt"Think_Bleed")
        }
    }
}

public 
Think_Bleed(iEnt)
{
    if( 
pev(iEntpev_iuser1) == BLEED_ENT && UTIL_Bleed(iEnt) )
    {
        
set_pev(iEntpev_nextthinkget_gametime() + random_float(2.06.0))
    }
}

RemoveBleed(id)
{
    new 
iBleed g_iBleeding[id]
    if( 
pev_validiBleed ) )
    {
        
set_pev(iBleedpev_flagsFL_KILLME)
        
g_iBleeding[id] = 0
    
}
}

UTIL_Bleed(iEnt)
{
    new 
id pev(iEntpev_owner)

    if( !
IsAlive[id] )
    {
        if(
g_iBleeding[id]) // o_O
        
{
            
set_pev(g_iBleeding[id], pev_flagsFL_KILLME)
            
g_iBleeding[id] = 0
        
}
        return 
0
    
}

    new 
trace_handled
    
new Float:flFractionFloat:fDirection[3]
    new 
Float:start[3], Float:dest[3]

    
trace_handled create_tr2()
    
pev(idpev_originstart)

    
dest[0] = start[0]
    
dest[1] = start[1]
    
dest[2] = start[2] - 9999.0
                
    engfunc
(EngFunc_TraceLinestartdestIGNORE_MONSTERSidtrace_handled)
    
get_tr2(trace_handledTR_flFractionflFraction)
    if( 
flFraction != 1.0 )
    {
        
fDirection[0] = random_float(-1.01.0)
        
fDirection[1] = random_float(-1.01.0)
        
fDirection[2] = random_float(-1.00.0)
        
ExecuteHam(Ham_TraceBleedid50.0fDirectiontrace_handledDMG_BULLET)
        
UTIL_BloodStream(startfDirection7050 get_user_health(id))
    }
    
free_tr2(trace_handled)
    return 
1

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 05-17-2011 at 02:03.
ConnorMcLeod is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 05-17-2011 , 05:27   Re: another system than looping task as thinking ent(s)
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
In a private plugin i've never finished so i've never released, i'm using 1 entity per player (so players don't beel at the same time as in gore plugin and next bleed time is randomized) :

But you could manage with only 1 thinking entity ;)

PHP Code:
UTIL_CreateFollowingEnt(id)
{
    static 
iEntHamHook:Think
    iEnt 
engfunc(EngFunc_CreateNamedEntityg_iInfoTarget)

    if(
pev_valid(iEnt))
    {
        
set_pev(iEntpev_aimentid)
        
set_pev(iEntpev_movetypeMOVETYPE_FOLLOW)

        
set_pev(iEntpev_ownerid)

        
set_pev(iEntpev_nextthinkget_gametime() + random_float(1.04.0))

        
g_iBleeding[id] = iEnt

        set_pev
(iEntpev_iuser1BLEED_ENT)

        if( !
Think )
        {
            
Think RegisterHamFromEntity(Ham_ThinkiEnt"Think_Bleed")
        }
    }
}

public 
Think_Bleed(iEnt)
{
    if( 
pev(iEntpev_iuser1) == BLEED_ENT && UTIL_Bleed(iEnt) )
    {
        
set_pev(iEntpev_nextthinkget_gametime() + random_float(2.06.0))
    }
}

RemoveBleed(id)
{
    new 
iBleed g_iBleeding[id]
    if( 
pev_validiBleed ) )
    {
        
set_pev(iBleedpev_flagsFL_KILLME)
        
g_iBleeding[id] = 0
    
}
}

UTIL_Bleed(iEnt)
{
    new 
id pev(iEntpev_owner)

    if( !
IsAlive[id] )
    {
        if(
g_iBleeding[id]) // o_O
        
{
            
set_pev(g_iBleeding[id], pev_flagsFL_KILLME)
            
g_iBleeding[id] = 0
        
}
        return 
0
    
}

    new 
trace_handled
    
new Float:flFractionFloat:fDirection[3]
    new 
Float:start[3], Float:dest[3]

    
trace_handled create_tr2()
    
pev(idpev_originstart)

    
dest[0] = start[0]
    
dest[1] = start[1]
    
dest[2] = start[2] - 9999.0
                
    engfunc
(EngFunc_TraceLinestartdestIGNORE_MONSTERSidtrace_handled)
    
get_tr2(trace_handledTR_flFractionflFraction)
    if( 
flFraction != 1.0 )
    {
        
fDirection[0] = random_float(-1.01.0)
        
fDirection[1] = random_float(-1.01.0)
        
fDirection[2] = random_float(-1.00.0)
        
ExecuteHam(Ham_TraceBleedid50.0fDirectiontrace_handledDMG_BULLET)
        
UTIL_BloodStream(startfDirection7050 get_user_health(id))
    }
    
free_tr2(trace_handled)
    return 
1


lol i wish there was more documentation on this type stuff Hawks Tut kinda just tells you how to do it and why its better but no matter what i do i cant figure out how to do it...

Not to many examples out there.
Doc-Holiday is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 05-17-2011 , 06:47   Re: another system than looping task as thinking ent(s)
Reply With Quote #6

RegisterHamFromEntity(Ham_Think, iEnt, "Think_Bleed")
so this would register all Thinks from info_target entities and call Think_Bleed() on each of it thinking?
btw, does
RegisterHamFromEntity() also not accept any non-standard entity classnames like RegisterHam()?

PHP Code:
set_pev(iEntpev_iuser1BLEED_ENT)
if( 
pev(iEntpev_iuser1) == BLEED_ENT
in which case Entity would change it's id so you need to make checks like above but not just if(EntID == MyEntID)?
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.

Last edited by Owyn; 05-17-2011 at 07:09.
Owyn is offline
Send a message via ICQ to Owyn
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-17-2011 , 20:10   Re: another system than looping task as thinking ent(s)
Reply With Quote #7

Quote:
Originally Posted by Doc-Holiday View Post
Hawks Tut kinda just tells you how to do it and why its better
Well, that sounds like a great tutorial to me, one that tells you how to do it and justifies using it.
__________________
fysiks is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 05-18-2011 , 01:25   Re: another system than looping task as thinking ent(s)
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
Well, that sounds like a great tutorial to me, one that tells you how to do it and justifies using it.
i agree lol.. but its just not alot of examples out there and I'm not very good with scripting so i have to read up on plenty of things before i actually understand it lol...


ive been playing with it but haven't figured it out yet it takes time.... i only code like once a month lol... work/school takes to much time
Doc-Holiday is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 05-18-2011 , 02:03   Re: another system than looping task as thinking ent(s)
Reply With Quote #9

What haven't you figure out ?

A basic global entity think:
Code:
#include <amxmodx>
#include <engine>

public plugin_init()
{
    new ent = create_entity("info_target") /* creates "info_target", the most commonly used entity classname for custom entity creation */

    if(ent) /* if entity was succesfully created */
    {
        entity_set_string(ent, EV_SZ_classname, "globalThink") /* this changes entity's classname from info_target to globalThink wich is an invented entity */

        entity_set_float(ent, EV_FL_nextthink, get_gametime()) /* this sets when the entity's next think call occurs, and get_gametime() means NOW */

        register_think("globalThink", "ent_think") /* hook entity's thinking process and call ent_think() when that occurs */
    }
}

public ent_think(ent) /* ent is the entity's id that called the function, there can be more than one entity for one classname, that's why I invented a new classname, so only one triggers */
{
    server_print("[debug] globalThink :: gametime=%f", get_gametime()) /* just to see it works, prints gametime to server when this triggers */

    entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.05) /* Set when the entity's next think call occurs, that is in 0.05 seconds */
}
There you go, a commented simple example :}

The rest of Connor's code is just to make bleeding work efficiently, so just use that and figure it out when you have time to learn.
__________________
Hunter-Digital is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 05-18-2011 , 15:53   Re: another system than looping task as thinking ent(s)
Reply With Quote #10

@Hunter

It takes time bro... lol the only time i even try to create plugins is when i need something for my servers that isnt already out there. So i dont play with it often. other then that the only code i play with is Small basic and i do that with my 8 and 10 year old lil bros.

I start school again on July 4th which will finally get me going into programing classes. fucking general ed blows!!!!!. So i should be able to start playing with code more and actually understanding it lol.. i know very lil enough to get me by with pawn. but the classes I'm taking are mainly C++ and what not my major is Computer Forensics.

But thanks.. i just haven't had time to really get into this.
Doc-Holiday is offline
Reply



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 04:29.


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