I have a piece of code I've made that works, involving polymorphism behaviour and I'm actually suprised it works out of the box. So, I would like to know if it is normal behaviour or if I'm very lucky here.
I have a base actor :
Code: Select all
class Z_Headshot : Actor
{
...
}
Code: Select all
class Z_Headshot_Green : Z_Headshot
{
Default
{
BloodType "Green_Blood", "GreenSawBlood", "GreenSawBlood";
BloodColor "DarkGreen";
}
}
Later, I instantiate one or the other depending of some condition:
Code: Select all
Z_Headshot hs;
if (...) {
hs = Z_Headshot(Spawn("Z_Headshot_Green", Owner.Pos, NO_REPLACE));
} else {
hs = Z_Headshot(Spawn("Z_Headshot", Owner.Pos, NO_REPLACE));
}
Code: Select all
self.myHeadshot = hs;
That polymorphism is just what I wanted but I wonder if it is intended behaviour or just luck.
Thanks !