PC's throwing boulders

I was wondering if any script writers can make a script where a PC can throw a boulder…like giants can using that same animation. I have a half-giant class in my module I thought it would be cool if they could throw boulders. Dependent on strength of course. I was thinking a strength of 32 or greater to lift and throw the boulder. Opening it up to other races too if they meet the required strength. So maybe just a simple script that allows the throwing of boulders (using the giant boulder throwing animation) for anyone having a strength of over 32. Can any script writer do this?

Here’s the throw script:

AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionCastSpellAtObject(
	775, oTarget, METAMAGIC_ANY, TRUE));

See spells.2da how this (Giant_hurl_rock) spell is made (projectile, trajectory, etc).

Hi NWShacker

Thanks but I would not know how to write that script or where to put it. Could you do one for me and tell me where to put the script(s)?

Put it anywhere you want, customizing the thrower and target.

In the end they’d go to OnActivateItem for a boulder item PC picks to throw (there you can do a STR check and so on).

Here’s just for testing. Put this script as OnPlayerChat handler (in module properties):

void main()
{
    object oPC = GetPCChatSpeaker();
    object oTarget = GetNearestCreature(
        CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN, oPC);

    AssignCommand(oPC, ClearAllActions());
    AssignCommand(oPC, ActionCastSpellAtObject(
        775, oTarget, METAMAGIC_ANY, TRUE));
}

Then, inside the module, send a chat message. PC will throw the rock it at a nearest creature.

If you edit spells.2da you can also customize the projectile:

3 Likes

Wow thanks…lol…but I am dumb when it comes to all this scripting stuff.

You know how some in the past just use to put a script on the vault and you would download it. It had all the steps in a Notepad or word document explaining what goes where etc.

So I look at this script but I don’t see where it checks for strength…nor does it have a boulder check. I was thinking of making a boulder item you can carry in inventory (you pick up and carry). I have a throwable net I once downloaded from the vault years ago. That kind of concept. You would pick it up…carry it…then throw it. It had an inventory item…and a placeable.

So with the above script I would just put that script on a boulder placeable and a PC could pick it up then throw it then an animated boulder like that of a giant throwing it would show up being thrown? Sorry still not seeing that in that script…I’m sorry for bothering you…I’m just not a scripter.

Example of my Net script I found years back:

Onactivateitem

}
//* Gladiator Net?
if(sItemTag == “it_netfight” && GetObjectType(oTarget)==OBJECT_TYPE_CREATURE )
{
if(GetDistanceBetween(oPC,oTarget) > 10.0)
{
//SendMessageToPC(oPC,“Ihr seid zu weit entfernt.”);
SendMessageToPC(oPC,“You are too far away.”);
return;
}
ExecuteScript(“sp_netfight”, OBJECT_SELF);
}

And…

sp_netfight

void main()
{
object oPC = GetItemActivator();
object oTarget = GetItemActivatedTarget();
object oUsed = GetItemActivated();
object oWeap_RH= GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
object oWeap_LH= GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);

  if(GetHasFeat(FEAT_WEAPON_PROFICIENCY_EXOTIC, oPC)==FALSE)
    {
     //SendMessageToPC(oPC,"Ihr besitzt nicht das nötige Talent im Umgang mit dieser Waffe..."); //german text//
     SendMessageToPC(oPC,"You need EXOTIC WEAPON PROFICIENCY, to use this weapon...");
     return;
    }
  if((oWeap_RH != OBJECT_INVALID) && (oWeap_LH != OBJECT_INVALID) )
    {
     //SendMessageToPC(oPC,"Ihr benötigt mindestens eine freie Hand, um das Netz zielgerichtet zu werfen..."); //german text//
     SendMessageToPC(oPC,"You need one free hand, to use this weapon...");
     return;
    }
  if(GetHasSpellEffect(1644, oTarget)==TRUE)
    {
     //SendMessageToPC(oPC,"Das Ziel ist bereits in einem Netz verstrickt..."); //german text//
     SendMessageToPC(oPC,"Target already is entangled...");
     return;
    }
  DestroyObject(oUsed);
  AssignCommand(oPC,ActionCastSpellAtObject(1501, oTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

}

Have you tried my script and saw what happens?

Because it doesn’t do any of these. I showed you the hardest part, the rest is for you as a homework. You’ll learn 100 times more this way rather than if I gave you the answer right away. That’s because item’s “unique power” are coded that way - this is quite common functionality.

Well, that’s the idea, but you need to start from somewhere. Prepare an item (any item for now) with Cast Spell -> Activate Item property. Give it a unique tag (i.e. “BOULDER”). Then add rest of functionality to OnActivateItem skeleton below:

void main()
{
    object oPC = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    location lTarget = GetItemActivatedTargetLocation();

    if(GetTag(oItem) == "BOULDER")
    {
        // boulder item activated
        AssignCommand(oPC, ClearAllActions());
        AssignCommand(oPC, ActionCastSpellAtObject(
            775, oTarget, METAMAGIC_ANY, TRUE, 0, 0, TRUE));
    }
}

“Picking a placeable” and turning it into an item is another thing. It is not directly related to item activation and can be done separately later.

When you are done, post your script here, just don’t forget to put it in [code] and [/code] tags (each tag in a separate line or they won’t work).

Hi NWShacker

I appreciate you trying to help me learn scripting, but it is like learning a language for me. I have zero knowledge of. Years ago when I played I use to just download scripts like the net throwing script I posted above. It was easy enough for me to copy and follow the instructions and I knew where to put in which Event scripts because the uploader would give specific step by step instructions…that’s about as much as I know about scripting. You asking me to put together a script is like me teaching you Spanish in one day…lol…beyond my capability. Sorry.

You’ll never know if you give up right at the start.

Try now. I merged the scripts. Make an activatable item with BOULDER tag and it will fly.

Did you like the above net throwing script I posted above? I downloaded that off the vault years ago …a German guy posted it. I wish someone could do the same for this rock throwing script I would like to have.

Ok…I will make a boulder with that tag.

It’s exactly the same functionality. Just with extra stuff.

The rock must have a Cast Spell -> Activate Item (long range) property (and extra weight - it’s a rock). Target a creature with it.

Will do. It is just after midnight here. I will do this tomorrow. I will get back to you and let you know how it worked…or did not work…lol.

One thing I am confused about is where in the script it says to check for strength? I want only strength of 32 or better to be able to throw this.

All right, try this.
void main()
{
    object oPC = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();

    if(GetTag(oItem) == "BOULDER")
    {
        if(GetObjectType(oTarget) != OBJECT_TYPE_CREATURE)
        {
            FloatingTextStringOnCreature(
                "You could throw this at someone...", oPC);
        }
        else if(GetAbilityScore(oPC, ABILITY_STRENGTH) < 32)
        {
            FloatingTextStringOnCreature(
                "You are not strong enough to throw this.", oPC);
        }
        else
        {
            AssignCommand(oPC, ClearAllActions());
            AssignCommand(oPC, ActionCastSpellAtObject(
                775, oTarget, METAMAGIC_ANY, TRUE, 0, 0, TRUE));
            AssignCommand(oPC, ActionDoCommand(DestroyObject(oItem)));
        }
    }
}

The item must have unlimited uses per day or it will be consumed even if activator does not meet the ability requirement. That’s also why manual item’s destruction has to be scheduled after the spell action is completed.

Ok…created item as you stated above. I also put the script above at the end of my OnActivateItem script event on the module as per below (last few lines):

   }
      }
   {
 //staff of dancing
   }
  object oUsed = GetItemActivated();
  if (GetTag(oUsed) == "STAFFOFDANCING")
    {
       object oUser = GetItemActivator();
       if (GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oUser) != oUsed)
       {
            SendMessageToPC(oUser, "You must equip the staff before you can use its special power.");
       }else{
       DestroyObject(oUsed);
       location mySummon = GetLocation(oUser);
       effect eAppear = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
       object oStaff = CreateObject(OBJECT_TYPE_CREATURE, "eas_staffdance", mySummon, TRUE);
       mySummon = GetLocation(oStaff);
       ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eAppear, mySummon, 1.5);
       SetIsTemporaryFriend(oUser,oStaff,FALSE);
       SetLocalInt(oStaff, "TIMER", 6);
       SetLocalObject(oStaff, "OWNER", oUser);
  // Boulder
     {
    object oPC = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    location lTarget = GetItemActivatedTargetLocation();

    if(GetTag(oItem) == "BOULDER")
    {
        // boulder item activated
        AssignCommand(oPC, ClearAllActions());
        AssignCommand(oPC, ActionCastSpellAtObject(
            775, oTarget, METAMAGIC_ANY, TRUE, 0, 0, TRUE));
    }
}

       }

    }
 }

I saved. It compiled. I tried it in game. I threw the item (used it’s unique property) at a creature. Nothing. No boulder animation was seen. No damage was taken. And where in this script does it say how much damage it causes or where strength comes into this? I’m confused.

And I did the stupid… “[ code ]”… and…"[ /code ]"… thing here to highlight my code above and it didn’t work (see above)…ugh…this is frustrating. LOL…I can’t even figure out how to post my code on this thread…see…lol…I’m not that great at this stuff. This is a scripter’s thing…I can add a script to the end of my script well enough…but that’s about it.

  1. [code] must be in in its own line with no other code or it won’t be formatted correctly - you can edit your post.
  2. Make a fresh module and try my code alone there - do not mix it with your code yet.

Your OnActivateItem should pretty much always look like this:

string sTag = GetTag(oItem); // tag of activated item

if(sTag == "STAFFOFDANCING")
{
    // handle staff of dancing
}
else if(sTag == "BOULDER")
{
    // handle boulder
}
else if(sTag == // another item
else if(sTag == // another item
else if(sTag == // another item
else
{
    // unhandled item activated
    SendMessageToPC(oPC, "Activated " + GetName(oItem));
}

The damage is done in boulder spell’s impact script. Here you invoke that script via ActionSpellCast.

Thanks man…but this is just beyond my skills. You are speaking a completely different language to me with this scripting stuff. I’m use to the old way things were uploaded on the vault all packaged nicely ready to implement with step by step instructions on how to do it…either I’m too dumb now to figure it out or things got more complicated since I use to do this years ago. I just can’t do this one…sorry man…I give up. Thanks for trying to help me.

[EDIT] I remember I just use to add new stuff to the end of my Event scripts and then compile it…use to work back in the day…now it’s not so simple…lol

[EDIT 2]

Ah I edited the code above I posted…thanks…that seems to have worked…that part I now understand…lol