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 → Stunhit Cog - Need Help
Stunhit Cog - Need Help
2001-04-19, 8:30 AM #1
Code:
#================================================================================================#
# Jedi Knight Cog Script									 #
#											         #
# STUNHIT.COG										 	 #
#												 #
# [Darth Haun 1999]										 #
#================================================================================================#

symbols

thing		victim					local
template	sphere_tpl=+stunfield		local
int		sphere=-1				local
int		type						local
flex		weapon					local

message	touched
message	timer

end

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

Code

Touched:

	victim = GetSourceRef();
        type = GetThingType(victim);        

        if(type == 2)                       // ACTOR
        {
               sphere = CreateThingAtPosNR(sphere_tpl, GetThingSector(victim), GetThingPos(victim), '0.0 0.0 0.0');
               AttachThingToThingEx(sphere, victim, 0x8);
               SetParticleGrowthSpeed(sphere, -0.3);
               SetLifeLeft(sphere, 1.5);
	       SetActorFlags(victim, 0x40000);
	       weapon=GetActorWeapon(victim, 1);
               SetActorWeapon(victim, 1, -1);
	       KillTimerEx(victim);
	       SetTimerEx(1.5, victim, GetThingSignature(victim), 0);
        }
        else if(type == 10)                 // OTHER PLAYER
        {
               sphere = CreateThingAtPosNR(sphere_tpl, GetThingSector(victim), GetThingPos(victim), '0.0 0.0 0.0');
               AttachThingToThingEx(sphere, victim, 0x8);
               SetParticleGrowthSpeed(sphere, -0.3);
               SetLifeLeft(sphere, 1.5);
	       SetActorFlags(victim, 0x40000);
	       KillTimerEx(victim);
	       SetTimerEx(1.5, victim, GetThingSignature(victim), 0);
        }

   Return;

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

Timer:

if(GetParam(0) == GetThingSignature(GetSenderId()))
{
   if(type == 2)                       
   {
	ClearActorFlags(GetSenderId(), 0x40000);
	SetActorWeapon(GetSenderId(), 1, weapon);
   }
   ClearActorFlags(GetSenderId(), 0x40000);
}

Return;

End
#===============================================#


This is IWP2's stunhit cog. But it has at least two problems.
When you stun an AI, this cog finds out what weapon the AI has and saves it to a variable.
Then, the cog sets the actor's weapon to -1. So, if you stunned him twice, weapon would get a
value of -1 and the real value would be lost.

I think that can be fixed with
Code:
 if(getactorweapon(victim, 1) > -1) weapon=GetActorWeapon(victim, 1);
Does that seem ok?

The other problem is when you stun two AI. Weapon will be set to the last stunned AI's
weapon bin number. So, the one that was stunned first will be given the second's bin
number when the timer ends. This problem I really need help on as it is way too complicated for me.
Thankyou [http://forums.massassi.net/html/wink.gif]

------------------
And though your very flesh and blood
..Be what your Eagle eats and Drinks,
You'll praise him for the best of birds,
..Not knowing, what the Eagle thinks. -Cassandra

[This message has been edited by SaberMaster (edited April 19, 2001).]

[This message has been edited by SaberMaster (edited April 19, 2001).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-04-19, 8:31 AM #2
Have you asked permission to use the cog?

------------------
Together we stand.
Divided we fall.
2001-04-19, 8:36 AM #3
Han5678 told me that Darth_Haun no longer edits. I have emailed him, but he didn't answer me.

Here's what he said in the readme:
Quote:
<font face="Verdana, Arial" size="2">Anyone MAY use the contents of this patch in levels, patches, TCs, or any modification as long
as you notify me.</font>


So, I guess it's ok.

------------------
And though your very flesh and blood
..Be what your Eagle eats and Drinks,
You'll praise him for the best of birds,
..Not knowing, what the Eagle thinks. -Cassandra

[This message has been edited by SaberMaster (edited April 19, 2001).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-04-19, 12:36 PM #4
Yeah iwp2 was his retirement project, So i don't think he would mind, as long as u warn him.
roses are red, violets are blue, I am schizophrenic, and I am too!
2001-04-21, 3:12 PM #5
I need someone good at COG to help with this. [http://forums.massassi.net/html/smile.gif]

------------------
Warning! User is not Windows compatible.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-04-21, 3:44 PM #6
Found good points.
The first problem may be solved that way.
As for the second, send the weapon variable in the SetTimerEx as the 2nd parameter and recover it in the timer message with GetParam(1) to set the actor weapon.

------------------
http://millennium.massassi.net/ - Millennium
2001-04-23, 6:12 AM #7
I just did some testing and the cog is working great, but, there's one small problem left.

Look at this code:

if(getactorweapon(victim, 1) > -1)
weapon=GetActorWeapon(victim, 1);
SetActorWeapon(victim, 1, -1);
KillTimerEx(victim);
SetTimerEx(1.5, victim, GetThingSignature victim), weapon);


If you stun an AI, then stun another AI and then stun the first again, the first will get the second's weapon. Because the first AI had a weapon value of -1 when he was stunned, the last weapon value was used in its place. You won't notice it if you keep stunning the same AI, but when you stun one with different weapon and then stun an AI with the -1 value, the AI with the -1 will get the wrong weapon.

Thanks for your help, Hideki [http://forums.massassi.net/html/smile.gif]

------------------
Warning! User is not Windows compatible.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-04-24, 4:37 AM #8
boosting [http://forums.massassi.net/html/smile.gif]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-04-24, 5:18 AM #9
Since it only wants to immobilize the actor not to shoot, you can just use this rather.

Part of touched message.

Code:
   SetActorFlags(victim, 0x200000);
   KillTimerEx(victim);
   SetTimerEx(1.5, victim, GetThingSignature(victim), 0);


Part of timer

Code:
   ClearActorFlags(GetSenderID(), 0x200000);


This flag will also disable the weapon firing.

------------------
http://millennium.massassi.net/ - Millennium
2001-04-24, 2:01 PM #10
I need the AI to be immobilized and not fire. It can't be done with setactorweapon unless I make it much more complicated.

So, I added flags to make him blind and deaf. It didn't work with 0x200000 so I had to use 0x40000.

It works ok now. The AI will fire rarely- some more than others. I might make a better system for stun later, but for now it's ok.

Thanks a lot for your help, Hideki [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/biggrin.gif]

------------------
Warning! User is not Windows compatible.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!