Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Melonpizza

Is there a way to base damage upon velocity? (in decorate)

Question

Hello

 

So if you read the title, i think that you have a question

 

1.What do you mean "Damage upon Velocity"?

like a way to take a Velocity number (x,z preferably), and make that the damage of (preferably) an Pushable actor

For example:

or Z= 1 - 1 melee damage

 

My question is:

1.Which Expression will do the job?

2. Which action function is the best for it?

1a. If not an expression, What else Will do?

 

It should take X and Z into consideration, Y is optional. And it is on an non-player actor which is no monster

 

Thanks

Share this post


Link to post

14 answers to this question

Recommended Posts

  • 0

Actually my question is: What are you looking for? Cause I couldn't really understand anything :/

You mean you want to throw/shoot a projectile/monster that will deal damage on impact equal to its velocity?

Share this post


Link to post
  • 0
15 hours ago, Kan3 said:

Actually my question is: What are you looking for? Cause I couldn't really understand anything :/

You mean you want to throw/shoot a projectile/monster that will deal damage on impact equal to its velocity?

Close, i want to make a Entity with the pushable Flag, and nofriction so it can be pushed better (because the Player will always slow down on Impact with the Entity, which i dont know how to Fix, sience the Player still has to be able to push it), and it shall attack Monsters by dealing "damage on impact equal to its velocity" (it would be neat to cap the Damage to like 1000 so you cant one-shot a cyberdemon) the Push and Entity part is already done btw

Share this post


Link to post
  • 0
23 minutes ago, ebigautisticnerd said:

Close, i want to make a Entity with the pushable Flag, and nofriction so it can be pushed better (because the Player will always slow down on Impact with the Entity, which i dont know how to Fix, sience the Player still has to be able to push it), and it shall attack Monsters by dealing "damage on impact equal to its velocity" (it would be neat to cap the Damage to like 1000 so you cant one-shot a cyberdemon) the Push and Entity part is already done btw

I see.
The only way to push entities and have them deal (and receive) damage on impact with something (wall or another entity) is with A_RadiusThrust or A_Blast, but unfortunately you cannot change the impact damage.
You could do the trick by using DamageThing.

 

It's quite tricky and I don't really know how to do it, but you could set the flag BUMPSPECIAL to the entity being pushed, with the Activation property aswell (go check for the flags you want, you'll gonna need at least THINGSPEC_TriggerActs to make it work) and lastly, the special itself that would be DamageThing, where you can define the damage (you can get the actor actual velocity just by using velx, vely and velz).

The real problem here is how you're going to call all this for any random actor you want to push... but if you have a custom actor for this, you should be fine (?)

Share this post


Link to post
  • 0
23 hours ago, Kan3 said:

I see.
The only way to push entities and have them deal (and receive) damage on impact with something (wall or another entity) is with A_RadiusThrust or A_Blast, but unfortunately you cannot change the impact damage.
You could do the trick by using DamageThing.

 

It's quite tricky and I don't really know how to do it, but you could set the flag BUMPSPECIAL to the entity being pushed, with the Activation property aswell (go check for the flags you want, you'll gonna need at least THINGSPEC_TriggerActs to make it work) and lastly, the special itself that would be DamageThing, where you can define the damage (you can get the actor actual velocity just by using velx, vely and velz).

The real problem here is how you're going to call all this for any random actor you want to push... but if you have a custom actor for this, you should be fine (?)

Well i have a coustom actor with no base (no monsters thing)

 

Also Where do i put the "Special"

Edited by ebigautisticnerd

Share this post


Link to post
  • 0
On 10/25/2021 at 3:44 PM, ebigautisticnerd said:

Well i have a coustom actor with no base (no monsters thing)

 

Also Where do i put the "Special"

Ok, than it should be already quite done (I guess).

I never really used special actions before yet, but you can use them like every other action functions, so, in this case, you should try to add a DamageThing in a frame of you spawn state of your custom actor.

Example: 

[...]
States
{
	Spawn:
		XXXX A 0 DamageThing
		Loop
}
       

 

Share this post


Link to post
  • 0
15 hours ago, Kan3 said:

Ok, than it should be already quite done (I guess).

I never really used special actions before yet, but you can use them like every other action functions, so, in this case, you should try to add a DamageThing in a frame of you spawn state of your custom actor.

Example: 


[...]
States
{
	Spawn:
		XXXX A 0 DamageThing
		Loop
}
       

 

Damagething(Velx|Vely|Velz)

is that right?

Share this post


Link to post
  • 0
2 hours ago, ebigautisticnerd said:

Damagething(Velx|Vely|Velz)

is that right?

Yes, you write your expression with Velx, y, z or all of the three and it's done (hopefully)

Share this post


Link to post
  • 0
22 hours ago, Kan3 said:

Yes, you write your expression with Velx, y, z or all of the three and it's done (hopefully)

Well exept its not

actor OfficeChair 6587
{
height 25
mass 30
radius 15
PushFactor 0.85
Activation THINGSPEC_TriggerActs|THINGSPEC_MonsterTrigger
+BUMPSPECIAL
+allowbounceonactors
+Slidesonwalls
+solid
+pushable
+jumpdown
+nofriction
states
{
spawn:
BCHA A 1 Damagething(Velx|Vely|Velz)
loop
	}
}

(The source code of the actor)

Share this post


Link to post
  • 0
13 minutes ago, ebigautisticnerd said:

Well exept its not


actor OfficeChair 6587
{
height 25
mass 30
radius 15
PushFactor 0.85
Activation THINGSPEC_TriggerActs|THINGSPEC_MonsterTrigger
+BUMPSPECIAL
+allowbounceonactors
+Slidesonwalls
+solid
+pushable
+jumpdown
+nofriction
states
{
spawn:
BCHA A 1 Damagething(Velx|Vely|Velz)
loop
	}
}

(The source code of the actor)

 

That's not how DamageThing works, see the wiki article on it here. It takes a single value that it applies as damage.

 

You need to separately retrieve the velocity of the Entity and use that to calculate a value that you feed to DamageThing.

 

I'm not a Decorate/ZScript expert, but there's a ZDoom Forum post here on getting an actor's velocity that should point you in the right direction. 

Share this post


Link to post
  • 0
5 hours ago, ebigautisticnerd said:

Well exept its not


actor OfficeChair 6587
{
height 25
mass 30
radius 15
PushFactor 0.85
Activation THINGSPEC_TriggerActs|THINGSPEC_MonsterTrigger
+BUMPSPECIAL
+allowbounceonactors
+Slidesonwalls
+solid
+pushable
+jumpdown
+nofriction
states
{
spawn:
BCHA A 1 Damagething(Velx|Vely|Velz)
loop
	}
}

(The source code of the actor)

Lol, I didn't know you meant THAT expression. That doesn't make any sense at all, the "|" operator cannot be used there.
I meant you need to write a mathematical expression there with velx etc.

Share this post


Link to post
  • 0

Ok, I made some test and it turns out that the BUMPSPECIAL flag doesn't work as I intended (the "bumpers" will take damage only they bump against the thing and not if the thing bumps against them, it could be useful for a kind of static spike thing etc. but this is not the case).

So I've thought about a trick:

Spoiler

Actor yyyy 
{
	height 25
	mass 30
	radius 15
	PushFactor 0.85
	Damage 0
	BounceType Doom
	+MISSILE
	+STRIFEDAMAGE
	+BOUNCEONACTORS
	+allowbounceonactors
	-BOUNCEONWALLS
	+Slidesonwalls
	+pushable
	+FLOORHUGGER
	+DROPOFF
	+nofriction
	var int user_tvel;
	states
	{
	spawn:
		TNT1 A 0 NoDelay {
		user_tvel = (velx + vely)/2;		
		}
		
		TNT1 A 0 {
		if(user_tvel > 0) {
			SetDamage(user_tvel);
			}
		}
		XXXX A 1
		Loop
	Death:	
		XXXX A 1 A_SpawnItemEx("yyyy", 0, 0, 0, velx, vely, velz, angle)
		Stop
	}
}

 

  • I've set the MISSILE flag on the actor, so that it can make use of the damage property
  • I've set the damage to 0, so that it won't deal damage when it's still
  • I've defined a int variable and given it a value equal to the thing velocity on both axis (divided by 2 cause otherwise it will deal too much damage for it to be a chair)
  • Then I keep changing it's damage using the SetDamage function with my variable as the damage value and looping
  • Since now it's a missile, I had to set up a Death state where it will spawn itself on death, or it will just disappear

I changed a couple of flags to better feet the class (JUMPDOWN flag it's completely pointless for actors who have no AI, you need to use DROPOFF, as well as ALLOWBOUNCEONACTOR won't make it bounce without BOUNONACTORS and defining the BounceType).

Now it works quite fine, the damage is a bit "buggy" for different reasons: the first one it's cause of the doom's inevitable randomized damage (that's why I add the STRIFEDAMAGE flag), the others are probably due to the bouncing behavior and the tricky way I'm using (I'm not that expert, like at all).

Now, I'd suggest you to learn the basics before trying to make something "advanced" like this, cause you clearly just started to deal with decorate's stuff and better study the wiki to understand what you're doing and what to use and modify.

Share this post


Link to post
  • 0
On 10/29/2021 at 12:05 PM, Kan3 said:

Ok, I made some test and it turns out that the BUMPSPECIAL flag doesn't work as I intended (the "bumpers" will take damage only they bump against the thing and not if the thing bumps against them, it could be useful for a kind of static spike thing etc. but this is not the case).

So I've thought about a trick:

  Hide contents


Actor yyyy 
{
	height 25
	mass 30
	radius 15
	PushFactor 0.85
	Damage 0
	BounceType Doom
	+MISSILE
	+STRIFEDAMAGE
	+BOUNCEONACTORS
	+allowbounceonactors
	-BOUNCEONWALLS
	+Slidesonwalls
	+pushable
	+FLOORHUGGER
	+DROPOFF
	+nofriction
	var int user_tvel;
	states
	{
	spawn:
		TNT1 A 0 NoDelay {
		user_tvel = (velx + vely)/2;		
		}
		
		TNT1 A 0 {
		if(user_tvel > 0) {
			SetDamage(user_tvel);
			}
		}
		XXXX A 1
		Loop
	Death:	
		XXXX A 1 A_SpawnItemEx("yyyy", 0, 0, 0, velx, vely, velz, angle)
		Stop
	}
}

 

  • I've set the MISSILE flag on the actor, so that it can make use of the damage property
  • I've set the damage to 0, so that it won't deal damage when it's still
  • I've defined a int variable and given it a value equal to the thing velocity on both axis (divided by 2 cause otherwise it will deal too much damage for it to be a chair)
  • Then I keep changing it's damage using the SetDamage function with my variable as the damage value and looping
  • Since now it's a missile, I had to set up a Death state where it will spawn itself on death, or it will just disappear

I changed a couple of flags to better feet the class (JUMPDOWN flag it's completely pointless for actors who have no AI, you need to use DROPOFF, as well as ALLOWBOUNCEONACTOR won't make it bounce without BOUNONACTORS and defining the BounceType).

Now it works quite fine, the damage is a bit "buggy" for different reasons: the first one it's cause of the doom's inevitable randomized damage (that's why I add the STRIFEDAMAGE flag), the others are probably due to the bouncing behavior and the tricky way I'm using (I'm not that expert, like at all).

Now, I'd suggest you to learn the basics before trying to make something "advanced" like this, cause you clearly just started to deal with decorate's stuff and better study the wiki to understand what you're doing and what to use and modify.

well im not bad at coding, this is just a "see, implement and dont look further" (this time ist "anomynous functions" and co) of me, but stilll thanks (i always feel like a clown if i post my spagetti code on the internet tbh)

 

Also has this been playtested?, because when i touch the actor to push it. i just go straight trough

Edited by ebigautisticnerd

Share this post


Link to post
  • 0
9 hours ago, ebigautisticnerd said:

well im not bad at coding, this is just a "see, implement and dont look further" (this time ist "anomynous functions" and co) of me, but stilll thanks (i always feel like a clown if i post my spagetti code on the internet tbh)

 

Also has this been playtested?, because when i touch the actor to push it. i just go straight trough

Oh, ok, I see.
You shouldn't, everyone has surely posted in their career something "spaghettiful" here x)

Yeah, here's a video (I've used the stalagtite sprites just fro test) 

EDIT: Dammit, i just noticed it didn't pasted the +SOLID flag in the code I gave you, sorry! Just add it to the flags list and it'll work

Share this post


Link to post
  • 0
On 10/31/2021 at 9:02 AM, Kan3 said:

Oh, ok, I see.
You shouldn't, everyone has surely posted in their career something "spaghettiful" here x)

Yeah, here's a video (I've used the stalagtite sprites just fro test) 

EDIT: Dammit, i just noticed it didn't pasted the +SOLID flag in the code I gave you, sorry! Just add it to the flags list and it'll work

Ah!, Happens. Thank you very much

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×