All pastes #2050737 Raw Edit

Unnamed

public text v1 · immutable
#2050737 ·published 2011-04-26 03:02 UTC
rendered paste body
gmkeyhook.h:

class MDB_SSGM_Taunt_Key : public MDB_SSGM_KeyHook {
	Vector3 oldpos, newpos;
	bool can_use_taunts;

	void Created(GameObject *obj);
	void KeyHookFunc();
	void Timer_Expired(GameObject *obj,int number);

gmkeyhook.cpp:

void MDB_SSGM_Taunt_Key::Created(GameObject *obj) {
	if (is_keyhook_set != 1337) {
		hookid = AddHook(Get_Parameter("Key"),obj);
		is_keyhook_set = 1337;
		can_use_taunts = true;
	}
}

void MDB_SSGM_Taunt_Key::KeyHookFunc() {
	if (Get_Vehicle(Owner()) == 0) {
		Commands->Start_Timer(Owner(),this,0.1,442);
	}
}

void MDB_SSGM_Taunt_Key::Timer_Expired(GameObject *obj,int number) {
float oldpos2;

	if (number == 442) {
		oldpos = Commands->Get_Position(Owner());
		Commands->Start_Timer(Owner(),this,0.1,443);
		oldpos2 = oldpos.Z;
	}
	if ((number == 443) && (can_use_taunts == true)){
		can_use_taunts = false;
		newpos = Commands->Get_Position(Owner()); //New position 0.5 seconds later

		if ((oldpos.Z - newpos.Z) < (float)1.000000 ) {

			Commands->Set_Animation(Owner(),Get_Parameter("Anim"),false,0,0.0f,-1.0f,false); //play animation if Z-height didn't change in those 0.5 secs
			Commands->Start_Timer(Owner(),this,5,444); //Timer to limit use of taunts to every 5 secs
		}
	}
	if (number == 444) {
	can_use_taunts = true;
	}
}