BUMPSPECIAL doesn't make player target?
Posted: Wed Dec 20, 2023 11:52 pm
I have two actors, one of which uses USESPECIAL to start a script, the other of which uses BUMPSPECIAL. All the important code is the same, but the first one works as intended and the second one does not.
Here is the first item: An item that can be bought in a store. When you hit the use key, it activates an ACS script.
Once per second it also spawns a second item that uses BUMPSPECIAL to provide the player with information about the item before they buy it:
As you can see, Activation THINGSPEC_Switch|THINGSPEC_ThingTargets is present for both actors. The only difference is the USESPECIAL/BUMPSPECIAL flags.
According to the wiki:
USESPECIAL
The actor's special will be triggered when the player presses use while facing this actor. The player will be considered the activator of the special.
Note: This default behavior can be modified with the Activation property.
BUMPSPECIAL
The actor's special will be triggered when the player touches this actor. The player will be considered the activator of the special.
Note: This default behavior can be modified with the Activation property.
In both cases it says "The player will be considered the activator of the special" however, when I run ACS_NamedExecuteAlways, it still uses the actor as the activator of the script rather than the player who triggered it so THINGSPEC_ThingTargets was an easy workaround. I just set the player as its target and the first code in the ACS script is:
This sets "i" to the player's TID for various purposes, and then it sets the actor's target (the player) to the activator of the script.
In the case of the item with the USESPECIAL, it works properly and with the BUMPSPECIAL it does not. I did a test with a print statement.
With the USESPECIAL it prints "1" and "0" for TID 1 and Player Number 1.
With the BUMPSPECIAL it prints "0" and "-1"
What am I doing wrong?
Here is the first item: An item that can be bought in a store. When you hit the use key, it activates an ACS script.
Code: Select all
Class ShopTorch : SwitchableDecoration
{
Default
{
Radius 16;
Height 16;
Mass 1000;
Activation THINGSPEC_Switch|THINGSPEC_ThingTargets;
+USESPECIAL;
+INVULNERABLE;
+DONTTHRUST;
+NOGRAVITY;
}
States
{
Spawn:
TRCH A 0;
TRCH A 10;
Idle:
#### # 35 A_SpawnItemEx("ShopTorchBrowse");
Loop;
Active:
TRCH A 4;
TRCH A 10 ACS_NamedExecuteAlways("Shop",0,1,1);
TRCH A 165;
Goto Idle;
Inactive:
TRCH A 4;
TRCH A 10 ACS_NamedExecuteAlways("Shop",0,1,1);
TRCH A 165;
Goto Idle;
}
}
Code: Select all
Class ShopTorchBrowse : SwitchableDecoration
{
Default
{
Radius 32;
Height 32;
Mass 1;
Activation THINGSPEC_Switch|THINGSPEC_ThingTargets;
+BUMPSPECIAL;
+INVULNERABLE;
+NOGRAVITY;
+SOLID;
+PUSHABLE;
}
States
{
Spawn:
TNT1 A 34;
Stop;
Active:
TNT1 A 1 ACS_NamedExecuteAlways("Shop",0,1,0);
TNT1 A 35;
Stop;
}
}
According to the wiki:
USESPECIAL
The actor's special will be triggered when the player presses use while facing this actor. The player will be considered the activator of the special.
Note: This default behavior can be modified with the Activation property.
BUMPSPECIAL
The actor's special will be triggered when the player touches this actor. The player will be considered the activator of the special.
Note: This default behavior can be modified with the Activation property.
In both cases it says "The player will be considered the activator of the special" however, when I run ACS_NamedExecuteAlways, it still uses the actor as the activator of the script rather than the player who triggered it so THINGSPEC_ThingTargets was an easy workaround. I just set the player as its target and the first code in the ACS script is:
Code: Select all
int i=GetActorProperty(0,APROP_TargetTID);
SetActivatorToTarget(0);
In the case of the item with the USESPECIAL, it works properly and with the BUMPSPECIAL it does not. I did a test with a print statement.
Code: Select all
script "Shop" (int itemnumber, int shoporlook)
{
int i=GetActorProperty(0,APROP_TargetTID);
SetActivatorToTarget(0);
print(d: i);
print(d: PlayerNumber());
}
With the BUMPSPECIAL it prints "0" and "-1"
What am I doing wrong?