[Resolved]What's wrong with my ball?

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.
Locked
User avatar
Chl
Posts: 219
Joined: Sat Dec 05, 2015 2:18 pm

[Resolved]What's wrong with my ball?

Post by Chl »

I can't get it to work as I want it too. Whenever the player hits it with a punch I want it to bounce away in the direction the player is facing. But there are 2 problems.

1. I don't think it ever gets the player as its master since it just moves in 2 directions when you hit it. And I don't know much about pointers to spot why.

2. After it has hit a wall a couple of times it just disappears. Never the first time it hits a wall but on the 2nd or 3rd time. Why? I know it does not have a solid flag right now but that makes no difference.

Code: Select all

actor Ball 10000
{
	Radius 4
   Height 4
	Health 10000
	Friction 1
	PainChance 256
	+SHOOTABLE
	+NODAMAGE
	+ALLOWPAIN
	+DONTTHRUST
	+NOBLOOD
	+BOUNCEONWALLS
	+BOUNCEONFLOORS
	+BOUNCEONCEILINGS
	+ALLOWBOUNCEONACTORS
	+BOUNCEAUTOOFFFLOORONLY
	+BOUNCEONACTORS
	+MBFBOUNCER
	+FORCEXYBILLBOARD
	States
	{
	Spawn:
		eyeb a 0 nodelay A_RearrangePointers(AAPTR_DEFAULT, AAPTR_PLAYER1, AAPTR_DEFAULT)
		
	Idle:
		eyeb a -1 
		
	Pain:
		eyeb a 1 A_FaceMaster(0, 270, 180, 0, 0, 0)
		eyeb a 1 A_ChangeVelocity(16, 0, 16, CVF_RELATIVE | CVF_REPLACE)
		goto Idle
		
	Death:
		eyab a 0 
		goto Idle
	}
}
Last edited by Chl on Sun Jul 24, 2016 3:17 pm, edited 1 time in total.
User avatar
comet1337
Posts: 876
Joined: Fri Sep 25, 2015 3:48 am
Location: elsewhere

Re: What's wrong with my ball?

Post by comet1337 »

i believe you need a 'stop' after 'eyeb a -1'
and i think actors turn their attacker into their target
and try removing +mbfbouncer since you already have all the other bounce flags
User avatar
Chl
Posts: 219
Joined: Sat Dec 05, 2015 2:18 pm

Re: What's wrong with my ball?

Post by Chl »

comet1338 wrote:i believe you need a 'stop' after 'eyeb a -1'
No, it's not needed and it would remove the actor if its reached.
comet1338 wrote:and i think actors turn their attacker into their target
Maybe, but it still doesn't make it work.
comet1338 wrote:and try removing +mbfbouncer since you already have all the other bounce flags
If I remove any of those flags it stops bouncing.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: What's wrong with my ball?

Post by NeuralStunner »

comet1338 wrote:i believe you need a 'stop' after 'eyeb a -1'
Stop, loop, or wait, it doesn't really matter as it's an infinite frame (-1). But something, because not terminating states is a horrifically bad habit.
User avatar
Chl
Posts: 219
Joined: Sat Dec 05, 2015 2:18 pm

Re: What's wrong with my ball?

Post by Chl »

NeuralStunner wrote:
comet1338 wrote:i believe you need a 'stop' after 'eyeb a -1'
Stop, loop, or wait, it doesn't really matter as it's an infinite frame (-1). But something, because not terminating states is a horrifically bad habit.
How is that a bad habit? I use it all the time for one time setups since when it reaches the end it jumps to the next state. Never had a problem with it.

But that is not what this thread is about but "why does the actor randomly get removed when hitting a wall and why doesn't it make the player its master"?
User avatar
InsanityBringer
Posts: 3392
Joined: Thu Jul 05, 2007 4:53 pm
Location: opening the forbidden box

Re: What's wrong with my ball?

Post by InsanityBringer »

From the looks of things, AAPTR_PLAYER1 isn't allowed in this context (A_RearrangePointers, looking at the zd source, really just seems to do what it says on the tin and rearrange pointers. The wiki's list of valid pointers seems to confirm this).

Replacing the A_FaceMaster call with A_FaceTarget seemed to work on my end.

As for the ball vanishing, its not actually vanishing, but it seems to be leaving the map! I'm not quite sure what's going on there.
User avatar
Chl
Posts: 219
Joined: Sat Dec 05, 2015 2:18 pm

Re: What's wrong with my ball?

Post by Chl »

InsanityBringer wrote:From the looks of things, AAPTR_PLAYER1 isn't allowed in this context (A_RearrangePointers, looking at the zd source, really just seems to do what it says on the tin and rearrange pointers. The wiki's list of valid pointers seems to confirm this).

Replacing the A_FaceMaster call with A_FaceTarget seemed to work on my end.
Thanks for explaining that. But your solution is something I already tried but with no success. Can I see your code?
InsanityBringer wrote:As for the ball vanishing, its not actually vanishing, but it seems to be leaving the map! I'm not quite sure what's going on there.
Yes I started to suspect that. Maybe its time for a bug report?
User avatar
InsanityBringer
Posts: 3392
Joined: Thu Jul 05, 2007 4:53 pm
Location: opening the forbidden box

Re: What's wrong with my ball?

Post by InsanityBringer »

This is all I did for the A_FaceTarget thing. It seems to work right: (note the sprites were changed for local testing)

Code: Select all

    Pain:
        BAL2 B 1
        BAL2 B 0 A_FaceTarget(0, 270, 180)
        BAL2 a 1 A_ChangeVelocity(-16, 0, 16, CVF_RELATIVE | CVF_REPLACE)
        goto Idle
It looks like a single frame has to be injected in there or else it won't work right on the first hit. I guess it sets the state and calls the A_FaceTarget call before setting the target pointer. Doom is weird sometimes.

As for the leaving the map thing, I'm honestly not sure. Might be a case of the thing moving faster than its radius would allow? I don't know.
User avatar
Chl
Posts: 219
Joined: Sat Dec 05, 2015 2:18 pm

Re: What's wrong with my ball?

Post by Chl »

InsanityBringer wrote:This is all I did for the A_FaceTarget thing. It seems to work right: (note the sprites were changed for local testing)

Code: Select all

    Pain:
        BAL2 B 1
        BAL2 B 0 A_FaceTarget(0, 270, 180)
        BAL2 a 1 A_ChangeVelocity(-16, 0, 16, CVF_RELATIVE | CVF_REPLACE)
        goto Idle
It looks like a single frame has to be injected in there or else it won't work right on the first hit. I guess it sets the state and calls the A_FaceTarget call before setting the target pointer. Doom is weird sometimes.

As for the leaving the map thing, I'm honestly not sure. Might be a case of the thing moving faster than its radius would allow? I don't know.
Great, thanks a lot. This fixed both problems. :)

Well. sort of anyway. By making the radius bigger it fixed the problem of going outside the map, but now its much bigger then the actual sprite. Adding the missile flag fixed that but added the problem that it would not be affected by friction. :shrug:
User avatar
Chl
Posts: 219
Joined: Sat Dec 05, 2015 2:18 pm

Re: What's wrong with my ball?

Post by Chl »

So after some more fiddling I've gotten the ball to behave as intended, for now. :mrgreen:

Code: Select all

actor Ball 10000
{
	Radius 4
    Height 4
	Health 10000
	Friction 1
	PainChance 256
	Mass 100
	Gravity 0.6
	+Missile
	+Solid
	+SHOOTABLE
	+NODAMAGE
	+ALLOWPAIN
	+DONTTHRUST
	+NOBLOOD
	+BOUNCEONWALLS
	+BOUNCEONFLOORS
	+BOUNCEONCEILINGS
	+ALLOWBOUNCEONACTORS
	+BOUNCEAUTOOFF
	+BOUNCEONACTORS
	+MBFBOUNCER
	+FORCEXYBILLBOARD
	States
	{
	Spawn:
		eyeb a 0
		{
		A_Changeflag("Missile", true);
		A_Changeflag("SHOOTABLE", true);
		}
		
	Idle:
		eyeb a 1
		{
		if ((z - floorz) < 1)
			{
				A_ScaleVelocity(0.95);
			}
		else
			{
			}
		}
		loop
		
	Pain:
		eyeb a 1 
		eyeb a 0 
		{
		A_FaceTarget(0, 270, 180);
		A_ChangeVelocity(16, 0, 16, CVF_RELATIVE | CVF_REPLACE);
		}
		goto Idle
		
	Death:
		eyab a 0 
		goto Spawn
	}
}
	
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: What's wrong with my ball?

Post by NeuralStunner »

Chl wrote:How is that a bad habit? I use it all the time for one time setups since when it reaches the end it jumps to the next state. Never had a problem with it.
I'm talking about this:

Code: Select all

   Idle:
      eyeb a -1

If it's not intended to fall through, it needs to be terminated. Not because it "hurts anything", but because it's good practice.

If you've ever had to debug an actor that's falling out of its own state table, you'll understand why this is something that shouldn't be missed.)
User avatar
Chl
Posts: 219
Joined: Sat Dec 05, 2015 2:18 pm

Re: [Resolved]What's wrong with my ball?

Post by Chl »

Makes sense. Thought you meant it was always a bad idea.
Locked

Return to “Editing (Archive)”