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

Entity output parameter truncated?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BCG
Junior Member
Join Date: Sep 2015
Old 03-10-2018 , 14:31   Entity output parameter truncated?
Reply With Quote #1

Hi,

I'm writing a plugin for Insurgency. On many maps, there are cash registers (prop_dynamic) which react to damage by making a "ding!" noise, emitting sparks, and popping open the cash drawer.

It appears that this is implemented using the entity I/O system. I used Hammer to look at the entity outputs:
Code:
Output        Target  Target input          Parameter  Delay  Only once
============  ======  ====================  =========  =====  =========
OnTakeDamage  !self   SetAnimation          break      0.00   Yes 
OnTakeDamage  !self   SetDefaultAnimation   open       0.00   Yes
As you can see, once these outputs are fired, they are removed, and the register will no longer react to damage.

I'm attempting to add more outputs to make the register reset itself after a few seconds. This is what I have so far:

PHP Code:
new register = -1;

while ((
register FindEntityByClassname(register"prop_dynamic")) != -1) {
        new 
String:model[PLATFORM_MAX_PATH];
        
GetEntPropString(registerProp_Data"m_ModelName"modelsizeof(model));

        if (
StrEqual(model"models/static_props/cash_register_break.mdl")) {
                
SetVariantString("OnTakeDamage !self,FireUser4,,0.0,1"); // Only once = yes
                
AcceptEntityInput(register"AddOutput");

                
SetVariantString("OnUser4 !self,SetAnimation,break,0.0,-1");
                
AcceptEntityInput(register"AddOutput");

                
SetVariantString("OnUser4 !self,SetAnimation,idle,3.0,-1");
                
AcceptEntityInput(register"AddOutput");

                
SetVariantString("OnUser4 !self,AddOutput,OnTakeDamage !self:FireUser4::0.0:1,3.1,-1");
                
AcceptEntityInput(register"AddOutput");
        }

In essence, when the register takes damage, it fires User4. User4 is supposed to:
  1. Immediately set the animation to "break" (ding!, sparks, drawer opens)
  2. After 3.0 seconds, set the animation to "idle" (drawer closes)
  3. After 3.1 seconds, re-add a OnTakeDamage output to trigger User4 at a later time

The problem I'm having is that although the first two steps work properly (sparks fly, drawer opens, drawer closes), the re-add of the OnTakeDamage output fails. I ran my server in developer mode (passing -dev on the command line) and looked at the output.

I can see my script adding the outputs:

Code:
(1.02) input <NULL>: prop_dynamic.AddOutput(OnTakeDamage !self,FireUser4,,0.0,1)
(1.02) input <NULL>: prop_dynamic.AddOutput(OnUser4 !self,SetAnimation,break,0.0,-1)
(1.02) input <NULL>: prop_dynamic.AddOutput(OnUser4 !self,SetAnimation,idle,3.0,-1)
(1.02) input <NULL>: prop_dynamic.AddOutput(OnUser4 !self,AddOutput,OnTakeDamage !self:FireUser4::0.0:1,3.1,-1)
But when I shoot the register, I see this:
Code:
(62.91) output: (prop_dynamic,) -> (!self,FireUser4)()
Removing from action list: (prop_dynamic,) -> (!self,FireUser4)
(62.91) output: (prop_dynamic,) -> (!self,SetDefaultAnimation)(open)
Removing from action list: (prop_dynamic,) -> (!self,SetDefaultAnimation)
(62.91) output: (prop_dynamic,) -> (!self,SetAnimation)(break)
Removing from action list: (prop_dynamic,) -> (!self,SetAnimation)
(62.91) input : prop_dynamic.FireUser4()
(62.91) output: (prop_dynamic,) -> (!self,AddOutput)(OnTakeDamage !self)
(62.91) output: (prop_dynamic,) -> (!self,SetAnimation,3.0)(idle)
(62.91) output: (prop_dynamic,) -> (!self,SetAnimation)(break)
(62.91) input : prop_dynamic.SetDefaultAnimation(open)
(62.91) input : prop_dynamic.SetAnimation(break)
(62.91) input : prop_dynamic.AddOutput(OnTakeDamage !self)
(62.91) input : prop_dynamic.SetAnimation(break)
(65.91) input : prop_dynamic.SetAnimation(idle)
This is the suspicious line here:
Code:
(62.91) output: (prop_dynamic,) -> (!self,AddOutput)(OnTakeDamage !self)
Why isn't the whole parameter "OnTakeDamage !self:FireUser4::0.0:1" passed? It doesn't appear that the delay of 3.1 seconds is parsed, either. It seems the whole thing is being truncated at the colon.

Does anyone have insight as to why this is not working?

Last edited by BCG; 03-11-2018 at 14:14.
BCG is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-10-2018 , 19:50   Re: Entity output parameter truncated?
Reply With Quote #2

AddOutputs are separated by colons, not commas to seperate other outputs
https://developer.valvesoftware.com/wiki/AddOutput

Try This:
Code:
                SetVariantString("OnTakeDamage !self:FireUser4::0.0:1"); // Only once = yes 
                AcceptEntityInput(register, "AddOutput"); 

                SetVariantString("OnUser4 !self:SetAnimation:break:0.0:-1"); 
                AcceptEntityInput(register, "AddOutput"); 

                SetVariantString("OnUser4 !self:SetAnimation:idle:3.0:-1"); 
                AcceptEntityInput(register, "AddOutput"); 

                SetVariantString("OnUser4 !self:AddOutput:“OnTakeDamage !self:FireUser4::0.0:1”:3.1:-1"); 
                AcceptEntityInput(register, "AddOutput");

Last edited by Mitchell; 03-10-2018 at 19:54.
Mitchell is offline
BCG
Junior Member
Join Date: Sep 2015
Old 03-10-2018 , 23:17   Re: Entity output parameter truncated?
Reply With Quote #3

I tried the code you suggested, but still come up with the same result:

Code:
(23.88) output: (prop_dynamic,) -> (!self,FireUser4)()
Removing from action list: (prop_dynamic,) -> (!self,FireUser4)
(23.88) output: (prop_dynamic,) -> (!self,SetDefaultAnimation)(open)
Removing from action list: (prop_dynamic,) -> (!self,SetDefaultAnimation)
(23.88) output: (prop_dynamic,) -> (!self,SetAnimation)(break)
Removing from action list: (prop_dynamic,) -> (!self,SetAnimation)
(23.88) input : prop_dynamic.FireUser4()
(23.88) output: (prop_dynamic,) -> (!self,AddOutput)(“OnTakeDamage !self) <---------------
(23.88) output: (prop_dynamic,) -> (!self,SetAnimation,3.0)(idle)
(23.88) output: (prop_dynamic,) -> (!self,SetAnimation)(break)
(23.88) input : prop_dynamic.SetDefaultAnimation(open)
(23.88) input : prop_dynamic.SetAnimation(break)
(23.88) input : prop_dynamic.AddOutput(“OnTakeDamage !self)
(23.88) input : prop_dynamic.SetAnimation(break)
(26.88) input : prop_dynamic.SetAnimation(idle)
With the commas swapped for colons, the first two steps are executed properly.

However, the third step's parameter is truncated as before.
BCG is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 03-11-2018 , 01:19   Re: Entity output parameter truncated?
Reply With Quote #4

Is the truncation happening specifically due to the colon, or is there a max size or something?
hmmmmm is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-11-2018 , 06:36   Re: Entity output parameter truncated?
Reply With Quote #5

You’ve got Unicode “fancy” quotes in that snippet which won’t be helping at all.
__________________
asherkin is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-11-2018 , 12:17   Re: Entity output parameter truncated?
Reply With Quote #6

Quote:
Originally Posted by asherkin View Post
You’ve got Unicode “fancy” quotes in that snippet which won’t be helping at all.
Literally took those from the wikipage. Unless they need to be escaped or something then why is it in the wiki?
Mitchell is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-11-2018 , 12:39   Re: Entity output parameter truncated?
Reply With Quote #7

Looking at the SDK code, it doesn't look like it is possible to do this - there is definitely no parsing for quoted strings at all.

AddOutput replaces all colons in the string input with commas indiscriminately, and the parameter override parsing code doesn't have any way to handle parameters containing commas.

Since you're writing a plugin anyway, I suggest replacing all this garbage with an OnTakeDamage hook and a couple of timers.

EDIT: You could also use https://forums.alliedmods.net/showthread.php?t=305343 to add the output actions directly, as the problem is in how the AddOutput input parses things.
__________________

Last edited by asherkin; 03-11-2018 at 12:43.
asherkin is offline
BCG
Junior Member
Join Date: Sep 2015
Old 03-11-2018 , 14:12   Re: Entity output parameter truncated?
Reply With Quote #8

Thanks for the info. I already had the behavior I wanted implemented with the OnTakeDamage hook. I figured the I/O stuff would be more elegant. Too bad it's broken in this use case.
BCG is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-12-2018 , 16:30   Re: Entity output parameter truncated?
Reply With Quote #9

Create a point_template entity and link the entities you want to respawn to it. The point_template entity will allow you to respawn the template via an input.

https://developer.valvesoftware.com/wiki/Point_template
__________________
Neuro Toxin 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 08:58.


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