Author Topic: Calling combat functions  (Read 344 times)

Legacy_Sarcose

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Calling combat functions
« on: February 17, 2012, 04:00:38 pm »


               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.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Calling combat functions
« Reply #1 on: February 17, 2012, 04:23:17 pm »


               No, there isn't. AoOs are hardcoded behavior. You'll have to emulate one.

Funky
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Calling combat functions
« Reply #2 on: February 17, 2012, 04:30:14 pm »


               

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 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Calling combat functions
« Reply #3 on: February 17, 2012, 04:50:11 pm »


               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 .
                     
                  


            

Legacy_Sarcose

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Calling combat functions
« Reply #4 on: February 17, 2012, 09:47:23 pm »


               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 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Calling combat functions
« Reply #5 on: February 17, 2012, 10:07:28 pm »


               

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 .
                     
                  


            

Legacy_Sarcose

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Calling combat functions
« Reply #6 on: February 17, 2012, 10:44:24 pm »


               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.