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 → AI cog verbs
AI cog verbs
2004-03-14, 2:09 PM #1
AISetClass(actor, ai);

When the ai file is set, is it based on the difficulty? For example, if I had "ai aifile=aistormie.ai" as a symbol, and I used "AISetClass(getSenderRef(), aifile)", would it give the sender "aistromie.ai2" on hard, or will it only give "aistormie.ai"?

[edit] I forgot. Shoot. While you're here, can you please tell me where Seifer's POV weapon cog is available?

Thanks.

------------------
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 March 14, 2004).]
May the mass times acceleration be with you.
2004-03-14, 5:48 PM #2
Ruthven has a copy of it...

------------------
The future is here, and all bets are off.
And when the moment is right, I'm gonna fly a kite.
2004-03-15, 12:04 AM #3
From my experience of working with AI files, I believe that:

*.ai0 = easy
*.ai = medium
*.ai2 = hard

Ideally, you should provide all three for a custom level because the engine selects the appropriate AI file for the selected difficulty level (that the player chooses when starting JK). If however you only supply one AI file, no matter which difficulty level you choose, it will use and apply that one ai file as the default for that actor's AI class.

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

-Jackpot

PS: I do love tweaking the AI files - it's not really apparent in JK but the advances in MotS AI (coupled with COG's advances - "AIGetAlignment()" and similar verbs) are fairly numerous and provide a lot more interactive possibilities - the first level of MotS, fighting alongside your companions, still being one of my favourite levels [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/biggrin.gif]

------------------
"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-03-19, 10:33 AM #4
Yeah, LJ, but I'm changing the AI after startup via cogverb ant the top of this page. I'm asking if that will give the actor the ai file basedon difficulty.

For example, the symbol value is "blah.ai" and the difficulty is easy. Even though the value specifies the ai file for medium diff., will the JK system give the actor "blah.ai0" instead because the difficulty is on easy? I hope you understand this question.

And I'll ask ruthven about the cog.

------------------
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-03-20, 2:28 AM #5
Why don't you just check the diff settings and apply the proper ai file manually?

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2004-03-20, 7:30 AM #6
I didn't see the GetDifficulty() verb before. I must've just overlooked it or something...
Thanks.
[http://forums.massassi.net/html/smile.gif]

------------------
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-03-22, 12:05 PM #7
Arrrggghh! Just my luck.

I have this code, and the italicized parts don't seem to be working right (particularly concerned with disabling their ai for a moment so they can reload).
Code:
# Jedi Knight Cog Script
#
# ACTOR_RB.COG
#
# ACTOR Script - Ree Yees with Blaster
#
# 3/20/04 - Added feature so this actor reloads his gun
#
# [Darth Slaw]
#
# (C) 2004 Nightfire Mod
#==============================================================#
symbols

message   killed
message   damaged
message   skill
message   fire
message   timer
message   created

sound     reloadsound=trprsht1.wav  local #to be implemented

template  powerup=+DSTRifle         local
template  dummybrownRY=reeyeesGUN   local
template  limb=+RYlimb              local
template  limbblack=+RHlimb         local

thing     newThing                  local
thing     victim                    local
thing     reeyees                   local

int       bin                       local
int       senderref=-1              local
int       damage                    local
int       shots=32                  local
int       maxshots=32               local

keyframe  reloadkey=ryfire.key      local

ai        flee_ai=noweapon.ai       local
ai        newai=rybdefault.ai       local

end
#==============================================================#
code
created:
	senderref = getsenderref();
	AISetClass(senderref, newai);
	setThingUserData(senderref, maxshots);

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);
				if(GetThingTemplate(victim) == dummybrownRY)	// we have a brown ree yees
				newThing = CreateThingAtPos(limb, GetThingSector(victim), GetThingPos(victim), '0 0 0');
				else newThing = CreateThingAtPos(limbblack, GetThingSector(victim), GetThingPos(victim), '0 0 0');
				SetThingVel(newThing, '0.0 0.7 1.4');
			}
		}
	}
	ReturnEx(damage);

Return;
#------------------------------------------------------
killed:
	victim = GetSenderRef();
	if(GetActorWeapon(victim, 1) != -1)
	{
		AmputateJoint(victim, 3);
		newThing = CreateThing(powerup, victim);
		SetLifeLeft(newThing, 200.0);
	}

Return;
#------------------------------------------------------
skill:
	bin = GetParam(0);
	if(bin == 24)	// Force Pull
	{
		senderref = GetSenderRef();
		newThing = CreateThing(powerup, senderref);
		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;
#------------------------------------------------------
fire:
	//fire is called for each burst, not each shot
	reeyees = GetSourceRef();
	shots = GetThingUserData(reeyees);
	if(shots == -1) shots = maxshots;
	shots = shots - 1;
	setThingUserData(reeyees, shots);
	print("fire!");
	printint(shots);
	if(shots <= 0)
	{
		ISetMode(reeyees, 0x1000);
		AIClearMode(reeyees, 0x2000);
		PlayKey(senderref, reloadkey, 1, 10);
		SetTimerEx(GetKeyLen(reloadkey) + 2.0, 0, 0, 0);
		Print("reloading");
	}

Return;
#------------------------------------------------------
timer:
	if(GetSenderID() == 0)
	{
		shots = maxshots;
		setThingUserData(reeyees, maxshots);
		AIClearMode(reeyees, 0x1000);
		AISetMode(reeyees, 0x2000);
		print("fire ok again for reeyees");
	}

Return;
#------------------------------------------------------
end

Below is the ai script I replaced rybdefault.ai with (I have tried making it a whole new file instead of a replacement (i.e. 'reeyeedflt.ai'), but I got the same result). I want him to fire fast like a machine gun, but it isn't doing it! It also isn't firing in 10-11 shot bursts.
Code:
alignment=-1.0, rank=0.5, fov=200, maxstep=0.4, sightdist=5.0, heardist=2.0, accuracy=0.30
#instinct			args
#############################################
Jump					2000.0, 0.2, 0.2
LookForTarget   	500.0, 40000.0
Listen          	0.50, 2.0
PrimaryFire     	8.0, 0.8, 5.0, 0.30, 0.0, 600.0, 0.00, 0.00, 10.0, 600.0
BlindFire       	7.0, 0.50, 0, 0.8, 0.0, 0.40
Follow          	0.0, 1.0
OpenDoors
ReturnHome
Talk            	10000.0, 0.10

Please help; this is driving me nuts! [http://forums.massassi.net/html/mad.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 March 22, 2004).]
May the mass times acceleration be with you.
2004-03-23, 1:03 AM #8
Just a cursory glance, but in the if statement body of your "fire" message, you have ISetMode (params) rather than AISetMode (params) [http://forums.massassi.net/html/wink.gif] - it could be something as trivial as this... [http://forums.massassi.net/html/tongue.gif]

I suspect that there's something more afoot with the cog script, but I can't test it at the moment... [http://forums.massassi.net/html/redface.gif]. If you try some print statements, what does it tell you the values of the parameters for your setThingUserData() verbs are?

Hope this (somewhat) 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-03-23, 10:36 AM #9
It always prints '-1' for the output statements that print the user data. I'm gonna try a slightly different approach to the output though: concatenation. I should learn those verbs and use it more often for these types of situations [http://forums.massassi.net/html/rolleyes.gif] .

ISetMode()? Oops. must've somehow deleted it accidentally when adding the [ i] and [ /i] tags. [http://forums.massassi.net/html/redface.gif] Because it's not ISetMode in the cog; it has the preceding 'A' (damnit how I wish that was the problem!).

[edit]
Updated code again. In the timer[id=0] code, it only sets the userdata of the reeyee to 32 once in a while (once in every 5-10 reloads), and I have explicitly stated in the command to set it to 32. Every other time it leaves the userdata unchanged [http://forums.massassi.net/html/confused.gif] . And in the "fire" message, it always gets '0.000000' for the userdata even when it was just set to 32 in the "timer" message WTF is up with all that?

I did find an error I made: I was setting (clearing) the 0x1000 ai mode flag at the same time I was clearing (setting) the 0x2000 flag. I should have been setting (clearing) them at the same time as each other. That has been fixed in the code, but it still is having no effect at the moment.
Note:
0x1000 -- Actor will not attack
0x2000 -- Actor's AI is disabled

I also made the cog change the ai of the reeyee to a dummy one that has params that make the actor never fire. The ai doesn't change. Seems very little of the stuff in this frigging cog works. [http://forums.massassi.net/html/mad.gif]

Code:
# Jedi Knight Cog Script
#
# ACTOR_RB.COG
#
# ACTOR Script - Ree Yees with Blaster
#
# 3/20/04 - Added feature so this actor reloads his gun
#
# [Darth Slaw]
#
# (C) 2004 Nightfire Mod
#==============================================================#
symbols

message   killed
message   damaged
message   skill
message   fire
message   timer
message   created

sound     reloadsound=trprsht1.wav  local #to be implemented

template  powerup=+DSTRifle         local
template  dummybrownRY=reeyeesGUN   local
template  limb=+RYlimb              local
template  limbblack=+RHlimb         local

thing     newThing                  local
thing     victim                    local
thing     reeyees                   local

int       bin                       local
int       senderref=-1              local
int       damage                    local
#int       shots=32                  local

flex      maxshots=32.0             local

keyframe  reloadkey=ryfire.key      local

ai        flee_ai=noweapon.ai       local
ai        newai=reeyeesdflt.ai      local
ai        nullai=null.ai            local

end
#==============================================================#
code
created:
	senderref = getsenderref();
	SetTimerEx(0.1, 1, senderref, 0);	

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);
				if(GetThingTemplate(victim) == dummybrownRY)	// we have a brown ree yees
				newThing = CreateThingAtPos(limb, GetThingSector(victim), GetThingPos(victim), '0 0 0');
				else newThing = CreateThingAtPos(limbblack, GetThingSector(victim), GetThingPos(victim), '0 0 0');
				SetThingVel(newThing, '0.0 0.7 1.4');
			}
		}
	}
	ReturnEx(damage);

Return;
#------------------------------------------------------
killed:
	victim = GetSenderRef();
	if(GetActorWeapon(victim, 1) != -1)
	{
		AmputateJoint(victim, 3);
		newThing = CreateThing(powerup, victim);
		SetLifeLeft(newThing, 200.0);
	}

Return;
#------------------------------------------------------
skill:
	bin = GetParam(0);
	if(bin == 24)	// Force Pull
	{
		senderref = GetSenderRef();
		newThing = CreateThing(powerup, senderref);
		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;
#------------------------------------------------------
fire:
	//fire is called for each burst, not each shot
	reeyees = GetSourceRef();
	jkStringClear();
	jkStringConcatAsciiString("olduserdata=");
	jkStringConcatFlex(GetThingUserData(reeyees));
	SetThingUserData(reeyees, GetThingUserData(reeyees) - 1.0);
	jkStringConcatAsciiString(" ; newuserdata=");
	jkStringConcatFlex(getThinguserdata(reeyees));
	if(getThingUserData(reeyees) <= 0.0)
	{
		AISetClass(getParam(0), nullai);
		AISetMode(reeyees, 0x3000);
		PlayKey(senderref, reloadkey, 1, 10);
		SetTimerEx(3.0, 0, reeyees, 0);
		jkStringConcatAsciiString(" ; reloading");
	}
	jkstringoutput(-3, -1);

Return;
#------------------------------------------------------
timer:
	if(GetSenderID() == 0)
	{
		AIClearMode(getParam(0), 0x3000);
		AISetClass(getParam(0), newai);
		jkStringClear();
		jkStringConcatAsciiString("prereload userdata=");
		jkStringConcatFlex(GetThingUserData(reeyees));
		SetThingUserData(getParam(0), 32);
		jkStringConcatAsciiString(" ; postreload userdata=");
		jkStringConcatFlex(getThinguserdata(getParam(0)));
		jkstringoutput(-3, -1);
	}
	else if(getSenderID() == 1)
	{
		AISetClass(getParam(0), newai);
		SetThingUserData(getParam(0), 32);
		jkStringClear();
		jkStringConcatAsciiString("Startup userdata=");
		jkStringConcatFlex(GetThingUserData(getParam(0)));
		jkStringOutput(-3, -1);
	}

Return;
#------------------------------------------------------
end

Code:
# Jedi Knight AI File
#
# NULL.AI
#
# Dummy AI for reloading enemies to temporarily use until reload time expires
#
# [Darth Slaw]
#
# 3/23/04
#
# (c) 2004 Nightfire Mod

alignment=-1.0, rank=0.5, fov=200, maxstep=0.4, sightdist=5.0, heardist=2.0, accuracy=0.30

#instinct			args
#############################################

Jump					2000.0, 0.2, 0.2
LookForTarget   	500.0, 40000.0
Listen          	0.50, 2.0
PrimaryFire     	99999.9, 1.0, 0.0, 0.0, 0.0, 99999.9, 0.00, 0.00, 0.0, 99999.9
BlindFire       	99999.0, 0, 0, 1.0, 0.0, 0
Follow          	0.0, 1.0
OpenDoors
ReturnHome
Talk            	10000.0, 0.10


[This message has been edited by Darth Slaw (edited March 23, 2004).]
May the mass times acceleration be with you.
2004-03-26, 11:52 AM #10
* bump *

Any ideas? Should I start over? Try another method?

------------------
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.

↑ Up to the top!