Shkwarkel Posted December 20, 2023 (edited) I create an item using the SPAWN command. The item spawns in front of the player at a distance of 100 on the x-axis. I want when the player picks up it a specific scpit is executed. Can you help me to do it? I think I need to use TID? Edited December 20, 2023 by Shkwarkel 0 Quote Share this post Link to post
Rifleman Posted December 20, 2023 Not sure if possible purely with scripting. You could make a simple Medikit replacement actor that runs a script when picked up. 0 Quote Share this post Link to post
Russell_P Posted December 20, 2023 Off the top of my head.... assuming you are only spawning one Medikit2 and only the player can pick it up (and it's single player...maybe) int aTag = UniqueTID(); do{ delay(1); int x = GetActorX(0) + 200.0; int y = GetActorY(0); int z = GetActorZ(0); } until (Spawn("Medikit2",x,y,z,aTag,0)); //might want a delay here? while ( ThingCountName("Medikit2", aTag) > 0 ) { delay(1); } //then put your wanted code here or ACS_Execute to start the desired script Or do it in DECORATE, making the class execute a specified script on pickup. 2 Quote Share this post Link to post
Shkwarkel Posted December 20, 2023 4 hours ago, Russell_P said: Off the top of my head.... assuming you are only spawning one Medikit2 and only the player can pick it up (and it's single player...maybe) int aTag = UniqueTID(); do{ delay(1); int x = GetActorX(0) + 200.0; int y = GetActorY(0); int z = GetActorZ(0); } until (Spawn("Medikit2",x,y,z,aTag,0)); //might want a delay here? while ( ThingCountName("Medikit2", aTag) > 0 ) { delay(1); } //then put your wanted code here or ACS_Execute to start the desired script Or do it in DECORATE, making the class execute a specified script on pickup. Yeah, it works. Thank you so much. If it's not too much trouble, could you give me a link to a tutorial on how to assign a script to an object via DECORATE? I think I could really use it in my project. 0 Quote Share this post Link to post
candyman64 Posted December 21, 2023 The way I always done it is i placed a thing outside of the map with the dormant flag checked then teleport & Thing_Activate it instead of spawning And it had the appropriate action already attached to it that upon picking it up/killing it if it sa monster the action is performed like open a door 1 Quote Share this post Link to post
Russell_P Posted December 21, 2023 (edited) I don't know of any tutorials. I tend to bash my head against the zdoom wiki until I figure things out. Failing that I go and find a mod that does what I want and then use that as an example. I'm very rusty on some of this stuff, but I had a pickup in doom raider that executed a script. Here's the DECORATE code, you should hopefully figure it out from that. ACTOR ProtectionAmulet : CustomInventory 19121 { Inventory.PickupMessage "Amulet of protection" Inventory.Icon "ST_AMUL" +INVENTORY.FANCYPICKUPSOUND +INVENTORY.ALWAYSPICKUP +COUNTITEM Inventory.PickupFlash none States { Spawn: AMUL A 12 //Bright AMUL B 6 Loop Pickup: TNT1 A 0 A_GiveInventory("ProtectionArmour",1) TNT1 A 0 ACS_NamedExecuteAlways("blueFlash", 0) Stop } } edit: Try this ACTOR Medikit2 : CustomInventory { Inventory.PickupMessage "myMessage" +INVENTORY.ALWAYSPICKUP States { Spawn: AMUL A 12 //change this to whatever your sprites are AMUL B 6 Loop Pickup: TNT1 A 0 A_GiveInventory("Medikit",25) //assuming this is a medikit variant and you want the same effect TNT1 A 0 ACS_NamedExecuteAlways("myScript", 0) Stop } } ...I seem to remember that only classses that inherit from CustomInventory can have pickup states. If I'm wrong then I'm overcomplicating the whole thing Edited December 21, 2023 by Russell_P added code suggestion 1 Quote Share this post Link to post
Shkwarkel Posted December 22, 2023 On 12/21/2023 at 2:23 AM, candyman64 said: The way I always done it is i placed a thing outside of the map with the dormant flag checked then teleport & Thing_Activate it instead of spawning And it had the appropriate action already attached to it that upon picking it up/killing it if it sa monster the action is performed like open a door good idea, thank you! 0 Quote Share this post Link to post
Shkwarkel Posted December 22, 2023 22 hours ago, Russell_P said: I don't know of any tutorials. I tend to bash my head against the zdoom wiki until I figure things out. Failing that I go and find a mod that does what I want and then use that as an example. I'm very rusty on some of this stuff, but I had a pickup in doom raider that executed a script. Here's the DECORATE code, you should hopefully figure it out from that. ACTOR ProtectionAmulet : CustomInventory 19121 { Inventory.PickupMessage "Amulet of protection" Inventory.Icon "ST_AMUL" +INVENTORY.FANCYPICKUPSOUND +INVENTORY.ALWAYSPICKUP +COUNTITEM Inventory.PickupFlash none States { Spawn: AMUL A 12 //Bright AMUL B 6 Loop Pickup: TNT1 A 0 A_GiveInventory("ProtectionArmour",1) TNT1 A 0 ACS_NamedExecuteAlways("blueFlash", 0) Stop } } edit: Try this ACTOR Medikit2 : CustomInventory { Inventory.PickupMessage "myMessage" +INVENTORY.ALWAYSPICKUP States { Spawn: AMUL A 12 //change this to whatever your sprites are AMUL B 6 Loop Pickup: TNT1 A 0 A_GiveInventory("Medikit",25) //assuming this is a medikit variant and you want the same effect TNT1 A 0 ACS_NamedExecuteAlways("myScript", 0) Stop } } ...I seem to remember that only classses that inherit from CustomInventory can have pickup states. If I'm wrong then I'm overcomplicating the whole thing I see what you mean. Thanks for your help. 0 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.