Making a sprite stick to a player

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
GraveUypo
Posts: 11
Joined: Sat Jun 03, 2017 6:20 pm

Making a sprite stick to a player

Post by GraveUypo »

I'm making a powerup that hugely boosts all player weapons and i want it to be visually obvious when a player picks it up by sticking an aura animation on the player for the duration of the power up.
How would i go about doing that? I have no idea how to spawn the thing when the powerup is picked up (maybe give the power up actor a "death" state and then use that to spawn it?) and then make it follow the player around for the duration of the effect.
it's for gzdoom and meant mostly for multiplayer (yes, i know gzdoom isn't meant for that, but it works fine for my lans and my wad requires gz).
any tips?
Guest

Re: Making a sprite stick to a player

Post by Guest »

You just need to have an ACS script running in the background (use the ENTER, DEATH and RESPAWN script types) checking if the powerup is in that player's inventory and spawn an actor if that's the case.

Here's a modified example from my CTF mod:
Script "SpawnAura" Enter
{
if(CheckInventory("HasPowerup"))
{ SpawnForced("PowerupAura", GetActorX(0), GetActorY(0), GetActorZ(0)); }
delay(1);
restart;
}

Make the PowerupAura actor last only one tic so it looks smooth when moving. Also try to make the aura lower than the player's view height or it won't look good (or just make it transparent)

Can i get a copy of the mod when it's done?
User avatar
TDRR
Posts: 815
Joined: Sun Mar 11, 2018 4:15 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Debian 12/ Manjaro
Graphics Processor: nVidia with Vulkan support
Location: Venezuela

Re: Making a sprite stick to a player

Post by TDRR »

Try using an ACS script like this:

script "AuraSpawn" ENTER
{
if(CheckInventory("PowerupItem"))
{ SpawnForced("PowerupAura", GetActorX(0), GetActorY(0), GetActorZ(0)); delay(1); restart; }
delay(1);
restart;
}

script "AuraSpawn2" RESPAWN
{
if(CheckInventory("PowerupItem"))
{ SpawnForced("PowerupAura", GetActorX(0), GetActorY(0), GetActorZ(0)); delay(1); restart; }
delay(1);
restart;
}

Use both ACS scripts so even if you respawn the ACS script will continue checking.

Make the PowerupAura transparent and make it only last 1 tic.
I did something similar on my CTF mod that allows offsetting of the actor but it's a rather ugly hack and isn't very efficient. (to be fair that was when i knew next to nothing of ACS)
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Making a sprite stick to a player

Post by Blue Shadow »

@TDRR: Please make sure you're logged in when posting, so you don't end up posting as a guest. Posts made by guests need be approved first before they become visible to the public. This is why you don't see them immediately.
User avatar
TDRR
Posts: 815
Joined: Sun Mar 11, 2018 4:15 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Debian 12/ Manjaro
Graphics Processor: nVidia with Vulkan support
Location: Venezuela

Re: Making a sprite stick to a player

Post by TDRR »

Blue Shadow wrote:@TDRR: Please make sure you're logged in when posting, so you don't end up posting as a guest. Posts made by guests need be approved first before they become visible to the public. This is why you don't see them immediately.
Yeah, i know, but the fact that Firefox just decided to log me out of my forum account confused me and i didn't notice. Lesson learned then.
Guest

Re: Making a sprite stick to a player

Post by Guest »

Jack Hackleman wrote:You just need to have an ACS script running in the background (use the ENTER, DEATH and RESPAWN script types) checking if the powerup is in that player's inventory and spawn an actor if that's the case.

Here's a modified example from my CTF mod:
Script "SpawnAura" Enter
{
if(CheckInventory("HasPowerup"))
{ SpawnForced("PowerupAura", GetActorX(0), GetActorY(0), GetActorZ(0)); }
delay(1);
restart;
}

Make the PowerupAura actor last only one tic so it looks smooth when moving. Also try to make the aura lower than the player's view height or it won't look good (or just make it transparent)

Can i get a copy of the mod when it's done?
thanks, i'll try that when i get the time.





about my wad, i have a thread on doomworld for it, not sure if this forum allows linking to another forum though.

I suppose i could just post the download links. Here's a link to the last public release:
https://drive.google.com/file/d/1VVZWD3 ... sp=sharing

And here's the most current version i'm working on (ima call it "nightly") that includes the powerup.
https://drive.google.com/file/d/11v9GR6 ... sp=sharing

the campaign on the public release is playable from levels gmap01 to gmap06 continuously, gmap07 is very early wip and i'm not sure i'm keeping it, and gmap08 is still unfinished even though the level itself is basically done, just need to populate it and give it some finishing touches. this is something i've been working on for years and learning as i go, so quality varies wildly. which is why i've been "remaking" the older maps this year. done gmap01, gmap02, gmap05 and (working on gmap03 now, kinda).

The nightly one has some new stuff over the public release. some new textures, a new bgm, started reworking gmap03, made a new deathmatch map - dm07, and changed the double damage powerup to this one i mentioned - hasn't been balanced at all yet, so some stuff may be WAY too overpowered with the powerup even when they're meant to be very powerful anyway). this powerup is meant to go through ammo mercilessly, but only some weapons (like the supershotgun) do so yet. i want to test it in lanplay before nerfing it.

requires gzdoom.
maps included are :
gmap01 to gmap08 (campaign maps)
dm01 to dm07 (deathmatch maps)
dm09 (a wip map from another mod i made that i put inside this one and maybe one day will turn into a large death match map)

there's a bunch of new monsters and weapons too.

if you try it, please do give feedback, very few people did so far :(
can't guarantee you'll like it, but my friends seem to love the campaign.
User avatar
GraveUypo
Posts: 11
Joined: Sat Jun 03, 2017 6:20 pm

Re: Making a sprite stick to a player

Post by GraveUypo »

damn, i posted as a guest :oops:
welp, thanks for all the replies. i'll try that next time i'm messing with this wad. my guest post should show up here eventually with links to my wad, so please give it a try.
meanwhile, here's a link to the "nightly version": https://drive.google.com/file/d/11v9GR6 ... sp=sharing

oh, if you want to mess around with the power up by summoning it by console command, the actor name is BookOfPower

[edit] oh hey, it worked!
https://i.postimg.cc/nxdNdLMb/Screensho ... 234727.png
although i had to split the aura actor into 4 different actors, one for each frame of animation.
i might i'll redo it later using with a looping actor and SetActorPosition or something instead of spawning a new one for each tic. that way the aura won't glitch out when i type freeze on the console
Post Reply

Return to “Scripting”