PDA

View Full Version : Player won't die?!



serthy
6th January 2013, 13:17
Hey,

I got into troubles with my modified Callback_PlayerDamage()

i call this:

player thread [[level.callbackPlayerDamage]]( self , player , player.health + 666 , 0 , "MOD_SUICIDE" , "none" , player.origin , ( 0 , 0 , 1 ) , "none" , 0 );on a player, the health drops down to 0 (finishPlayerDamage() is triggered) but the player is still alive!
the Callback_PlayerKilled() isn't called at all! >>> isAlive() turns false, the sessionstate remains on "playing"

SO: why the Callback_PlayerKilled() is not called and therefore the player will not die despite the fact that finishPlayerDamage() ran before?


EDIT:
added a 0.05s delay before the [[level.callbackPlayerDamage]](), fixed it, but its not solved at all...
before i aplied the damage i set a new playermodel, unlinked the player and enabled the weapons, since the player was a driver of a vehicle...
i guess the game needs a delay between re-model and the damagefunc

kung foo man
6th January 2013, 13:36
I guess you change the value of this function-pointer somewhere to a buggy Callback_PlayerKilled()?



[[level.callbackPlayerDamage]]

You could search with Notepad++ "In Files", so every script will be searched. I guess you would find a non-wanted change of the function-pointer.

Besides that, you could try to call the Callback_PlayerKilled() directly:



player thread maps\mp\gametypes\zom::Callback_PlayerKilled( self , player , player.health + 666 , 0 , "MOD_SUICIDE" , "none" , player.origin , ( 0 , 0 , 1 ) , "none" , 0 );


This could work instantly but it would be a bad style, because the reference to the "zom"-script would be hardcoded. The function-callback-pointers in "level" are basically exporting the functions, so e.g. map-scripts can access them (i always export functions like spawnplayer() also).

serthy
6th January 2013, 15:14
setupCallbacks()
{
level.callbackStartGameType = ::Callback_StartGameType;
level.callbackPlayerConnect = serthy\_serthywars_playerlogic::Callback_PlayerCon nect;
level.callbackPlayerDisconnect = serthy\_serthywars_playerlogic::Callback_PlayerDis connect;
level.callbackPlayerDamage = serthy\_serthywars_damage::Callback_PlayerDamage;
level.callbackPlayerKilled = serthy\_serthywars_damage::Callback_PlayerKilled;

level.onPrecacheGameType = ::blank;

level.abort = ::AbortLevel;

//level.autoassign = serthy\_serthywars_menus::menuAutoAssign;
//level.allies = serthy\_serthywars_menus::menuAllies;
//level.axis = serthy\_serthywars_menus::menuAxis;
//level.spectator = serthy\_serthywars_menus::menuSpectator;

level.spawnPlayer = serthy\_serthywars_playerlogic::spawnPlayer;
level.spawnSpectator = serthy\_serthywars_playerlogic::spawnSpectator;
level.spawnIntermission = serthy\_serthywars_playerlogic::spawnIntermission;

level.getSpawnPointPlayer = serthy\_serthywars_spawnlogic::getSpawnPoint_Rando m;
level.getSpawnPointSpectator = serthy\_serthywars_spawnlogic::getSpawnPoint_Rando m;
level.getSpawnPointIntermission = serthy\_serthywars_spawnlogic::getSpawnPoint_Rando m;

level.onSpawnPlayer = ::blank;
level.onSpawnSpectator = ::blank;
level.onSpawnIntermission = ::blank;

level.onScoreLimit = ::onScoreLimit;

level.team = serthy\_serthywars_menus::menuTeam;
level.class = serthy\_serthywars_menus::menuClass;

level.endgame = ::endMap;
level.endmap = ::endMap;
}

yh i wrote everything on my own, so i know that there is the only place i set the level.callbackPlayerDamage pointer

the strange is:
- i link() the player to my plane, setModel(""), detachAll() and hide().
- fly around, hit the ground
- unlink(), loadModel(), show()
- (delay)
- apply damage

the thing is that i kill the player with finishPlayerDamage(), but the level.callbackPlayerKilled is triggered only after a frame delay, without you will stay a zombie

Tally
6th January 2013, 17:06
After years of doing this stuff is, all I can recommend, don't thread to your custom callbacks from within the stock callbacks GSC file. I wont go into it in detail, but the reason to follow this advice is all about the way the engine works and timing. Even Infinity Ward did not do fiddle with the stock callbacks when building global game files like _globallogic.gsc in COD4 and onwards. Always intercept player damage, or player killed from within the gametype GSC main() method.

This is how I built my custom callbacks:

1. _callbacksetup.gsc:


/*================
Called from the gametype script to store off the default callback functions.
This allows the callbacks to be overridden by level script, but not lost.
================*/
SetDefaultCallbacks()
{
level.callbackStartGameType = maps\mp\gametypes\_globalgametypes::Callback_Start GameType;
level.callbackPlayerConnect = maps\mp\gametypes\_globalgametypes::Callback_Playe rConnect;
level.callbackPlayerDisconnect = maps\mp\gametypes\_globalgametypes::Callback_Playe rDisconnect;
level.callbackPlayerDamage = maps\mp\gametypes\_globalgametypes::Callback_Playe rDamage;
level.callbackPlayerKilled = maps\mp\gametypes\_globalgametypes::Callback_Playe rKilled;

maps\mp\gametypes\_globalgametypes::SetUpCallBacks ();
demon\_globallogic::setupCallbacks();
}

2. demon\_globallogic::setupCallbacks();


setupCallbacks()
{
level.demon_onGametypeStarted = ::onGametypeStarted;
level.demon_onPlayerConnect = ::onPlayerConnect;
level.demon_onPlayerDisconnect = ::onPlayerDisconnect;
level.demon_onPlayerPreSpawned = ::onPlayerPreSpawned;
level.demon_onPlayerSpawned = ::onPlayerSpawned;
level.demon_onPlayerDamage = ::onPlayerDamage;
level.demon_onPlayerKilled = ::onPlayerKilled;
level.demon_onSpawnSpectator = ::onSpawnSpectator;
level.demon_onSwitchingTeams = ::demon_onSwitchingTeams;
level.onPlayerJoinedTeam = ::onPlayerJoinedTeam;
}

3. _globalgametypes::Callback_PlayerDamage():


Callback_PlayerDamage( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime )
{
if( self.sessionteam == "spectator" )
return;

//--- Spawn Protection ---
if( self.spawnprotected )
return;

// specialty checks - bulletdamage and armorvest
iDamage = maps\mp\gametypes\_class::modified_damage( self, eAttacker, iDamage, sMeansOfDeath );

// Don't do knockback if the damage direction was not specified
if(!isDefined(vDir))
iDFlags |= level.iDFLAGS_NO_KNOCKBACK;

friendly = undefined;

self thread [[level.onPlayerDamage]]( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime );
self thread [[level.demon_onPlayerDamage]]( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime );

---- snip ---


You will see that I have 2 sets of callbacks - those used by the stock gametype files, and those for my mod. You don't have to do it like this - you could just have 1 set of callbacks, but the main point is that you thread to a callback from the gametype file, not the stock callbacks file.

EDIT -

I was half asleep when I wrote this. After reading through the thread again, I can see I didn't understand the issue properly. Feel free to ignore what I've said.

randall
6th January 2013, 17:10
Is "MOD_SUICIDE" an existing value? Try with "MOD_HEAD_SHOT" or anything.

Another possibility: the link() and unlink() need a frame to ready, that's why you should wait a server frame (default: 0.05sec). It's a frequent problem.

Tally
6th January 2013, 17:11
Is "MOD_SUICIDE" an existing value? Try with "MOD_HEAD_SHOT" or anything.

Another possibility: the link() and unlink() need a frame to ready, that's why you should wait a server frame (default: 0.05sec). It's a frequent problem.

Yep, MOD_SUICIDE is a stock method of death.

serthy
6th January 2013, 20:35
after struggling a while with that, i found it, its what randall said, i commented out the 'player unLink();' and it works as it should
does the player automatically unLink() upon death? since i respawned, im not linked anylonger to the model..

but Tally, how you mean that?:

...don't thread to your custom callbacks from within the stock callbacks GSC file...
...Always intercept player damage, or player killed from within the gametype GSC main() method...

this is my way for the global callbacks:
maps\mp\gametypes_callbacksetup.gsc

CodeCallback_StartGameType()
{
level thread serthy\_serthywars_callbacksetup::CodeCallback_Sta rtGameType();
}
serthy\_serthywars_callbacksetup.gsc

CodeCallback_StartGameType()
{
if( !isDefined( level.gametypestarted ) || !level.gametypestarted )
{
level thread [[level.callbackStartGameType]]();

level.gametypestarted = true;
}
}

Sense
10th January 2013, 20:22
Nah you need to look for messy codes, i had this problem once i wish i could remember how i fixed it. If you have a assist script in your mod you might want to look at it again, becouse if i remember right mine was causing people not to die (rare).