Pin enemy to a wall //SOLVED//

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

Pin enemy to a wall //SOLVED//

Post by Niphura »

PB 3.0 has this effect with the nailgun and i wanted to ask how it's done? i know that the gun needs to shoot a proyectile that gives an item to the monster to check and go to a "pin to the wall" state.
But i don't know how the state would look like, can you help me? or at least tell me how to do it or if there is any flags
Last edited by Niphura on Sun Dec 23, 2018 10:13 am, edited 1 time in total.
gramps
Posts: 300
Joined: Thu Oct 18, 2018 2:16 pm

Re: Pin enemy to a wall ((Help))

Post by gramps »

Hmm, wouldn't the pin to the wall state just be a few "struggling" frames with no calls to any functions that would move the enemy? As long as you don't mind knockback / disc of repulsion / etc. knocking it loose, anyway.

About flags, would NOTARGETSWITCH + STANDSTILL work? Maybe you can just set the flags and avoid having to add a new state.

Or maybe just stun lock the enemy in the pain state with continuous "damage" (that doesn't actually damage, but causes pain)?
Guest

Re: Pin enemy to a wall ((Help))

Post by Guest »

You can just make the projectile/hitscan have a custom damagetype and make a state like this:
Of course replace the CustomDamage with the custom damagetype

Death.CustomDamage:
POSS A 1 A_FaceTarget
POSS A 3 A_CustomMissile("CheckForWall", 1.0, 0, 128)
POSS A 1 A_JumpIfInventory("WallBehind", 1, 1)
Goto Death
TNT1 A 0 A_NoGravity
POSS A -1 A_Stop
Wait

This state shoots a projectile from the back of the monster, which checks if there's a wall:

Actor CheckForWall
{
Speed 30
Projectile
states
{
Spawn:
TNT1 A -1
Stop

Death:
TNT1 A 0 A_GiveToTarget("WallBehind", 1)
Stop

Crash:
XDeath:
TNT1 A 0
Stop
}
}

And finally here's the token item:

Actor WallBehind : Inventory {}
User avatar
Niphura
Posts: 192
Joined: Fri Jun 16, 2017 3:07 pm
Location: Argentina

Re: Pin enemy to a wall ((Help))

Post by Niphura »

Hannah Hivingpitch wrote:You can just make the projectile/hitscan have a custom damagetype and make a state like this:
Of course replace the CustomDamage with the custom damagetype

Death.CustomDamage:
POSS A 1 A_FaceTarget
POSS A 3 A_CustomMissile("CheckForWall", 1.0, 0, 128)
POSS A 1 A_JumpIfInventory("WallBehind", 1, 1)
Goto Death
TNT1 A 0 A_NoGravity
POSS A -1 A_Stop
Wait

This state shoots a projectile from the back of the monster, which checks if there's a wall:

Actor CheckForWall
{
Speed 30
Projectile
states
{
Spawn:
TNT1 A -1
Stop

Death:
TNT1 A 0 A_GiveToTarget("WallBehind", 1)
Stop

Crash:
XDeath:
TNT1 A 0
Stop
}
}

And finally here's the token item:

Actor WallBehind : Inventory {}
Thank you! i will try this 8-)
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: Pin enemy to a wall ((Help))

Post by TDRR »

Niphura wrote:Thank you! i will try this 8-)
Yeah don't use it as is because i messed up in the Spawn state of the projectile: it should be TNT1 A 2 not TNT1 A -1, if you use it as is the monster will always get stuck because of the projectile's infinite range.

You can also change the Death.CustomDamage part that says A_Stop to say: POSS A 1 A_Stop so that no explosion moves the monster out of it's position.
User avatar
Niphura
Posts: 192
Joined: Fri Jun 16, 2017 3:07 pm
Location: Argentina

Re: Pin enemy to a wall ((Help))

Post by Niphura »

TDRR wrote:
Niphura wrote:Thank you! i will try this 8-)
Yeah don't use it as is because i messed up in the Spawn state of the projectile: it should be TNT1 A 2 not TNT1 A -1, if you use it as is the monster will always get stuck because of the projectile's infinite range.

You can also change the Death.CustomDamage part that says A_Stop to say: POSS A 1 A_Stop so that no explosion moves the monster out of it's position.
Ok
User avatar
Niphura
Posts: 192
Joined: Fri Jun 16, 2017 3:07 pm
Location: Argentina

Re: Pin enemy to a wall ((Help))

Post by Niphura »

Okay so i made a weapon and a enemy with the things that you said, but there's a problem: when the enemy dies it stays on the air, it doesn't pin on the wall. it detects that is near a wall and go to the state of the damagetype in this case "Empalado" (that means impaled)

here's the files of the enemy and the weapon:

http://www.mediafire.com/file/x1w4u7hss ... r.pk3/file
http://www.mediafire.com/file/19dpe28eh ... w.pk3/file
User avatar
Niphura
Posts: 192
Joined: Fri Jun 16, 2017 3:07 pm
Location: Argentina

Re: Pin enemy to a wall ((Help))

Post by Niphura »

Another way that i can think of is doing a projectile that push the enemy until the projectile crashes on a wall, any ideas on how to do that kind of projectile?
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: Pin enemy to a wall ((Help))

Post by TDRR »

Niphura wrote:Another way that i can think of is doing a projectile that push the enemy until the projectile crashes on a wall, any ideas on how to do that kind of projectile?
Do you want your mod/TC compatible with Zandronum or not?
User avatar
Niphura
Posts: 192
Joined: Fri Jun 16, 2017 3:07 pm
Location: Argentina

Re: Pin enemy to a wall ((Help))

Post by Niphura »

TDRR wrote:
Niphura wrote:Another way that i can think of is doing a projectile that push the enemy until the projectile crashes on a wall, any ideas on how to do that kind of projectile?
Do you want your mod/TC compatible with Zandronum or not?
nope
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: Pin enemy to a wall ((Help))

Post by TDRR »

Niphura wrote:nope
Take this ZScript solution:

Code: Select all

class Harpooned : Inventory
{
	default
	{
		Inventory.MaxAmount 1;
	}
}

class CrossbowBolt : Actor
{
	Actor victim;
	double victimHeight;
	
	bool attachSelf;
	Vector3 posOffset;
	
	default
	{
		Radius 5;
		Height 5;
		Speed 50;
		Damage 10;
		Projectile;
	}
	
	override void PostBeginPlay()
	{
		super.PostBeginPlay();
		pitch = target.pitch;
	}
	
	override int SpecialMissileHit(Actor victim)
	{
		if (!self.victim && victim != target)
		{
			let a = victim.angle;
			let r = victim.radius;
			victim.A_DamageSelf(damage);
			
			self.victim = victim;
			victimHeight = victim.height;
			A_PlaySound("harpoon/hit", CHAN_AUTO);
			
			// stuff
			if (victim.CountInv("Harpooned") || victim.health > 0)
			{
				Destroy();
				return 1;
				
				// UNUSED
				attachSelf = true;
				posOffset = (
					pos.x - (victim.pos.x + (cos(a) * r)),
					pos.y - (victim.pos.y + (sin(a) * r)),
					pos.z - victim.pos.z
				);
			}
			
			if (victim.health <= 0)
			{
				victim.bNoGravity = true;
				victim.painChance = 0;
				victim.painSound = "";
				victim.A_GiveInventory("Harpooned");
			}
		}
		return 1;
	}
	
	override void Tick()
	{
		if (victim)
		{
			if ((victim is "PlayerPawn" || victim.bIsMonster) && !attachSelf)
				victim.SetStateLabel("Pain");
			
			if (attachSelf)
			{
				SetOrigin(victim.Vec3Offset(posOffset.x, posOffset.y, posOffset.z), true);
				vel = victim.vel;
			}
			else
			{
				let zofs = -victimHeight / 2;
				victim.SetOrigin(Vec3Offset(0, 0, zofs), true);
				victim.angle = angle + 180;
			}
		}
		
		if (vel.z == 0)
		{
			if (pos.z == ceilingz)
				SetOrigin(Vec3Offset(0, 0, -height), true);
			else if (pos.z == floorz)
				SetOrigin(Vec3Offset(0, 0, height), true);
		}
		
		super.Tick();
	}
	
	states
	{
		Death:
			TNT1 A 0 { 
				if (victim)
				{
					victim.A_DamageSelf(victim.health);
					if (victim is "PlayerPawn" && !attachSelf)
					{
						victim.A_TakeInventory("Harpooned");
						victim.Destroy();
						victim = Spawn("DoomPlayer");
						victim.A_GiveInventory("Harpooned");
					}
				}
				else if (attachSelf)
					bNoGravity = false;
			}
			TNT1 A 0 A_PlaySound("harpoon/wall", CHAN_AUTO);
		Spawn:
			HARP A -1;
			stop;
	}
}
Post Reply

Return to “Scripting”