[MANUAL] Ncp ворует адену

Тема в разделе "Установка и настройка (Setup and configuration)", создана пользователем root, 27 сен 2014.

  1. root

    root Administrator Команда форума Administrator Moderator Developers Team

    Регистрация:
    23 авг 2014
    Сообщения:
    254
    Симпатии:
    58
    Баллы:
    11
    Создаем в городе, умеют подбирать мусор, также по рандому воруют адену, и убегают от игрока, если догнать и убить, по рандому можно получить 0,5; 1,0; 1,5 от с ворованной суммы.
    AI:
    Код:
    class 1 vagabond_thief : citizen{
    parameter:
    	  string	fnHi = "";
    
    
    handler:
    
    
    	EventHandler CREATED()
    	{
    		myself::AddTimerEx(1001, 1000);
    		myself.i_ai0 = 0;
    		myself.i_ai1 = 0;
    	}
    	
    	EventHandler TALKED(talker)
    	{
    		myself::RemoveAllAttackDesire();
    		myself::StopMove();
    		myself::ShowPage(talker, fnHi);
    	}
    
    
    	EventHandler TIMER_FIRED_EX(timer_id, c0)
    	{
    		if ( timer_id == 1001 )
    		{
    			if ( myself::InMyTerritory(myself.sm) == 0 && gg::Rand(2) < 1 && myself.p_state != 3 )
    			{
    				myself::InstantTeleport(myself.sm, myself.start_x, myself.start_y, myself.start_z);
    				myself::RemoveAllAttackDesire();
    				myself::StopMove();
    			}
    			myself::AddTimerEx(1001, 300000);
    		}
    		if ( timer_id == 1002 )
    		{
    			myself::StopMove();
    		}
    		if ( timer_id == 100001 )
    		{
    			myself::AddGetItemDesire(myself.c_ai0, 1000);
    		}
    		if ( timer_id == 100002 )
    		{
    			myself::AddGetItemDesire(myself.c_ai1, 1000);
    		}
    		if ( timer_id == 100003 )
    		{
    			myself::AddGetItemDesire(myself.c_ai2, 1000);
    		}
    		if ( timer_id == 100004 )
    		{
    			myself::AddGetItemDesire(myself.c_ai3, 1000);
    		}
    		if ( timer_id == 100005 )
    		{
    			myself::AddGetItemDesire(myself.c_ai4, 1000);
    		}
    	}
    
    
    	EventHandler NO_DESIRE()
    	{
    		if ( myself.i_ai0 == 0 )
    		{
    			myself::AddMoveAroundDesire(5, 5);
    		}
    		else
    		{
    			myself::RemoveAllAttackDesire();
    			myself::StopMove();
    		}
    	}
    
    
    	EventHandler ATTACKED(attacker,damage, i0, i1, i2)
    	{
    		i0 = gg::Rand(20);
    		if ( i0  > 15 )
    		{
    			i1 = gg::Rand(10);
    			i2 = 1002170 + i1;
    			myself::Say(myself::MakeFString(i2, "", "", "", "", ""));
    		}
    	}
    
    
    	EventHandler SEE_ITEM(item)
    	{    
    		if (myself.c_ai0 <= 0)
    		{
    			myself.c_ai0 = item;
    			myself::AddTimerEx(100001, 5000);
    		}
    		else if (myself.c_ai1 <= 0)
    		{
    			myself.c_ai1 = item;
    			myself::AddTimerEx(100002, 7000);
    		}
    		else if (myself.c_ai2 <= 0)
    		{
    			myself.c_ai2 = item;
    			myself::AddTimerEx(100003, 9000);
    		}
    		else if (myself.c_ai3 <= 0)
    		{
    			myself.c_ai3 = item;
    			myself::AddTimerEx(100004, 11000);
    		}
    		else if (myself.c_ai4 <= 0)
    		{
    			myself.c_ai4 = item;
    			myself::AddTimerEx(100005, 13000);
    		}
    		else
    		{
    			myself::AddGetItemDesire(item, 10);
    		}
    	}
    
    
    	EventHandler GET_ITEM_FINISHED(item)
    	{      
    		if (myself.c_ai0 == item)
    		{
    			myself.c_ai0 = 0;
    		}
    		else if (myself.c_ai1 == item)
    		{
    			myself.c_ai1 = 0;
    		}
    		else if (myself.c_ai2 == item)
    		{
    			myself.c_ai2 = 0;
    		}
    		else if (myself.c_ai3 == item)
    		{
    			myself.c_ai3 = 0;
    		}
    		else if (myself.c_ai4 == item)
    		{
    			myself.c_ai4 = 0;
    		} 
    	myself::DeleteItem1(myself, item, (myself::OwnItemCount(myself, item)));
    	}
    
    
    	EventHandler SEE_CREATURE(creature, i0, i1, i2)
    	{
    		if ( myself::DistFromMe(creature) < 500 && myself.i_ai0 == 0 )
    		{
    			myself::AddFollowDesire(creature, 100);
    			myself::AddTimerEx(1002, 120000);
    			if ( myself::GetCookie(creature, "vagabond_thief") == -1 && gg::Rand(100) >= 90 && myself::OwnItemCount(creature, 57) >= 10000 )
    			{
    				if ( myself::OwnItemCount(creature, 57) >= 10000 && myself::OwnItemCount(creature, 57) <= 100000 )
    				{
    					myself::DeleteItem1(creature, 57, 10000);
    					myself::SetCookie(creature, "vagabond_thief", 1);
    					myself.i_ai0 = 1;
    					myself::AddFleeDesire(creature, 100000);
    				}
    				else if ( myself::OwnItemCount(creature, 57) >= 100001 && myself::OwnItemCount(creature, 57) <= 1000000 )
    				{
    					myself::DeleteItem1(creature, 57, 100000);
    					myself::SetCookie(creature, "vagabond_thief", 2);
    					myself.i_ai0 = 2;
    					myself::AddFleeDesire(creature, 100000);
    				}
    				else if ( myself::OwnItemCount(creature, 57) >= 1000001 && myself::OwnItemCount(creature, 57) <= 10000000 )
    				{
    					myself::DeleteItem1(creature, 57, 500000);
    					myself::SetCookie(creature, "vagabond_thief", 3);
    					myself.i_ai0 = 3;
    					myself::AddFleeDesire(creature, 100000);
    				}
    				else if ( myself::OwnItemCount(creature, 57) >= 10000001 )
    				{
    					myself::DeleteItem1(creature, 57, 1000000);
    					myself::SetCookie(creature, "vagabond_thief", 4);
    					myself.i_ai0 = 4;
    					myself::AddFleeDesire(creature, 100000);
    				}
    			}
    			
    		}
    		else
    		{
    			myself::AddFleeDesire(creature, 100000);
    		}
    		if ( creature.alive == 1 && creature.is_pc == 1 && myself::GetCookie(creature, "vagabond") < 2 )
    		{
    			i0 = gg::Rand(800);
    			if ( i0  < 10 )
    			{
    				i1 = gg::Rand(7);
    				i2 = 1002180 + i1;
    				myself::Say(myself::MakeFString(i2, "", "", "", "", ""));
    				myself::SetCookie(creature, "vagabond", (myself::GetCookie(creature, "vagabond") + 1));
    			}
    		}
    
    
    	}
    
    
    	EventHandler MENU_SELECTED(talker, ask, reply, i0, i1, i2)
    	{
    		if ( ask == 25 )
    		{
    			if ( reply == 1) // 10000 аден
    			{
    				myself::DeleteItem1(talker, 57, 10000);
    				if ( gg::Rand(10) < 5 )
    				{
    					i1 = gg::Rand(3);
    					i2 = 1002187 + i1;
    					myself::SetCookie(talker, "vagabond_thief", 5);
    					myself::Say(myself::MakeFString(i2, talker.name, "", "", "", ""));
    				}
    			}
    			if ( reply == 2) // 100000 аден
    			{
    				myself::DeleteItem1(talker, 57, 100000);
    				i1 = gg::Rand(3);
    				i2 = 1002187 + i1;
    				myself::SetCookie(talker, "vagabond_thief", 5);
    				myself::Say(myself::MakeFString(i2, talker.name, "", "", "", ""));
    			}
    		}
    	}
    
    
    	EventHandler MY_DYING(last_attacker, target, i0)
    	{
    		target = last_attacker;
    		if ( myself.i_ai0 == 1 && myself::GetCookie(target, "vagabond_thief") == 1 )
    		{
    			i0 = gg::Rand(1000);
    			if ( i0 < 300 )
    			{
    				myself::GiveItem1(target, 57, 5000);
    			}
    			else if ( i0 >= 300 && i0 <= 990 )
    			{
    				myself::GiveItem1(target, 57, 10000);
    			}
    			else
    			{
    				myself::GiveItem1(target, 57, 15000);
    			}
    		}
    		else if ( myself.i_ai0 == 2 && myself::GetCookie(target, "vagabond_thief") == 2 )
    		{
    			i0 = gg::Rand(1000);
    			if ( i0 < 300 )
    			{
    				myself::GiveItem1(target, 57, 50000);
    			}
    			else if ( i0 >= 300 && i0 <= 990 )
    			{
    				myself::GiveItem1(target, 57, 100000);
    			}
    			else
    			{
    				myself::GiveItem1(target, 57, 150000);
    			}
    		}
    		else if ( myself.i_ai0 == 3 && myself::GetCookie(target, "vagabond_thief") == 3 )
    		{
    			i0 = gg::Rand(1000);
    			if ( i0 < 300 )
    			{
    				myself::GiveItem1(target, 57, 250000);
    			}
    			else if ( i0 >= 300 && i0 <= 990 )
    			{
    				myself::GiveItem1(target, 57, 500000);
    			}
    			else
    			{
    				myself::GiveItem1(target, 57, 1000000);
    			}
    		}
    		else if ( myself.i_ai0 == 4 && myself::GetCookie(target, "vagabond_thief") == 4 )
    		{
    			i0 = gg::Rand(1000);
    			if ( i0 < 300 )
    			{
    				myself::GiveItem1(target, 57, 500000);
    			}
    			else if ( i0 >= 300 && i0 <= 990 )
    			{
    				myself::GiveItem1(target, 57, 1000000);
    			}
    			else
    			{
    				myself::GiveItem1(target, 57, 1500000);
    			}
    		}
    	}
    
    
    }
    html:
    Код:
    <html><head>
    <body>
    Бродяга:<br>
    Милый человек, помоги мне пожалуйста!!!<br>
    Подай на пропитание.<br>
    Я уже третью неделю ничего не ел!!!<br>
    <br><a action="bypass -h menu_select?ask=25&reply=1">"Дать  10 000 аден"</a>
    <br><a action="bypass -h menu_select?ask=25&reply=2">"Дать 100 000 аден"</a>
    </body>
    </html>
     
  2. root

    root Administrator Команда форума Administrator Moderator Developers Team

    Регистрация:
    23 авг 2014
    Сообщения:
    254
    Симпатии:
    58
    Баллы:
    11
    Должен подбирать мусор с пола весь, не пропуская его...
    Код:
    EventHandler CREATED()	{
    		myself::AddTimerEx(1001, 1000);
    		myself.i_ai0 = 0;
    		myself.i_ai1 = 0;
    		myself::AddTimerEx(1003, 1000);
    	}
    
    
    
    Код:
    		if ( timer_id == 1003 )		{
    			myself::LookItem(1200);
    			myself::AddTimerEx(1003, 60000);
    		}