Aller au contenu

Photo

Calling combat functions


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Sarcose

Sarcose
  • Members
  • 17 messages
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.

#2
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
No, there isn't. AoOs are hardcoded behavior. You'll have to emulate one.

Funky

#3
WhiZard

WhiZard
  • Members
  • 1 204 messages

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
WhiZard

WhiZard
  • Members
  • 1 204 messages
If you don't want 2da modification you can always hijack a working example and put in your own custom behavior if a certain variable is set (remembering to unset it within the custom behavior).


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
Sarcose

Sarcose
  • Members
  • 17 messages
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.

Modifié par Sarcose, 17 février 2012 - 09:48 .


#6
WhiZard

WhiZard
  • Members
  • 1 204 messages

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
Sarcose

Sarcose
  • Members
  • 17 messages
Hm. I could theoretically enslave a single script in this fashion for all my custom abilities that need to trigger AoO's.

Thanks for the advice! This is a pretty good development in my scripting plans.