Changing Velocity of player when hit by Monster
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!)
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!)
- Aerosplinter
- Posts: 98
- Joined: Wed Feb 01, 2017 2:14 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
Changing Velocity of player when hit by Monster
Is it possible to change the velocity of the player so that he goes up whenever he is hit, for example, by an uppercut of the enemy?
Re: Changing Velocity of player when hit by Monster
Code: Select all
override void damagemobj(actor inflictor, actor source, int damage, name mod, int flags=0, double angle)
{
if(mod == 'uppercut')
{
self.vel.z += 50;
}
return super.damagemobj(inflictor, source, damage, mod, flags,angle
}
Re: Changing Velocity of player when hit by Monster
Wouldn't it be better if you coded the functionality in to the monster? Maybe something like:
It would make it so that it launches enemies in infights as well.
Code: Select all
TROO A 5 A_DoThing();
TROO A 0 A_AttackThing();
TROO A 0 { target.vel.z += 50; }
- Aerosplinter
- Posts: 98
- Joined: Wed Feb 01, 2017 2:14 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
Re: Changing Velocity of player when hit by Monster
Is this code Decorate or ZScript?Tartlman wrote:Wouldn't it be better if you coded the functionality in to the monster? Maybe something like:
It would make it so that it launches enemies in infights as well.Code: Select all
TROO A 5 A_DoThing(); TROO A 0 A_AttackThing(); TROO A 0 { target.vel.z += 50; }
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Changing Velocity of player when hit by Monster
If it has semicolons after the state function calls it's ZScript.
- Aerosplinter
- Posts: 98
- Joined: Wed Feb 01, 2017 2:14 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
Re: Changing Velocity of player when hit by Monster
Would something similar to this also work with DECORATE, but modified to fit DECORATE's language?Tartlman wrote:Wouldn't it be better if you coded the functionality in to the monster? Maybe something like:
It would make it so that it launches enemies in infights as well.Code: Select all
TROO A 5 A_DoThing(); TROO A 0 A_AttackThing(); TROO A 0 { target.vel.z += 50; }
- Dan_The_Noob
- Posts: 880
- Joined: Tue May 07, 2019 12:24 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: Changing Velocity of player when hit by Monster
you could put a A_ChangeVelocity into the player pain state or something?
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Changing Velocity of player when hit by Monster
[wiki]A_ChangeVelocity[/wiki] takes a pointer so the imp can do it to its target in that state.