Modme Forums
Menu:

Damage callback

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: mathfag
Can someone please explain the damage callback function (not even sure it that's what it's called). Basically I'd like a function that does something when an ai gets shot or dies, like was it a headshot, torso shot, mustang and sally kill...
Also where in the script would I add it.


3 gold stars to whoever responds usefully :)

Disclaimer: Gold stars may be digital images from google


ModmeBot:

Reply By: Harry Bo21

mathfag
Can someone please explain the damage callback function (not even sure it that's what it's called). Basically I'd like a function that does something when an ai gets shot or dies, like was it a headshot, torso shot, mustang and sally kill... Also where in the script would I add it. 3 gold stars to whoever responds usefully :) Disclaimer: Gold stars may be digital images from google



zm_spawner::register_zombie_damage_callback( &function );	


add the function you pass to an array, when a zombie takes damage, it runs every single call back in the array, until one returns true, if none returns true, it continues the normal damage behavior

if one returns true, it performs whatever was in that callback - and abandons the rest of the "normal" zombie takes damage behavior

function function_we_passed( str_mod, str_hit_location, v_hit_origin, e_player, n_amount, w_weapon, direction_vec, tagName, modelName, partName, dFlags, inflictor, chargeLevel )
{
	// self == zombie
	// e_player == player or entity that dealt the damage
	if ( w_weapon.name == "a weapon of our choice" )
	{
		do_stuff();
		return true;
	}
	else
	{
		// wasnt hit by my gun or under the conditions i want to change what happens when damaged
		return false;
	}
}


tag_name will return the closest tag to what was hit, v_hit_origin will return the exact origin of impact, if you wanna run special behavior - and still allow the regular behavior to happen, return false after your logic instead of true

theres a death call back too, damage call backs wont happen if they die, the death one does instead

zm_spawner::register_zombie_death_event_callback( &function_to_run );


and to run a function on ai when they spawn in ( for setting crap up if needed )

zm_spawner::add_custom_zombie_spawn_logic( &function_to_run );



check where these functions get called in zm_spawner if you need to see what arguments are being passed to them


ModmeBot:

Reply By: mathfag

Harry Bo21
mathfag Can someone please explain the damage callback function (not even sure it that's what it's called). Basically I'd like a function that does something when an ai gets shot or dies, like was it a headshot, torso shot, mustang and sally kill... Also where in the script would I add it. 3 gold stars to whoever responds usefully :) Disclaimer: Gold stars may be digital images from google zm_spawner::register_zombie_damage_callback( &function ); add the function you pass to an array, when a zombie takes damage, it runs every single call back in the array, until one returns true, if none returns true, it continues the normal damage behavior if one returns true, it performs whatever was in that callback - and abandons the rest of the "normal" zombie takes damage behavior function function_we_passed( str_mod, str_hit_location, v_hit_origin, e_player, n_amount, w_weapon, direction_vec, tagName, modelName, partName, dFlags, inflictor, chargeLevel ) { // self == zombie // e_player == player or entity that dealt the damage if ( w_weapon.name == "a weapon of our choice" ) { do_stuff(); return true; } else { // wasnt hit by my gun or under the conditions i want to change what happens when damaged return false; } } tag_name will return the closest tag to what was hit, v_hit_origin will return the exact origin of impact, if you wanna run special behavior - and still allow the regular behavior to happen, return false after your logic instead of true theres a death call back too, damage call backs wont happen if they die, the death one does instead zm_spawner::register_zombie_death_event_callback( &function_to_run ); and to run a function on ai when they spawn in ( for setting crap up if needed ) zm_spawner::add_custom_zombie_spawn_logic( &function_to_run );