Page 1 of 1

need help with custom spectator class

Posted: Mon Mar 05, 2018 8:22 am
by OwYeaW
hey guys, im creating a custom spectator class and ran into a very strange problem:

my customized Fire and AltFire functions are being overridden by something else, and i have no idea where it comes from
i was told that i should look into the playerpawn states, and indeed there are Fire and AltFire functions inside them
but, even after overwriting all these states inside my own custom spectator class, the problem is still happening

this is the class:

Code: Select all

class BTSpectator expands CHSpectator;
 
replication
{
    reliable if(Role < ROLE_Authority)
        WTF;
}
 
exec function Fire(optional float F)
{
    WTF();
    ClientMessage   ("XXXXX Fire Original");
    Log             ("XXXXX Fire Original");
}
 
exec function AltFire(optional float F)
{
    WTF();
    ClientMessage   ("XXXXX AltFire Original");
    Log             ("XXXXX AltFire Original");
}
 
simulated function WTF()
{
    ClientMessage   ("XXXXX WTF");
    Log             ("XXXXX WTF");
}
my custom Fire/AltFire functions do seem to work in the first second after entering the server, then after this second the Fire/AltFire functions become something else:
the Fire function works as in the original CHSpectator
and the AltFire function only seems to trigger ViewSelf(), i couldnt find any trace of logic about why ViewSelf() is triggered

so i have been trying many different things, but now i seriously dont know wtf to do
i hope someone knows whats going wrong, help is very much appreciated :)

Re: need help with custom spectator class

Posted: Tue Mar 06, 2018 2:20 am
by ShaiHulud
Sorry OwYeaW, it's been about 5 months since I did any scripting, so I feel pretty rusty. But have you looked at Higor's enhanced spectator? Perhaps it might yield something informative.

Re: need help with custom spectator class

Posted: Tue Mar 06, 2018 5:14 pm
by Barbie
I had a quick look at the above code and got the impression that it is copied from several parent objects? Better use inheritance... It's also easier to see your modifications then.

Re: need help with custom spectator class

Posted: Sat Mar 10, 2018 4:13 pm
by OwYeaW
ShaiHulud wrote:Sorry OwYeaW, it's been about 5 months since I did any scripting, so I feel pretty rusty. But have you looked at Higor's enhanced spectator? Perhaps it might yield something informative.
i noticed that the same problem is happening with Higor's XC_Spec_r10, its custom AltFire is being overwritten
im running a vanilla server with no other things than this spectator mutator
Barbie wrote:I had a quick look at the above code and got the impression that it is copied from several parent objects? Better use inheritance... It's also easier to see your modifications then.
a lot of functions are taken from parent classes, but are modified/simplified

now ive made the class very simple, with only the Fire/AltFire functions, and the problem is still occuring
this is the class:

Code: Select all

class BTSpectator expands CHSpectator;
 
replication
{
    reliable if(Role < ROLE_Authority)
        WTF;
}
 
exec function Fire(optional float F)
{
    WTF();
    ClientMessage   ("XXXXX Fire Original");
    Log             ("XXXXX Fire Original");
}
 
exec function AltFire(optional float F)
{
    WTF();
    ClientMessage   ("XXXXX AltFire Original");
    Log             ("XXXXX AltFire Original");
}
 
simulated function WTF()
{
    ClientMessage   ("XXXXX WTF");
    Log             ("XXXXX WTF");
}
im sure that im not the first person to make a custom spectator class, so i think there should be others that noticed this issue with the Fire/AltFire functions