Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → cog problem
cog problem
2002-01-25, 6:26 AM #1
Well, I'm making a cog that gets the current sector of a player, creates an NPC, and then makes it into a sidekick useing the 00_aisidekick cog. Please help.
Code:
 # Jedi Knight Cog Script
#
# sidekick.cog
#
# Sidekick is generated an follows character # around. Sidekick for now is noncombatant.
#
# 
# ==========================================

symbols

message      startup
message      entered
message      killed
message      pulse

sector       trigger

thing        sidekick=mn.3do  linkid=0
thing        master           linkid=1

flex         followspeed=1       

end

# ===========================================

code

startup:

   master = GetSourceRef();
   trigger = GetThingSector(master);
   SetPulse(1);

Return;

# ===========================================

entered:
	SetPulse(0);
	CreateThing(sidekick, master);
 	AISetMoveSpeed(sidekick, followspeed);
	AISetMode(sidekick, 0x1);

Return;

# ===========================================

killed:

	SetPulse(0);
	DestroyThing(sidekick);

Return; 

# ===========================================

pulse:

AISetLookPos(sidekick, masterpos);
AISetMoveThing(sidekick, GetThingPos(master));

Return;

end

Please help.
"The world is neither black nor white but differing shades of gray."
-By me.
2002-01-25, 7:58 AM #2
Yes, you do have problems. [http://forums.massassi.net/html/frown.gif]

Code:
thing        sidekick=mn.3do  linkid=0


You need a sidekick template and a sidekick thing. And you don't need linkids. Do like
this:
Code:
thing   sidekick   local
template sktemp=man1   local


^That's assuming that man1 is the name of your sidekick template.

Code:
master=GetLocalPlayerThing();


^That is how to get a handle on the player. Source and Sender are message properties.

Code:
trigger = GetThingSector(master);


Since you don't have a "local" after trigger in the symbols, you are already defining
trigger in JED? Why are finding the player's sector in startup? You're not using it.

Code:
entered:
SetPulse(0);
CreateThing(sidekick, master);
 AISetMoveSpeed(sidekick, followspeed);
AISetMode(sidekick, 0x1);
Return;


Why are you stopping the pulse just when you create the sidekick? CreateThing() will
create the sidekick right on top of the player. Instead, the sidekick should be in
the level(unless this is MP). What are you expecting the 0x1 mode to do? It's not going
to do anything there.

CreateThing() creates a template and returns the thingref of the thing once it is created.
IE:
Code:
thingref=CreateThing(template, thing);


Code:
killed:
SetPulse(0);
DestroyThing(sidekick);
Return;


Why destroy the sidekick when he dies?

Code:
pulse:
AISetLookPos(sidekick, masterpos);
AISetMoveThing(sidekick, GetThingPos(master));
Return;


masterpos is not defined and AISetMoveThing() uses a thing to move to, not a position.

Fix those errors and post the cog again or if it runs, tell us what problems you have. [http://forums.massassi.net/html/smile.gif]

[This message has been edited by SaberMaster (edited January 25, 2002).]

[This message has been edited by SaberMaster (edited January 25, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-25, 8:06 AM #3
Sorry if the above was a little sketchy. [http://forums.massassi.net/html/redface.gif]

------------------
More matter with less art.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!