Aller au contenu

Photo

Scripting Add Spawns


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
DM Veil

DM Veil
  • Members
  • 249 messages
First off, I pretty much know nothing about scripting. So what I am trying to do is spawn additional mobs when my boss creature gets to 1/3 hp and have them attack the player. I tried to do this on my own by opening up chapter 4 of the single player campaign and looking at the Aribeth encounter to see how they got her to stop fighting and talk to the player after she was weakened, and then adapt that to spawning creatures instead. When I looked at the script to add in creatures that is written by Lilac's Script Generator and try to use that in the above mentioned script I can't get it to compile.

This is what I have so far:

void main()
{
    int nUser = GetUserDefinedEventNumber();

    if (nUser = 1006)
    {
        int nMaxHP = GetMaxHitPoints();
        int nCurrHP = GetCurrentHitPoints();
        if((nCurrHP * 3) <= nMaxHP && GetLocalInt(OBJECT_SELF,"walker_do_once") == 0)
        {
            oTarget = oPC;
            ITarget = GetLocation(oTarget);
            oSpawn = CreateObject(OBJECT_TYPE_CREATURE,"testing",ITarget);
            oTarget = oSpawn;
            SetIsTemporaryEnemy(oPC, oTarget);
            AssignCommand(oTarget, ActionAttack(oPC));

            oTarget = oPC;
            ITarget = GetLocation(oTarget);
            oSpawn = CreateObject(OBJECT_TYPE_CREATURE,"testing",ITarget);
            oTarget = oSpawn;
            SetIsTemporaryEnemy(oPC, oTarget);
            AssignCommand(oTarget, ActionAttack(oPC));

            oTarget = oPC;
            ITarget = GetLocation(oTarget);
            oSpawn = CreateObject(OBJECT_TYPE_CREATURE,"testing",ITarget);
            oTarget = oSpawn;
            SetIsTemporaryEnemy(oPC, oTarget);
            AssignCommand(oTarget, ActionAttack(oPC));

         }
         SetLocalInt(OBJECT_SELF,"walker_do_once",1);
    }

}

The error  is: VARIABLE DEFINED WITHOUT TYPE on line 11 (oTarget = oPC;)

Since I don't know how to write my own scripts and am trying to adapt premade scripts for my own use I'm not sure what to do and I'm guessing that besides something being wrong up there, it could also use some cleaning up. Any help would be greatly appreciated.

Modifié par DM Veil, 22 octobre 2011 - 03:17 .


#2
Kato -

Kato -
  • Members
  • 392 messages
If the creatures you're spawning are hostile, you don't need to call ActionAttack, so it would give:

void main()
{    
    if(GetUserDefinedEventNumber() == 1006)
    {       
         int nMaxHP = GetMaxHitPoints();
         int nCurrHP = GetCurrentHitPoints();
         if((nCurrHP * 3) <= nMaxHP && !GetLocalInt(OBJECT_SELF,"walker_do_once") ) 
         { 
             location loc = GetLocation(GetLastDamager());
             CreateObject(OBJECT_TYPE_CREATURE, "testing", loc);
             CreateObject(OBJECT_TYPE_CREATURE, "testing", loc);
             CreateObject(OBJECT_TYPE_CREATURE, "testing", loc);
             SetLocalInt(OBJECT_SELF,"walker_do_once",1);  
         }        
    }
}


Kato 

Modifié par Kato_Yang, 22 octobre 2011 - 04:03 .


#3
DM Veil

DM Veil
  • Members
  • 249 messages
That looks so much nicer lol, thank you very much for the help!