so I pulled this code from https://zdoom.org/wiki/Converting_DECOR ... to_ZScript, I understand it well but the problem is it seems to have trouble with the "extend class Actor" it returns " line 6: Class Actor cannot be found in the current translation unit." so how would I convert this A_Dothis action and still have it usable to the entire cast of monsters and actors?
//===========================================================================
//
// Code (must be attached to Actor)
//
//===========================================================================
extend class Actor
{
void A_HeadAttack()
{
if (target)
{
if (CheckMeleeRange())
{
int damage = random[pr_headattack](1, 6) * 10;
A_PlaySound (AttackSound, CHAN_WEAPON);
int newdam = target.DamageMobj (self, self, damage, "Melee");
target.TraceBleed (newdam > 0 ? newdam : damage, self);
}
else
{
// launch a missile
SpawnMissile (target, "CacodemonBall");
}
}
}
}
Learning zscript possible bad example given
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!)
- PlayTheDemO65
- Posts: 5
- Joined: Mon May 25, 2020 1:26 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: Learning zscript possible bad example given
You can extend only classes that defined in same pack.
Actor class defined in gzdoom.pack, so you cant extend it in you mod.pack because its in separate pack.
And if you want to change how A_HeadAttack() works, you cant do so. Its not virtual so you cant redefine it.
If you want change something in it and use in you mod, all you can do is copy it into you mod, change it there and then use it at place of old a_headattack().
Actor class defined in gzdoom.pack, so you cant extend it in you mod.pack because its in separate pack.
And if you want to change how A_HeadAttack() works, you cant do so. Its not virtual so you cant redefine it.
If you want change something in it and use in you mod, all you can do is copy it into you mod, change it there and then use it at place of old a_headattack().
- PlayTheDemO65
- Posts: 5
- Joined: Mon May 25, 2020 1:26 pm
- Graphics Processor: nVidia (Modern GZDoom)