Results 1 to 8 of 8

Thread: Player won't die?!

  1. #1
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts

    Player won't die?!

    Hey,

    I got into troubles with my modified Callback_PlayerDamage()

    i call this:
    Code:
    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
    Last edited by serthy; 6th January 2013 at 12:35. Reason: kinda fixed, not solved

  2. The Following User Says Thank You to serthy For This Useful Post:

    firefox (8th January 2013)

  3. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    I guess you change the value of this function-pointer somewhere to a buggy Callback_PlayerKilled()?

    Code:
    [[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:

    Code:
    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).
    timescale 0.01

  4. The Following User Says Thank You to kung foo man For This Useful Post:

    firefox (8th January 2013)

  5. #3
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Code:
    setupCallbacks()
    {
    	level.callbackStartGameType 		= ::Callback_StartGameType;
    	level.callbackPlayerConnect 		= serthy\_serthywars_playerlogic::Callback_PlayerConnect;
    	level.callbackPlayerDisconnect 	= serthy\_serthywars_playerlogic::Callback_PlayerDisconnect;
    	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_Random;
    	level.getSpawnPointSpectator 		= serthy\_serthywars_spawnlogic::getSpawnPoint_Random;
    	level.getSpawnPointIntermission	= serthy\_serthywars_spawnlogic::getSpawnPoint_Random;
    
    	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

  6. The Following User Says Thank You to serthy For This Useful Post:

    firefox (8th January 2013)

  7. #4
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    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:

    Code:
    /*================
    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_StartGameType;
    	level.callbackPlayerConnect = maps\mp\gametypes\_globalgametypes::Callback_PlayerConnect;
    	level.callbackPlayerDisconnect = maps\mp\gametypes\_globalgametypes::Callback_PlayerDisconnect;
    	level.callbackPlayerDamage = maps\mp\gametypes\_globalgametypes::Callback_PlayerDamage;
    	level.callbackPlayerKilled = maps\mp\gametypes\_globalgametypes::Callback_PlayerKilled;
    	
    	maps\mp\gametypes\_globalgametypes::SetUpCallBacks();
    	demon\_globallogic::setupCallbacks();
    }
    2. demon\_globallogic::setupCallbacks();

    Code:
    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():

    Code:
    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.
    Last edited by Tally; 6th January 2013 at 16:10.

  8. The Following 2 Users Say Thank You to Tally For This Useful Post:

    firefox (8th January 2013),kung foo man (6th January 2013)

  9. #5
    Private
    Join Date
    Jan 2013
    Location
    Hungary
    Posts
    113
    Thanks
    10
    Thanked 74 Times in 45 Posts
    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.

  10. The Following 2 Users Say Thank You to randall For This Useful Post:

    firefox (8th January 2013),kung foo man (6th January 2013)

  11. #6
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by randall View Post
    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.

  12. The Following 2 Users Say Thank You to Tally For This Useful Post:

    firefox (8th January 2013),kung foo man (6th January 2013)

  13. #7
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    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
    Code:
    CodeCallback_StartGameType()
    {
    	level thread serthy\_serthywars_callbacksetup::CodeCallback_StartGameType();
    }
    serthy\_serthywars_callbacksetup.gsc
    Code:
    CodeCallback_StartGameType()
    {
    	if( !isDefined( level.gametypestarted ) || !level.gametypestarted )
    	{
    		level thread [[level.callbackStartGameType]]();
    
    		level.gametypestarted = true;
    	}
    }
    Last edited by serthy; 6th January 2013 at 19:39.

  14. The Following 2 Users Say Thank You to serthy For This Useful Post:

    firefox (8th January 2013),kung foo man (6th January 2013)

  15. #8
    Private
    Join Date
    Nov 2012
    Location
    Denmark, where else
    Posts
    27
    Thanks
    5
    Thanked 13 Times in 6 Posts
    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •