@LabelIndex 114300
@StringIndex 0
class 0 cruma_totem : default_npc {
parameter:
	int	Skill01_ID = -1;
	int	Skill02_ID = -1;
	int	Skill03_ID = -1;
	int	Skill04_ID = -1;
	int	DespawnTime = -1;

handler:
	EventHandler CREATED(i0) {
		i0 = ( gg::Rand(4) + 1 );
		switch(i0) {
			case 1: {
				myself.i_ai1 = Skill01_ID;
				break;
			}
			case 2: {
				myself.i_ai1 = Skill02_ID;
				break;
			}
			case 3: {
				myself.i_ai1 = Skill03_ID;
				break;
			}
			case 4: {
				myself.i_ai1 = Skill04_ID;
				break;
			}
		}
		myself.i_ai0 = 0;
		myself::AddTimerEx(2000,( DespawnTime * 1000 ));
		myself::AddMoveAroundDesire(5,5);
		myself.i_ai2 = 1;
		super;
	}

	EventHandler ATTACKED(attacker,c0,party0,i0,i1) {
		myself.i_ai0 = 1;
		if( myself.sm.hp <= 1 ) {
			c0 = myself::GetLastAttacker();
			if( myself.i_ai2 == 1 ) {
				if( myself::IsNullCreature(c0) == 0 ) {
					party0 = gg::GetParty(c0);
					if( myself::IsNullParty(party0) == 0 ) {
						i0 = party0.member_count;
						for(i1 = 0; i1 < i0; i1++) {
							c0 = myself::GetMemberOfParty(party0,i1);
							if( myself::IsNullCreature(c0) == 0 ) {
								myself::CastBuffForQuestReward(c0,myself.i_ai1);
							}
						}
					} else {
						myself::CastBuffForQuestReward(c0,myself.i_ai1);
					}
				}
				myself::AddTimerEx(2002,( 1 * 1000 ));
				myself.i_ai2 = ( myself.i_ai2 + 1 );
			}
		}
	}

	EventHandler TIMER_FIRED_EX(timer_id) {
		if( timer_id == 2000 ) {
			if( myself.i_ai0 == 0 ) {
				myself::Despawn();
			}
		}
		if( timer_id == 2002 ) {
			myself::Suicide();
		}
	}

	EventHandler SEE_CREATURE(creature,i0,i1,c0,party0) {
	}

}
