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?