Author Topic: Scripting Help?  (Read 616 times)

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #15 on: December 09, 2010, 06:18:02 pm »


               @ehye_khandee
nope tried that and it still didn't work.

@Baragg
Ok I understand your script but I'm not sure on how to get an item to activate it do I make an item with the ability use unique power on self?
Also do I have to edit the code to specify a certain item?
or does this work with all items?
               
               

               


                     Modifié par Zaxtaj, 09 décembre 2010 - 06:31 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Scripting Help?
« Reply #16 on: December 09, 2010, 10:15:54 pm »


               OK Zaxtaj,
There are two basic ways to execute script from a item. and probly many more.

Way 1)
//::///////////////////////////////////////////////
//:: Title : MODULE, onUseItem Event
//:: Author:
//:: Module:
//:: Date  :
//:: Vers  : 1.0
//:://////////////////////////////////////////////

void main() {

 location lLoc        = GetItemActivatedTargetLocation();
 object   oItem       = GetItemActivated();
 object   oCaster     = GetItemActivator();
 object   oTarget     = GetItemActivatedTarget();
 string   oCasterName = GetName(oCaster);
 string   oTargetName = GetName(oTarget);



//=======================================================================
//  Add Special Activate Script Here
//=======================================================================
// this would be your script from the forums


}



Way 2)
//:://////////////////////////////////////////////////////////////
//:: Title : mod_on_act
//:: Author: Greyfort
//:: Module: any who need
//:: Date  : Aug 18, 2010
//:: Vers  : 1.0
//:://////////////////////////////////////////////////////////////

//::///////////////////////////////////////////////
//:: Example XP2 OnActivate Script Script
//:: x2_mod_def_act
//:: © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
   Put into: OnItemActivate Event

*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////

#include "x2_inc_switches"
void main()
{
    object oItem = GetItemActivated();

    // * Generic Item Script Execution Code
    // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
    // * it will execute a script that has the same name as the item's tag
    // * inside this script you can manage scripts for all events by checking against
    // * GetUserDefinedItemEventNumber(). See x2_it_example.nss
    if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
    {
       SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
       int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
       if (nRet == X2_EXECUTE_SCRIPT_END)
       {
          return;
       }

    }

}
put this in your module event Activate Item

Open a new script pasete this in..

#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
switch (nEvent)
{
case X2_ITEM_EVENT_ACTIVATE:
ExecuteScript("ac_"+GetTag(GetItemActivated()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_EQUIP:
ExecuteScript("eq_"+GetTag(GetPCItemLastEquipped()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_UNEQUIP:
ExecuteScript("ue_"+GetTag(GetPCItemLastUnequipped()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_ACQUIRE:
ExecuteScript("aq_"+GetTag(GetModuleItemAcquired()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_UNACQUIRE:
ExecuteScript("ua_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_SPELLCAST_AT:
ExecuteScript("sp_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_ONHITCAST:
ExecuteScript("on_"+GetTag(GetSpellCastItem()),
OBJECT_SELF); break;
}
}

save script the name of your item “itemtag”

Now open a new script, paste code from forums in

#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());
}
}

save script as “ac_tag of item”

be sure item as property unique power self , or unique power and nuber of time to unlimeted just for your testing yu can change that at any time

build mod checking script only, no need to build anything else and test.  I prefer the 2nd way because you mod event act item can get rather large with way1).  If i missed any thing let me know.

I almost forgot for way2) you need to gointo you module on load and make sure it looks like this:

    // * Item Event Scripts: The game's default event scripts allow routing of all item related events
    // * into a single file, based on the tag of that item. If an item's tag is "test", it will fire a
    // * script called "test" when an item based event (equip, unequip, acquire, unacquire, activate,...)
    // * is triggered. Check "x2_it_example.nss" for an example.
    // * This feature is disabled by default.
   SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);

   if (GetModuleSwitchValue (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
   {
        // * If Tagbased scripts are enabled, and you are running a Local Vault Server
        // * you should use the line below to add a layer of security to your server, preventing
        // * people to execute script you don't want them to. If you use the feature below,
        // * all called item scrips will be the prefix + the Tag of the item you want to execute, up to a
        // * maximum of 16 chars, instead of the pure tag of the object.
        // * i.e. without the line below a user activating an item with the tag "test",
        // * will result in the execution of a script called "test". If you uncomment the line below
        // * the script called will be "1_test.nss"
        // SetUserDefinedItemEventPrefix("1_");

   }

Greyfort
               
               

               


                     Modifié par Greyfort, 09 décembre 2010 - 10:36 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Scripting Help?
« Reply #17 on: December 09, 2010, 10:18:26 pm »


               I miss spoke save files "itemname" should be "itemtag"
Forgive me I missed the Edit button on the previous post.  To clarify what I'm trying to say is this:

When createing a item make a habit of nameing in resref ie:
I maked a Altimeter in tool set misc small, then in properties I make sure it can cast spell unique power self unlimeted, and check id for testing. then when naming it i start with the advanced tab and name in there ie "altim" knowing there is alimit to the size of the resref used in creating script and copy paste that name into tag, then make name "Altimeter". 
This insures that when I use the way2) method of executing script for item I call the handler script "altim", the item code script "ac_altim".  This way2) also allows you to create unique code for item aquierd "aq_altim" or item eqiped all mod event as seen in the handler code Example belowe:

// handler code
#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
switch (nEvent)
{
case X2_ITEM_EVENT_ACTIVATE:
ExecuteScript("ac_"+GetTag(GetItemActivated()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_EQUIP:
ExecuteScript("eq_"+GetTag(GetPCItemLastEquipped()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_UNEQUIP:
ExecuteScript("ue_"+GetTag(GetPCItemLastUnequipped()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_ACQUIRE:
ExecuteScript("aq_"+GetTag(GetModuleItemAcquired()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_UNACQUIRE:
ExecuteScript("ua_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_SPELLCAST_AT:
ExecuteScript("sp_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_ONHITCAST:
ExecuteScript("on_"+GetTag(GetSpellCastItem()),
OBJECT_SELF); break;
}
}

once again any questions Drop me a PM if you need, I hope this helps.

Greyfort
               
               

               


                     Modifié par Greyfort, 09 décembre 2010 - 10:40 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Scripting Help?
« Reply #18 on: December 09, 2010, 11:47:25 pm »


               Create your widget, make sure it has the itemporperty Unique self only, then tag that widget with the same name as you have for the script. Also insure you have the tag based scripting enabled for the mod. Then when you activate the widget it will run the script with the same name as the tag of the item activated.
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #19 on: December 10, 2010, 04:49:48 pm »


               Both your methods probably work but that isn't the problem. the problem is my script not how it's being activated does any one have suggestions on how to modify my script so it works?
But thank you both for working hard and telling me how to activate my script with an item I have it all set up. =)
right now I'm starting to think that I should reset my script so it will only summon 5 clones instead of your level...

Also the edited version of my script made to work with items had a messed up for command... I'm going to test it again.
               
               

               


                     Modifié par Zaxtaj, 10 décembre 2010 - 04:59 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Scripting Help?
« Reply #20 on: December 11, 2010, 12:08:22 am »


               You said before it worked to summon one, correct? Did you only add a loop to accomadate more clones?
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #21 on: December 11, 2010, 02:53:25 am »


               Yes I did and I said I tested it to summon more then one but for some reason when I try to use the script in a spell, or with an item, it doesn't work it might just be me or it could be my module. and yes I did look up how to make items use scripts, and I did edit the module so it could.
but whenever it's time for the script to run it's like its just ignored.
               
               

               


                     Modifié par Zaxtaj, 11 décembre 2010 - 08:22 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Scripting Help?
« Reply #22 on: December 11, 2010, 03:16:41 am »


               It would help if you posted your script.  Along with how you are calling it.  



Along with the Tag of the item if you are useing tag based scripting.
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #23 on: December 11, 2010, 08:26:51 pm »


               ok then script is...



#include "x2_inc_switches"



void Actions()

{

ASSOCIATE_COMMAND_ATTACKNEAREST;

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 (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);

}

ASSOCIATE_COMMAND_FOLLOWMASTER;

AssignCommand(OBJECT_SELF, Actions());

}

void main()

{

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

{

oCloneHandle = GetCasterLevel(OBJECT_SELF);

}

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

{

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));

AssignCommand(oClone, Actions());

}

}



I am calling it through an item, which uses the ability unique power on self, The item is a ring(if this helps) the tag is RingofClones
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Scripting Help?
« Reply #24 on: December 16, 2010, 12:27:00 am »


               Quickly I looked at your script there seems to be a issue in your actions() function caused pc to freeze...  I haven't isolated it yet. but if you /*   */ out your function and take out the for statement buy //for... it does create a clone.  I had to do this because I was testing with a level one spell caster.  I will level up a char and see what happens and report back...

EDITED TEXT:

Paste this in you ac_ringofclones script

/////////////////////////////////////////////
//
// ac_ringofclones
//
/////////////////////////////////////////////

#include "x2_inc_switches"
// include files here


void Actions()

{

ASSOCIATE_COMMAND_ATTACKNEAREST;

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 (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);

}

ASSOCIATE_COMMAND_FOLLOWMASTER;

AssignCommand(OBJECT_SELF, Actions());

}

///////////////////////////////////////////
void main()

{

if(GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;

object oPC = GetItemActivator();

object oClone;

int oCloneHandle;

if (GetAssociate(ASSOCIATE_TYPE_DOMINATED, oPC, 1) == OBJECT_INVALID)
{
// eq=0
oCloneHandle = 0;
//DEBUGING TEXT
SendMessageToPC(oPC,"if oCloneHandle="+IntToString(oCloneHandle)+"");
}
else{
// eq= pc caster levels
oCloneHandle = GetCasterLevel(oPC);
//DEBUGING TEXT
SendMessageToPC(oPC,"else oCloneHandle="+IntToString(oCloneHandle)+"");
}

// oCloneHandle= (1-9)  no for loop to execute
for(oCloneHandle; oCloneHandle<=GetCasterLevel(oPC)-1; oCloneHandle++)
{
                                          //was OBJECT_INVALID
oClone = CopyObject(oPC, GetLocation(oPC), oPC, "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));

    if(GetIsObjectValid(oClone)==TRUE)
    {
    //DEBUGING TEXT
    SendMessageToPC(oPC,"clone"+IntToString(oCloneHandle)+" valid assign Actions()");
    // This function is broken causes PC to freeze
    //AssignCommand(oClone, Actions());
    //DelayCommand (3.7,AssignCommand(oClone, Actions()));
    }
 //DEBUGING TEXT
 SendMessageToPC(oPC,"for oCloneHandle="+IntToString(oCloneHandle)+"");
 SendMessageToPC(oPC,"for GetCasterLevel(oPC)="+IntToString(GetCasterLevel(oPC))+"");
}//needed for statment

}//end of script

This script will create # of spell caster levels clones, I tested it with a level 40 bard which gave me a lvl 10 spell caster score so 10 clones be sure to read on lexicon about this function GetCasterLevel there are some bugs with it.

In your script you had OBJECT_SELF instead of oPC, and your  AssignCommand(oClone, Actions()); function cause computer to crash. still looking into that.  But you can create clones now '<img'>
               
               

               


                     Modifié par Greyfort, 16 décembre 2010 - 01:54 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Scripting Help?
« Reply #25 on: December 16, 2010, 02:40:55 am »


               Ok your custom fuction at the top of script was causeign lock up I seporated it not that you need to.  You can paste the include file I made in place of your code at the top of script.  I also left you notes on what caused lock up.

/////////////////////////////////////////////
//
// created by Zaxtaj
// 12.??.2010
// ringclones_inc
//
/////////////////////////////////////////////



// makes clone preform actions
// see ringclones_inc for actions
void ActionsClone(object oClone=OBJECT_SELF);


//
void ActionsClone(object oClone=OBJECT_SELF)

{
ASSOCIATE_COMMAND_ATTACKNEAREST;

if (GetMaster(oClone) == OBJECT_INVALID)
{
SetPCLike(GetMaster(oClone), OBJECT_SELF);

ChangeToStandardFaction(oClone, STANDARD_FACTION_COMMONER);

ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));

DestroyObject(oClone, 0.0);
}

if (GetIsDead(oClone) == TRUE)
{
SetIsDestroyable(FALSE,TRUE,FALSE);

ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));

int nHealed = GetMaxHitPoints(oClone);

effect eRaise = EffectResurrection();

effect eHeal = EffectHeal(nHealed + 10);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eRaise, oClone);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oClone);

SetIsDestroyable(TRUE,FALSE,FALSE);

DestroyObject(oClone, 0.0);
}

ASSOCIATE_COMMAND_FOLLOWMASTER;
// The line belowe was causeing lock up
//AssignCommand(oClone, Actions());
}

I have no issues of lock up and the clones seem to do ok.  but if you rest you dont domonate them anylonger you may have to fiddle a little with them not sure if there hamburger for the grinder or you want them to pal around with PC but your script is fixed and works
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Scripting Help?
« Reply #26 on: December 16, 2010, 03:02:37 am »


               paste this in your ac_ringofclones script:

/////////////////////////////////////////////
//
// created by Zaxtaj
// 12.??.2010
// ac_ringofclones
//
/////////////////////////////////////////////

#include "x2_inc_switches"
#include "ringclones_inc"

//////// include files here



/*


//
void Actions(object oClone=OBJECT_SELF)

{

ASSOCIATE_COMMAND_ATTACKNEAREST;

if (GetMaster(oClone) == OBJECT_INVALID)

{

SetPCLike(GetMaster(oClone), OBJECT_SELF);

ChangeToStandardFaction(oClone, STANDARD_FACTION_COMMONER);

ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));

DestroyObject(oClone, 0.0);

}

if (GetIsDead(oClone) == TRUE)

{

SetIsDestroyable(FALSE,TRUE,FALSE);

ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));

int nHealed = GetMaxHitPoints(oClone);

effect eRaise = EffectResurrection();

effect eHeal = EffectHeal(nHealed + 10);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eRaise, oClone);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oClone);

SetIsDestroyable(TRUE,FALSE,FALSE);

DestroyObject(oClone, 0.0);

}

ASSOCIATE_COMMAND_FOLLOWMASTER;

AssignCommand(oClone, Actions());

}
*/

///////////////////////////////////////////
void main()

{

if(GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;

object oPC = GetItemActivator();

object oClone;

int oCloneHandle;

if (GetAssociate(ASSOCIATE_TYPE_DOMINATED, oPC, 1) == OBJECT_INVALID)
{
// eq=0
oCloneHandle = 0;
//DEBUGING TEXT
SendMessageToPC(oPC,"if oCloneHandle="+IntToString(oCloneHandle)+"");
}
else{
// eq= pc caster levels
oCloneHandle = GetCasterLevel(oPC);
//DEBUGING TEXT
SendMessageToPC(oPC,"else oCloneHandle="+IntToString(oCloneHandle)+"");
}

// oCloneHandle= (1-9)  no for loop to execute
for(oCloneHandle; oCloneHandle<=GetCasterLevel(oPC)-1; oCloneHandle++)
{
                                          //was OBJECT_INVALID
oClone = CopyObject(oPC, GetLocation(oPC), oPC, "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));

    if(GetIsObjectValid(oClone)==TRUE)
    {
    //DEBUGING TEXT
    SendMessageToPC(oPC,"clone"+IntToString(oCloneHandle)+" valid assign Actions()");
    // function in include
    AssignCommand(oClone, ActionsClone());
    //DelayCommand (3.7,AssignCommand(oClone, Actions()));
    }
 //DEBUGING TEXT
 SendMessageToPC(oPC,"for oCloneHandle="+IntToString(oCloneHandle)+"");
 SendMessageToPC(oPC,"for GetCasterLevel(oPC)="+IntToString(GetCasterLevel(oPC))+"");
}//needed for statment

}//end of script

with the two scripts it works fine.  I'm sure you know this you can take what i have given you and make it one script:

/////////////////////////////////////////////
// one_script
// created by Zaxtaj
// 12.??.2010
//
// copy and paste whole script
// in your ac_ringofclones script
//
/////////////////////////////////////////////

#include "x2_inc_switches"


//////// include files here

//
// makes clone preform actions
void ActionsClone(object oClone=OBJECT_SELF);


//
void ActionsClone(object oClone=OBJECT_SELF)

{
ASSOCIATE_COMMAND_ATTACKNEAREST;

if (GetMaster(oClone) == OBJECT_INVALID)
{
SetPCLike(GetMaster(oClone), OBJECT_SELF);

ChangeToStandardFaction(oClone, STANDARD_FACTION_COMMONER);

ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));

DestroyObject(oClone, 0.0);
}

if (GetIsDead(oClone) == TRUE)
{
SetIsDestroyable(FALSE,TRUE,FALSE);

ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));

int nHealed = GetMaxHitPoints(oClone);

effect eRaise = EffectResurrection();

effect eHeal = EffectHeal(nHealed + 10);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eRaise, oClone);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oClone);

SetIsDestroyable(TRUE,FALSE,FALSE);

DestroyObject(oClone, 0.0);
}

ASSOCIATE_COMMAND_FOLLOWMASTER;
// The line belowe was causeing lock up
//AssignCommand(oClone, Actions());
}


///////////////////////////////////////////
void main()

{

if(GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;

object oPC = GetItemActivator();

object oClone;

int oCloneHandle;

if (GetAssociate(ASSOCIATE_TYPE_DOMINATED, oPC, 1) == OBJECT_INVALID)
{
// eq=0
oCloneHandle = 0;
//DEBUGING TEXT
SendMessageToPC(oPC,"if oCloneHandle="+IntToString(oCloneHandle)+"");
}
else{
// eq= pc caster levels
oCloneHandle = GetCasterLevel(oPC);
//DEBUGING TEXT
SendMessageToPC(oPC,"else oCloneHandle="+IntToString(oCloneHandle)+"");
}

// oCloneHandle= (1-9)  no for loop to execute
for(oCloneHandle; oCloneHandle<=GetCasterLevel(oPC)-1; oCloneHandle++)
{
                                          //was OBJECT_INVALID
oClone = CopyObject(oPC, GetLocation(oPC), oPC, "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));

    if(GetIsObjectValid(oClone)==TRUE)
    {
    //DEBUGING TEXT
    SendMessageToPC(oPC,"clone"+IntToString(oCloneHandle)+" valid assign Actions()");
    // function in include
    AssignCommand(oClone, ActionsClone());
    //DelayCommand (3.7,AssignCommand(oClone, Actions()));
    }
 //DEBUGING TEXT
 SendMessageToPC(oPC,"for oCloneHandle="+IntToString(oCloneHandle)+"");
 SendMessageToPC(oPC,"for GetCasterLevel(oPC)="+IntToString(GetCasterLevel(oPC))+"");
}//needed for statment

}//end of script

I think thats everything forgive me if I forgot anything just send me a pm or post here

God Bless
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #27 on: December 19, 2010, 04:37:51 am »


               Awesome thank you for all your hard work =)
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #28 on: December 19, 2010, 05:09:31 am »


               Oh and about them no longer being dominated after resting the part of the script...

if (GetMaster(oClone) == OBJECT_INVALID)

{

SetPCLike(GetMaster(oClone), OBJECT_SELF);



ChangeToStandardFaction(oClone, STANDARD_FACTION_COMMONER);



ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(OBJECT_SELF));



DestroyObject(oClone, 0.0);

}

Would destroy them if they have no master or if in other words they are no longer dominated
               
               

               
            

Legacy_Zaxtaj

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Scripting Help?
« Reply #29 on: March 17, 2012, 07:30:45 pm »


               It has been a year since I got help with this topic and I did find another way to do this code, This version makes specifically 4 clones only but it works very nicely

What this spell code does is it makes 4 clones and it removes all of your dominated accossicates by killing them this way if you want to summon more clones in case your down to like 2 you don't have to rest or wait until they die it will just summon 4 again and get rid of the 2 you have left.

I also set it up so the clones couldn't summon more clones by putting the spell id for the clone spell in he script, you will have to change that in the script if you don't want a million clones.

void Kill()
{
        effect eDead = EffectDamage(5000, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_NORMAL);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDead, GetAssociate(ASSOCIATE_TYPE_DOMINATED, GetMaster(OBJECT_SELF), 1));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDead, GetAssociate(ASSOCIATE_TYPE_DOMINATED, GetMaster(OBJECT_SELF), 2));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDead, GetAssociate(ASSOCIATE_TYPE_DOMINATED, GetMaster(OBJECT_SELF), 3));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDead, GetAssociate(ASSOCIATE_TYPE_DOMINATED, GetMaster(OBJECT_SELF), 4));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDead, GetAssociate(ASSOCIATE_TYPE_DOMINATED, GetMaster(OBJECT_SELF), 5));
}
void Actions()
{
    int InBattle;
    object oEnemy = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
    if (InBattle == 0)
    {
        if (GetIsObjectValid(oEnemy) )
        {
            ActionEquipMostDamagingMelee(oEnemy, FALSE);
            ActionAttack(oEnemy, FALSE);
            InBattle = 1;
        }
    }
//  Speel ID of the spell goes here!!!!!!
    if(GetSpellId() == 806)
    {
        if (GetIsObjectValid(oEnemy) )
        {
            ActionEquipMostDamagingMelee(oEnemy, FALSE);
            ActionAttack(oEnemy, FALSE);
            InBattle = 1;
        }
    }
    if (GetGoingToBeAttackedBy(oEnemy) == OBJECT_INVALID)
    {
        InBattle = 0;
    }
    if (GetMaster(OBJECT_SELF) == OBJECT_INVALID)
    {
        AssignCommand(OBJECT_SELF, PlayAnimation(ANIMATION_LOOPING_PAUSE_TIRED));
        int nDie = GetMaxHitPoints(OBJECT_SELF);
        effect eDead = EffectDamage(nDie + 500, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_NORMAL);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDead, OBJECT_SELF);
    }
    if (GetIsDead(OBJECT_SELF) == TRUE)
    {
        AssignCommand(OBJECT_SELF, RemoveFromParty(OBJECT_SELF));
        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);
    }
    DelayCommand(1.0, Actions());
}
void main()
{
    int KillClo;
    KillClo=0;
    int oCloneHandle;
    while(oCloneHandle<=4)
    {
        object oClone = CopyObject(OBJECT_SELF, GetLocation(OBJECT_SELF), OBJECT_INVALID, "Clone of "+GetName(OBJECT_SELF));
        SetLootable(oClone, FALSE);
        SetLocalObject(oClone, "Player", OBJECT_SELF);
        ChangeToStandardFaction(oClone, AI_LEVEL_VERY_HIGH);
        AssignCommand(OBJECT_SELF, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectCutsceneDominated(), oClone));
        AssignCommand(OBJECT_SELF, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectNegativeLevel(4, FALSE), oClone));
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oClone));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_IOUNSTONE_BLUE), OBJECT_SELF, 5.0);
        if (KillClo==0)
        {
            AssignCommand(oClone, Kill());
            KillClo++;
        }
        AssignCommand(OBJECT_SELF, AddToParty(OBJECT_SELF, oClone));
        ASSOCIATE_COMMAND_ATTACKNEAREST;
        AssignCommand(oClone, Actions());
        ASSOCIATE_COMMAND_TOGGLECASTING;
        oCloneHandle++;
    }
}