Calling combat functions
#1
Posté 17 février 2012 - 04:00
I am creating an item that causes the caster of the object to make a touch attack against an opponent (which I can just emulate using statcalls), rip off a chunk of flesh and eat it, slapping the opponent with a debuff.
What I would like to do is cause this to trigger an attack of opportunity, as it would normally in RAW for the pnp.
Otherwise I guess I could emulate an attack of opportunity using the same method to emulate the touch attack.
#2
Posté 17 février 2012 - 04:23
Funky
#3
Posté 17 février 2012 - 04:30
Sarcose wrote...
Is there a way to call any function of combat?
I am creating an item that causes the caster of the object to make a touch attack against an opponent (which I can just emulate using statcalls), rip off a chunk of flesh and eat it, slapping the opponent with a debuff.
What I would like to do is cause this to trigger an attack of opportunity, as it would normally in RAW for the pnp.
Otherwise I guess I could emulate an attack of opportunity using the same method to emulate the touch attack.
Actually provoking an AoO is easy if you use a spell.2da line. Set the user type to 1 and the conjure and cast time to 0 or ****. Call the spell using the normal scripted commands (ActionCastSpellAt...()).
EDIT: You may want to look at the line for "shadow attack" to get a good idea how this is set up.
Modifié par WhiZard, 17 février 2012 - 04:33 .
#4
Posté 17 février 2012 - 04:50
For example this script would hijack into "x2_s1_shadow" using the shadow attack ability that is already set up to cause an AoO.
void main()
{
object oTarget = GetSpellTargetObject();
if(!GetIsObjectValid(oTarget))
{
SendMessageToPC(OBJECT_SELF, "INVALID TARGET");
return;
}
SetLocalInt(OBJECT_SELF, "INSERT_CUSTOM_ABILITY_NAME", TRUE);
ActionCastSpellAtObject(769 , oTarget, METAMAGIC_ANY, TRUE);
}
EDIT: I set this up under a normal spell script, if you use tag based scripting and are refering to a tag based script use the ActivateItem event commands to get the caster and target.
Modifié par WhiZard, 17 février 2012 - 04:56 .
#5
Posté 17 février 2012 - 09:47
^--It would sure solve the dilemma I was having about whether to even bother trying to find a way to properly emulate all the possible OnHit triggers for weapons.
Modifié par Sarcose, 17 février 2012 - 09:48 .
#6
Posté 17 février 2012 - 10:07
Sarcose wrote...
So essentially have the script cast the shadow attack (in that example) with a local variable that triggers a different behavior inside the script for said attack?
^--It would sure solve the dilemma I was having about whether to even bother trying to find a way to properly emulate all the possible OnHit triggers for weapons.
Yes, after the voidmain() it would look something like this
if(GetLocalInt(OBJECT_SELF, "INSERT_CUSTOM_ABILITY") )
{
DoCustomAbility();
DeleteLocalInt(OBJECT_SELF, "INSERT_CUSTOM_ABILITY");
return;
}
If there is more than one ability, you might be better off setting constants and using a switch.
int nValue = GetLocalInt(OBJECT_SELF, "CUSTOM_ABILITY_STORAGE");
DeleteLocalInt(OBJECT_SELF, "CUSTOM_ABILITY_STORAGE");
switch (nValue)
{
case CUSTOM_ABILITY_1:
{
DoCustomAbility1();
return;
}
case CUSTOM_ABILITY_2:
{
DoCustomAbility2();
return;
}
...
}
Modifié par WhiZard, 17 février 2012 - 10:17 .
#7
Posté 17 février 2012 - 10:44
Thanks for the advice! This is a pretty good development in my scripting plans.





Retour en haut






