AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [TF2] Simple Ghost (https://forums.alliedmods.net/showthread.php?t=239983)

Pelipoika 05-06-2014 15:47

[TF2] Simple Ghost
 
1 Attachment(s)



What is it?
It's an unused entity called simple_bot that i made to mimic the TF2 ghost as best as i could


Can i configure it in any way?
Of cource you can! BUT BE NOTED THE GHOST WILL NOT MOVE IF YOUR MAP DOESN'T HAVE A .NAV MESH!

Commands:

sm_simpleghost : Spawns a simple_ghost on top of you [Default acces: ROOT]
sm_killghost : Kills all the simple_ghosts on the map [Default acces: ROOT]

Cvars:
sm_ghost_minvistime (default: 5.0) Minimum duration to stay visible
sm_ghost_maxvistime (default: 10.0) Maximum duration to stay visible

sm_ghost_mininvistime (default: 60.0) Minimum duration to stay invisible
sm_ghost_maxinvistime (default: 120.0) Maximum duration to stay invisible

sm_ghost_stunduration (default: 5.0) Duration of the 'BOO!' condition on client
sm_ghost_checkdelay (default: 0.1) How often to check for nearby clients to Spook
sm_ghost_checkdistance (default: 240.0) How far away to stun clients

Changelog:
1.0 Initial Release
1.1 Fixed unescessary looping
1.2 Fixed removing other simple_bots than the ones that were spawned by this plugin
1.3 Sentries should no longer target the ghost

Credits to Leonardo for some of the code i use in this plugin :3

Mitchell 05-06-2014 15:56

Re: [TF2] Simple Ghost
 
Command_KillBot would kill any simple_bots in the map. Could cause issues.

Also the ghost think is quite redundant.
You have a think for each ghost, but within that think instead of finding every one around the 1 ghost and scare the players it find everyone around all of the simple_bots and scares them.

so if there was 5 active ghosts (visible) and 32 active players all alive and playing it would do:
FindByClassname 5 time per think
and would check the distance away from a ghost and a player 5*32 times, that's alot of unneeded math.

If my math is right anyways..

Pelipoika 05-06-2014 16:03

Re: [TF2] Simple Ghost
 
Quote:

Originally Posted by Mitchell (Post 2134587)
Command_KillBot would kill any simple_bots in the map. Could cause issues.

Also the ghost think is quite redundant.
You have a think for each ghost, but within that think instead of finding every one around the 1 ghost and scare the players it find everyone around all of the simple_bots and scares them.

so if there was 5 active ghosts (visible) and 32 active players all alive and playing it would do:
FindByClassname 5 time per think
and would check the distance away from a ghost and a player 5*32 times, that's alot of unneeded math.

If my math is right anyways..

Fixed the too many loops thing.
Not so sure about how to fix not removing other simple_bot's

Mitchell 05-06-2014 16:45

Re: [TF2] Simple Ghost
 
Quote:

Originally Posted by Pelipoika (Post 2134592)
Fixed the too many loops thing.
Not so sure about how to fix not removing other simple_bot's

You could use ADT Arrays,

I THINK THIS WOULD WORK:
or another simple, but still cost the same amount of processing time just change the class name after the entity is created:
PHP Code:

        new Ghost CreateEntityByName("simple_bot"); 
        if(
Ghost || Ghost 2048
        {
            
DispatchKeyValue(Ghost"classname""ghost_ent");
            
DispatchSpawn(Ghost); 
            
SetEntProp(GhostProp_Data"m_takedamage"01);
            
SetEntProp(GhostProp_Send"m_CollisionGroup"2);
            
TeleportEntity(GhostposNULL_VECTORNULL_VECTOR); 
            
AttachParticle(Ghost"ghost_appearation"_5.0);
            
SetEntityModel(Ghost"models/props_halloween/ghost.mdl");
            
g_bInvisible[Ghost] = false;
            
CreateTimer(GetRandomFloat(g_flCvarMinVisibleg_flCvarMaxVisible), Timer_ToggleInvisEntIndexToEntRef(Ghost));
            
SDKHook(GhostSDKHook_TouchGhostThink); 
        } 

and change all the FindByClassname functions to search for "ghost_ent"

ADT Example would be:
PHP Code:

new Handle:hGhosts;
//To Create:
//USE ON PLUGIN START:
hGhosts CreateArray();

//Delete Index:
new entity EntRefToEntIndex(GetArrayCell(hGhostsINDEX_HERE));
if(
IsValidEntity(entity))
{
    
AcceptEntityInput(entity"Kill");
}

//Delete All: (Since all entities are deleted when the round restarts just clear the array)
    
new entity = -1;
    for(new 
0GetArraySize(hGhosts); i++)
    {
        
entity EntRefToEntIndex(GetArrayCell(hGhostsi));
        if(
IsValidEntity(entity))
        {
            
AcceptEntityInput(entity"Kill");
        }
    }
    
ClearArray(hGhosts);

//Find an entity in the array: (probably wont use it.)
FindValueInArray(hGhosts,  EntIndexToEntRef(Entity));

//Clear Array:
ClearArray(hGhosts);

//To add (push) to the ADT:
PushArrayCell(hGhostsEntIndexToEntRef(Ghost)); 

i may or may not have screwed up on something within that. You dont need to convert the entity back into a reference if you dont want to.

SoulSharD 07-07-2014 17:55

Re: [TF2] Simple Ghost
 
Hmm, the sentries appear to be able to attack the ghosts, both RED and BLU sentries.

Wouldn't it be worth adding FL_NOTARGET flag onto the ghosts? Just an idea, perhaps make it a CVAR or something.

Pelipoika 07-07-2014 18:27

Re: [TF2] Simple Ghost
 
Quote:

Originally Posted by SoulSharD (Post 2163592)
Hmm, the sentries appear to be able to attack the ghosts, both RED and BLU sentries.

Wouldn't it be worth adding FL_NOTARGET flag onto the ghosts? Just an idea, perhaps make it a CVAR or something.

Done, didn't test it tho


All times are GMT -4. The time now is 19:55.

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