need help with custom spectator class

Discussions about Coding and Scripting

need help with custom spectator class

Postby OwYeaW » Mon Mar 05, 2018 8:22 am

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: https://pastebin.com/Exp74niT
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 :)
Last edited by OwYeaW on Sun Mar 11, 2018 11:12 pm, edited 1 time in total.
OwYeaW
Average
 
Posts: 56
Joined: Fri Jan 09, 2015 4:24 pm

Re: need help with custom spectator class

Postby ShaiHulud » Tue Mar 06, 2018 2:20 am

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.
ShaiHulud
Adept
 
Posts: 341
Joined: Sat Dec 22, 2012 6:37 am

Re: need help with custom spectator class

Postby Barbie » Tue Mar 06, 2018 5:14 pm

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.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Barbie
Godlike
 
Posts: 1463
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: need help with custom spectator class

Postby OwYeaW » Sat Mar 10, 2018 4:13 pm

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: https://pastebin.com/Exp74niT
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
OwYeaW
Average
 
Posts: 56
Joined: Fri Jan 09, 2015 4:24 pm


Return to Coding, Scripting

Who is online

Users browsing this forum: No registered users and 1 guest