/*	Renegade Scripts.dll
	Scripts by Kamuix
	Copyright 2006 Kamuix, Jonathan Wilson

	This file is part of the Renegade scripts.dll
	The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
	the terms of the GNU General Public License as published by the Free
	Software Foundation; either version 2, or (at your option) any later
	version. See the file COPYING for more details.
	In addition, an exemption is given to allow Run Time Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
	Only the source code to the module(s) containing the licenced code has to be released.
*/

#include "scripts.h"
#include "engine.h"
#include "kamuix.h"

void Kamuix_PAMSG_Zone::Entered(GameObject *obj,GameObject *enter)
{
	int x;
	x = Get_Int_Parameter("Player_Type");
	if (CheckPlayerType(enter,x))
	{
		
	return;
	}
	if (!Commands->Is_A_Star(enter))
	{
		
	return;
	}
	char message[1000];
	sprintf(message,"pamsg %d %s",Get_Player_ID(enter),Get_Parameter("Message"));
	Console_Input(message);
}

void Kamuix_Send_FDS_MSG_Zone::Entered(GameObject *obj,GameObject *enter)
{
	char message[100];
	sprintf(message,"%s",Get_Parameter("Message"));
	Console_Input(message);
}

void Kamuix_Team_Change_Zone::Entered(GameObject *obj,GameObject *enter)
{
	int x;
	x = Get_Int_Parameter("Player_Type");
	if (CheckPlayerType(enter,x))
	{	
		return;
	}
	if (!Commands->Is_A_Star(enter))
	{
		return;
	}
	char message[1000];
	sprintf(message,"team2 %d %s",Get_Player_ID(enter),Get_Parameter("Team"));
	Console_Input(message);
}

void Kamuix_Announce_Preset_Buy::Entered(GameObject *obj,GameObject *enter)
{
	const char *preset;
	int x;
	int cost;
	Vector3 spawn_position;
	x = Get_Int_Parameter("Player_Type");
	if (CheckPlayerType(enter,x))
	{
		return;
	}
	char message[1000];
	preset = Get_Parameter("Preset_Name");
	cost = Get_Int_Parameter("Cost");
	if (cost <= Commands->Get_Money(enter))
	{
		cost = -cost;
		spawn_position = Get_Vector3_Parameter("location");
		Commands->Give_Money(enter,(float)cost,0);
		Commands->Create_Object(preset,spawn_position);
		sprintf(message,"Msg %s Has Purchased A %s",Get_Player_Name(enter),Get_Parameter("DisplayName"));
		Console_Input(message);
	}
	else
	{
		sprintf(message,"ppage %d You do not have enouph money to purchase this!!",Get_Player_ID(enter));
		Console_Input(message);
	}
}

void Kamuix_Death_Announce::Killed(GameObject *obj,GameObject *shooter)
{
	GameObject *object;
	object = Commands->Find_Object(ID);
	char message1[1000];
	sprintf(message1,"msg Player %s has destroyed the %s",Get_Player_Name(shooter),Get_Parameter("DestroyedName"));
	Console_Input(message1);
}

void Kamuix_Damaged_Send_MsgFds::Damaged(GameObject *obj,GameObject *damager,float damage)
{
	char message4[1000];
	sprintf(message4,"%s",Get_Parameter("FDSMessage"));
	Console_Input(message4);

}

void Kamuix_Death_Send_MsgFds::Killed(GameObject *obj,GameObject *shooter)
{
	char message5[1000];
	sprintf(message5,"%s",Get_Parameter("FDSMessage"));
	Console_Input(message5);
}

ScriptRegistrant<Kamuix_PAMSG_Zone> Kamuix_PAMSG_Zone_Registrant("Kamuix_PAMSG_Zone","Player_Type:int,Message:string");
ScriptRegistrant<Kamuix_Send_FDS_MSG_Zone> Kamuix_Send_FDS_MSG_Zone_Registrant("Kamuix_Send_FDS_MSG_Zone","Message:string");
ScriptRegistrant<Kamuix_Team_Change_Zone> Kamuix_Team_Change_Zone_Registrant("Kamuix_Team_Change_Zone","Player_Type:int,Team:int");
ScriptRegistrant<Kamuix_Announce_Preset_Buy> Kamuix_Announce_Preset_Buy_Registrant("Kamuix_Announce_Preset_Buy","Preset_Name:string,Cost:int,location:vector3,Player_Type:int,DisplayName:String");
ScriptRegistrant<Kamuix_Death_Announce> Kamuix_Death_Announce_Registrant("Kamuix_Death_Announce","DestroyedName:string");
ScriptRegistrant<Kamuix_Damaged_Send_MsgFds> Kamuix_Damaged_Send_MsgFds_Registrant("Kamuix_Damaged_Send_MsgFds","FDSMessage:string");
ScriptRegistrant<Kamuix_Death_Send_MsgFds> Kamuix_Death_Send_MsgFds_Registrant("Kamuix_Death_Send_MsgFds","FDSMessage:string");
