All pastes #442137 Raw Edit

Something

public text v1 · immutable
·published 2007-04-16 01:12 UTC
rendered paste body
/* Changelog:
 * 2007-04-15-p1: - initial
 */

; Todo: these will probably need to be re-assigned for clarity, to keep them in order of importance.
#define ActionNPC_State_Finished 0
#define ActionNPC_State_TooFar 1
#define ActionNPC_State_Arrived 2
#define ActionNPC_State_AtGossip 3
#return ActionNPC_State_Sell 4
#return ActionNPC_State_Repair 5
#return ActionNPC_State_Train 6

#define ActionNPC_Static_DISTANCE 4

objectdef oActionNPC inherits oBase
{
	variable string Action
	variable objectref CurrentNPC
	variable bool InteractingWithNPC = FALSE
	variable bool HaveNPC = FALSE

	method InteractNPC(string GUID, string Action)
	{
		This.Action:Set${Action}
		This.HaveNPC:Set[TRUE]
		CurrentNPC:Set[${GUID}
		
	}

	member TrainerHasNewSkills()
	{
		
		if ${WoWScript[ClassTrainerFrame:IsShown()]}
		{
			WoWScript SetTrainerServiceTypeFilter("unavailable",0)
			WoWScript SetTrainerServiceTypeFilter("used",0)
			WoWScript SetTrainerServiceTypeFilter("available",1)
				
			if ${WoWScript[GetNumTrainerServices()]}>0 
			{
				return TRUE
			}
			else
			{
				return FALSE
			}
		}
		
		return FALSE
	}	

	member State()
	{
		; ActionNPC_State_TooFar: Returns if toon is more then 4m away from NPC,
		; and we are not currently moving towards the NPC.
		; TODO: Add Navigation system check to see if toon is not moving to the target NPC:
		if  ${Math.Distance[${Me.Location},${NpcUnit.Location}]} > ActionNPC_Static_DISTANCE && <TODO>
		{
			return ActionNPC_State_TooFar
		}

		; ActionNPC_State_Arrived: Returns if toon is less then 4m away from NPC,
		; and we are currently moving.
		; TODO: Add Navigation system check to see if toon is currently moving:
		if ${Math.Distance[${Me.Location},${NpcUnit.Location}]} < NPC_DISTANCE && <TODO>
		{
			return ActionNPC_State_Arrived
		}

		; ActionNPC_State_NeedtoOpen: Triggered if the toon is at NPC (based on failure
		; of previous 2 checks), and we are currently not interacting with the NPC.
		if !${This.InteractingWithNPC}
		{
			return ActionNPC_State_NeedtoOpen
		}

		; ActionNPC_State_AtGossip: Triggered if the toon is currently listening to RP
		; crap at the gossip screen.
		if ${WoWScript[GossipFrame:IsShown()]}
		{
			return ActionNPC_State_AtGossip
		}

		; ActionNPC_State_Sell: Triggered if the merchantframe is up, and we can sell.
		; TODO: Add Inventory check to see if we have stuff to sell:
		if ${WoWScript[MerchantFrame:IsShown()]} && <TODO>
		{
			return ActionNPC_State_Sell
		}

		; ActionNPC_State_Repair: Triggered if the merchantframe is up, and we need to repair.
		; TODO: Add Check to see if the current NPC can repair:
		; TODO: Add Inventory check to see if we need to repair:
		if ${WoWScript[MerchantFrame:IsShown()]} && <TODO> && <TODO>
		{
			return ActionNPC_State_Repair
		}

		; ActionNPC_State_Train: Triggered if InteractNPC was called with action Train, and Trainer
		; has new skills (according to TrainHasNewSkills
		if ${This.Action.Equal[Train]} && ${This.TrainHasNewSkills} 
		{
			return ActionNPC_State_Train
		}	

	method Pulse()
	{
		This.Currentstate:Set[${This.State}
		
		<TODO>

	}

}