Jump to content

Make actor spawn item based on player inventory


Recommended Posts

I'm trying to take a Pentagram actor from a mod and have it spawn the Unmaker...unless you already have the Unmaker.  How do I have the Pentagram do a player inventory check when it spawns to determine what it spawns in turn?  The following does not seem to work:

 

ACTOR BDECPentagram 25856
{
    +NOBLOCKMAP
    +NOTELEPORT
    +DONTSPLASH
	+FORCEXYBILLBOARD
    +CLIENTSIDEONLY
    +NOCLIP
	-NOGRAVITY
	RenderStyle Translucent
    XScale 0.3
	YScale 0.1
	Alpha 1
	Gravity 1
	Radius 1
	Height 1
	States
	{
    Spawn:
	See:
		TNT1 A  0 A_JumpIfInTargetInventory("Unmaker", 1, "Upgrade1")
        PNTG B 1 BRIGHT
		TNT1 A 0 A_SpawnItemEx("CandleStick", 26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 0, -40, 0)
		TNT1 A 0 A_SpawnItemEx("Unmaker", 0, 0, 0)
		PNTG B -1 BRIGHT
        Stop
	Upgrade1:
        PNTG B 1 BRIGHT
		TNT1 A 0 A_SpawnItemEx("CandleStick", 26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 0, -40, 0)
		TNT1 A 0 A_SpawnItemEx("UnmakerUpgrade1", 0, 0, 0)
		PNTG B -1 BRIGHT
	}
}

 

Share this post


Link to post

It's not working because this thing has no target.

To make it acquire the player as a target, you can for example give it the MONSTER flag and repeatedly call for A_Look in its spawn state (like a normal monster would) and then do the target check (you may want to spawn the candles before the check though).

Share this post


Link to post

Ah, thanks.  I was wondering.  I added the MONSTER flag, had it spawn right into a see state and used A_Chase, but that didn't work.  A_Look will work better?

Share this post


Link to post

A_Chase it's useless here, because again it's missing a target. A_Look only serves (in this case) to find a proper target (in this case, the player).

You could even go for A_LookEx if you need more features

Share this post


Link to post

Well this spawns the Pentagram without the candles, the Unmaker or the upgrade, every time.  Where did I mess up now?

 

ACTOR BDECPentagram 25856
{
    +NOBLOCKMAP
    +NOTELEPORT
    +DONTSPLASH
	+FORCEXYBILLBOARD
    +CLIENTSIDEONLY
    +NOCLIP
	-NOGRAVITY
	+ISMONSTER
	RenderStyle Translucent
    XScale 0.3
	YScale 0.1
	Alpha 1
	Gravity 1
	Radius 1
	Height 1
	States
	{
    Spawn:
	PNTG B 1 BRIGHT A_Look
	TNT1 A  0 A_JumpIfInTargetInventory("Unmaker", 1, "Upgrade1")
	PNTG B 1 BRIGHT A_Look
	Loop
	See:
		PNTG B 1 BRIGHT
		TNT1 A 0 A_SpawnItemEx("CandleStick", 26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 0, -40, 0)
		TNT1 A 0 A_SpawnItemEx("Unmaker", 0, 0, 0)
		PNTG B -1 BRIGHT
        Stop
	Upgrade1:
        PNTG B 1 BRIGHT
		TNT1 A 0 A_SpawnItemEx("CandleStick", 26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 0, -40, 0)
		TNT1 A 0 A_SpawnItemEx("UnmakerUpgrade1", 0, 0, 0)
		PNTG B -1 BRIGHT
	}
}

 

Share this post


Link to post
TNT1 A  0 A_JumpIfInTargetInventory("Unmaker", 1, "Upgrade1")

This will never be called, because, again, this thing has no target. I sent you the link to the functions because you were supposed to read them...

And you're missing a Stop in the Upgrade1 State

 

Anyhow, I tested it with a slightly more polished code and it works perfectly fine, so my guess is that you're testing it "wrong".

I gave you the link to A_LookEx for a reason and that is because with that you can set the fov of the thing; since normal monsters have a limited fov, they won't normally be able to see what's behind them and my guess is that you're coming from behind the pentagram.

 

If you want to stick with A_Look, fine, add the LOOKALLAROUND flag and you're done.

This is the cleaner code I used:

Spoiler

States
	{
	Spawn:
		PNTG B 1 BRIGHT A_Look
		Loop
	See:
		TNT1 A 0 A_SpawnItemEx("CandleStick", 26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -26, 25, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", -40, -15, 0)
		TNT1 A 0 A_SpawnItemEx("CandleStick", 0, -40, 0)
		TNT1 A 0 A_JumpIfInTargetInventory("Unmaker", 1, "Upgrade1")
		TNT1 A 0 A_SpawnItemEx("Unmaker", 0, 0, 0)
		PNTG B -1 BRIGHT
        Stop
	Upgrade1:
		TNT1 A 0 A_SpawnItemEx("UnmakerUpgrade1", 0, 0, 0)
		PNTG B -1 BRIGHT
		Stop
	}

 

 

Share this post


Link to post
1 hour ago, Kan3 said:

 I sent you the link to the functions because you were supposed to read them...

 

I gave you the link to A_LookEx for a reason

 

  Hide contents

 

It works!  Thanks for the help.  But I am a mere mortal.  I did read your link and I did check out A_Look.  I didn't see what I could do with either despite your advice.

 

Share this post


Link to post
7 hours ago, rabidrage said:

 

No problem!

Mine was pointed toward the fact that A_Look makes the monster directly jump to the See state, like the wiki says, when the conditions are met, acquiring a target, so everything else that needs a target to work in the Spawn state will never be executed.

Share this post


Link to post
2 hours ago, Kan3 said:

No problem!

Mine was pointed toward the fact that A_Look makes the monster directly jump to the See state, like the wiki says, when the conditions are met, acquiring a target, so everything else that needs a target to work in the Spawn state will never be executed.

 

I think that sums up my confusion as well.  I wanted to use A_Look, but I wanted the actor to behave as though it had spawned that way (with the expected item spawned on top of it).  So then it became a question of having it see the player before the player sees it, and I know LookAllAround is good for that, but you still have to have line of sight...

 

...perhaps I overthought the whole thing.

Share this post


Link to post

Everything rises because of the limit of the need of having a target and (from what I know), there's no way to acquire one without a possible line of sight or hearing it.

You can spawn the candles in the spawn state, since they don't require a target if you want.

 

Although, you can use a more complex "trick" that require ACS to directly check the player inventory and so spawn the according item without the need of a target or anything else.

You would need to give the player a TID once he enters the map and make the pentagram to repeatedly check the inventory (and the "existence") of that specific player in the map.

 

If you want to try it, I'll see if it's possible in DECORATE (or even if I can pull it off)  

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...