Raised This Month: $32 Target: $400
 8% 

Adding Spy Cloakflicker?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 09-27-2013 , 06:00   Adding Spy Cloakflicker?
Reply With Quote #1

I was wondering if there's a way to force the cloakflicker effect from the cloak and dagger, doesn't seem like I can do it with attributes, and setting the cloakmeter low or to 0 just makes the player unstealth. Similarly addconds do nothing.

There's a few spy netprops, but most look like they are related to times for cloaking/uncloaking and switching disguises.

With attributes it seems the meter will just run out, and I can never cloak again
Might be able to send the addcond ongameframe, I think I got that to work in the past, though Id like to avoid it.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 09-27-2013 at 07:05.
friagram is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-26-2019 , 13:44   Re: Adding Spy Cloakflicker?
Reply With Quote #2

I was looking into this also, 6 years later, turns out there's a property called "m_flLastStealthExposeTime" which does just this.

CTFPlayerShared Touch
Code:
m_flLastStealthExposeTime = gpGlobals->curtime;
AddCond( TF_COND_STEALTHED_BLINK );
Seems a mix of the attribute 159 and firing the "Touch" offset might do this fine.
Touch has to be an enemy though.

Turns out I couldn't get touch to do anything when firing it and stuck to just damaging the player here for anybody interested.
Code:
public void flickerCloak(int client) {
    int oldTakeDamage = GetEntProp(client, Prop_Data, "m_takedamage");
    SetEntProp(client, Prop_Data, "m_takedamage", 1, 1); //Don't do damage, but still fire the damage hooks.
    SDKHooks_TakeDamage(client, 0, 0, 6.0, DMG_PREVENT_PHYSICS_FORCE, 0, NULL_VECTOR, NULL_VECTOR);
    SetEntPropVector(client, Prop_Send, "m_vecPunchAngle", NULL_VECTOR); //Resets the punch angle.
    SetEntPropVector(client, Prop_Send, "m_vecPunchAngleVel", NULL_VECTOR);
    SetEntProp(client, Prop_Data, "m_takedamage", oldTakeDamage, 1);
}

public void OnClientPutInServer(int client) {
    SDKHook(client, SDKHook_OnTakeDamageAlive, TakeDamageAliveHook);
}

public Action TakeDamageAliveHook(int client, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon,
        float damageForce[3], float damagePosition[3], int damagecustom) {
    if(attacker == 0 && damagetype == DMG_PREVENT_PHYSICS_FORCE) {
        return Plugin_Stop; //Prevents the blood effect.
    }
    return Plugin_Continue;
}

Last edited by Mitchell; 02-26-2019 at 18:21.
Mitchell is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 02-26-2019 , 20:04   Re: Adding Spy Cloakflicker?
Reply With Quote #3

Did a quick look through the disassembly; one way to go about it is to set m_flLastStealthExposeTime to some longer time in the future then add TFCond_CloakFlicker:

Code:
int offs_CTFPlayerShared = FindSendPropInfo("CTFPlayer", "m_Shared");

// note:  0x150 is the offset to m_flLastStealthExposeTime relative to m_Shared on Linux; this is an internal property
// you can check CTFPlayerShared::OnSpyTouchedByEnemy() in the event it changes in the future
SetEntDataFloat(client, offs_CTFPlayerShared + 0x150, GetGameTime() + 10.0);
TF2_AddCondition(client, TFCond_CloakFlicker);
You'll (probably) also want to add TFCond_Cloaked or TFCond_Stealthed so the player is actually cloaked.

The flicker gets removed in ConditionGameRulesThink; it does the following:
Code:
// note: sp pseudocode
float flBlinkTimePenalty = 0.3; // different when cloak_blink_time_penalty is present; I think it's additive

if (GetGameTime() - m_flLastStealthExposeTime > flBlinkTimePenalty) {
    TF2_RemoveCondition(client, TFCond_CloakFlicker);
}
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 02-26-2019 at 21:04.
nosoop is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-26-2019 , 22:38   Re: Adding Spy Cloakflicker?
Reply With Quote #4

Quote:
Originally Posted by nosoop View Post
etc
Seems to work, just mainly scared if anything changes in an update it will break this code.
Mitchell is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 02-26-2019 , 23:30   Re: Adding Spy Cloakflicker?
Reply With Quote #5

Unless they decide to refactor the entire codebase, you should be fine. The property's been there for a very long time (and it's not like TF2 gets updates these days).

I do get the concern about code breakage though; been there myself.

You can also calculate the offset relative to the player as GetEntSendPropOffs(client, "m_flInvisChangeCompleteTime", true) + 0x04, which should be more robust (the only case where it would break is if that sendprop stops existing or if they insert a new property between the two).
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 02-26-2019 at 23:32.
nosoop 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 10:44.


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