Aller au contenu

Photo

Having trouble with this script


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

#1
Ainiana

Ainiana
  • Members
  • 45 messages
 Hello ive set up this script which should summon a goblin slave (tag slave_goblin) and add it as a henchman
When testing in game the goblin is summoned fine and it appears next to the player, however it does not add as a henchman, initially i thought it may be due to the creature not appearing immediately hence the added delay to the script. 
Anyone have any ideas what ive done wrong? (it compiles fine)

--------------------------------------------------------------------------------
#include "ginc_actions"
#include "ginc_henchman"


void HenchmanAddVoid(object oMaster, object oHench)

{
    HenchmanAdd(oMaster,oHench);
}
void main()
{
object oPC = GetFirstPC();
string sSlave = "slave_goblin";
location lLocation = GetLocation(oPC);
object oMaster = oPC;
object oHench = GetObjectByTag("slave_goblin");


    ActionCreateObject(OBJECT_TYPE_CREATURE, sSlave, lLocation);
DelayCommand(5.0f, HenchmanAddVoid(oMaster,oHench));


}
------------------------------------------------------------------------------

Modifié par Ainiana, 22 mars 2011 - 04:19 .


#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
GetObjectByTag doesn't work instantaneously, it takes time for the game engine to update it's list of tags.
What you should do is use CreateObject to spawn your goblin slave. CreateObject returns the created object, so you can define oHench at the same time.
Actually, it seems you're looking for the goblin before you've spawned it.

#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
This may be it: I notice that you define oHench before you spawn the goblin slave. Try defining oHench after the line that creates the slave and see if that works for you.

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Dangit! I got ninja'd by Lugaid! Very well, you win this time!

#5
Ainiana

Ainiana
  • Members
  • 45 messages
thanks a lot both of you :) that was indeed the problem ;)