The "How do I..." Thread

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Expect No Mercy
Posts: 45
Joined: Sun Mar 18, 2012 1:43 am

Re: The "How do I..." Thread

Post by Expect No Mercy »

DoomKrakken wrote:...

@Expect No Mercy, Projectiles will enter their Death state sequence if they hit a ceiling, as well as a wall or floor. They can also enter into the Death state sequence if it hits a bleeding actor and has an XDeath state sequence defined, or a non-bleeding actor and has a Crash state sequence defined. I think from there, using the SKYEXPLODE flag, ZScript will be required. I can't really go further from there...
That's really pretty simple. Never thought about that. Thanks! :mrgreen:
User avatar
silentzora
Posts: 450
Joined: Sun Jan 04, 2004 6:24 pm
Contact:

Re: The "How do I..." Thread

Post by silentzora »

Is there a method of determining what the target of a given actor is, and switching attack types accordingly? I'm goofing around with an automatic turret, and want to know if I can get it to launch anti-air missiles if the target is a Caco or something. Closest I've been able to find is A_CheckProximity, but if a Caco is in range, and the actual target is a Sergeant, the thing might launch a rocket at the wrong target.
User avatar
DoomKrakken
Posts: 3482
Joined: Sun Oct 19, 2014 6:45 pm
Location: Plahnit Urff
Contact:

Re: The "How do I..." Thread

Post by DoomKrakken »

Use CheckClass in a DECORATE expression, like so...

Code: Select all

Missile:
    TNT1 A 0 A_JumpIf(CheckClass("Cacodemon",AAPTR_TARGET,TRUE), "AntiAir")
    Goto FireBullets
AntiAir:
    TURR A 0 A_FaceTarget
    TURR A 0 A_CyberAttack
    TURR ABCDE 7
    TNT1 A 0 A_CPosReFire
    Loop
FireBullets:
    CPOS E 10 A_FaceTarget
    CPOS FE 4 bright A_CPosAttack
    CPOS F 1 A_CPosRefire
    Goto FireBullets+1
User avatar
silentzora
Posts: 450
Joined: Sun Jan 04, 2004 6:24 pm
Contact:

Re: The "How do I..." Thread

Post by silentzora »

Awesome, that's exactly what I'm looking for. Thanks!
User avatar
DoomKrakken
Posts: 3482
Joined: Sun Oct 19, 2014 6:45 pm
Location: Plahnit Urff
Contact:

Re: The "How do I..." Thread

Post by DoomKrakken »

No problem! ;)

By the way, you may want to omit the TRUE keyword in CheckClass if you're checking for the vanilla Cacodemon itself, if I remember correctly...
User avatar
Rip and Tear
Posts: 185
Joined: Tue May 02, 2017 3:54 pm

Re: The "How do I..." Thread

Post by Rip and Tear »

Going to post this again since it got buried at the end of the last page.

Is there any sort of pointer from a teleport fog to the actor that teleported?
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: The "How do I..." Thread

Post by Blue Shadow »

The teleporting actor becomes the target of the teleport fog.
User avatar
NeoTerraNova
Posts: 153
Joined: Tue Mar 14, 2017 5:18 pm
Location: Western North Southlandia (East Side)

Re: The "How do I..." Thread

Post by NeoTerraNova »

After experimenting with all three methods of inflicting damage-over-time via ACS, I'm stuck. Thanks to DoomKrakken, I can get the Scripts to activate when they should, but they're not doing what they ought to (inflict damage over time on the Player). I'm guessing I have the syntax completely wrong somewhere. Here's all three examples of what I've tried - any help figuring out where I'm going wrong would be greatly appreciated.

First attempt:

Code: Select all

Script "PoisonScript" (void) //Damage Script for venom/poison. Credit to DoomKrakken.
{
	SetActivator (AAPTR_TARGET);
	GiveInventory ("Recovery", 1); //This is working - it gives me the item repeatedly over time.
	damageactor (0,AAPTR_TARGET,0,AAPTR_NULL,3,"venom"); //Inflict 3 Damage. This isn't working at all.
	delay(35); //Do it about 1 time per second	
	restart;
}

Second attempt:

Code: Select all

Script "PoisonScript2" (void) //Damage Script for venom/poison. Credit to DoomKrakken.
{
	SetActivator (AAPTR_TARGET);
	GiveInventory ("Recovery", 1); //Again, this works.
	Thing_Damage(AAPTR_TARGET,3,"venom"); //Inflict 3 Damage. Again, this doesn't.
	delay(35); //Do it about 1 time per second	
	restart;
}
Third attempt:

Code: Select all

Script "PoisonScript3" (void) //Damage Script for venom/poison. Credit to DoomKrakken.
{
	SetActivator (AAPTR_TARGET);
	GiveInventory ("Recovery", 1); //Still works.
	Thing_Damage2(AAPTR_TARGET,3,"venom"); //Inflict 3 Damage. Still not works.
	delay(35); //Do it about 1 time per second	
	restart;
}
Of course, I want this to be reversible - If I give the Player an item that has the function of Terminate Script, I'm guessing this would stop it, but is there also a way to check and see if the Script is actually running, and thus prevent the Player from using the item if it isn't?
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: The "How do I..." Thread

Post by Blue Shadow »

In the first attempt, for DamageActor, change AAPTR_TARGET to AAPTR_DEFAULT. AAPTR_TARGET in that case means damage the script activator's target.
User avatar
NeoTerraNova
Posts: 153
Joined: Tue Mar 14, 2017 5:18 pm
Location: Western North Southlandia (East Side)

Re: The "How do I..." Thread

Post by NeoTerraNova »

Code: Select all

Script "PoisonScript" (void) //Damage Script for venom/poison. Credit to DoomKrakken & Blue Shadow.
{
	SetActivator (AAPTR_TARGET);
	GiveInventory ("Recovery", 1);
	damageactor (0,AAPTR_DEFAULT,0,AAPTR_NULL,3,"venom"); //Inflict 3 Damage
	delay(35); //Do it about 1 time per second	
	restart;
}
Thank you for the help, Blue Shadow.

I tested it, and it's still not working like it should. As before, I'm getting the Script to generate Recovery items in the Player's inventory, but the damage isn't being applied.
User avatar
NeoTerraNova
Posts: 153
Joined: Tue Mar 14, 2017 5:18 pm
Location: Western North Southlandia (East Side)

Re: The "How do I..." Thread

Post by NeoTerraNova »

I FIXED IT!

MAJOR, MAJOR THANKS to DoomKrakken and BlueShadow for their help. It turns out, in my last post, I hadn't set a TID for SetActivator. Now, though, I have another problem. I can't shut it off.

I thought I could get away with using ACS_NamedTerminate with an item, but it doesn't seem to be working. My intent is to have a storeable inventory item that the Player can pick up and save for later, that will "cure" their Poison state.

For reference, for anyone that needs it, here's my working "Poison" script.

Code: Select all

Script "PoisonScript" (void) //Damage Script for venom/poison. Major credit to DoomKrakken & Blue Shadow.
{
	SetActivator (0, AAPTR_TARGET);
	Thing_Damage2(AAPTR_DEFAULT,3,MOD_POISON); //Inflict 3 Damage
	delay(35); //Do it about 1 time per second	
	restart;
}
And here's the item I'm trying to use to stop the PoisonScript script.

Code: Select all

ACTOR Serum : CustomInventory

{
	Scale 0.125
	Inventory.MaxAmount 4
	Inventory.InterHubAmount 4
	Inventory.Icon "I_SRUM"
	Inventory.UseSound "meds/medium"
	Inventory.PickupSound "item/health_carry"
	Inventory.PickupMessage "Serum"
	Tag "Serum"
	+INVENTORY.INVBAR
	States
	{
	Spawn:
		SRUM A -1
		Loop
	Use:
	TNT1 A 0 ACS_NamedTerminate ("PoisonScript", 0)
	Stop
	}
}
User avatar
DoomKrakken
Posts: 3482
Joined: Sun Oct 19, 2014 6:45 pm
Location: Plahnit Urff
Contact:

Re: The "How do I..." Thread

Post by DoomKrakken »

Glad to help! :D

For future reference, instead of SetActivator(0, AAPTR_TARGET), you could instead do SetActivatorToTarget(0). That seems to be the only variant of SetActivator, currently.
User avatar
NeoTerraNova
Posts: 153
Joined: Tue Mar 14, 2017 5:18 pm
Location: Western North Southlandia (East Side)

Re: The "How do I..." Thread

Post by NeoTerraNova »

I appreciate the help very much. Any advice on how to get the "curative" item to work properly?
User avatar
DoomKrakken
Posts: 3482
Joined: Sun Oct 19, 2014 6:45 pm
Location: Plahnit Urff
Contact:

Re: The "How do I..." Thread

Post by DoomKrakken »

Why not have the serum give an inventory item upon use, and have the poison script check for said item and terminate if it finds it?
User avatar
NeoTerraNova
Posts: 153
Joined: Tue Mar 14, 2017 5:18 pm
Location: Western North Southlandia (East Side)

Re: The "How do I..." Thread

Post by NeoTerraNova »

Sounds like a plan. Would it be possible to edit the Poison script to, additionally, take away this fake inventory item when it gets activated? I'd rather not have a huge fake inventory full of "I've been cured of Poison" tags. That, and I'm afraid of a conflict (Get poisoned, get cured once, can't get poisoned again).

For the latter question, would attaching a "TakeInventory" action to the correct enemy's Poison-inflicting attack work?

If this all works as planned, of course, I intend to reproduce it for a "bleeding" effect.
Locked

Return to “Editing (Archive)”