20_bocsearch.cog
6 years ago
Skåne, Sweden

[quote]

symbols message startup message timer message pulse

thing		darkJedi			nolink

sector	sect0				nolink

thing		searchNode0		nolink
thing		searchNode1		nolink
thing		searchNode2		nolink
thing		searchNode3		nolink
thing		searchNode4		nolink
thing		searchNode5		nolink
thing		searchNode6		nolink
thing		searchNode7		nolink
thing		searchNode8		nolink
thing		searchNode9		nolink
thing		searchNode10	nolink
thing		searchNode11	nolink
thing		searchNode12	nolink
thing		searchNode13	nolink
thing		searchNode14	nolink
thing		searchNode15	nolink

float		searchWait=5.0
float		searchSpeed=2.0

int		searchNodes=-1	local
vector	currNode			local

int		player			local
float		lastSeenTime	local
int		looking=0		local

int		i=0				local
int		debug=0			local

end

code

startup: player = jkGetLocalPlayer(); SetTimerEx(1.0, 1, 0, 0);

for (i=0; i<=15; i=i+1)
{
	if (searchNode0[i] >= 0)
		searchNodes = searchNodes + 1;
}	
	if (debug) print("Number of Search Nodes:");
	if (debug) printint(searchNodes);
return;

timer: if (GetSenderId() == 1) { if (HasLOS(darkJedi, player)) { SetPulse(0.0); lastSeenTime = GetLevelTime(); looking = 0; } else { if ((!looking) && ((GetLevelTime() - lastSeenTime) > searchWait)) { if (debug) print("Looking for Kyle..."); call StartSearch; looking = 1; } } SetTimerEx(1.0, 1, 0, 0); } return;

StartSearch: currNode = 0; if (GetThingSector(darkJedi) == sect0) { // Boc is in the main chamber currNode = 0; } else { for (i=1; i<=searchNodes; i=i+1) { if (VectorDist(GetThingPos(darkJedi), GetThingPos(searchNode0[i])) < VectorDist(GetThingPos(darkJedi), GetThingPos(searchNode0[currNode]))) { currNode = i; } } } call DJMove; return;

DJMove: if (debug) print("Heading to node:"); if (debug) printint(currNode); AISetMode(darkJedi, 0x200); // awake and active AISetLookPos(darkJedi, GetThingPos(searchNode0[currNode])); AISetMovePos(darkJedi, GetThingPos(searchNode0[currNode])); AISetMoveSpeed(darkJedi, searchSpeed); SetPulse(0.5); return;

pulse: if (debug) printflex(VectorDist(GetThingPos(darkJedi), GetThingPos(searchNode0[currNode])));

call DJMove;
if (VectorDist(GetThingPos(darkJedi), GetThingPos(searchNode0[currNode])) < 0.2)
{
	if (debug) print("Reached Node:");
	if (debug) printint(currNode);
	// Dark Jedi has reached a node
	SetPulse(0.0);
	if (currNode == searchNodes)
	{
		currNode = 0;
	}
	else
	{
		currNode = currNode + 1;
	}		
	call DJMove;
}
return;

end [/quote]

Modificato da l'autore 6 years ago
Statistiche del gioco
Follower
75
Runs
123
Giocatori
15
Giocate recenti
Discussioni recenti
Pubblicato 6 years ago
0 risposte
Pubblicato 7 years ago
0 risposte
Pubblicato 7 years ago