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 → More problems with bob!
More problems with bob!
2003-01-29, 8:17 AM #1
Well, I decided to upgrade bob and add the feature of multiple modes. The idea is, that there are two modes. The first mode attaches bob to the player, the second mode detaches bob from the player wherever the mode was activated. All you have to do is press the activate button again after you have engaged mode one. But for some reason, the cog is running the modes at the same time and creating and destroying bob in one swift run of the script. here's what I have:

Code:
# Jedi Knight Cog Script
#
# bob.COG
#
# bob the cog does his best to bring justice to those deserving a terrible terrible death that involves many pointy objects!
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

model		bobmod=remo.3do		local

thing		bob				local
thing		player				local
thing		victim				local

sector		playersector			local

sound		bobshoot=ricochet03.wav	local
sound		dropbob=droidbody2.wav	local

template	bobtemp=ghost			local
template	projectile1=+bryarbolt	local

int		mode				local

vector		playerpos			local
vector		victimpos			local
vector		playerposa			local
vector		bobpos				local

message	startup
message	activated
message	pulse	

end

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

code

startup:
	player = GetLocalPlayerThing();
	mode = 0;
	return;

activated:
	if(mode == 0)
	{
		playersector = GetThingSector(player);
		playerpos = GetThingPos(player);
		bobpos = VectorAdd(playerpos,'0 0 0.1');
		bob = CreateThingatPos(bobtemp,playersector,bobpos,'0 0 0');
		SetThingModel(bob,bobmod);
		AttachThingToThingEx(bob,player,0x8);
		SetPulse(.05);
		mode = 1;
	}
	if(mode == 1)
	{
		bobpos = GetThingPos(bob);
		DetachThing(bob);
		PlaySoundPos(dropbob,bobpos,8,0,3,0x80);
		mode = 2;
	}
	if(mode == 2)
	{
		DestroyThing(bob);
		SetPulse(0);
		mode = 0;
	}
	return;

pulse:
	victim = FirstThingInView(bob,180,6,0x404);
 	while(victim != -1)
	{
		if(
			HasLos(bob,victim) &&
			(victim != player)
		)
		{
			victimpos = VectorSub(GetThingPos(victim),GetThingPos(bob));
			SetThingLook(bob,victimpos);
			FireProjectile(bob,projectile1,bobshoot,8,'0 0 0','0 0 0',1.0,0,0,0);
		}
	victim = NextThingInView();
	}
	return;
		
	

# ........................................................................................

end


I know that bob is being run, because I hear the drop sound in mode 2 (if(mode == 1); statement). So what did I do wrong? I'd imagine that the script is changeing the mode and moving on to the next if statement before I press the activate button again. How do I fix this?

------------------
Those who stare in the eyes of death and laugh will be the first to go.
Those who stare in the eyes of death and laugh will be the first to go.
2003-01-29, 10:13 AM #2
You sections are running together because your not telling the code to stop. You were missing Return;'s in Activated:

Code:
activated:
        if(mode == 0)
        {
              playersector = GetThingSector(player);
              playerpos = GetThingPos(player);
              bobpos = VectorAdd(playerpos,'0 0 0.1');
              bob = CreateThingatPos(bobtemp,playersector,bobpos,'0 0 0');
              SetThingModel(bob,bobmod);
              AttachThingToThingEx(bob,player,0x8);
              SetPulse(.05);
              mode = 1;
              Return; // Missing Return
        }
        if(mode == 1)
        {
              bobpos = GetThingPos(bob);
              DetachThing(bob);	
              PlaySoundPos(dropbob,bobpos,8,0,3,0x80);
              mode = 2;
              Return; // Missing Return
        }
        if(mode == 2)
        {
              DestroyThing(bob);
              SetPulse(0);	
              mode = 0;
              Return; // Not really needed unless you add more modes.
        }
        return;
- Wisdom is 99% experience, 1% knowledge. -
2003-01-29, 10:19 AM #3
or you can use the Else statement.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-01-29, 1:41 PM #4
Hoard why didnt you make bob an ai and go from there? Anyways maybe its easier to go this way.

Anyways just change these if's too:
else if(mode == 1)
else if(mode == 2)
Team Battle.

↑ Up to the top!