Author Topic: Scripting Help?  (Read 615 times)

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« on: December 05, 2010, 05:58:49 am »


               I'm a relativly new to scripting and I thought wow wouldn't it be cool if there was a script that made clones of your guy?
Then I started working on the script it goes like this...

void Actions()
{

// The actions the clones carry out once created.
// Attack nearest enemy

    ASSOCIATE_COMMAND_ATTACKNEAREST;

// if there is no master destroy the clone

    if (GetMaster(OBJECT_SELF) == OBJECT_INVALID)
    {
        SetPCLike(GetMaster(OBJECT_SELF), OBJECT_SELF);
        ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_COMMONER);
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));
        DestroyObject(OBJECT_SELF, 0.0);
    }

// if the clone dies (so you can't loot it's items) revive then destroy it.

    if (GetIsDead(OBJECT_SELF) == TRUE)
    {
        SetIsDestroyable(FALSE,TRUE,FALSE);
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));
        int nHealed = GetMaxHitPoints(OBJECT_SELF);
        effect eRaise = EffectResurrection();
        effect eHeal = EffectHeal(nHealed + 10);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eRaise, OBJECT_SELF);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, OBJECT_SELF);
        SetIsDestroyable(TRUE,FALSE,FALSE);
        DestroyObject(OBJECT_SELF, 0.0);
    }

// follow the master if there are no enemys, or if not dieing

    ASSOCIATE_COMMAND_FOLLOWMASTER;

// repeat checks.

    AssignCommand(OBJECT_SELF, Actions());
}
void main()
{

// checking if you have any dominated people in your party if you do no clones will be summoned.

    int oCloneHandle;
    if (GetAssociate(ASSOCIATE_TYPE_DOMINATED, OBJECT_SELF, 1) == OBJECT_INVALID)
    {
        oCloneHandle = 0;
    } else {

// set clones to summon equal to the casters level

        oCloneHandle = GetCasterLevel(OBJECT_SELF);
    }
    for (;oCloneHandle<=GetCasterLevel(OBJECT_SELF)-1; oCloneHandle++)
    {

// this is the clone creation process

        object oPC = OBJECT_SELF;
        object oClone = CopyObject(oPC, GetLocation(OBJECT_SELF), OBJECT_INVALID, "Clone of "+GetName(oPC));
        SetLootable(oClone, FALSE);
        SetLocalObject(oClone, "Player", oPC);
        ChangeToStandardFaction(oClone, AI_LEVEL_VERY_HIGH);
        AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectCutsceneDominated(), oClone));
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oClone));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_IOUNSTONE_BLUE), oPC, 5.0);
        AssignCommand(oPC, AddToParty(oPC, oClone));

// tell clone to do it's checks

        AssignCommand(oClone, Actions());
    }
}


Now When I tested this as a script to make a set number of clones, it worked.
But then I thought it would be awesome to make it a spell!
so I changed the amount of clones to summon to equal your level, and I have all the information for the spell.
then I get the game started the spell is there but when I use it the script wont run, and I did check if I wrote the script name correctly in the spells.2da file.

I think that my script may need to be edited to become a spell can I have some help?
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Scripting Help?
« Reply #1 on: December 05, 2010, 06:39:54 am »


               Someone (bioware) beat you to it: x0_s3_clonefist. Their version creates an exploit though - you can pp the gear. Here's our modded version:


//::///////////////////////////////////////////////
//:: x0_s3_clonefist
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Create a fiery version of the character
    to help them fight.
*/
//:://////////////////////////////////////////////
//:: Created By:
//:: Created On:
//:://////////////////////////////////////////////
#include "nw_i0_generic"

void FakeHB()
{
    effect eFlame = EffectVisualEffect(VFX_IMP_FLAME_M);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eFlame, OBJECT_SELF);
    int nExplode = GetLocalInt(OBJECT_SELF, "X0_L_MYTIMERTOEXPLODE");
    object oMaster = GetLocalObject(OBJECT_SELF, "X0_L_MYMASTER");
    if (nExplode == 6)
    {

        ClearAllActions();
        PlayVoiceChat(VOICE_CHAT_GOODBYE);
        effect eFirePro = EffectDamageImmunityIncrease(DAMAGE_TYPE_FIRE, 100);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFirePro, oMaster, 3.5);
        ActionCastSpellAtLocation(SPELL_FIREBALL, GetLocation(OBJECT_SELF), METAMAGIC_ANY, TRUE, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);

        DestroyObject(OBJECT_SELF, 0.5);
        SetCommandable(FALSE);
        return;
    }
    else
    {
        object oEnemy = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, oMaster, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
        // * attack my master's enemy
        if (GetIsObjectValid(oEnemy) )
        {
            DetermineCombatRound(oEnemy);
        }

        ActionMoveToObject(GetLocalObject(OBJECT_SELF, "X0_L_MYMASTER"), TRUE);
        SetLocalInt(OBJECT_SELF, "X0_L_MYTIMERTOEXPLODE", nExplode + 1);
        DelayCommand(3.0, FakeHB());
    }
}

void main()
{
    object oPC = OBJECT_SELF;
    object oFireGuy = CopyObject(oPC, GetLocation(OBJECT_SELF), OBJECT_INVALID, GetName(oPC) + "CLONEFROMFISTS");
    object oItem = GetFirstItemInInventory(oFireGuy);
    while (oItem != OBJECT_INVALID)  {
         SetDroppableFlag(oItem, FALSE);
         SetItemCursedFlag(oItem, TRUE);
         oItem = GetNextItemInInventory(oFireGuy);
    }
    SetLocalInt(oFireGuy, "X0_L_MYTIMERTOEXPLODE",1);
    SetLocalObject(oFireGuy, "X0_L_MYMASTER", oPC);
    ChangeToStandardFaction(oFireGuy, STANDARD_FACTION_COMMONER);
    SetPCLike(oPC, oFireGuy);
    DelayCommand(0.5, SetPlotFlag(oFireGuy, TRUE)); // * so items don't drop, I can destroy myself.
    AssignCommand(oFireGuy, FakeHB());
    effect eVis = EffectVisualEffect(VFX_DUR_ELEMENTAL_SHIELD);
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eVis, oFireGuy);

}

Funky
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #2 on: December 05, 2010, 06:44:46 am »


               I already know about that script but I don't like it,
it makes one clone, if you attack civilians it attacks you, it only lasts 5 seconds then explodes, if fire resistance fails, and it has failed for me many times, you instantly die.

I made my clone script based off this one so I have seen it many, many times =o
               
               

               


                     Modifié par Zaxtaj, 05 décembre 2010 - 06:45 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Scripting Help?
« Reply #3 on: December 05, 2010, 06:46:49 am »


               Neat I did an off take of the doppleganger mirror script is that the same thing?
               
               

               


                     Modifié par Baragg, 05 décembre 2010 - 06:47 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Scripting Help?
« Reply #4 on: December 05, 2010, 06:48:36 am »


               Ah, I see it isn't.
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #5 on: December 05, 2010, 06:51:56 am »


               ahhh... to quick for me... didn't get a chance to check xD
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Scripting Help?
« Reply #6 on: December 05, 2010, 01:23:49 pm »


               Uh, sorry I don't know squat bout doin spells probably best to ask in custom content they would know.
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #7 on: December 05, 2010, 04:05:30 pm »


               Ok then should I remake this thread there?

or ask for it to be moved?
               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
Scripting Help?
« Reply #8 on: December 05, 2010, 07:38:15 pm »


               It is a scripting issue, examine the command CopyObject() is the tool for the job.



Be well. Game on.

GM_ODA
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Scripting Help?
« Reply #9 on: December 05, 2010, 08:01:36 pm »


               So they should change the call for oPC from OBJECT_SELF to GetLastSpellCaster();? I would never had thought of that thanks ehye_khandee. Learning is a wonderful thing.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Scripting Help?
« Reply #10 on: December 05, 2010, 09:11:41 pm »


               

Baragg wrote...

So they should change the call for oPC from OBJECT_SELF to GetLastSpellCaster();? I would never had thought of that thanks ehye_khandee. Learning is a wonderful thing.

Depends on how you're implementing it. You need 2da edits to add a new spell, but if you just want to overwrite an old spell, or make an item special power, you can do it all in script. What did you have in mind, exactly?

Funky
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #11 on: December 06, 2010, 04:47:56 pm »


               Well I was going to make it a spell, then I was going to make it so it could only be used by one item.
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #12 on: December 06, 2010, 04:53:45 pm »


               @ehye_khandee

ok I took your suggestion and tested it in game, and it still didn't work I think there might be more errors in my code.
               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
Scripting Help?
« Reply #13 on: December 08, 2010, 04:28:59 pm »


               

Zaxtaj wrote...

@ehye_khandee
ok I took your suggestion and tested it in game, and it still didn't work I think there might be more errors in my code.


Sorry, did not mean to confuse - it was my brevity. '<img'> I'll elaborate but pardon me because I'm not at the toolkit to do actual scripting and syntax checking -



CopyObject is a function of scripting -

[url=type.object.html]object[/url] CopyObject(
    [url=type.object.html]object[/url] oSource,
    [url=type.location.html]location[/url] locLocation,
    [url=type.object.html]object[/url] oOwner = OBJECT_INVALID,
    [url=type.string.html]string[/url] sNewTag = ""
);


a command such as 


object oCopyOfPC = CopyObject(oPC,GetLocation(oPC),,"Copy_"+GetName(oPC));

_should_ work assuming object oPC is the PC you want to copy.

This iirc is all you'd need to copy a PC with all gear, though my memory is shakey on that blank bit between the two commas ... if the code does not work as shown, insert

[/code]
oCopyOfPc
[/code]

between the two commas. I'll follow the thread to see how your results turn out.

Be well. Game on.
GM_ODA
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Scripting Help?
« Reply #14 on: December 09, 2010, 01:23:14 pm »


               Here I took the script of the OP and added item activation to it, hopefully it helps(untested).


#include "x2_inc_switches"

void Actions()
{

// The actions the clones carry out once created.
// Attack nearest enemy

    ASSOCIATE_COMMAND_ATTACKNEAREST;

// if there is no master destroy the clone

    if (GetMaster(OBJECT_SELF) == OBJECT_INVALID)
    {
        SetPCLike(GetMaster(OBJECT_SELF), OBJECT_SELF);
        ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_COMMONER);
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));
        DestroyObject(OBJECT_SELF, 0.0);
    }

// if the clone dies (so you can't loot it's items) revive then destroy it.

    if (GetIsDead(OBJECT_SELF) == TRUE)
    {
        SetIsDestroyable(FALSE,TRUE,FALSE);
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));
        int nHealed = GetMaxHitPoints(OBJECT_SELF);
        effect eRaise = EffectResurrection();
        effect eHeal = EffectHeal(nHealed + 10);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eRaise, OBJECT_SELF);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, OBJECT_SELF);
        SetIsDestroyable(TRUE,FALSE,FALSE);
        DestroyObject(OBJECT_SELF, 0.0);
    }

// follow the master if there are no enemys, or if not dieing

    ASSOCIATE_COMMAND_FOLLOWMASTER;

// repeat checks.

    AssignCommand(OBJECT_SELF, Actions());
}
void main()
{// checking if you have any dominated people in your party if you do no clones will be summoned.

    if(GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;

    object oPC = GetItemActivator();
    object oClone;
    int oCloneHandle;

    if (GetAssociate(ASSOCIATE_TYPE_DOMINATED, oPC, 1) == OBJECT_INVALID)
    {
        oCloneHandle = 0;
    }
    else
    {// set clones to summon equal to the casters level

        oCloneHandle = GetCasterLevel(oPC);
    }
    for (;oCloneHandle
    {// this is the clone creation process

        oClone = CopyObject(oPC, GetLocation(oPC), OBJECT_INVALID, "Clone of "+GetName(oPC));
        SetLootable(oClone, FALSE);
        SetLocalObject(oClone, "Player", oPC);
        ChangeToStandardFaction(oClone, AI_LEVEL_VERY_HIGH);
        AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectCutsceneDominated(), oClone));
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oClone));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_IOUNSTONE_BLUE), oPC, 5.0);
        AssignCommand(oPC, AddToParty(oPC, oClone));

// tell clone to do it's checks

        AssignCommand(oClone, Actions());
    }
}

               
               

               


                     Modifié par Baragg, 09 décembre 2010 - 01:23 .