Example #1
0
    EXPORT void __stdcall SPObjCollision(struct SSPObjCollisionInfo const &ci, unsigned int iClientID)
    {
	    returncode = DEFAULT_RETURNCODE;
	
		uint iShip;
		uint iClientIDTarget = HkGetClientIDByShip(ci.dwTargetShip);
		pub::Player::GetShip(iClientID, iShip);
		uint iType;
		pub::SpaceObj::GetType(ci.dwTargetShip, iType);
		if(iType == 65536)
		{
			float fMass;
			pub::SpaceObj::GetMass(iShip, fMass);
			if(set_fSpinProtectMass!=-1.0f && !iClientIDTarget && fMass>=set_fSpinProtectMass)
			{
				Vector V1, V2;
				pub::SpaceObj::GetMotion(ci.dwTargetShip, V1, V2);
				pub::SpaceObj::GetMass(ci.dwTargetShip, fMass);
				V1.x *= set_fSpinImpulseMultiplier * fMass;
				V1.y *= set_fSpinImpulseMultiplier * fMass;
				V1.z *= set_fSpinImpulseMultiplier * fMass;
				V2.x *= set_fSpinImpulseMultiplier * fMass;
				V2.y *= set_fSpinImpulseMultiplier * fMass;
				V2.z *= set_fSpinImpulseMultiplier * fMass;
				pub::SpaceObj::AddImpulse(ci.dwTargetShip, V1, V2);
			}
		}
	}
Example #2
0
	bool PlayerInfo::UserCmd_ShowInfo(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage)
	{
		const wchar_t *wszTargetName = 0;
		const wstring &wscCommand = GetParam(wscParam, ' ', 0);
		if (wscCommand == L"me")
		{
			wszTargetName = Players.GetActiveCharacterName(iClientID);
		}
		else
		{
			uint iShip;
			pub::Player::GetShip(iClientID, iShip);

			uint iTargetShip;
			pub::SpaceObj::GetTarget(iShip, iTargetShip);

			uint iTargetClientID = HkGetClientIDByShip(iTargetShip);
			if (HkIsValidClientID(iTargetClientID))
				wszTargetName = Players.GetActiveCharacterName(iTargetClientID);
		}

		if (!wszTargetName)
		{
			PrintUserCmdText(iClientID, L"ERR No target");
			return true;
		}

		string scFilePath = GetUserFilePath(wszTargetName, "-info.ini");
		wstring wscPlayerInfo = L"<RDL><PUSH/>";
		for (int i = 1; i <= MAX_PARAGRAPHS; i++)
		{
			wstring wscXML = IniGetLongWS(scFilePath, "Info", itos(i), L"");
			if (wscXML.length())
				wscPlayerInfo += L"<TEXT>" + wscXML + L"</TEXT><PARA/><PARA/>";
		}
		wstring wscXML = IniGetLongWS(scFilePath, "Info", "AdminNote", L"");
		if (wscXML.length())
				wscPlayerInfo += L"<TEXT>" + wscXML + L"</TEXT><PARA/><PARA/>";
		wscPlayerInfo += L"<POP/></RDL>";

		if (wscPlayerInfo.length() < 30)
		{
			PrintUserCmdText(iClientID, L"ERR No information available");
			return true;
		}

		HkChangeIDSString(iClientID, RSRCID_PLAYERINFO_TITLE, wszTargetName);
		HkChangeIDSString(iClientID, RSRCID_PLAYERINFO_TEXT, wscPlayerInfo);

		FmtStr caption(0, 0);
		caption.begin_mad_lib(RSRCID_PLAYERINFO_TITLE);
		caption.end_mad_lib();

		FmtStr message(0, 0);
		message.begin_mad_lib(RSRCID_PLAYERINFO_TEXT);
		message.end_mad_lib();

		pub::Player::PopUpDialog(iClientID, caption, message, POPUPDIALOG_BUTTONS_CENTER_OK);
		return true;
	}
Example #3
0
void __stdcall ShipDestroyed(DamageList *_dmg, DWORD *ecx, uint iKill)
{
	returncode = DEFAULT_RETURNCODE;
	if (iKill)
	{
		CShip *cship = (CShip*)ecx[4];
		//check the death was a player
		if (cship->is_player())
		{
			uint iDestroyedID = cship->GetOwnerPlayer();
			wstring wscDestroyedName = ToLower((wchar_t*)Players.GetActiveCharacterName(iDestroyedID));
			//check if they have a bounty
			BountyTargetInfo BTId = mapBountyTargets[wscDestroyedName];
			if (BTId.Char == wstos(wscDestroyedName) && stoi(BTId.xTimes) > 0 && BTId.active)
			{
				if (deleteBountyCfg(BTId))
				{
					///ConPrint(L"bounty removed from cfg\n");
				}
				else
				{
					ConPrint(L"BOUNTYTRACKER: Err removing from cfg. is server admin?\n");
				}
				// calls the killer the last one to damage the victim
				DamageList dmg;
				try { dmg = *_dmg; }
				catch (...) { return; }
				dmg = ClientInfo[iDestroyedID].dmgLast;

				//The killer's id
				uint iKillerID = HkGetClientIDByShip(dmg.get_inflictor_id());
				//The killer's name
				wstring wscKillerName = (wchar_t*)Players.GetActiveCharacterName(iKillerID);

				//check if player killed by ai
				if (stoi(wstos(HkGetAccountIDByClientID(iKillerID))) == -1)
				{
					///ConPrint(L"nevermind, ai got him");
					return;
				}
				if (iKillerID == iDestroyedID)
				{
					///ConPrint(L"killer and victim are the same");
					return;
				}
				if (ToLower(wscKillerName) == stows(BTId.issuer))
				{
					///ConPrint(L"killer was the issuer of the bounty");
					return;
				}
				// -1 to contracts left
				BTId.xTimes = itos(stoi(BTId.xTimes) - 1);
				if (stoi(BTId.xTimes) == 0)
				{
					//bounty has been fullfilled, clear all dataa
					BTId.active = false;
					BTId.Cash = "0";
					BTId.xTimes = "0";
					BTId.issuer = "n/a";
					BTId.lastTime = itos((int)time(0));
					BTId.issueTime = "0";
				}

				//upload into neural net
				mapBountyTargets[wscDestroyedName] = BTId;
				if (appendBountyCfg(BTId))
				{
					///ConPrint(L"cfg saved\n");
				}
				else
				{
					ConPrint(L"BOUNTYTRACKER: Err saving to cfg. is serevr admin?\n");
				}

				//Print Friendly Wide String TargetInfo
				wstring PFwsTargetInfo;
				PFwsTargetInfo = L"Target: ";
				PFwsTargetInfo += ToLower(wscDestroyedName);
				PFwsTargetInfo += L" Worth: ";
				PFwsTargetInfo += stows(BTId.Cash);
				PFwsTargetInfo += L" Contracts Left: ";
				PFwsTargetInfo += stows(BTId.xTimes);
				PFwsTargetInfo += L" Issuer: ";
				PFwsTargetInfo += stows(BTId.issuer);
				PFwsTargetInfo += L" Issued at: ";
				PFwsTargetInfo += stows(BTId.issueTime);

				//add bounty cash
				HkAddCash(wscKillerName, stoi(BTId.Cash));
				PrintUserCmdText(iKillerID, L"Successfully collected bounty on");
				PrintUserCmdText(iKillerID, PFwsTargetInfo);
				PrintUserCmdText(iKillerID, L"Alerting bounty issuer...");
				wstring IssuerMailMsg = L"Bounty Alert: " + wscKillerName + L" Has collected your bounty on " + wscDestroyedName + L". " + stows(BTId.xTimes) + L" Contracts remaining.";
				MailSend(stows(BTId.issuer), MSG_LOG, IssuerMailMsg);
				PrintUserCmdText(iKillerID, L"Saving record...");
				wstring KillerMailMsg = L"Bounty Alert: " + wscKillerName + L" Has collected a bounty on " + wscDestroyedName + L". " + stows(BTId.xTimes) + L" Contracts remaining.";
				MailSend(wscKillerName, MSG_LOG, KillerMailMsg);
				PrintUserCmdText(iKillerID, L"OK");
				return;
			}
			else
			{
				///ConPrint(L"bounty tracker found no name match, or no more contracts for name\n");//either the name didn't match, or they have exhaused the number of contracts left on them.
			}
		}
		else
		{
			///ConPrint(L"Bounty tracker found dead ai\n");//never mind, it's just an ai death
		}
	}
	return;
}