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 → Mutator cog
Mutator cog
2002-03-10, 4:13 AM #1
here it is (the random mutation works fine, but the killing mutation does not work at all):
Code:
symbols

thing		mutant				local
thing		victim				local
thing		killer				local
thing		kill				local

sound		catch=21forceabsorb1.wav	local
sound		release=forceabsorb02.wav	local

model		oldmodel			local
model		mutantskin=kyA17.3do		local

int		random				local
int		numplayers			local
int		score				local

message		loading
message		pulse
message		trigger
message		killed

end

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

code

loading:
	if(!IsServer()) Return;
	mutant = -1;
	SetPulse(10);
	Return;

pulse:
	numplayers = GetNumPlayers();
	if(numplayers < 2)
	{
		jkStringClear();
		jkStringConcatAsciiString("You are alone");
		jkStringOutput(-3, -1);
		Return;
	}

	jkStringClear();
	jkStringConcatAsciiString("Timed Mutation");
	jkStringOutput(-3, -1);

	random = Rand() * (numplayers - 1);
	victim = GetPlayerThing(random);
	if(victim == mutant) victim = GetPlayerThing(random + 1);
	
	SendTrigger(-1, 112, mutant, victim, -1, -1);
	Return;

trigger:
	if(GetSourceRef() == 112)
	{
		SetPulse(0);
		mutant = GetParam(0);
		victim = GetParam(1);
		SetThingModel(mutant, oldmodel);
		PlaySoundThing(release, mutant, 1.0, -1, -1, 0x80);

		oldmodel = GetThingModel(victim);
		SetThingModel(victim, mutantskin);
		PlaySoundThing(catch, victim, 1.0, -1, -1, 0x80);
		mutant = victim;
		SetPulse(60);
	}

	Return;

killed:
	victim = GetSenderRef();
	kill = GetSourceRef();
	killer = GetThingParent(kill);
	if(victim == killer) Return;
	if(killer == mutant)
	{
		jkStringClear();
		jkStringConcatAsciiString("Mutation due to kill");
		jkStringOutput(-3, -1);

		SendTrigger(-1, 112, mutant, victim, -1, -1);
	}
	else if(victim == mutant)
	{
		jkStringClear();
		jkStringConcatAsciiString("Mutant got killed");
		jkStringOutput(-3, -1);
		score = GetPlayerScore(killer);
		score = score + 5;
		SetPlayerScore(killer, score);
	}
	
	Return;
end
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-03-10, 12:45 PM #2
This is a problem:

Code:
random = Rand() * (numplayers - 1);
victim = GetPlayerThing(random);


Assigning a flex value to an integer does not truncate the flex part of the value. Instead, random will become a flex to accomodate the new value. Using PrintInt(), you wont see this. But use PrintFlex(), and those decimal digits will be there.

To fix this, use:
Code:
random=random-random%1;


Try that and see. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.

[This message has been edited by SaberMaster (edited March 10, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-03-11, 1:03 AM #3
hmm...ok, but that's not the problem. The problem is that the mutation due to kill (killed message) does not work properly. If the mutant killed someone, the mutant should get remuted and the victim should become the mutant, and if someone killed the mutant, he should get 5 points. But it gets all messed up instead...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-03-11, 6:12 AM #4
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
This is a problem:

Code:
random = Rand() * (numplayers - 1);
victim = GetPlayerThing(random);


Assigning a flex value to an integer does not truncate the flex part of the value. Instead, random will become a flex to accomodate the new value. Using PrintInt(), you wont see this. But use PrintFlex(), and those decimal digits will be there.

[/b]</font>


SM, if you use a flex instead of an int inside a cog verb, JK will chop off the decimal places. Like in GetPlayerThing(random);, if random was 4.5, JK would just accept the 4. Heck, I've used rand() that way with arrays and it works with no problem. [http://forums.massassi.net/html/smile.gif]
-Hell Raiser
2002-03-11, 12:48 PM #5
No one here has yet caught onto his real problem?!?! =)

It's not recieving the killed message because you have not captured that message. I don't know what exactly you are trying to get the message from though, so I can't quite tell you what to do. There are two ways to go about it though, one is to use CaptureThing(thing) on the thing that is going to be killed, and the other is to flag the thing variable in the cog using a flag which I have forgotten.

------------------
His pot is blacker than his kettle!
"And lo, let us open up into the holy book of Proxy2..." -genk
His pot is blacker than his kettle!
2002-03-11, 1:02 PM #6
When a thing that is included in the Symbols section is killed it will send a killed message to the cog. The thing doesn't need any flags added (at least not if it is an AI in single player).

------------------
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
2002-03-11, 1:34 PM #7
Quote:
<font face="Verdana, Arial" size="2">SM, if you use a flex instead of an int inside a cog verb, JK will chop off the decimal places.</font>


Yeah, I wasn't looking for that. My bad.

Quote:
<font face="Verdana, Arial" size="2">It's not recieving the killed message because you have not captured that message.</font>


Hmm... I assumed this was an items.dat cog with the flags to receive the player's messages.

Quote:
<font face="Verdana, Arial" size="2">When a thing that is included in the Symbols section is killed it will send a killed message to the cog.</font>


Only when a thing's value is passed from a JKL will its messages be received by the cog. Just listing it in the symbols will not work.

Zagibu:

You can't directly set a player's score with SetPlayerScore() unless JK's scoring system is disabled (0x4 MP Mode Flag). I explained this fully in the Score Verb notes of the DataMaster.

And is the kill message being called?

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.

[This message has been edited by SaberMaster (edited March 11, 2002).]

[This message has been edited by SaberMaster (edited March 12, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-03-12, 9:22 AM #8
ok. There is a mutant in this mod. At a given time interval, he will be randomly chosen. That works. But I also want the mutant to have the possibility to be "freed" before that interval and that should happen when he kills another player. If another player kills him, this player should get 5 extra points. But that does not work. I assume it is not getting called. Any ideas to fix it?
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-03-12, 9:51 AM #9
Use CaptureThing(victim) to receive the killed message of victim. You might also want to release the old victim with ReleaseThing(oldVictim).

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!