You can do that with an item that has whatever that cast unique spell power is called (I don't build in the toolset much...
'>) and have it run a script that calls
ClearActions();
AssignCommand(oTargetedObject, DetermineCombatRound(oPC));
or just a DoCommand if you don't want to lose their current action stack... Shouldn't matter in combat though.
That'll force the monster to attack the player who used the item.
However, you could make it server wide and automatic fairly easy... A lot of it could be handled by an AI override probably.
The parts that I mentioned in my post about what I would do doesn't actually consist of very much code. If you have a decent amount of experience, I bet you could make a system that is trully great in a few days or less.
Begin by deciding what actions should make a player gain threat...
Example:
Attacking: +1 Threat
Damaging Melee: DamageInflicted/5
Damaging Spell: TotalDamageInflicted/5
OtherHarmfulSpell: SpellLevel (Things like Sleep that are offensive but no damage)
BuffsOnFriendlies: SpellLevel
Now, take a look at the creature events that would handle those things. That list would require OnAttacked, OnDamaged, and OnSpellCastAt.
Add a bit of code that adds the correct amount to a variable on the PC = to whatever is on your list. This will probably only wind up being a few lines of code in each of the events.
The exception is the Buffs on Friendlies. That would require small bit of code in a spell hook, which can be done in the default scripts in much the same way as the AI override. If you don't know how to hook spells, it's easy once you've done it.
Add a bit of code to the modules hb event that cycles through each PC and subtracts 1 or 2 points from their threat score (Minimum 0, of course).
Use an AI Override script like Lightfoot's, or replace the targetting code I mentioned.
The targetting code should cycle through each percieved PC and check their threat variable.
Whomever has the highest threat score is set as the NPC's combat target(Set the target the same way as the original code, just choose the target differently)
Add a line to the OnCombatRoundEnd or your AI Override script that deletes your old target each round. This will force them to allways attack whomever has the highest threat rating.
That'll give you a basic and universal threat based targetting system that'll work way better than the default for, probably, less than 50 lines of code.
Once you have that, you can start to think of ways to improve it and add new bits.
Modifié par wyldhunt1, 20 décembre 2011 - 05:17 .