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 → Arrrgh i hate COG!!
Arrrgh i hate COG!!
2001-06-21, 2:33 PM #1
i need a cog that does this
-The Cog Starts when Walkplayer enters specified sector 1
-The Cog generates enemy1 at thing1
-The enemy then walks to thing2
-The enemy then follows a set of frames over and over again (so he looks like he is patrolling)
-if he sees you he stops the patrol to chase you
-if he dies the cog starts all over again creating enemy1 ...
-The loop ends when Walkplayer enters specified sector 2

this is what i came up with sofar

Code:
# ROX Cog Script
#
# ENEMYPATHGENERATOR.COG
#
# Creates enemy and has him follow frames until player is seen.
#
#[Han5678]
 


symbols

thing        player                             local                         
thing        ghost1                                                           
thing        ghost2                                                           
thing        enemy                              local                         

template     enemy                                                            

sector       sector1                            linkid=1                      
sector       sector2                            linkid=2                      

int          cur_num=0                          local                         
int          cur_alive=0                        local                         
int          generate_num=1                     local                         
int          max_alive                          local                         


message      startup                                                          
message      entered                                                          
message      pulse                                                            
message      killed                                                           
message      sighted                                                                                                              

end                                                                           

# ========================================================================================
code

starup:
	player = GetLocalPlayerThing();
  return;

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

entered:
   if (GetSenderId() == 1) //if it is first sector create player
      {
      SetPulse(1);
      }
   else if (GetSenderId() == 2) // if it is second sector kill him and call it a day
      {
	DestroyThing(enemy);
	SetPulse(0);                    
       }	
  return;

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

pulse:
	if((cur_alive < max_alive)) //see if we have room for one more enemy
	{
		enemy = CreateThing(enemy, ghost1); // if so create him and make it so we can't have any more
		CaptureThing(enemy); // enemies
		cur_num   = cur_num + 1;
		cur_alive = cur_alive + 1;
		if(cur_num >= generate_num) SetPulse(0);
	}
  return;

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

killed:
	cur_alive = cur_alive - 1; //if he is killed set pulse to replace him
	SetPulse(1);
  return;

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

sighted:
	StopThing(enemy); //if the player sees him stop the enemy and make him go after player
	AISetInterest(enemy,player);
  return;
end


first of all the thing doesn't work. i am not very good with links so that might be the problem. second of all i can't figure out how to get the enemy to follow frames since he isn't created until the player enters sector1 i need help on this asap this is extremely aggravaiting and would like to get it solved soon
roses are red, violets are blue, I am schizophrenic, and I am too!
2001-06-22, 7:20 AM #2
I would base it on one of the cogs from any level with a stormtrooper in it! Just open it in a level editor or whatever and extract it. If you use MotS, open the generator from the very first level. I figured that out because i realized that it triggers a landing craft to descend when you walk into the second room. If you need cogs to base stuff on, and you don't have it already, get MotS. It's got some cool ones.
Aisha Clan-Clan: "The Ctarl-Ctarl are an invincible race of beings. We're all as strong as ten humans!"
Gene Starwind: "Is that so?"
*Pulls out his Caster Gun and shoots her. She lies on the ground in a daze*
Gene Starwind: "Wow, you really are invincible!"

- Excerpt from 'Outlaw Star,' Episode 5
2001-06-22, 8:34 AM #3
i am using mots and anyways i can fix most of it but the part i need help on is i can't figure out a way to assign frames to an object that has not yet been created and then have those frames loop. And also i was wondering if this code would work at all?
roses are red, violets are blue, I am schizophrenic, and I am too!
2001-06-23, 10:03 AM #4
come on people i need some help here
roses are red, violets are blue, I am schizophrenic, and I am too!
2001-06-24, 6:41 AM #5
Take a look at the 00_aiframepatrol.cog in JK, you can probably figure out quickly how to accomplish what you want.

About moving things to frames that aren't there, simply put a check before doing anything.

ie:
if(enemy)
{
\\do stuff here
}

That way, the code wont give you an error, but will function when the enemy is created.
2001-06-24, 6:57 AM #6
okay thanks i never would of thought of that i have the rest of the cog working now so i just needed help with the frame thing
roses are red, violets are blue, I am schizophrenic, and I am too!

↑ Up to the top!