Author Topic: Area of Effect script  (Read 327 times)

Legacy_Tassle_Hof

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
Area of Effect script
« on: May 12, 2011, 05:35:46 pm »


               Okay, I am trying to create an effect where the PC has to go into the sewer and kill a giant beetle. The PC comes out smelling awful and has to go bath before anyone will talk to them, etc. I have a script that decreased the PC's charisma and other things but I need it to put the charisma decreased symbol up on the screen as well as I need a script that will make all the NPC's the PC comes across react in various ways. Lightfoot 8 had a good idea about an area of effect script but then never got it posted and I have never used an area of effect script and have no idea where to start. I am a newbie to scripting so I need HELP!! 'Image

Here is the script I have Ondeath of the beetle, it works for the most part, the way I want it to other than putting the charisma decreased symbol up. I need help with the area of effect script for the NPC's as well as the remove the decrease script for the bath, although that one I can probably muddle my through on my own, it's the area of effect I am completely clueless about.

#include "x2_inc_compon"
#include "x0_i0_spawncond"
#include "x3_inc_horse"
#include "x2_inc_itemprop"

void main()
{
object oPC = GetLastKiller();
while (GetIsObjectValid(GetMaster(oPC)))
   {
   oPC=GetMaster(oPC);
   }
if (!GetIsPC(oPC)) return;
    int nclass = GetLevelByclass(class_TYPE_COMMONER);
    int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);

    object oKiller_chest =GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
    //do not know your amount, so put 2
    int iAmount = 8;
    itemproperty ip_Stink =ItemPropertyDecreaseAbility(IP_CONST_ABILITY_CHA,iAmount);
    if(oKiller_chest!=OBJECT_INVALID)
    {
    IPSafeAddItemProperty(oKiller_chest,ip_Stink,0.0,X2_IP_ADDPROP_POLICY_REPLACE_EXISTING);
    SetLocalInt(oPC,"iStink", 1);
    HorseAddHorseMenu(oPC);
    SendMessageToPC(oPC,"I stink!");
    GiveXPToCreature(oPC,1500);
    AddJournalQuestEntry("jt_Infestation", 7, oPC, TRUE, FALSE);
    SetLocalInt(oPC, "QueenBeetleDead", 1);
    }

Any help would be greatly appreciated and Lightfoot 8, if your out there, I loved the ideas you had awhile back, if you still have them and could show me how to script them I would be forever grateful.'Image
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Area of Effect script
« Reply #1 on: May 12, 2011, 07:19:02 pm »


               Well not to throw you off of what you are doing with your script..but it might be easier to just apply the effects directly to the player instead of messing around with item properties on an equipped item.

You could do something like this for the beetles OnDeath:

First in the toolset put an invisible object near the beetle. We'll give it the tag "StinkMaker" for this example. You can put it under the ground too if you want to get it out of the way. It's not going to be usueable. This will be the effect creator so that we can easily remove the effects when you get to the bath part.

OnDeath script:

void main()
{
    object oPC = GetLastKiller();
    if (GetIsObjectValid(GetMaster(oPC)))
    {
        oPC = GetMaster(oPC);
    }
    if (!GetIsPC(oPC)) return;
    object oECreator = GetNearestObjectByTag("StinkMaker", OBJECT_SELF, 1);
    effect eEffect1 = SupernaturalEffect(EffectAbilityDecrease(ABILITY_CHARISMA, 8));
    effect eEffect2 = SupernaturalEffect(EffectAreaOfEffect(AOE_PER_INVIS_SPHERE, "test_enter_stink", "****", "****"));

    AssignCommand(oECreator, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect1, oPC));
    AssignCommand(oECreator, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect2, oPC));

    SendMessageToPC(oPC, "I stink!");
    GiveXPToCreature(oPC, 1500);
    AddJournalQuestEntry("jt_Infestation", 7, oPC, TRUE, FALSE);
    SetLocalInt(oPC, "QueenBeetleDead", 1);
}

When you create an AreaOfEffect effect you need to fill in the 3 scripts into it's perameters that will run while this effect is on the creature. The OnEnter, OnHeartbeat, and OnExit. If you don't want to use one of these events for your AreaOfEffect then you would just put in "****". In the script above you can see that I just put in on OnEnter script("test_enter_stink") and left the other ones out

For examples sake this is what I used for "test_enter_stink":

void main()
{
    object oResponder = GetEnteringObject();
    PlayVoiceChat(VOICE_CHAT_CUSS, oResponder);
}

So every time you get near someone(player or npc enters your erea of effect) they will use their cuss voice chat.


Now when you get to the bath taking part you could use something like this to remove the effects:

void main()
{
    object oPC = GetLastUsedBy();
    effect eEffect = GetFirstEffect(oPC);
    while (GetIsEffectValid(eEffect))
    {
        if (GetEffectCreator(eEffect) == GetObjectByTag("StinkMaker"))
        RemoveEffect(oPC, eEffect);
        eEffect = GetNextEffect(oPC);
    }
}


You could always add extra stuff on to these like little extra visual effecs and what not but hopefully this will help you out.
Good luck.
               
               

               


                     Modifié par GhostOfGod, 12 mai 2011 - 06:25 .
                     
                  


            

Legacy_Tassle_Hof

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
Area of Effect script
« Reply #2 on: May 12, 2011, 09:42:59 pm »


               Hey GOG! Thanks for the advice on the script. I can't remember why it was recomended to use the item properties . . . someone suggested it as I was having troubles getting the effect(s) to stick with the PC . . . I've been away from it for awhile so the brain's a little fuzy. I will give your way a try since I'm all for easier.
For the area of effect, I want to have some random comments/actions from the NPC's the PC encounters. Ideally, I would like the guards to stay put but make a comment (Lightfoot 8's idea was have the guard say something like, "Somebody light a match" and then wave a torch around or something) and then have normal 'citizens' react in different ways, some run away, some faint, all refuse to talk to or interact with the PC until the bath is taken, that kind of thing. I'm not sure how to script that, I haven't gotten very good at random yet.
This is purely for entertainment purposes, just for laughs, I just thought it would be funny. As PC's, we always end up in the sewers and I always thought that we'd come out smelling awful, so I thought I'd have a little fun with it in my own module.
Thanks for your help and if you have any tips on the area of effect script for the randomness I would sure appreciate it.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Area of Effect script
« Reply #3 on: May 12, 2011, 09:51:08 pm »


               Sure. You could do something like this:

void main()
{
    object oResponder = GetEnteringObject();
    int iRand = Random(3);
    string sSay;
    switch (iRand)
    {
        case 0:sSay = "Somebody light a match!";break;
        case 1:sSay = "Did you just fart?";break;
        case 2:sSay = "Dear god what is that smell? Alert the gauards. We may have a zombie in town.";break;
    }
    AssignCommand(oResponder, ActionSpeakString(sSay));
}

Only thing is the player also triggers the OnEnter event of the AreaOfEffect one time when it is first applied, so you might want to put at check in there to exclude the player. Off the top of my head I wasn't sure how to do that quickly and I need to head to work.

Hope this helps. Good luck.
               
               

               
            

Legacy_Tassle_Hof

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
Area of Effect script
« Reply #4 on: May 13, 2011, 02:05:32 pm »


               Thanks GOG! I will play around with it and see what happens. I appreciate the time and energy and help!