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 → KEY motions
KEY motions
2004-01-19, 10:27 AM #1
Well Im not so sure how to do this (Im not an expert cogger) but Im pretty sure this is only possible with cog. What I need is (this is for mp ai):

*When an AI spots any player, then the AI will perform 1 key motion before it starts attacking the players.
*The AI should then hold its position while attacking, but after a minute or so, reverse the key motion it just performed before and be able to move.
If you can guess, its a go prone key animation.
*The AI should only play it once because if there are more than one player in the game that he sees both, he shouldnt replay the key for every player. Can you understand this?

Would I need to make a whole new actor_x.cog type cog file for the ai template?

------------------
nil nip nada zip zero naught lip zil
This is retarded, and I mean drooling at the mouth
2004-01-19, 12:40 PM #2
is the answer... cheese?

Be more specific in your requests, that way people like me don't up their postcounts with stupid posts like these.

------------------
"I was driving along listening to the radio, when Judas Priest comes on. It was 'You've got another thing coming.' All of a sudden, I enter 'VICE CITY RAMAGE MODE' and nearly ran some guy over"
- ]-[ellequin
ᵗʰᵉᵇˢᵍ๒ᵍᵐᵃᶥᶫ∙ᶜᵒᵐ
ᴸᶥᵛᵉ ᴼᵑ ᴬᵈᵃᵐ
2004-01-19, 2:43 PM #3
Sorry. I guess I was trying to type my mind but it wasn't working, lol. But I'll do better:

-------------------------------------------
I NEED: an enemy to play a .key file when he sees the player.

BUT: the level is for multiplayer. If, for example, TWO players come into view of the enemy AI, the enemy should perform the .key once. Until after a certain delay should the enemy be able to repeat this action.
-------------------------------------------

I think that I would have to edit the enemy's actor cog to put in these codes, so I come here for any ideas from the experts [http://forums.massassi.net/html/wink.gif]

[This message has been edited by F-Body (edited January 19, 2004).]
This is retarded, and I mean drooling at the mouth
2004-01-20, 5:18 AM #4
jedikerby, i ahte to say it.. but thats seems pretty simple to understand to me

what he want is when a AI sees the player he will play a keyframe, stay in teh same place.. and after a time play the keyframe again backwards.

as far as i see its entirely possible. but you would need two keyframes one for forwards and one for backwards. all you need to do to see if the player is being attacked is to use a While() loop to check teh actor flags fo the AI. to make it stand in one place is simple anough just get its pos and Lvec and reset them, or change its actor flags and to make it play one time just use a int..

can you handle that or shall i do the work
(looks like some kind of mobile attack droid thing to me)

------------------
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?
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?
2004-01-20, 11:30 AM #5
Well I dont really know cog all to well, if you could post the basic form I would be more than happy.

------------------
nil nip nada zip zero naught lip zil
This is retarded, and I mean drooling at the mouth
2004-01-20, 5:36 PM #6
This is my new actor cog based off of the actor_s3.cog- I messed with it and it turns out that I suck at cogging!: I NEED YOUR HELP

Code:
# This Cog is Not supported by LucasArts Entertainment Co.


symbols

message     killed
message	    startup
message     damaged
message     pulse
message     skill

template    powerup=+mynewgun               local
thing       newThing                         local
thing       player                           local
thing       aiguy                            local
keyframe    dive=sdive.key 	             local
keyframe    undive=sudive.key 	             local
int         isdown=0                         local
int         isWaiting=0                      local
int         victim                           local
int         bin                              local
int         senderref=-1                     local
ai          flee_ai=noweapon.ai              local
int         damage                           local

end

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

code

startup:
   player = GetLocalPlayerThing();
   victim = GetSenderRef();
   SetPulse(0.5);
   Return;

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

damaged:
   damage = GetParam(0);
   if(GetParam(1) == 16)                        // saber damage might cause dismemberment
   {
      damage = (damage * 2.0);
      victim = GetSenderRef();
      if(GetThingHealth(victim) <= damage) // but only if damage is sufficient to kill
      {
         if(rand() < 0.05)                      // random chance
         {
            AmputateJoint(victim, 5);
            SetThingVel(newThing, '0.0 0.7 1.4');
         }
      }
   }
   ReturnEx(damage);
   return;

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

pulse:
   SetPulse(0.5);

   if(isdown==1)
      Return;

   if(IsThingVisible(victim))
   {
      call diver;
      Return;
   }

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

diver:

if(isdown==0)
{
PlayKey(victim, dive, 1, 0x4);
SetActorFlags(victim, 0x40000);
isdown=1;
}
if(isdown==1)
{
ClearActorFlags(victim, 0x40000);
isdown=0;
StopKey(victim, udive, 0.01);
}

Return;

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

killed:
   victim = GetSenderRef();

   if (GetActorWeapon( victim, 1 ) != -1)
   {
      AmputateJoint( victim, 3 );
      newThing = CreateThing(powerup, GetSenderRef());
      SetLifeleft(newThing, 200.0);
   }

   return;

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

skill:
   bin = GetParam(0);
   if (bin == 24)                            // Force Pull
   {
      senderref = GetSenderRef();
      newThing = CreateThing(powerup, GetSenderRef());
      SetLifeleft(newThing, 30.0);
      ReturnEx(newThing);

      AISetClass(senderref, flee_ai);
      AIFlee(senderref, GetLocalPlayerThing());

      Return;
   }
   else
   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;

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

end



well I tried to use HasLOS instead of IsThingVisible but that made it not load the level at all!

What I need yet is a timer of some sort to make it so the enemy stays at isdown==0 until a certain time before it activates the undo key (meaning, the player is out of sight or killed but the enemy stays at position until the time given)

Also I need a return phrase so that if the enemy sees a different player, then it wont re-activate the code (meaning, if the enemy is already down, then stay down and dont repeat the action if he sees a different player)
This is hard to explain but I think I did well. I know this can be done but I dont really know how to make it efficient (more or less even work!)

------------------
nil nip nada zip zero naught lip zil
This is retarded, and I mean drooling at the mouth
2004-01-21, 10:51 AM #7
You don't need a SetPulse() command in the Pulse message.

You need to define "message dives" in the symbols section or it won't do anything at all with that message (trust me, it's even that way with JK's default messages).

You might also want to fire a template or something in the damaged message (i.e. newthing = fireprojectile(...) ) because you don't have it and yet you're amputating a joint and setting newthing's velocity. Doesn't make much sense to me.

------------------
I am Darth Slaw.
The Dark Lord of the Sith,
And part of the Nightfire mod team

[This message has been edited by Darth Slaw (edited January 21, 2004).]
May the mass times acceleration be with you.
2004-01-21, 1:48 PM #8
You don't need to define the "diver" function as a message in the symbols section because it's a custom message, as outlined in the DataMaster [http://forums.massassi.net/html/smile.gif]. Thinking about it though, I've never used custom messages in class cogs before, but I really don't see why that function shouldn't function...

And as far as I can make out (after a cursory glance, because it's late now), you're quite right about questioning the reason why he's (attempting) to set newThing's velocity; standard actor cogs normally contain the following code:
Code:
            AmputateJoint(victim, 5);
            newThing = CreateThingAtPos(limb, GetThingSector(victim), GetThingPos(victim), '0 0 0');
            SetThingVel(newThing, '0.0 0.7 1.4');


... which I believe gives a little "bump/rise" to the newly created object, thus creating the illusion of sabering someone's arm off and seeing it fly "up and off" at the shoulder [http://forums.massassi.net/html/biggrin.gif]. However, the middle line in his cog is omitted... [http://forums.massassi.net/html/redface.gif]

Nice to see JK can actually be (somewhat semi) gory/grotesque [http://forums.massassi.net/html/wink.gif]

I'm merely going to suggest the word "Parsec" for now [http://forums.massassi.net/html/biggrin.gif]. I'll add this to the list of cogs I've got to do over the weekend [http://forums.massassi.net/html/wink.gif]

Hope this helps [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

------------------
"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" - by Adam Lindsay Gordon)
"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 ||
2004-01-21, 4:45 PM #9
LJ, it seems you're right about that. I checked DM. I've traditionally always declared all my vars, but that's just me [http://forums.massassi.net/html/wink.gif].

Anyway, I think I found something worth looking at. See your diver message? I spy a missing reserved word: else. Try adding else before the line:
"if(isdown == 1)", making it "else if(isdown == 1)". Without it, it looks like you're cancelling yourself out there. It'll run the isdown==0, set isdown to 1, then run isdown==1 and undo what you did.

Also, in that block of code, there is the variable udive in the stopkey command. I'm guessing that's supposed to be undive? (Other than this one thing, Parsec is only informing me of unused variables as errors).

Also, add a return; statement at the end of your pulse message. Otherwise I'm guessing it'll run the diver message's code too? Not an expert in that area, but you need that return; statement.

Other than that, I'm not sure what else could be wrong. Hope this has been helpful to you [http://forums.massassi.net/html/smile.gif].

------------------
I am Darth Slaw.
The Dark Lord of the Sith,
And part of the Nightfire mod team

[This message has been edited by Darth Slaw (edited January 21, 2004).]
May the mass times acceleration be with you.
2004-01-22, 9:55 AM #10
Well I did some editing and I came up with a new cog: I used sighted message. But I still cannot get it to where the enemy sees the player:
Code:
# Jedi Knight Cog Script
#
# ACTOR_fbody.COG
#
# ACTOR Script - My New Enemy
#
# Is modified from actor_s3.cog
# (Don't ask "why s3?", I Don't know either)
#
# [F_Body]
#
# This Cog is Not supported by LucasArts Entertainment Co.


symbols

message     killed
message	    sighted
message     damaged
message     diver
message     skill

template    powerup=+newgun             local
thing       newThing                         local
thing       victim                           local
thing       player                           local
keyframe    sdive=sdive.key 	             local
flex        vistarget                        local
int         victim                           local
int         isdown=0                         local
int         bin                              local
int         senderref=-1                     local
ai          flee_ai=noweapon.ai              local
int         damage                           local

end

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

code

damaged:
   damage = GetParam(0);
   if(GetParam(1) == 16)                        // saber damage might cause dismemberment
   {
      damage = (damage * 2.0);
      victim = GetSenderRef();
      if(GetThingHealth(victim) <= damage) // but only if damage is sufficient to kill
      {
         if(rand() < 0.05)                      // random chance
         {
            AmputateJoint(victim, 5);
            SetThingVel(newThing, '0.0 0.7 1.4');
         }
      }
   }
   ReturnEx(damage);
   return;

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

sighted:
   victim = GetSenderRef();
   player = GetSourceRef();
   vistarget = HasLOS(dude, player);
   if((isdown==0) && vistarget=1);
   {
      isdown=1;
      call diver;
   }
   else if(isdown = 1) Return;
   else if(vistarget = 0) Return;
   else Return;
   return;

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

diver:
   SetActorFlags(victim, 0x40000);
   PlayKey(victim, sdive, 1, 0x4);
   isdown=1;
   return;

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

killed:
   victim = GetSenderRef();

   if (GetActorWeapon( victim, 1 ) != -1)
   {
      AmputateJoint( victim, 3 );
      newThing = CreateThing(powerup, GetSenderRef());
      SetLifeleft(newThing, 200.0);
   }

   return;

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

skill:
   bin = GetParam(0);
   if (bin == 24)                            // Force Pull
   {
      senderref = GetSenderRef();
      newThing = CreateThing(powerup, GetSenderRef());
      SetLifeleft(newThing, 30.0);
      ReturnEx(newThing);

      AISetClass(senderref, flee_ai);
      AIFlee(senderref, GetLocalPlayerThing());

      Return;
   }
   else
   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;

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

end


Since he holds a new weapon I made it so that he arm never amputates when he gets sabered

------------------
nil nip nada zip zero naught lip zil
This is retarded, and I mean drooling at the mouth
2004-01-22, 3:09 PM #11
In the Sighted message, there is no GetSourceRef(). Unless a previously-called message did, then GetSourceRef would get THAT message's source. The sneder of the Sighted message (GetSenderRef() ) is the thing that was sighted. And where is the variable "dude" coming from in that message? [http://forums.massassi.net/html/confused.gif] Also, the cog will still amputate the arm of your actor, since the code still exists in the damaged message (without creating a newthing).

I had trouble when I tried setting the 0x40000 actor flags for one of my mods a few days ago; it seemed to have no effect on my actor. Try ClearPhysicsFlags(victim, 0x2) to immobilize your actor, and SetPhysicsFlags(victim, 0x2) to reinstate them. It has, essentially, the same effect.

------------------
I am Darth Slaw.
The Dark Lord of the Sith,
And part of the Nightfire mod team
May the mass times acceleration be with you.
2004-01-23, 10:44 AM #12
Thanks for the tips Darth Slaw, Im experimenting with other variations now
By the way, whats the diff?: = and == and does it matter for 'if' statements?

------------------
nil nip nada zip zero naught lip zil
This is retarded, and I mean drooling at the mouth

↑ Up to the top!