@LabelIndex 70397
@StringIndex 11308
class 0 event_ai_milk_big_cow : default_npc {
parameter:
	int	event_coin = 9142;
	int	event_animal = 2;
	int	b_oneshot_kill = 1;
	int	award_cow_coin = 0;
	int	award_cow_coin_bonus = 0;
	int	award_cow_gold_coin = 0;
	int	award_cow_gold_coin_bonus = 0;

handler:
	EventHandler CREATED() {
		myself.c_ai0 = gg::GetNullCreature();
		myself.c_ai1 = gg::GetNullCreature();
		myself.c_ai2 = gg::GetNullCreature();
		myself.c_ai3 = gg::GetNullCreature();
		myself.c_ai4 = gg::GetNullCreature();
		myself.i_ai0 = 0;
		myself.i_ai1 = 0;
		myself.i_ai2 = 0;
		myself.i_ai3 = 0;
		myself.i_ai4 = 0;
		myself.i_quest0 = 0;
		myself.i_quest1 = 0;
		myself.i_quest2 = 0;
		myself.i_quest3 = 0;
		myself.i_quest4 = 0;
		myself.c_quest4 = gg::GetNullCreature();
		myself.c_quest0 = gg::GetNullCreature();
		myself::AddTimerEx(20000,360000);
	}

	EventHandler ATTACKED(attacker,damage,skill_name_id,i0,i1,i2,i3,i4) {
		if( gg::Rand(100) < 33 ) {
			if( myself::Skill_GetConsumeMP(368246785) < myself.sm.mp && myself::Skill_GetConsumeHP(368246785) < myself.sm.hp && myself::Skill_InReuseDelay(368246785) == 0 ) {
				myself::AddUseSkillDesire(attacker,368246785,0,1,1000000);
			}
		}
		if( skill_name_id == 187891713 || skill_name_id == 187957249 ) {
			if( myself.i_ai3 == 0 ) {
				if( myself::IsNullCreature(attacker) == 0 ) {
					myself.i_ai0 = attacker.id;
					myself.i_ai3 = 1;
					myself::Shout(myself.sm.name + "  :" + gg::IntToStr(myself.m_WorldTrapState));
					i0 = gg::Rand(100);
					if( i0 < 50 ) {
						myself::EffectMusic(myself.sm,1000,"EV_03");
						gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0," : 40     2!");
						if( myself::IsNullCreature(myself.sm) == 0 ) {
							myself::AddTimerEx(20001,3000);
						} else {
							myself.i_ai4 = 1;
						}
					}
				}
			} else {
				myself::Say("~  ˆ ");
			}
		} else {
			myself::Say("~    !     !");
		}
	}

	EventHandler NO_DESIRE() {
		myself::AddMoveAroundDesire(40,20);
	}

	EventHandler TIMER_FIRED_EX(timer_id,i0,i1,i2,c0) {
		if( timer_id == 20000 ) {
			myself::Despawn();
		}
		if( timer_id == 20001 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"40 .");
				myself::AddTimerEx(20002,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20002 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"39 .");
				myself::AddTimerEx(20003,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20003 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"38 .");
				myself::AddTimerEx(20004,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20004 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"37 .");
				myself::AddTimerEx(20005,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20005 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"36 .");
				myself::AddTimerEx(20006,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20006 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"35 .");
				myself::AddTimerEx(20007,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20007 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"34 .");
				myself::AddTimerEx(20008,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20008 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"33 .");
				myself::AddTimerEx(20009,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20009 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"32 .");
				myself::AddTimerEx(20010,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20010 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"31 .");
				myself::AddTimerEx(20011,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20011 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"30 ");
				myself::AddTimerEx(20012,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20012 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"29 .");
				myself::AddTimerEx(20013,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20013 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"28 .");
				myself::AddTimerEx(20014,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20014 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"27 .");
				myself::AddTimerEx(20015,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20015 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"26 .");
				myself::AddTimerEx(20016,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20016 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"25 .");
				myself::AddTimerEx(20017,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20017 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"24 .");
				myself::AddTimerEx(20018,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20018 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"23 .");
				myself::AddTimerEx(20019,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20019 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"22 .");
				myself::AddTimerEx(20020,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20020 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"21 .");
				myself::AddTimerEx(20021,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20021 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"20 .");
				myself::AddTimerEx(20022,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20022 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"19 .");
				myself::AddTimerEx(20023,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20023 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"18 .");
				myself::AddTimerEx(20024,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20024 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"17 .");
				myself::AddTimerEx(20025,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20025 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"16 .");
				myself::AddTimerEx(20026,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20026 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"15 .");
				myself::AddTimerEx(20027,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20027 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"14 .");
				myself::AddTimerEx(20028,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20028 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"13 .");
				myself::AddTimerEx(20029,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20029 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"12 .");
				myself::AddTimerEx(20030,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20030 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"11 .");
				myself::AddTimerEx(20031,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20031 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"10 .");
				myself::AddTimerEx(20032,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20032 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"9 .");
				myself::AddTimerEx(20033,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20033 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"8 .");
				myself::AddTimerEx(20034,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20034 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"7 .");
				myself::AddTimerEx(20035,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20035 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"6 .");
				myself::AddTimerEx(20036,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20036 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"5 .");
				myself::AddTimerEx(20037,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20037 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"4 .");
				myself::AddTimerEx(20038,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20038 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"3 .");
				myself::AddTimerEx(20039,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20039 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"2 .");
				myself::AddTimerEx(20040,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20040 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"1 .");
				myself::AddTimerEx(20041,1000);
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20041 ) {
			if( myself::IsNullCreature(myself.sm) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,6000,2,0,0,0,0,1,1000,0,"40 sec Mission Failed");
			} else {
				myself.i_ai4 = 1;
			}
		}
		if( timer_id == 20042 ) {
			myself::Despawn();
		}
	}

	EventHandler MY_DYING(last_attacker,i0,i1,i2,i3,i4,i5,c0,c1,party0) {
		c1 = gg::GetCreatureFromID(myself.i_ai0);
		party0 = gg::GetParty(c1);
		if( myself::IsNullCreature(c0) == 0 ) {
			if( myself::IsNullParty(party0) == 0 ) {
				i0 = party0.member_count;
				i2 = gg::Rand(i0);
				for(i1 = 0; i1 < i0; i1++) {
					c0 = myself::GetMemberOfParty(party0,i1);
					if( myself::DistFromMe(c0) <= 300 ) {
						if( myself::IsNullCreature(c0) == 0 && myself.i_ai4 == 1 ) {
							myself.i_ai1 = ( myself.i_ai1 + 1 );
							if( myself.i_ai1 == 1 ) {
								if( i1 == i2 ) {
									i3 = ( ( gg::FloatToInt(( ( i0 * 2 ) * 0.200000 )) + 2 ) * 2 );
									if( myself::GetInventoryInfo(c0,0) >= ( myself::GetInventoryInfo(c0,1) * 0.800000 ) || myself::GetInventoryInfo(c0,2) >= ( myself::GetInventoryInfo(c0,3) * 0.800000 ) ) {
										myself::ShowSystemMessage(c0,1118);
										return;
									}
									myself::GiveItem1(c0,2781,i3);
								} else if( myself::GetInventoryInfo(c0,0) >= ( myself::GetInventoryInfo(c0,1) * 0.800000 ) || myself::GetInventoryInfo(c0,2) >= ( myself::GetInventoryInfo(c0,3) * 0.800000 ) ) {
									myself::ShowSystemMessage(c0,1118);
									return;
								}
								myself::GiveItem1(c0,2781,4);
							} else if( myself.i_ai1 > 1 ) {
								myself.i_ai4 = 0;
								if( i1 == i2 ) {
									i4 = ( gg::FloatToInt(( ( i0 * 2 ) * 0.200000 )) + 2 );
									if( myself::GetInventoryInfo(c0,0) >= ( myself::GetInventoryInfo(c0,1) * 0.800000 ) || myself::GetInventoryInfo(c0,2) >= ( myself::GetInventoryInfo(c0,3) * 0.800000 ) ) {
										myself::ShowSystemMessage(c0,1118);
										return;
									}
									myself::GiveItem1(c0,2781,i4);
								} else if( myself::GetInventoryInfo(c0,0) >= ( myself::GetInventoryInfo(c0,1) * 0.800000 ) || myself::GetInventoryInfo(c0,2) >= ( myself::GetInventoryInfo(c0,3) * 0.800000 ) ) {
									myself::ShowSystemMessage(c0,1118);
									return;
								}
								myself::GiveItem1(c0,2781,2);
							}
						} else if( myself::IsNullCreature(c0) == 0 && myself.i_ai4 == 0 ) {
							if( i1 == i2 ) {
								i5 = ( gg::FloatToInt(( ( i0 * 2 ) * 0.200000 )) + 2 );
								if( myself::GetInventoryInfo(c0,0) >= ( myself::GetInventoryInfo(c0,1) * 0.800000 ) || myself::GetInventoryInfo(c0,2) >= ( myself::GetInventoryInfo(c0,3) * 0.800000 ) ) {
									myself::ShowSystemMessage(c0,1118);
									return;
								}
								myself::GiveItem1(c0,2781,i5);
							} else if( myself::GetInventoryInfo(c0,0) >= ( myself::GetInventoryInfo(c0,1) * 0.800000 ) || myself::GetInventoryInfo(c0,2) >= ( myself::GetInventoryInfo(c0,3) * 0.800000 ) ) {
								myself::ShowSystemMessage(c0,1118);
								return;
							}
							myself::GiveItem1(c0,2781,1);
						}
					} else {
						myself::Say("  ˆ  ˆ.");
					}
				}
			} else {
				myself::Say("ˆ ˆ   .");
			}
		} else {
			myself::Say("  ˆ  .  ~   ~  .");
			myself::AddTimerEx(20013,5000);
		}
	}

}
