En:OnUnitActionWithItem

Материал из Pocket Fallout для КПК на PDA PC PPC Mobile.

Содержание

Syntax

function OnUnitActionWithItem(unit_name : String, 
                              item_name : String) : Boolean

Description

Called when unit with name <unit_name> does action with item with name <item_name> from inventory.

Parameters

  • unit_name - string. Unit name;
  • item_name - string. Item name;

Result

The function returns :

  • true - action can be done;
  • false - action can't be done.

Data type - Boolean

Example

function OnUnitActionWithItem(unit_name, item_name)  	
 	var bot = CreateObject("MapObject");
	var hero = CreateObject("MapObject");
	
	bot.GetObjectByName(unit_name);
	hero.GetObjectByName("hero");
	
	if (item_name == "apple") Then // If unit eats apple
		// Add by current health 10 (ten) lives
		var old_health = bot.GetUnitParam(UnitParam.Health);
		bot.SetUnitParam(UnitParam.Health, old_health + 10);
		hero.DeleteItemFromInventory(item_name);
		if (unit_name == "hero") Then
                       // This message by index from messages.txt file
			AddStringMessageByIndex(1000); 
		endif
	endif
	
	hero.Free();
	bot.Free();
	
	return true;
endfunction

See also

Predefined procedures and functions (events)

Личные инструменты