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 → Darn COG!!!
Darn COG!!!
2003-07-22, 11:46 AM #1
Hi!
What's wrong here?
Code:
# You kill him, he drops stuff...
#
# By Edward
symbols

message		killed

thing		guy

template	item

end
#
code
killed:
	If(GetSenderRef()!=guy) return;
	CreateThing(item,guy);
return;
end

When I kill guy, he does not "drop" the template keyyellow...
/Edward


[This message has been edited by Edward (edited July 22, 2003).]
Edward's Cognative Hazards
2003-07-22, 12:28 PM #2
Hi there - I hope this code serves your needs [http://forums.massassi.net/html/smile.gif]

Apologies about the formatting - I'm not too hot with UBB codes :S

Code:
# Jedi Knight Cog Script
#
# actor_key.COG
#
# Actor COG for character.
# Creates a key colour of your choice upon death
#
#
# lucky_jackpot@hotmail.com
# [RJS]
#
# ========================================================================================
symbols

message         killed
message         skill
message         damaged

template        key
thing           newThing                local
int             bin                     local
flex            rval                    local
flex            damageType              local
flex            damageAmount            local
flex            totalDamage             local

end

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

code

killed:
      newThing = CreateThing(key, GetSenderRef());
      return;

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

skill:
   bin = GetParam(0);
   if (bin == 31)       // Force Grip
   {
      ReturnEx(10);     // return base damage that is taken by this actor.
      return;
   }
   else
   if (bin == 34)       // Deadly Sight
   {
      ReturnEx(5);      // return base damage that is taken by this actor.
      return;
   }
   ReturnEx(-1);
   return;


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

damaged:
   damage = GetParam(0);
   if(GetParam(1) == 16)
   {
      damage = (damage * 2.0);
   }
   ReturnEx(damage);
   return;

end
#=================================


Let me know if this doesn't work and I'll gladly try and iron out any glitches, though it should be fine [http://forums.massassi.net/html/biggrin.gif]

------------------
"Life is mostly froth and bubble,
But two things stand in stone,
Kindness in another's trouble,
Courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)


[This message has been edited by lucky_jackpot (edited July 22, 2003).]
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||
2003-07-22, 1:59 PM #3
i think he wants a level cog, may i personaly surjest 12_officerkey.cog

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-07-22, 9:01 PM #4
I'd be more interested in why such a simple cog doesn't work, than in trying to find a new one. I don't see a thing wrong with the cog, it should work. Make sure you gave the cog correct variables in the level.

And you can remove the sender check from the cog. It's not like the cog is going to secretly capture a random thing from the level and steal its killed messages...

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-22, 9:47 PM #5
OK, I forgot something in the code... I didn't include them because at the moment I had put // infront of them because I was waiting for a reply on something on another topic...
Code:
# You kill him, he drops stuff...
#
# By Edward
symbols

message		killed

thing		guy

template	item

end
#
code
killed:
	If(GetSenderRef()!=guy) return;
	if(item==LoadTemplate("random"))
	{
		     if(rand()==0.0)                { item=LoadTemplate("+drepeatergun"); }
		Else If(rand()>=0.0 && rand()<0.1)  { item=LoadTemplate("+dhealthpack"); }
		Else if(rand()>=0.1 && rand()<0.2)  { item=LoadTemplate("+dbactatank"); }
		else if(rand()>=0.2 && rand()<0.3)  { item=LoadTemplate("+dshield"); }
		Else if(rand()>=0.3 && rand()<0.4)  { item=LoadTemplate("+dbattery"); }
		else if(rand()>=0.4 && rand()<0.45) { item=LoadTemplate("+denergycell"); }
		else if(rand()>=0.45 && rand()<0.5) { item=LoadTemplate("+drailgun"); }
		else if(rand()>=0.5 && rand()<0.55) { item=LoadTemplate("+dpowercell"); }
		else if(rand()>=0.55 && rand()<0.6) { item=LoadTemplate("+dconcrifle"); }
		else if(rand()>=0.6 && rand()<0.7)  { item=LoadTemplate("+dsmbp"); }
		else if(rand()>=0.7 && rand()<0.8)  { item=LoadTemplate("+dgreedopistol"); }
		else if(rand()>=0.8 && rand()<0.9)  { item=LoadTemplate("+ddetonator"); }
		else if(rand()>=0.9 && rand()<1.0)  { item=LoadTemplate("+dsingle"); }
		else if(rand()==1.0)                { item=LoadTemplate("+dcrossbow"); }
	}
	CreateThing(item,guy);
return;
end

But I did set the item for the key for one guy, and for another I set random... None drop anything...

/Edward
Related Topic: http://forums.massassi.net/html/Forum4/HTML/003830.html

[This message has been edited by Edward (edited July 23, 2003).]
Edward's Cognative Hazards
2003-07-23, 5:13 AM #6
Do you really have a template named random in your jkl? You can't just enter a string in JED because templates are integers holding a number of a template in a jkl.

The second major problem is that you can't use Rand() that way. Rand() isn't going to return the same thing every time, so testing it's value in those if else statements is useless. So you'll have to create a variable, assign it to Rand() and then check it.

Rand() is hardly ever going to return 0 or 1 so no use testing for them. And when you're using else statements, you don't need extra conditions to make sure the previous condition was false. E.g.,

Code:
Else If(rand()>=0.0 && rand()<0.1)  { item=LoadTemplate("+dhealthpack"); }
Else if(rand()>=0.1 && rand()<0.2)  { item=LoadTemplate("+dbactatank"); }


The code in bold is not doing anything because we already know that (assuming that you fix it to use a variable) random is greater than 0 if the first else is running and greater than 0.1 if the second is running, etc.

And always post all of the relevant code when you can - don't cut stuff out like that.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited July 23, 2003).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-23, 6:53 AM #7
The reason for not posting all of it is because at the moment the entire random block had // infront of them... I was waiting for help from somewhere else about the template testing. Anyway... I won't be able to test the COG simply because of a BIG error...

/Edward
Edward's Cognative Hazards
2003-07-23, 11:07 AM #8
I'm assuming you all noticed that he didn't define 'guy' anywhere, right?

Also, instead of loadtemplate, try template=(template defined in symbols); then after all of that have a creatething.
------------------
Brutally honest since 1998

[This message has been edited by Checksum (edited July 23, 2003).]
2003-07-23, 11:14 AM #9
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Checksum:
I'm assuming you all noticed that he didn't define 'guy' anywhere, right?

Also, instead of loadtemplate, try template=(template defined in symbols); then after all of that have a creatething.
</font>


Duh... ¿Qué? What COG are you on???

------------------
Edward's Cognative Hazards
2003-07-23, 8:06 PM #10
Code:
# Yep, this is it.
symbols

template item0=+drepeatergun
template item1=+dhealthpack
template item2=+dbactatank
template item3=+dshield
template item4=+dbattery
template item5=+denergycell
template item6=+drailgun
template item7=+dpowercell
template item8=+dconcrifle
template item9=+dsmbp
template item10=+dgreedopistol
template item11=+ddetonator
template item12=+dsingle
template item13=+dcrossbow

message startup
message killed

thing guy

end

# code section

code

# ........

startup:
player=getlocalplayerthing();
return;

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

killed:
if(player!=getsenderref()) return;
creatething(item0[rand()*14], player);
return;

end


Try this.

Loadtemplate is urban legend, if(item==loadtemplate("random")) is a fairy tale.

[edit] not called for.

[This message has been edited by Checksum (edited July 23, 2003).]

[This message has been edited by SaberMaster (edited July 24, 2003).]
2003-07-23, 10:10 PM #11
Hay! I don't want it always random.
Sometimes I want only a specific object, sometimes a random object...

/Edward
Edward's Cognative Hazards
2003-07-24, 1:58 AM #12
[edit] also not called for.

[This message has been edited by SaberMaster (edited July 24, 2003).]
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-07-24, 2:32 AM #13
CM I am lead to believe that its actually possible to get that 14th element in the array...

------------------
Team Battle.
Team Battle.
2003-07-24, 6:57 AM #14
Well Ed, you have to tell us the circumstances for certain items.

------------------
Brutally honest since 1998
2003-07-24, 11:32 AM #15
Checksum, I don't see how it becomes your obligation to accuse me for making so-called mistakes. Maybe you were just trying to help out, but don't get out of line like that again.

Quote:
<font face="Verdana, Arial" size="2">I'm assuming you all noticed that he didn't define 'guy' anywhere, right?</font>


It's defined from his jkl.

So you think LoadTemplate() is an urban legend? Have you ever tried it? I know it's in the DM.

But you may be partly right about the item == LoadTemplate() condition. Maybe LoadTemplate() won't return the same number as item even though they're the same template. It's worth testing.

Since we're on to finding errors in cogs, how about that last one? Seems to be a level cog with an array of fourteen items, one thing, and the startup and killed messages.

We know startup will run, it runs in every cog. And we have a thing in the symbols which can send us the killed event. But then why are we returning in killed if the player is not the sender? Unless guy and player are the same, the rest of killed won't run. I don't see why player is even in the cog, he's not in the symbols.

As far as the [rand()*14] goes, that's not a problem. Yeah, every 75,000 times this cog is run, it'll try to use startup as a template, and then it will create whatever template is fourth in the jkl.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited July 24, 2003).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!