by phantombeta » Wed Jul 26, 2017 2:33 am
Vaecrius wrote:Why can I not call SetStateLabel, FindState, etc. from a static function?
This will always hard crash on startup:
Code: Select all
struct HDMobStatic play{
static void HDA_Chase(actor self,actor movetarget=null){
if(!self.target||self.target.health<random(-5,1)){
self.target=null;
self.setstatelabel("spawn");
return;
}
/*
vector3 totarget=self.target.pos-self.pos;
...
*/
}
}
For some reason, calling SetStateLabel from a static function crashes GZDoom on startup.
Here's a better example:
Code: Select all
version "2.4"
struct SSLCrashTest play {
static void SSLCrashTestFunc (Actor act) {
act.SetStateLabel ("Spawn");
}
}
You don't need to actually call the function anywhere, just have it in a ZScript file.
Apparently if you change it from a struct to an actor it doesn't crash.
Even if you're not supposed to do that, GZDoom shouldn't crash.
[quote="Vaecrius"]Why can I not call SetStateLabel, FindState, etc. from a static function?
This will always hard crash on startup:[code]struct HDMobStatic play{
static void HDA_Chase(actor self,actor movetarget=null){
if(!self.target||self.target.health<random(-5,1)){
self.target=null;
self.setstatelabel("spawn");
return;
}
/*
vector3 totarget=self.target.pos-self.pos;
...
*/
}
}[/code][/quote]
For some reason, calling SetStateLabel from a static function crashes GZDoom on startup.
Here's a better example:
[code]
version "2.4"
struct SSLCrashTest play {
static void SSLCrashTestFunc (Actor act) {
act.SetStateLabel ("Spawn");
}
}[/code]
You don't need to actually call the function anywhere, just have it in a ZScript file.
Apparently if you change it from a struct to an actor it doesn't crash.
Even if you're not supposed to do that, GZDoom shouldn't crash.