AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Entity output parameter truncated? (https://forums.alliedmods.net/showthread.php?t=305947)

BCG 03-10-2018 14:31

Entity output parameter truncated?
 
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?

Mitchell 03-10-2018 19:50

Re: Entity output parameter truncated?
 
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");


BCG 03-10-2018 23:17

Re: Entity output parameter truncated?
 
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.

hmmmmm 03-11-2018 01:19

Re: Entity output parameter truncated?
 
Is the truncation happening specifically due to the colon, or is there a max size or something?

asherkin 03-11-2018 06:36

Re: Entity output parameter truncated?
 
You’ve got Unicode “fancy” quotes in that snippet which won’t be helping at all.

Mitchell 03-11-2018 12:17

Re: Entity output parameter truncated?
 
Quote:

Originally Posted by asherkin (Post 2582434)
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?

asherkin 03-11-2018 12:39

Re: Entity output parameter truncated?
 
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.

BCG 03-11-2018 14:12

Re: Entity output parameter truncated?
 
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.

Neuro Toxin 03-12-2018 16:30

Re: Entity output parameter truncated?
 
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


All times are GMT -4. The time now is 18:43.

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