Magnet items (how can i do it?)

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Niphura
Posts: 192
Joined: Fri Jun 16, 2017 3:07 pm
Location: Argentina

Magnet items (how can i do it?)

Post by Niphura »

So..i wanted to know how to make an item go to the player if he is close to it. Something like the health pickups in Doom eternal or 2016 after you do a glory kill. I´ve seen mods that have this feature but i don't remember which mods were.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Magnet items (how can i do it?)

Post by Jarewill »

Using ZScript you can detect if a player is nearby and make the item move towards the player.
Example code:
Spoiler:
User avatar
Niphura
Posts: 192
Joined: Fri Jun 16, 2017 3:07 pm
Location: Argentina

Re: Magnet items (how can i do it?)

Post by Niphura »

Jarewill wrote:Using ZScript you can detect if a player is nearby and make the item move towards the player.
Example code:
Spoiler:
Sorry i don't know how to use Zscript, i only know how to use decorate. Hmmm could you edit the zscript file inside the .pk3? inside you'll find the armor bonus item and you can use the default doom player, i'll make sure to add you to the credits if i post my mod later this year

the item: https://www.mediafire.com/file/03ulyem7 ... r.pk3/file
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Magnet items (how can i do it?)

Post by Jarewill »

Here you go.
I edited the item inside ZScript to look and function like your armor pickup.
I also included a MAPINFO file with editor number definition, because that's the only way to assign those numbers in ZScript.

There's just one small problem with this:
The item will only move horizontally and not vertically, but I have no idea how to fix it.
Someone more skilled in trigonometry might be able to help here.

Edit: Forgot to actually include the file.
Attachments
Smallarmor.pk3
(12.23 KiB) Downloaded 55 times
User avatar
Niphura
Posts: 192
Joined: Fri Jun 16, 2017 3:07 pm
Location: Argentina

Re: Magnet items (how can i do it?)

Post by Niphura »

Jarewill wrote:Here you go.
I edited the item inside ZScript to look and function like your armor pickup.
I also included a MAPINFO file with editor number definition, because that's the only way to assign those numbers in ZScript.

There's just one small problem with this:
The item will only move horizontally and not vertically, but I have no idea how to fix it.
Someone more skilled in trigonometry might be able to help here.

Edit: Forgot to actually include the file.
Thank you very much! don't worry about the vertically movement :)

EDIT: hmm i can't find the item on ultimate doom builder to place it somewhere in a map
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Magnet items (how can i do it?)

Post by Jarewill »

Right, I forgot.
First you will have to include gzdoom.pk3 in UDB.

To do that, first open your map.
In the resource menu as you open the map, you should add a new resource:

Then specify it to be a .pk3 and navigate to your gzdoom.pk3 file:

And lastly make sure to exclude it from the game itself:


Hope this helps.
User avatar
Niphura
Posts: 192
Joined: Fri Jun 16, 2017 3:07 pm
Location: Argentina

Re: Magnet items (how can i do it?)

Post by Niphura »

Jarewill wrote:Right, I forgot.
First you will have to include gzdoom.pk3 in UDB.

To do that, first open your map.
In the resource menu as you open the map, you should add a new resource:

Then specify it to be a .pk3 and navigate to your gzdoom.pk3 file:

And lastly make sure to exclude it from the game itself:


Hope this helps.
it works thank you very much!
User avatar
Leglock
Posts: 88
Joined: Sat Mar 02, 2019 2:04 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Magnet items (how can i do it?)

Post by Leglock »

Jarewill wrote: Sun Feb 27, 2022 8:14 am Using ZScript you can detect if a player is nearby and make the item move towards the player.
Example code:
Spoiler:
Sorry for the late bump, I´ve been looking for somthing like this as an "universal pick up drops" (Not static items like keys and ammo/health placed in the map, just enemy drops).
I never tried before scripting in Zscript, I know before I jump into this, I should read the tutotials. But I want to ask if this, or a modified version of this script could work as a universal add on for must mods, like nashgore, damnums or ucminimap.

I´m really looking for something like this to cut down unnecesary grind time collecting pick ups in some mods that, otherwise, they are a blast.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Magnet items (how can i do it?)

Post by Jarewill »

That can be possible using event handlers and inventory items with custom logic.
Example:
Attachments
ItemGlide.wad
(741 Bytes) Downloaded 80 times
User avatar
Leglock
Posts: 88
Joined: Sat Mar 02, 2019 2:04 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Magnet items (how can i do it?)

Post by Leglock »

Jarewill wrote: Tue Apr 18, 2023 1:09 pm That can be possible using event handlers and inventory items with custom logic.
Example:
I will check it out this weekend.
Thanks for the fast replay!
Post Reply

Return to “Scripting”