Author Topic: Ability of Hurl Rocks  (Read 606 times)

Legacy_Ivanovich

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
Ability of Hurl Rocks
« on: August 20, 2011, 11:53:48 pm »


               Greets.  The standard Bioware spell (ability) "Hurl Rocks" is found in x2_s1_hurlrock.  I've always hated how the rocks are like guided missles, following the target around walls, or as he/she runs and then hitting them.  The stones curve in the air and it's really absurd.  Instead, I was trying to make it so the rocks fly where the target was standing originally and then impact the ground at that spot, so if the PC runs off, he/she can get away.

I have altered the spell somewhat here but still cannot figure out why it does not work:

void RockDamage(location lImpact);

#include "x2_inc_shifter"
#include "x0_i0_spells"

void main()
{
    //Do damage here...//354 is rock flying, 460 is dust at impact
    object oTarget = GetSpellTargetObject();
    effect eImpact = EffectVisualEffect(354);
    effect eImpac1 = EffectVisualEffect(460);
    int nDamage;
    location lImpact = GetLocation(oTarget);
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImpact, lImpact);
    DelayCommand(0.2f,ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImpac1, lImpact));
    RockDamage(lImpact);
}

void RockDamage(location lImpact)
{
    float fDelay;
    int nDamage;
    effect eDam;
    //Declare the spell shape, size and the location.  Capture the first target object in the shape.
    object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_SMALL, lImpact, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
    //Cycle through the targets within the spell shape until an invalid object is captured.

    int nDC;

    int bShifter = (GetLevelByclass(class_TYPE_SHIFTER,OBJECT_SELF)>10);

    if (bShifter)
    {
        nDC = ShifterGetSaveDC(OBJECT_SELF,SHIFTER_DC_HARD);
    }
    else
    {
        nDC = GetSpellSaveDC()+2;
    }

     int nDice = GetHitDice(OBJECT_SELF) / 5;
     if (nDice <1)
     {
        nDice =1;
     }


    int nDamageAdjustment = GetAbilityModifier (ABILITY_STRENGTH,OBJECT_SELF);
    while (GetIsObjectValid(oTarget))
    {

        if (spellsIsTarget(oTarget,SPELL_TARGET_STANDARDHOSTILE,OBJECT_SELF))
        {
            //Fire cast spell at event for the specified target
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId()));
            //Get the distance between the explosion and the target to calculate delay
            fDelay = GetDistanceBetweenLocations(lImpact, GetLocation(oTarget))/20;
            //Roll damage for each target, but doors are always killed


             nDamage = d20(nDice) + nDamageAdjustment;



            //Adjust the damage based on the Reflex Save, Evasion and Improved Evasion.
            nDamage = GetReflexAdjustedDamage(nDamage, oTarget, nDC, SAVING_THROW_TYPE_NONE);
            //Set the damage effect
            eDam = EffectDamage(nDamage, DAMAGE_TYPE_BLUDGEONING,DAMAGE_POWER_PLUS_ONE);
            if(nDamage > 0)
            {
                // Apply effects to the currently selected target.
                DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
                DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectKnockdown(), oTarget, 4.0));
                //This visual effect is applied to the target object not the location as above.  This visual effect
                //represents the flame that erupts on the target not on the ground.
                //DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
            }
        }
        //Select the next target within the spell shape.
        oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lImpact, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
    }
}



The only thing I can figure out is that this change has to occur in the spells.2da under the "TargetType" column, which right now is set at 0x3E (which is target everything BUT self).  

Help?  Thank you in advance.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #1 on: August 21, 2011, 12:17:50 am »


               The rock animation will always follow its target.  You could have it only target the ground, but that would take an AI adjustment for the creature to know to cast it near the target when it can't cast it on the target.

Also delayed saving throws won't take saves vs. spells into consideration.
               
               

               
            

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #2 on: August 21, 2011, 04:44:38 am »


               

The rock animation will always follow its target. You could have it only target the ground, but that would take an AI adjustment for the creature to know to cast it near the target when it can't cast it on the target.


This is something I wanted to alter too, but wasn't limiting it to hurl rocks but in fact things like fireball. Is the same true of all projectiles - that is, that it's impossible to make them shoot to a location instead of an object?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #3 on: August 21, 2011, 03:53:55 pm »


               The Targeting of the spell and what it can target is controled by spells.2da.  You would have to edit the 2da and put it in a hak for both the servers and clients to get the results you are after.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #4 on: August 21, 2011, 04:15:17 pm »


               

Lightfoot8 wrote...

The Targeting of the spell and what it can target is controled by spells.2da.  You would have to edit the 2da and put it in a hak for both the servers and clients to get the results you are after.

Yes but as WhiZard said, there might be issue with AI. The AI might not handle use this special ability if you disable to cast it on creature. Im not sure since i tested this only at spells (no problem) and feat (AI issue resulted in no action) but not monster ability.

So if monsters wont do anything you will have to alter core AI scripts.


BTW if you finish it please share, I also like this idea 'B)'
               
               

               


                     Modifié par ShaDoOoW, 21 août 2011 - 03:16 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #5 on: August 21, 2011, 07:08:53 pm »


               I've made things like a catapult shoot to a waypoint.  So projectiles can be targeted to a waypoint. to To state that projectiles cannot be targeted to a waypoint is incorrect.  Come to think of it I think I made some spells, such as fireballs also target to a waypoint.  I suppose that is to an object so not technicaly a location.  So if I had an object that I wan't to shoot a fireball too, and then chose to use it's location parameter instead of it's object parameter it would not work?
So you could just do object oTarget =GetWaypointByTag(string sWaypointTag)
and then randomize the waypoints in a specific area just to have some rocks being thrown into a general area, though this won't specifically solve the problem of hurl rocks, it could be done rather easily, without all the heavy alterations in the 2da, and the reqirement of a hackpack.  Additionally you could create a waypoint based on the location of the PC and have rocks thrown to that waypoint, then destroying that waypoint and creating another one based on the PC's current location.  So standing still would not be a good idea.
               
               

               


                     Modifié par ffbj, 21 août 2011 - 06:32 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #6 on: August 21, 2011, 09:20:27 pm »


               

ffbj wrote...

I've made things like a catapult shoot to a waypoint.  So projectiles can be targeted to a waypoint. to To state that projectiles cannot be targeted to a waypoint is incorrect.  Come to think of it I think I made some spells, such as fireballs also target to a waypoint.  I suppose that is to an object so not technicaly a location.  So if I had an object that I wan't to shoot a fireball too, and then chose to use it's location parameter instead of it's object parameter it would not work?
So you could just do object oTarget =GetWaypointByTag(string sWaypointTag)
and then randomize the waypoints in a specific area just to have some rocks being thrown into a general area, though this won't specifically solve the problem of hurl rocks, it could be done rather easily, without all the heavy alterations in the 2da, and the reqirement of a hackpack.  Additionally you could create a waypoint based on the location of the PC and have rocks thrown to that waypoint, then destroying that waypoint and creating another one based on the PC's current location.  So standing still would not be a good idea.


Well you could also do this through AI without waypoints.


void main()
{
if(Random(5)) return;//20% chance of firing
int n =1;
object oCreature = GetNearestObject(OBJECT_TYPE_CREATURE);
location lLoc;
while(GetIsObjectValid(oCreature))
  {
  if(GetIsEnemy(oCreature))
    {
    if(GetDistanceToObject(oCreature)<= 40.0)//Range of Spell
      {
      lLoc = GetLocation(oCreature);
      ClearAllActions(TRUE);
      ActionCastSpellAtLocation(775, lLoc, METAMAGIC_ANY, TRUE);
      return;
      }
    else return;
    }
  n++;
  oCreature = GetNearestObject(OBJECT_TYPE_CREATURE, OBJECT_SELF, n);
  }
}

Note for the above you cannot rely on GetCasterLevel() in the spell script, as it will automatically use 10 as the caster level.  Also there is the possible issue of this spell being interrupted or countered (by greater dispelling or mords).  To prevent this use the talent system rather than the cheat cast above.

This script is simply placed as a custom AI script.

Also this script only prevents NPCs from using the rock throwing animation on a creature.  To prevent PCs from using the rock animation on a creature, spells.2da needs to be edited.
               
               

               


                     Modifié par WhiZard, 21 août 2011 - 08:37 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #7 on: August 22, 2011, 01:23:22 am »


               

WhiZard wrote...

The rock animation will always follow its target.


Just to clarify... 

The animation doesn't do anything other than make the model move in a prescribed manner. It is the ProjType column in spells.2da that defines how the projectile moves in relation to its origin and target points. However, as WhiZard stated, a projectile that targets a creature will always follow it, but you can always try some of the other projectile settings and see if that helps.
               
               

               


                     Modifié par Pstemarie, 22 août 2011 - 12:36 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #8 on: August 22, 2011, 02:21:55 am »


               

Pstemarie wrote...

WhiZard wrote...

The rock animation will always follow its target.


Just to clarify... 

The animation doesn't do anything other than make the model move in a prescribed manner. It is the ProjType column in spells.2da that defines how the projectile moves in relation to its origin and target points. However, as WhiZard stated, a projectile that targets a creature will always follow it, but you can always try some of the other projectile settings and see if that helps.


Projectile types are
bounce (e.g. grenades)
accelerating (e.g. hold person)
homing (e.g. fireball)
linked (e.g. lightning bolt)
spiral (e.g. seeker arrow)
ballistic (e.g. hurl rocks)

All of these will have the target as their endpoint.  Also the OP seems to be basing the delay upon the lag of the ballistic.
               
               

               


                     Modifié par WhiZard, 22 août 2011 - 01:31 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #9 on: August 22, 2011, 03:29:44 am »


               There's high ballistic, maybe for catapults, and default, which is what a straight line?
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #10 on: August 22, 2011, 06:25:44 am »


               EDIT

High ballistic is an additional one (not listed in spells.2da, but can be implemented through ActionCastSpell...())
Default just uses whatever spells.2da is using.
Which means ActionCastSpell...() does not supported linked, bounce, or spiral (unless they are default).
               
               

               


                     Modifié par WhiZard, 22 août 2011 - 05:42 .
                     
                  


            

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Ability of Hurl Rocks
« Reply #11 on: August 22, 2011, 07:25:57 am »


               Some great tips in here, thanks. '<img'>