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 → Refusing to target AI.
Refusing to target AI.
2004-05-09, 12:37 PM #1
Hi!
This COG is a class Cog for assassin balls. At some point before I added SetThingLook(Radnom()) every pulse, they were working fine. Now, I've removed that, and tried to replicate the Assassin droids from GOLEM.
Code:
# Assassin Ball
#
# By Edward
flags=0x240
symbols

message		created
message		pulse
message		damaged

thing		ball		local
thing		player		local

template	shoot=+repeaterball	local

sound		firesnd=LASER5.WAV	local
sound		bounce=BOUNCE.wav	local

model		ballmodel=ball2.3do	local

template	boom=+ball_exp		local

int		victim			local
flex		maxdot			local
flex		dot			local
int		potential		local

end
#
code
created:
	ball=GetSenderRef();
	player=GetThingParent(ball);
	SetThingPulse(ball,0.01);
return;
pulse:

	victim = -1;
	maxDot = 0;

	// Search for all players and actors.
	potential = FirstThingInView(GetSenderRef(), 180, 10, 0x404);
	while(potential != -1)
	{
		if(HasLOS(GetSenderRef(), potential) && (potential != player) && !(GetThingModel(GetSenderRef())==ballmodel) && (VectorDist(GetThingPos(GetSenderRef()), GetThingPos(potential)) <= 10) && !(GetThingFlags(potential) & 0x200) && !((jkGetFlags(potential) & 0x20) && !IsInvActivated(player, 23)))
		{
			dot = ThingViewDot(GetSenderRef(), potential);
			if(dot > maxDot)
			{
				victim = potential;
				maxDot = dot;
			}
		}
		potential = NextThingInView();
	}

	// If we have a victim...
	if((victim != -1)) 
	{
		SetThingLook(GetSenderRef(), VectorSub(GetThingPos(victim), GetThingPos(GetSenderRef())));
		FireProjectile(GetSenderRef(),shoot,firesnd,-1,'0 0 0','0 0 0',0,0,0,0);
		if(!(GetThingAttachFlags(GetSenderRef())==0) || (GetThingFlags(GetSenderRef()) & 0x2000000))
		{
			DetachThing(GetSenderRef());
			SetThingVel(GetSenderRef(),VectorAdd(GetThingLVec(GetSenderRef()),'0 0 1'));
			PlaySoundThing(bounce,GetSenderRef(),1,-1,10,0x80);
		}
	}
	else
	{
		jkEndTarget();
		SetThingLook(GetSenderRef(),VectorSet(rand()*360,rand()*360,rand()*360));
	}
return;
damaged:
	If(GetSenderRef()==ball)
	{
		CreateThing(boom,ball);
		destroyThing(ball);
	}
return;
end

The problems so far:
They don't attack anything apart from each other (sometimes), and myself if I don't set player=GetThingParent()...
Please help!

/Edward


[This message has been edited by Edward (edited May 21, 2004).]
Edward's Cognative Hazards
2004-05-12, 6:23 AM #2
Hm... Would it help if I gave a template?
Code:
+ball1		   none                 orient=(0/0/0) type=actor model3d=ball1.3DO size=0.025 movesize=0.025 soundclass=ball1.snd height=0.025 health=10 maxhealth=10 damageclass=0x1 damage=100 move=physics collide=1 vel=(0.000000/2.000000/1.500000) physflags=0x4267 mass=2 airdrag=0 surfdrag=1 buoyancy=1 typeflags=0x100161 thingflags=0x20000000 explode=+ball_exp cog=ball.cog

+assassinball	+ball1			model3d=ball2.3DO size=.0125 movesize=.0125 health=10 maxhealth=10 angvel=(0/0/0) vel=(0.000000/1.000000/0.000000) surfdrag=0 mass=1 physflags=0x4267 cog=assassinball.cog



[This message has been edited by Edward (edited May 15, 2004).]
Edward's Cognative Hazards
2004-05-15, 12:53 AM #3
HELLOOOO!?!?
Is there anything you don't get? Did I not express myself clearly? What was it you didn't get and I'll try to elaborate...

/Edward
Edward's Cognative Hazards
2004-05-15, 6:46 AM #4
Brief lookover...
Try, in that BIG FAT LONG if statement, removing "&& (potential != GetSenderRef())". I was recently working on one of these types of cogs, and removing the line fixed a problem with who the thing picked to attack.
I'm not experienced with the dot/maxdot stuff, but that might also be a problem with the target selecting (emphasis on "might be").
Hope this helps, at least a little. [http://forums.massassi.net/html/smile.gif]

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.
May the mass times acceleration be with you.
2004-05-15, 10:26 AM #5
OK, took away "&& (potential != GetSenderRef())", nothing happened.
Commented out player=GetThingParent(), they at first attacked those near by, then attacked things behind walls. A-wha'??? And only sometimes did they go after me...
If I shot them in the direction of a person, then yeah, they'd kill the person, before targetting an actor behind a wall or me...
I tried commenting out the Dot thing, but no change...
And the reason for having the LONG If statement and not chopping it down is because Parsec tells that there is a problem there and won't continue...

Edit: Decided to take away the ParseArg(AngVel) and add SetThingLook(Random(360))...

/Edward


[This message has been edited by Edward (edited May 15, 2004).]
Edward's Cognative Hazards
2004-05-21, 8:59 AM #6
Unanswered problems are a BAAAAD thing... Because, if problems go unanswered, then either there will be no more things submitted or unhappy customers... Have your pick...

/Edward
Edward's Cognative Hazards
2004-05-21, 6:22 PM #7
I played around with the cog, and I think the problem may lie in the big if statment. Don't know where. If not then next best place would be the if(dot/maxdot) statement, but that seems to be okay.
The balls are not supposed to be targetting ppl unless they are visible, yet it attacks things through walls like you said. 0_o What's up with HasLOS()?

I'll have to look at it some more tomorrow.

------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity
May the mass times acceleration be with you.
2004-05-24, 4:04 AM #8
Tomorrow has gone. Tonight is coming. I'd like answeres, as so many others do...

/Edward
Edward's Cognative Hazards
2004-05-24, 10:24 AM #9
Oh crap it's been a while [http://forums.massassi.net/html/redface.gif].
I couldn't solve anything; the best I got (well, worst technically) is that the things would attack ONLY ME! And I had "&& potential != [player]" (where [player] was "GetLocalPlayerThing()" AND "GetThingParent(GetSenderRef())").

------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity
May the mass times acceleration be with you.
2004-05-24, 2:23 PM #10
[edit]
call me stupid, I didn't check your template. My post is useless since you don't have an .ai file.

[don't read on]
[/edit]

Do you have an .ai file?

If so, check its alignment (I only edit MOTS, so if this is JK and it doesn't have alignment, just call me stupid)

'1' is good (you)
'-1' is bad (stormie trooper)

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

[This message has been edited by SG-fan (edited May 24, 2004).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-05-26, 9:07 PM #11
Needing help! Should I add an AI? Should I give up? Waaah!

/Edward
Edward's Cognative Hazards
2004-05-27, 2:11 PM #12
Yeah, probably. :P
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2004-05-30, 2:19 AM #13
Hm... The Assassin Droids didn't have an AI... Ho Hum...

/Edward
Edward's Cognative Hazards

↑ Up to the top!