I have a couple of questions about 1) type casting and 2) getting actors or classes from missile spawning functions.
1) Suppose a following example...
Code: Select all
Class MyDoomPlayer : DoomPlayer
{
int myCounter;
...
}
Class MyWeapon
{
(State 1)
{
MyDoomPlayer(players[0].mo).myCounter++;
}
}
While this works, it's a bit lengthy and cryptic if the "
MyDoomPlayer(players[0].mo)" - bit has to be used repeatedly when modifying the counter. Ok, I could simplify it this way:
Code: Select all
Class MyWeapon
{
(State 1)
{
let PLR = MyDoomPlayer(players[0].mo);
PLR.myCounter++;
}
}
But then PLR couldn't be seen in State 2, so now I would have to repeatedly write the "
let PLR = MyDoomPlayer(players[0].mo);" - line. So at this point I was thinking of trying the following:
Code: Select all
Class MyWeapon
{
MyDoomPlayer PLR;
override void BeginPlay()
{
PLR = MyDoomPlayer(players[0].mo);
Super.BeginPlay();
}
(State 1)
{
PLR.myCounter++;
}
(State 2)
{
PLR.myCounter++;
}
}
The above would be nice and short (in a way, heh) if it worked. But this produces an error saying "Self pointer used in ambiguous context; VM execution may abort!", and I don't know how to proceed from here. Of course, this is not a huge a problem as I have this working in one way, but it would nice to learn to do what I was attempting in the last code sample, if possible. I am also aware I could create the variable on the weapon itself and then access it using the "invoker." - prefix, but then I'm not sure how I would access and modify a variable on a player's weapon from some completely unrelated actor.
2) Is it possible to easily "get" or "create as" the actor created by A_FireProjectile, similar to what
[spawned, mo] = A_SpawnItemEx("MyCoolActor") does, or in some other way?