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 → Cog Help for AI
Cog Help for AI
2005-07-08, 5:26 PM #1
Hello all. By posting this, I am aware that I may sound ridiculous and idiotic as I am trying to edit COG in my level when I have very little experience in that matter. That said, you are warned.

I have two issues.

1. For my level Jedi Headquarters, I am currently adding some Jedi AI that walk around the level. I decided to use the Pedestrian COG/PUP/AI/SND that I modified to my liking. Things are going well, the Jedi can jump, roam, run, swim BUT they run like sissies when damaged. I wanted to change that so that instead of fleeing, the take out their lightsaber and fight. My idea is to use AISetClass() in the Pedestrian COG to change the Pedestrian AI to a Darkjedi AI that I will modify. Is that a good idea?

Here is the modified code from the Pedestrian COG: (I may look stupid, it's my first try.)

Code:
# ========================================================================================

code

damaged:
   StopSound(sound, 0);
   damage = GetParam(0);
   if(GetParam(1) == 16)
   {
      damage = (damage * 2.0);
   }
   ReturnEx(damage);
   AISetClass(me, yun.ai);
   return;

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


Is that any good? Or it's completely wrong?


2. I also wanted to change the power-up drops from the Pedestrians (Shields and Batteries) to Lightsabers. So, I changed:

Code:
template powerup1=+DHealthPack   local
template powerup2=+DShield       local
template powerup3=+DBattery      local


To this:

Code:
template powerup1=lightsaber     local
template powerup2=lightsaber     local
template powerup3=lightsaber     local


Sadly, Shields and Batteries still show up when I kill the Jedi. Any help on this? Am I yet again completely wrong?

Thanks.
Skateboarding is not a crime.
2005-07-09, 11:26 AM #2
Well here's a couple of bits of info here that I hope you'll find helpful :)

1.) A couple of bits here:

* Running like sissies: with the default puppet files/keyframes combo, sadly there's no way to make actors run in a "butch" way. If you have the time/knowledge, then you could re-design the keyframes (although I'm certainly no expert on modelling/keyframe editing...)

[PRE-POST EDIT]
Having just had a quick re-read of your query (because I lost my internet connectivity whilst typing this reply...), it would appear the Jedi would be reacting to a "damaged:" message, with the "SenseDanger" AI instinct probably being activated (depends on how the instinct is set-up as to how the AI will react when damaged).

With this in mind, I'd propose that in the symbols section, you have 2 ai sets: one for the original "passive" ai and one for the "aggressive" ai. Either in a level cog's "startup:" message or the actor's class cog's "created:" message, you would specify that the actor should be assigned the "passive" ai initially. The jedi will dynamically switch to "aggressive" ai mode when damaged (see next point below...)
[/EDIT]

* I don't whether AISetClass()'s 2nd parameter would work in that form. I don't see why it shouldn't, but I prefer to keep all my AI files that I'm using listed in the "symbols" section of my cog. Simply include:
Code:
symbols
    ai passiveAI=peddefault.ai
    ai aggressiveAI=yun.ai
   # ... other symbols stuff here...
end


...which you can then refer to as "AISetClass (me, aggressiveAI)" later on. As I say, I can't see why it would make a difference but it is an alternative way of doing things :)

* Related to the above, I'm not sure that you'd notice any changes in AI. Even though you're modifying the actor's AI class, the 3DO character model still won't have a weapon (if you're using the default pedestrian 3DO and pup/keyframes) to use. Coupled with the fact that if you try and assign lightsaber flags to an enemy that doesn't use a lightsaber (via cog), then I think JK bombs out (I can't recall this accurately enough to be certain of this though... :o)

* I think you'd also be wise to take care when considering switching AI files between actors. In MotS, this is a simple task to make sure they are indeed attacking the right enemy (good interaction between COG and AI files - "AIGetAlignment()" cog verb and "LookForOpposingTarget" AI instinct being prime examples). In JK, if you switch their AI to an aggressive nature, you have to be careful that the "friendly" AI don't attack each other. There are a handful of ways of doing this in JK, but none of them are truly effective (or efficient).


2.) My first guess as to the problems you're having with this issue are that there are quite a few different pedestrians (some mute, some who will say stuff when they are damaged, etc) - the point is though that these different 3DO models may well have a different pedestrian cog attached to them (making this a template issue). Try checking this first to make sure they all have the similar attached cog that you've edited (obviously the soundclasses should be different for the different genders ;))



Personally, I'd stick with the original JK dark-jedi models (and their associated pup/keyframes) but re-skin them. The actor's class cog, AI file and *.snd file can all be tweaked easily enough, so that isn't an issue.

It just strikes me that you're trying to make more work for yourself than is necessary ;). That is unless you enjoy keyframe animating (which I don't - I don't touch those with a barge-pole! :p)


I hope you find some of this info helpful (wow that was a lot of typing) :D

-Jackpot

PS: If you're interested in learning more about how JK's AI files work, don't hesitate to contact me because I've done quite a bit of research into the area, culminating in "AI Builder" (over at the JK Hub) :D
"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 ||
2005-07-09, 5:11 PM #3
Thanks for the reply.

Quote:
Originally posted by lucky_jackpot

* Running like sissies: with the default puppet files/keyframes combo, sadly there's no way to make actors run in a "butch" way. If you have the time/knowledge, then you could re-design the keyframes (although I'm certainly no expert on modelling/keyframe editing...)


Actually, I meant that they flee instead of fighting back.

Quote:
Originally posted by lucky_jackpot

Having just had a quick re-read of your query (because I lost my internet connectivity whilst typing this reply...), it would appear the Jedi would be reacting to a "damaged:" message, with the "SenseDanger" AI instinct probably being activated (depends on how the instinct is set-up as to how the AI will react when damaged).

With this in mind, I'd propose that in the symbols section, you have 2 ai sets: one for the original "passive" ai and one for the "aggressive" ai. Either in a level cog's "startup:" message or the actor's class cog's "created:" message, you would specify that the actor should be assigned the "passive" ai initially. The jedi will dynamically switch to "aggressive" ai mode when damaged (see next point below...)

* I don't whether AISetClass()'s 2nd parameter would work in that form. I don't see why it shouldn't, but I prefer to keep all my AI files that I'm using listed in the "symbols" section of my cog. Simply include:
Code:
symbols
    ai passiveAI=peddefault.ai
    ai aggressiveAI=yun.ai
   # ... other symbols stuff here...
end


...which you can then refer to as "AISetClass (me, aggressiveAI)" later on. As I say, I can't see why it would make a difference but it is an alternative way of doing things :)
[/B]


Yes. That would be a better way to do it. Thanks.

Quote:
Originally posted by lucky_jackpot

* Related to the above, I'm not sure that you'd notice any changes in AI. Even though you're modifying the actor's AI class, the 3DO character model still won't have a weapon (if you're using the default pedestrian 3DO and pup/keyframes) to use. Coupled with the fact that if you try and assign lightsaber flags to an enemy that doesn't use a lightsaber (via cog), then I think JK bombs out (I can't recall this accurately enough to be certain of this though... :o)


Actually, the models that I use (SBX Jedi models) are all using ky.pup's KEY animations. But I would appreciate if you showed me how to tweak the Pedestrian COG so that the Jedi have lightsabers.

Quote:
Originally posted by lucky_jackpot

* I think you'd also be wise to take care when considering switching AI files between actors. In MotS, this is a simple task to make sure they are indeed attacking the right enemy (good interaction between COG and AI files - "AIGetAlignment()" cog verb and "LookForOpposingTarget" AI instinct being prime examples). In JK, if you switch their AI to an aggressive nature, you have to be careful that the "friendly" AI don't attack each other. There are a handful of ways of doing this in JK, but none of them are truly effective (or efficient).


Hmm, I will have to figure something out for this, didn't think about this... But currently I would just like that the Jedi fight when damaged.

Quote:
Originally posted by lucky_jackpot

2.) My first guess as to the problems you're having with this issue are that there are quite a few different pedestrians (some mute, some who will say stuff when they are damaged, etc) - the point is though that these different 3DO models may well have a different pedestrian cog attached to them (making this a template issue). Try checking this first to make sure they all have the similar attached cog that you've edited (obviously the soundclasses should be different for the different genders ;))


Ok thanks, the COG's I modified didn't match those in the template file. I have a weird issue now. In Normal JK, power-ups are now lightsabers and when I hit the Jedi, they follow me (but can't attack yet as they do not have the lightsaber.). But, playing the game in SBX, it doesn't work. They drop nothing and the "passive" AI doesn't change to the "aggressive" AI... Any help on that?

Quote:
Originally posted by lucky_jackpot

Personally, I'd stick with the original JK dark-jedi models (and their associated pup/keyframes) but re-skin them. The actor's class cog, AI file and *.snd file can all be tweaked easily enough, so that isn't an issue.

It just strikes me that you're trying to make more work for yourself than is necessary ;). That is unless you enjoy keyframe animating (which I don't - I don't touch those with a barge-pole! :p)


Well, as I mentioned previously, I got myself models that work with ky.pup. They work fine.

Quote:
Originally posted by lucky_jackpot

PS: If you're interested in learning more about how JK's AI files work, don't hesitate to contact me because I've done quite a bit of research into the area, culminating in "AI Builder" (over at the JK Hub) :D


Yes I would like to. I checked your program, seems pretty neat. Do you have MSN?
Skateboarding is not a crime.
2005-07-11, 8:12 AM #4
Sorry about the long delay - we've only just got our internet connection sorted today (since the last time I posted :rolleyes:...)

Yes, I do have an MSN address: check here :) I respond to my email when I get it so that's not a problem although more often than not, I appear in #jkhub on irc.holonet.org so you can probably catch me there :).

Just for the record, I've decided to start compiling a COG + AI document detailing how to get the best out of JK's AI, which will be submitted to the Hub when I finish it (and test the cog examples ;)). Other than that, if I do appear online, give me a holler or email :)

Hope this helps :D

-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"
|| AI Builder: compatible with both JK & MotS || My website ||
2005-07-11, 8:29 AM #5
To give the jedi sabers, add this in the "damaged" message:
Code:
jkSetSaberInfo(me, side_mat, tip_mat, 0.003, 0.001, 0.101, tpl_wall, tpl_blood, tpl_saber);
jkSetFlags(me, 0x5);


And under "killed" add:
Code:
jkSetFlags(me, 0x8);


Also, add these to the symbols (copied from the jerec actor cog)
Code:
material       tip_mat=saberred0.mat         local
material       side_mat=saberred1.mat        local

template       tpl_wall=+ssparks_wall        local
template       tpl_blood=+ssparks_blood      local
template       tpl_saber=+ssparks_saber      local

You can change tip/side_mat to whatever colors you want
The saber blade may not be placed properly, so you might have to modify some offsets/hiearchy nodes.


I don't know why it wouldn't work in sbx, unless it has files (e.g. cogs, ai) with the same filename as yours. Otherwise, I dunno.
May the mass times acceleration be with you.
2005-07-11, 3:12 PM #6
Hmm. Now, when the Jedi are damaged, I get a Red Saber instead of my Green one. Weird though, "me" is supposed to be the Jedi... Help?

Also, for the SBX issue, the Jedi now drop the saber power-up, I take it, and if I kill another Jedi, the same saber appears at the same spot, so every time I kill a Jedi, all sabers respawn! Is that a Unsyched/Synched AI problem? I use a Unsynched AI COG, and I now it's bad...

Jackpot, I'll be sure to go by the JkHub. :)
Skateboarding is not a crime.
2005-07-11, 8:23 PM #7
D'oh! It's a class cog right (like, actor_[something].cog)? Then add "me = GetSenderRef();" at the start of the damaged message. Do the same for the killed message.

Now how did I overlook that?!?
May the mass times acceleration be with you.
2005-07-12, 6:37 AM #8
Yes. It's a class cog. But it still doesn't work. :(
Am I doing anything wrong?

Code:
# Jedi Knight Cog Script
#
# ACTOR_JEDIR.COG
#
#
# Actor COG for ROAMING Jedi Male Civilian
# Triggers various voice lines when touched
# Triggers Passive/Aggressive AI when damaged 
# Creates lightsaber upon death
# Increases morality bin by one upon death by player
# Increases pedestrian counter by one upon creation
#
# [Dominik]
#
# ========================================================================================

symbols

message     created
message     killed
message     skill
message     touched
message     timer
message     damaged

template powerup1=lightsaber     local
template powerup2=lightsaber     local
template powerup3=lightsaber     local
flex     rval                    local
int      bin                     local
int      count                   local
int      id                      local
thing    newThing                local
thing    me                      local
thing    player                  local
thing    toucher                 local
thing    killer                  local
sound    hey=i00mn02z.wav
sound    leaves=i00mn10z.wav
sound    nothing=i00mn12z.wav
sound    mind=i00mn13z.wav
sound    whats=i00mn16z.wav
int      damage                  local
int      sound                   local

ai passiveAI=jedi_passive_r.ai     
ai aggressiveAI=jedi_aggressive.ai

material       tip_mat=saberred0.mat         local
material       side_mat=saberred1.mat        local

template       tpl_wall=+ssparks_wall        local
template       tpl_blood=+ssparks_blood      local
template       tpl_saber=+ssparks_saber      local           

end

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

code

damaged:
   me = GetSenderRef();
   StopSound(sound, 0);
   damage = GetParam(0);
   if(GetParam(1) == 16)
   {
      damage = (damage * 2.0);
   }
   ReturnEx(damage);
   AISetClass(me, aggressiveAI);
   jkSetSaberInfo(me, side_mat, tip_mat, 0.003, 0.001, 0.101, tpl_wall, tpl_blood, tpl_saber);
   jkSetFlags(me, 0x5);
   return;

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

touched:
   me = GetSenderRef();
   toucher = GetSourceRef();
   player = GetLocalPlayerThing();

   if (player != toucher) return;

   if (BitTest(AiGetMode(me), 0x800)) return;

   if (count == 1) return;

   rval = Rand();

   if (GetThingUserData(me) == 2)
   {
      sound = PlaySoundThing(nothing, me, 1, -1, -1, 0x10080);
      SetThingUserData(me, GetThingUserData(me) + 1);
      count = 1;
      SetTimerEx(3.0, 0, 0.0, 0.0);
      return;
   }

   if (GetThingUserData(me) == 3)
   {
      sound = PlaySoundThing(mind, me, 1, -1, -1, 0x10080);
      count = 1;
      SetThingUserData(me, GetThingUserData(me) + 1);
      SetTimerEx(3.0, 0, 0.0, 0.0);
      return;
   }

   if (GetThingUserData(me) >= 4)
   {
      sound = PlaySoundThing(leaves, me, 1, -1, -1, 0x10080);
      count = 1;
      SetTimerEx(3.0, 0, 0.0, 0.0);
      return;
   }

   if (rval < 0.47)
   {
      sound = PlaySoundThing(hey, me, 1, -1, -1, 0x10080);
      SetThingUserData(me, GetThingUserData(me) + 1);
      SetTimerEx(3.0, 0, 0.0, 0.0);
   }
   else if (rval < 0.95)
   {
      sound = PlaySoundThing(whats, me, 1, -1, -1, 0x10080);
      SetThingUserData(me, GetThingUserData(me) + 1);
      SetTimerEx(3.0, 0, 0.0, 0.0);
   }

   count = 1;

   return;

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

created:
   SetThingUserData(GetSenderRef(), 0);
   SetTimerEx(1.0, 1, 0.0, 0.0);
   return;

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

killed:
   me = GetSenderRef();
   jkSetFlags(me, 0x8);
   player = GetLocalPlayerThing();
   killer = GetSourceRef();

   // Player killed a pedestrian.
   if (player == killer)
   {
      ChangeInv( player, 72, 1.0 );
   }

   rval = Rand();
   if (rval < 0.05)
   {
      newThing = CreateThing(powerup1, GetSenderRef());
      SetLifeleft(newThing, 200.0);
   }
   else if (rval <0.10)
   {
      newThing = CreateThing(powerup2, GetSenderRef());
      SetLifeLeft(newthing, 200.0);
   }
   else if (rval <0.15)
   {
      newThing = CreateThing(powerup3, GetSenderRef());
      SetLifeLeft(newthing, 200.0);
   }
   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;


timer:
   id = GetSenderId();
   if (id == 0)
   {
      count = 0;
   }
   else
   if (id == 1)
   {
      player = GetLocalPlayerThing();
      ChangeInv( player, 73, 1.0 );
   }
   return;

end


:(
Skateboarding is not a crime.
2005-07-12, 7:45 AM #9
The only error I see at a quick glance is your symbol "int sound local"
sound is a symbol type, and cannot be a symbol name.

I'll do some testing and see if I can come up with anything else.
May the mass times acceleration be with you.
2005-07-12, 9:17 AM #10
Hmm.... apparently, the 0x200 actor flag is also required for an actor to have saber blades... add this flag to your template's actor flags in the master.tpl
May the mass times acceleration be with you.
2005-07-12, 10:19 AM #11
Quote:
Originally posted by Darth Slaw
Hmm.... apparently, the 0x200 actor flag is also required for an actor to have saber blades... add this flag to your template's actor flags in the master.tpl


I'm not really good in Hexadecimal, what's 0x20000400 + 0x200? I put 0x20000600, but now the actors are ghosts.. :(
Skateboarding is not a crime.
2005-07-12, 12:00 PM #12
I think maybe you changed the thingflags... you want to change the typeflags.

[edit]
If all else fails, make a new template... set the parent to a dark jedi, and change the model, puppet, soundclass, aiclass, and class cogs appropriately (also, set the aiclass to the passive ai file, not the aggressive one). Then modify as needed from there.
[/edit]

[edit2]
I found another problem... find this code in your cog:
Code:
   rval = Rand();
   if (rval < 0.05)
   {
      newThing = CreateThing(powerup1, GetSenderRef());
      SetLifeleft(newThing, 200.0);
   }
   else if (rval <0.10)
   {
      newThing = CreateThing(powerup2, GetSenderRef());
      SetLifeLeft(newthing, 200.0);
   }
   else if (rval <0.15)
   {
      newThing = CreateThing(powerup3, GetSenderRef());
      SetLifeLeft(newthing, 200.0);
   }

change it to...
Code:
	newThing = CreateThing(powerup1, GetSenderRef());
	SetLifeleft(newThing, 200.0);

You can then remove "powerup2" and "powerup3" from the symbols if you want, since they're no longer being used :)
[/edit2]
May the mass times acceleration be with you.
2005-07-12, 4:06 PM #13
I was going to mention the powerup aspect Slaw, but I see you beat me to it ;). I didn't suggest modifying that part for Dominik just on the off-chance he wanted to spawn items other than lightsabers for the fallen jedi... ;)

Oh, the modification of the AI files can be done on the fly in cog anyway, so it's no huge issue whether he sets it in the template or via cog (though you probably already knew all that anyways ;)). For sake of keeping things simple though, I agree - make the jedi actors' aiclass (in the template file) the passiveAI by default :)

-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"
|| AI Builder: compatible with both JK & MotS || My website ||
2005-07-12, 4:59 PM #14
It may be nothing, as it turns out (setting the ai to the passive aiclass in the template), but I wrote a simple, level-based cog that activated sabers when they were damaged. Despite me setting the actor's ai to passive in the startup, he attacked me anyway (I was using LEC's default Yun as my jedi actor). I found out after I posted that I hadn't added startup to the symbols, so it never ran :rolleyes:, but I didn't change anything I wrote because it's safer (moreso for kyle :p) to make it passive to begin with. :)

One thing I couldn't get working fully, however, is the damaged message -- sabers cause the actor to call the message, but guns and fists do not 0_o. I can't figure that out... could be a flag issue (maybe that "mysterious" 0x200 actor flag has something to do with it?)
May the mass times acceleration be with you.
2005-07-13, 7:24 AM #15
:(

Doesn't work.

Here's my COG:

Code:
# Jedi Knight Cog Script
#
# ACTOR_PM.COG
#
#
# Actor COG for Barons Hed Male Pedestrians
# Triggers various voice lines when touched
# Possibly creates powerup upon death
# Increases morality bin by one upon death by player
# Increases pedestrian counter by one upon creation
#
# [CR & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
#
# ========================================================================================

symbols

message		created
message		killed
message		skill
message 	   touched
message 	   timer
message     damaged

template	   powerup1=+DHealthPack	local
template	   powerup2=+DShield    	local
template	   powerup3=+DBattery   	local
flex		   rval                 	local
int		   bin			            local
int		   count                	local
int		   id			               local
thing		   newThing		            local
thing		   me     			         local
thing		   player 			         local
thing		   toucher			         local
thing		   killer			         local
sound		   peace=i00mn17z.wav
sound		   please=i00mn14z.wav
sound		   hey=i00mn02z.wav
sound		   whats=i00mn16z.wav
int         damage                  local
int         sound                   local

end

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

code

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

touched:
	me = GetSenderRef();
	toucher = GetSourceRef();
	player = GetLocalPlayerThing();
	
	if (player != toucher) return;

	if (count == 1) return;
	
	if (BitTest(AiGetMode(me), 0x800)) return;
	
	rval = Rand();
	
	if (GetThingUserData(me) == 2)
	{
		sound = PlaySoundThing(peace, me, 1, -1, -1, 0x10080);
		SetThingUserData(me, GetThingUserData(me) + 1);
		count = 1;
		SetTimerEx(3.0, 0, 0.0, 0.0);
		return;
	}
	
	if (GetThingUserData(me) >= 3)
	{
		sound = PlaySoundThing(please, me, 1, -1, -1, 0x10080);
		count = 1;
		SetTimerEx(3.0, 0, 0.0, 0.0);
		return;
	}
	
	if (rval < 0.47)
	{
		sound = PlaySoundThing(hey, me, 1, -1, -1, 0x10080);
		SetThingUserData(me, GetThingUserData(me) + 1);
		SetTimerEx(3.0, 0, 0.0, 0.0);
	}
	else if (rval < 0.95)
	{
		sound = PlaySoundThing(whats, me, 1, -1, -1, 0x10080);
		SetThingUserData(me, GetThingUserData(me) + 1);
		SetTimerEx(3.0, 0, 0.0, 0.0);
	}
	
	count = 1;
	
	return;


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

created:
	SetThingUserData(GetSenderRef(), 0);
	SetTimerEx(1.0, 1, 0.0, 0.0);
	// ChangeInv(player, 73, 1.0 );
	return;

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

killed:
	player = GetLocalPlayerThing();
	killer = GetSourceRef();
	
	// Player killed a pedestrian.
	if (player == killer)
	{
		ChangeInv( player, 72, 1.0 );
	}
	
	newThing = CreateThing(powerup1, GetSenderRef());
	SetLifeleft(newThing, 200.0);
	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;


timer:
	id = GetSenderId();
	if (id == 0)
		count = 0;
	else
	if (id == 1)
	{
		player = GetLocalPlayerThing();
		ChangeInv(player, 73, 1.0 );
	}
	return;


end


And here's my template file:

Code:
# DESC: Jedi Akmetan Civilian
# BBOX: -.04 -.03 -.12 .04 .03 .06
akmetan           _darkjedi          thingflags=0x20000400 typeflags=0x200 model3d=akmetan.3do size=0.060000 movesize=0.060000 puppet=jedi.pup soundclass=mn1.snd cog=actor_jedir.cog maxvel=0.200000 health=100.00 maxhealth=100.00 maxthrust=0.50 maxrotthrust=60.00 aiclass=jedi_passive_r.ai


Any errors in that? Still, the Jedi follows and circles me like he should in the Aggressive AI when damaged, but still no saber. :(
Skateboarding is not a crime.
2005-07-13, 8:17 AM #16
This is the first full cog you posted on the thread, with the symbol 'sound' renamed to 'sound0' (just to be safe...) and the powerup code under "killed" will now always generate a powerup -- powerups 1, 2, and 3 each have a 33% chance of being created (in case you did want to make multiple possible powerups)
Your template is fine :) but I suggest making it "typeflags=0x201" instead so your jedi can look up and down (e.g. the player jumps)
Code:
# Jedi Knight Cog Script
#
# ACTOR_JEDIR.COG
#
#
# Actor COG for ROAMING Jedi Male Civilian
# Triggers various voice lines when touched
# Triggers Passive/Aggressive AI when damaged 
# Creates lightsaber upon death
# Increases morality bin by one upon death by player
# Increases pedestrian counter by one upon creation
#
# [Dominik]
#
#  ==================================================

symbols

message     created
message     killed
message     skill
message     touched
message     timer
message     damaged

template powerup1=lightsaber     local
template powerup2=lightsaber     local
template powerup3=lightsaber     local
flex     rval                    local
int      bin                     local
int      count                   local
int      id                      local
thing    newThing                local
thing    me                      local
thing    player                  local
thing    toucher                 local
thing    killer                  local
sound    hey=i00mn02z.wav
sound    leaves=i00mn10z.wav
sound    nothing=i00mn12z.wav
sound    mind=i00mn13z.wav
sound    whats=i00mn16z.wav
int      damage                  local
int      sound0                   local

ai passiveAI=jedi_passive_r.ai     
ai aggressiveAI=jedi_aggressive.ai

material       tip_mat=saberred0.mat         local
material       side_mat=saberred1.mat        local

template       tpl_wall=+ssparks_wall        local
template       tpl_blood=+ssparks_blood      local
template       tpl_saber=+ssparks_saber      local           

end

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

code

damaged:
   me = GetSenderRef();
   StopSound(sound0, 0);
   damage = GetParam(0);

   if(GetParam(1) == 16)
   {
      damage = (damage * 2.0);
   }
   ReturnEx(damage);
   AISetClass(me, aggressiveAI);
   jkSetSaberInfo(me, side_mat, tip_mat, 0.003, 0.001, 0.101, tpl_wall, tpl_blood, tpl_saber);
   jkSetFlags(me, 0x5);
   return;

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

touched:
   me = GetSenderRef();
   toucher = GetSourceRef();
   player = GetLocalPlayerThing();

   if (player != toucher) return;

   if (BitTest(AiGetMode(me), 0x800)) return;

   if (count == 1) return;

   rval = Rand();

   if (GetThingUserData(me) == 2)
   {
      sound0 = PlaySoundThing(nothing, me, 1, -1, -1, 0x10080);
      SetThingUserData(me, GetThingUserData(me) + 1);
      count = 1;
      SetTimerEx(3.0, 0, 0.0, 0.0);
      return;
   }

   if (GetThingUserData(me) == 3)
   {
      sound0 = PlaySoundThing(mind, me, 1, -1, -1, 0x10080);
      count = 1;
      SetThingUserData(me, GetThingUserData(me) + 1);
      SetTimerEx(3.0, 0, 0.0, 0.0);
      return;
   }

   if (GetThingUserData(me) >= 4)
   {
      sound0 = PlaySoundThing(leaves, me, 1, -1, -1, 0x10080);
      count = 1;
      SetTimerEx(3.0, 0, 0.0, 0.0);
      return;
   }

   if (rval < 0.47)
   {
      sound0 = PlaySoundThing(hey, me, 1, -1, -1, 0x10080);
      SetThingUserData(me, GetThingUserData(me) + 1);
      SetTimerEx(3.0, 0, 0.0, 0.0);
   }
   else if (rval < 0.95)
   {
      sound0 = PlaySoundThing(whats, me, 1, -1, -1, 0x10080);
      SetThingUserData(me, GetThingUserData(me) + 1);
      SetTimerEx(3.0, 0, 0.0, 0.0);
   }

   count = 1;

   return;

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

created:
   SetThingUserData(GetSenderRef(), 0);
   SetTimerEx(1.0, 1, 0.0, 0.0);
   return;

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

killed:
   me = GetSenderRef();
   jkSetFlags(me, 0x8);
   player = GetLocalPlayerThing();
   killer = GetSourceRef();

   // Player killed a pedestrian.
   if (player == killer)
   {
      ChangeInv( player, 72, 1.0 );
   }

   rval = Rand();
   if (rval < 0.33)
   {
      newThing = CreateThing(powerup1, GetSenderRef());
      SetLifeleft(newThing, 200.0);
   }
   else if (rval < 0.67)
   {
      newThing = CreateThing(powerup2, GetSenderRef());
      SetLifeLeft(newthing, 200.0);
   }
   else
   {
      newThing = CreateThing(powerup3, GetSenderRef());
      SetLifeLeft(newthing, 200.0);
   }
   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;


timer:
   id = GetSenderId();
   if (id == 0)
   {
      count = 0;
   }
   else
   if (id == 1)
   {
      player = GetLocalPlayerThing();
      ChangeInv( player, 73, 1.0 );
   }
   return;

end

May the mass times acceleration be with you.
2005-07-13, 10:10 AM #17
Thanks. I copy-pasted your cog. and changed the typeflags to 0x201. The lightsaber power-up issue is fixed, but still, the Jedi keep circling and following me, with no saber. :(

Am I doing anything wrong?
Skateboarding is not a crime.
2005-07-13, 10:25 AM #18
Hmm... maybe it's a 3do or puppet issue then... I used Yun's files in my test level (since I don't have a copy of yours) and it worked fine. Post your 3do and puppet and I'll see if I can find anything for ya.
May the mass times acceleration be with you.
2005-07-13, 4:43 PM #19
Here are the COG, PUP, 3DO and Master Template files.

Thanks for your help. :)
Attachment: 6077/files.zip (46,176 bytes)
Skateboarding is not a crime.
2005-07-14, 3:18 AM #20
I didn't read the entire thread, so if this was already mentioned or not the case anymore, ignore.

I'm no AI genius so I would just make a cog that would destroy the passive AI character and replace it with an identical aggressive character. If you want it to switch back, just destroy and create the passive one again. That's the easiest and most sure fire way I see how to do it.
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-07-14, 9:59 AM #21
The no-saber problem was in the puppet file... add this to the bottom of the file
Code:
joints
0=15 # 0 = head
1=16 # 1 = neck
2=17 # 2 = torso
3=12 # 3 = primary weapon fire
4=19 # 4 = secondard weapon fire
5=13 # 5 = primary weapon aiming joint
6=13 # 6 = secondary weapon aiming joint


There is one other issue, however.... concerning why the ai won't swing their sabers at you. That's because of the puppet file as well -- there are no entries for attack animations. We should fix that too (and also add some animations for choking, turning, and blocking), so add these lines into the mode=0 section.
Code:
choke      	kychoke0.key	0x28	4	4	# choke
turnleft   	kyturnl.key	0x00	2	2	# shufflin'
turnright  	kyturnr.key	0x00	2	2	# shufflin'
fire	 	kysabrf1.key	0x28	1	4	# Medium and Big (2 Swings)
fire2		kysnap3.key	0x28	1	4	# Medium
block           kyblock1.key    0x28    1       3
block2          kyblock2.key    0x28    1       3


Also, one last touch (that I should've put in the cog beforehand, but oh well)... add this line in the damaged message of the actor cog -- it will enable the actor to block attacks with his lightsaber once it is activated. (if he still isn't blocking when you add this, it's probably an AI file problem)
Code:
   SetActorFlags(me, 0x2000);


You'll also have to add these parameters to your template
Code:
error=0.60 fov=0.5 chance=1.00

  • error - Of all the projectiles that the actor deflects with the saber, the percentage that are not deflected back at the shooter (Scale from 0 to 1 -- 0.0=all shots are deflected back toward the shooter, 1.0=none of the deflected shots are deflected back toward the shooter)
  • chance - Chance of saber blocking (scale of 0 to 1 -- 1.0=always, 0.0=never)
  • fov=This parameter determines the fov range your AI is able to block. It is the cosine of the fov (scale from -1.0 to 1.0 -- -1.0=actor blocks all around him, 0.0=actor blocks everything in the 180 degrees arc in front of him, 1.0=actor blocks only staight in front of himself)


Okay, I think that should be it :) Hopefully the template param stuff made sense
May the mass times acceleration be with you.
2005-07-14, 12:32 PM #22
Thanks for the reply. Weird. Saber still doesn't show up, but it's there, when I shoot him he blocks. Doesn't swing at me though...

Sorry, you probably are fed up of this. :p
But here are the files. I don't see any errors in them, but still doesn't work. :(
Attachment: 6092/files2.zip (47,256 bytes)
Skateboarding is not a crime.
2005-07-14, 12:59 PM #23
Sorry if this sounds rude after all that work, but it would be infinitely easier if you just created an destroyed two separate AI things
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-07-15, 6:12 AM #24
Quote:
Originally posted by ProdigyOddigy
Sorry if this sounds rude after all that work, but it would be infinitely easier if you just created an destroyed two separate AI things


Maybe. But this would be useless now, as the AI changing works, it's just the saber that doesn't work.
Skateboarding is not a crime.
2005-07-16, 12:49 AM #25
Works fine for me... :confused:
Make sure all your resources are in the right directories (the JK Tree plugin does this all for you).

Also, this is probably the last post I'll be able to make in a while -- see the discussion forum (in my thread)
May the mass times acceleration be with you.
2005-07-16, 4:27 PM #26
Ok. Thanks a lot for all the help. :)

But I think I found out the problem. The AI work properly in SP, but not in MP. It worked in your level. Same thing happens, if you try putting Jerec in MP, he'll show up without any saber.
Skateboarding is not a crime.

↑ Up to the top!