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 → a few twittle errors
a few twittle errors
2001-03-17, 12:47 PM #1
okay i got two cogs. and since i am not the best cog writer they have some errors. the first one a lot of people have been having problems with. It is supposed to make an enemy be friendly. That cog doesn't print anything so it screws up near the begining.

Code:
# Han5678 Cog Script
#
# FORCE_CONVERT.COG
#  Bin 116
#
# This script converts an enemy into a friendly.
#
# [Han5678]
#
# (C) 2001 Han5678 All Rights Reserved


symbols

thing        player                             local                         
thing        victim                             local                         
ai           friend=frd.ai                      local                         
flex         cost=100.0                         local                         
flex         mana                               local                         
                                                         
message      startup                                                        
message      activated                                                          
message      pulse                                                            

end                                                                           

# ========================================================================================
code
startup:
   player = GetLocalPlayerThing();

   Return;
# ........................................................................................
pulse:
     
      victim = FirstThingInView(player, 20 + 15 * rank, 2 + rank, 0x404);
      while(victim != -1)
 
	if(victim != -1)
      {
         jkSetTargetColors(6, 7, 8);
         jkSetTarget(victim);
      }
      else
      {
	AiSetClass(victim,friend);
	Print("It tastes good");
}
   Return;
# ........................................................................................
activated:

   if(IsInvActivated(player, 116)) Return;

   mana = GetInv(player, 14);
   if(mana >= cost)
   {
      SetInvActivated(player, 116, 1);
      if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
      rank = GetInv(player, 116);
      Print("I like pizza");
}

   Return;

end


here is my other cog. It is supposed to change your 3do every time u use it. This does absolutely nothing. I was pretty sure i had this one set up right. I think it might be going through the list though, since i have it end on ky.3do as well as start but i doubt it.

Code:
# Han5678 Cog Script
#
# ITEM_MODEL.COG
#
# [Han5678]
#
# (C) 2001 Han5678 All Rights Reserved

symbols

thing        player                             local                         
model        model1=ky.3do                      local                         
model        model2=kyH4.3do                    local                         
model        model3=kyA10.3do                   local                         
model        model4=kyA12.3do                   local                         
model        model5=kyA16.3do                   local                         

message      activated                                                        
end                                                                           
# ========================================================================================

code

activted:

       player = GetSenderRef();
	if(GetThingModel(player) == model1)
   	{
		SetThingModel(player, model2);
	}
	else
   	if(GetThingModel(player) == model2)
   	{
		SetThingModel(player, model3);
	}
	else
   	if(GetThingModel(player) == model3)
   	{
		SetThingModel(player, model4);
	}
	else
   	if(GetThingModel(player) == model4)
   	{
		SetThingModel(player, model5);
	}
       else
   	if(GetThingModel(player) == model5)
   	{
		SetThingModel(player, model1);
	}

       return;
end


i hope someone can help me. I know it has nothing to do with my hotkeys. It has to be my horrible cogging.
roses are red, violets are blue, I am schizophrenic, and I am too!
2001-03-17, 2:56 PM #2
I didn't look all the way through, but in the first cog you have the statement:

while(victim != -1)

and then nothing afterwards

then you move on to if(victim != -1)

I think you are missing a bracket.

That second if statement is superflous if you contain the entire clause within the first while statement.
2001-03-17, 2:57 PM #3
On the second one, your else clauses aren't contained in brackets. Thats why it isn't working.

[edit]You could fix this easily by adding a return statement within the individual ifs. That way you don't have to deal with nesting. For example:

if(GetThingModel(player) == model1)
{
SetThingModel(player,model2);
return;
}
if(GetThingModel(player) == model2)
{
SetThingModel(player,model3);
return;
}

The return will stop the flow of code. I think. [/edit]

[This message has been edited by ApoK_DragonPhinn (edited March 17, 2001).]
2001-03-18, 7:01 AM #4
okay i see what u mean about the superflous. I have no idea why i stuck that in there i must have been asleep. Well thanks i probably could have figured out the first, with some time. The second though i thought i had it perfect. This helps alot, and hopefully will speed things up.
roses are red, violets are blue, I am schizophrenic, and I am too!
2001-03-19, 4:07 AM #5
In cog you don't have to nest the whole thing for single lines or if you want to nest the next whole thing.

ie : This is fine.

if(this == that) doThat;
else
if(that == next) doAnother;
else
.
.
.

So in the first cog, "while" is nesting the whole pulse message after "victim = ..." till "Return", if that is your intention.

------------------
http://millennium.massassi.net/ - Millennium
2001-03-19, 12:43 PM #6
Hey apoks way will still work won't it?
roses are red, violets are blue, I am schizophrenic, and I am too!
2001-03-19, 1:55 PM #7
To make an enemy be friendly, you just change values in the AI file, no?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-03-19, 2:14 PM #8
Yes i know how to do that but i am going to make this a force power. Like a new form of persausion. So when u use it your enemies help u and not shoot u.
roses are red, violets are blue, I am schizophrenic, and I am too!

↑ Up to the top!