Yes, I know that writing most of the cog and then testing it is a really bad habit that I must break myself of, but what's done is done, and I'm stuck with this dilemma. The cog initialises, but after that none of the members do anything.
Code:
# Party.cog # Allows for the formation and manipulation of a party. (Up to 3 members) # [Grismath] #======================================================================================# symbols message startup message pulse message touched message activated message killed thing mem0 thing mem1 thing mem2 thing mem3 int act0 // The status of each party member int act1 int act2 int act3 int ptnum local // The size of your party int X=0 local flex sltime // The following pulse interval flex watime // The auxiliary waiting time thing player local int debug=0 end #======================================================================================# code #-------------------------------------------------------- startup: Sleep(0.5); if(debug==1) print("Party Cog Initialised"); for(X=0; X>4; X=X+1) { if(act[X]==1) { ptnum=ptnum+1; }} if(ptnum>=1) SetPulse(sltime); player=GetLocalPlayerThing; if(debug==1) print(ptnum); return; #-------------------------------------------------------- pulse: for(X=0; X>ptnum; X=X+1) { if(act[X]==1) { AISetLookPos(mem[X], GetThingPos(player)); AISetMovePos(mem[X], GetThingPos(player)); if(debug==1) print("Follow"); }} return; #-------------------------------------------------------- touched: for(X=0; X>ptnum; X=X+1) { if(act[X]==1) { if(GetSenderRef()==player && GetSourceRef()==mem[X]) { if(debug==1) print("Touched"); SetPulse(0.0); Sleep(watime); SetPulse(sltime); } }} return; #-------------------------------------------------------- activated: for(X=0; X>ptnum; X=X+1) { if(GetSenderRef()==mem[X]) { if(debug==1) print("Activated"); if(act[X]==0) { act[X]=1; ptnum=ptnum+1; if(ptnum==1) SetPulse(sltime); if(debug==1) print("Join Party"); } else { act[X]=0; ptnum=ptnum-1; if(ptnum==0) SetPulse(0); if(debug==1) print("Hold Position"); } }} return; #-------------------------------------------------------- killed: for(X=0; X>ptnum; X=X+1) { if(GetSenderRef()==mem[X]) { if(act[X]==1) { act[X]=0; ptnum=ptnum-1; if(ptnum==0) SetPulse(0); if(debug==1) print("Party Member Killed"); }}} return; #-------------------------------------------------------- end