im trying to add an attack similar to a pain elemental where it shoots another enemy at the player. the problem im having with doing this is the actor fails to spawn because its in the same place as the enemy spawning it. is there any way to offset the actor being spawned based on the angle its facing when spawned?
heres my code by the way (ignore everything before the "launch a missile" comment thats just leftover from the original enemy's code)
extend class NewBaron
{
void A_BruisAttack()
{
let targ = target;
if (targ)
{
if (CheckMeleeRange())
{
int damage = random[pr_bruisattack](1, 8) * 10;
A_StartSound ("baron/melee", CHAN_WEAPON);
int newdam = target.DamageMobj (self, self, damage, "Melee");
targ.TraceBleed (newdam > 0 ? newdam : damage, self);
}
else
{
// launch a missile
Actor pain = SpawnMissile (target, "PainElemental");
if (pain)
{
pain.angle = angle;
}
}
}
}
}
offset spawned actor based on angle being faced
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!)
- choruscory
- Posts: 2
- Joined: Sat Sep 23, 2023 3:10 pm
- Preferred Pronouns: She/Her
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
Re: offset spawned actor based on angle being faced
To get an offset based on the angle, use AngleToVector:
Vector2 offset = AngleToVector(angle,amount); //angle is the angle to use, leaving it as "angle" will use the monster's angle, while amount is the offset
However SpawnMissile doesn't look like it can accept an offset, nor do I think it will work well with a non-projectile based actor.
The original function uses Spawn, after which it checks a bunch of things before calling A_SkullAttack from the spawned actor.
Your best bet is to copy that function instead and edit it, it can be found in gzdoom.pk3:zscript/actors/doom/painelemental.zs at lines 69-195.
Alternatively you can just use A_PainAttack for this.
Vector2 offset = AngleToVector(angle,amount); //angle is the angle to use, leaving it as "angle" will use the monster's angle, while amount is the offset
However SpawnMissile doesn't look like it can accept an offset, nor do I think it will work well with a non-projectile based actor.
The original function uses Spawn, after which it checks a bunch of things before calling A_SkullAttack from the spawned actor.
Your best bet is to copy that function instead and edit it, it can be found in gzdoom.pk3:zscript/actors/doom/painelemental.zs at lines 69-195.
Alternatively you can just use A_PainAttack for this.
- choruscory
- Posts: 2
- Joined: Sat Sep 23, 2023 3:10 pm
- Preferred Pronouns: She/Her
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
Re: offset spawned actor based on angle being faced
oh, i have no clue how i didnt notice that when looking through the pain elemental's code. thanks