Jump to content

Enemy fighter combat script


berelinde

Recommended Posts

I've got these three thugs in a quest. I'd like them to attack the party when the conditions for their hostility are met, but so far, all they do is just stand around.

 

I'm mostly all right with dialogue, but for some reason, I can't seem to get them to attack the nearest party member. These guys aren't geniuses. They aren't going to do anything even remotely approaching intelligent targeting. I just want them to find the nearest party member and attack them until they are dead and move along to the next one.

 

The only thing is that the attack variable needs to be set first.

 

Here is their script. It doesn't work:

/* Combat */
IF
 Global("B!QuestAttack1Floor","GLOBAL",1)
THEN
 RESPONSE #100
Enemy()
END

IF
 See([GOODCUTOFF]) 
THEN
 RESPONSE #100
Attack(NearestEnemyOf())
END

 

I feel so lame not to be able to get this right, but there you have it.

 

Maybe I have part of the problem fixed. I need to change the variable to:

GlobalGT("B!QuestAttack1Floor","GLOBAL",0)

 

Or maybe it should be:

IF

Global("B!QuestAttack1Floor","GLOBAL",1)

Global("B!Thug1Attack","LOCALS",0)

THEN

RESPONSE #100

SetGlobal("B!Thug1Attack","LOCALS",1)

Enemy()

END

Link to comment

I am, like, totally lame in this, but I had the same problem and I used the following:

 

IF
HPPercentLT(Myself,100)
Allegiance(Myself,NEUTRAL)
Global("O#XanTalosThiefAttacked","LOCALS",0)
THEN
RESPONSE #100
SetGlobal("O#XanTalosThiefAttacked","LOCALS",1)
SetGlobal("O#XanPCAttackedTalosThieves","GLOBAL",1)
Enemy()
END

IF
AttackedBy([ANYONE],DEFAULT)
Allegiance(Myself,NEUTRAL)
Global("O#XanTalosThiefAttacked","LOCALS",0)
THEN
RESPONSE #100
SetGlobal("O#XanTalosThiefAttacked","LOCALS",1)
SetGlobal("O#XanPCAttackedTalosThieves","GLOBAL",1)
Enemy()
END

IF
Global("O#XanPCAttackedTalosThieves","GLOBAL",1)
Allegiance(Myself,NEUTRAL)
Global("O#XanTalosThiefHostile","LOCALS",0)
THEN
RESPONSE #100
SetGlobal("O#XanTalosThiefHostile","LOCALS",1)
Enemy()
END

Link to comment

OK, that looks like it would work, and it would also get the bits where they'd turn hostile if the PC just walked up and bashed them, which they currently won't do.

 

Once they're Enemy(), will they attack automatically, or do I have to do anything to get them to do so?

Link to comment
Once they're Enemy(), will they attack automatically, or do I have to do anything to get them to do so?

 

You have to assign some game default scripts in their Class/Race script - WTASGHT(spelling?) or something worked for me.

Link to comment

Ah. Cool.

 

I think I know what I was doing wrong: not closing a variable.

 

With the first block as it was, they'd just keep turning into an enemy over and over and over again, and would never actually get to the point where they'd attack anyone.

Link to comment

Something I use in one of my "enemy" scripts.

 

IF
Global("CmDruidHostile","GLOBAL",1)
THEN
RESPONSE #100
	Enemy()
END

IF
AttackedBy([ANYONE],DEFAULT)
Global("CmDruidHostile","GLOBAL",0)
THEN
RESPONSE #100
	SetGlobal("CmDruidHostile","GLOBAL",1)
	Enemy()
END

The block of AttackedBy([ANYONE],DEFAULT) is something you may want to add also. When someone force attacks your bad guys, you may want them to turn into an enemy if that happens.

Link to comment

Try this:-

 

IF
 !Allegiance(Myself,ENEMY)
 OR(2)
Global("B!QuestAttack1Floor","GLOBAL",1)
AttackedBy([ANYONE],DEFAULT)
THEN
 RESPONSE #100
Enemy()
Continue()
END

IF
 Allegiance(Myself,ENEMY)
 See(NearestEnemyOf()) 
THEN
 RESPONSE #100
Attack(NearestEnemyOf())
END

 

That should get each thug to attack the nearest GOODCUTOFF. Your original problem was that the code block was continually seeing Global("B!QuestAttack1Floor","GLOBAL",1) and repeatedly setting your allegiance to Enemy() with no way to move on and no way to skip to the attack block once the allegiance had been changed.

 

If you want something a wee bit more -erm- nasty (as in the thugs attempting to support each other) let me know.

 

-Y-

 

[EDIT]Urr.. COM_S got there just before me.

Link to comment

Thanks much!

 

I see what all three of you are saying, and I think I'll be good with that.

 

These guys don't have to be nasty. They don't even have to be annoying. But they do need to do something instead of standing there like they're on a smoke break.

 

The reason for this is that the cleric in the room with them will be in the process of sinking them under a sea of skeletons ;)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...