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