Hello. I am wondering why this isn’t working.
class go_watermelon : public GameObjectScript
{
public:
go_watermelon() : GameObjectScript("go_watermelon") { }
struct go_watermelonAI : public GameObjectAI
{
go_watermelonAI(GameObject * gob) : GameObjectAI(gob)
{
Reset();
}
uint32 donetimer;
void Reset()
{
donetimer = 10000; //ONE_HOUR;
}
void UpdateAI(const uint32 diff)
{
if(donetimer <= diff)
{
char msg[150];
snprintf(msg, 150, "Watermelon");
sWorld->SendGlobalText(msg, NULL); // This is just to test to see if it works
donetimer = 10000; //ONE_HOUR;
}
else
donetimer -= diff;
}
};
GameObjectAI * GetAI(GameObject * gobject) const
{
return new go_watermelonAI(gobject);
}
};
Is there anything wrong with this? I don’t really see any problems; though, it isn’t working at all. I setup everything in CMakeLists, ScriptLoader.cpp, scripts > Source Files Project > (Database) GameObject (ScriptName). It did work, and I had an sql issue with it & I saw that I forgot to add
[CODE]
GameObjectAI * GetAI(GameObject * gobject) const
{
return new go_watermelonAI(gobject);
}[/CODE]
so when I added that, it didn’t work afterwards.
Help would be greatly appreciated.
You are not reducing donetimer, it will never go below diff.
I just noticed that a few minutes ago. But even with reducing the timer, it still won’t work… Lemme test it again though.
Edit: Yeah, still doesn’t work.
[CODE]class go_watermelon : public GameObjectScript
{
public:
go_watermelon() : GameObjectScript("go_watermelon") { }
struct go_watermelonAI : public GameObjectAI
{
go_watermelonAI(GameObject * gob) : GameObjectAI(gob)
{
Reset();
}
uint32 donetimer;
void Reset()
{
donetimer = 10000; // ONE_HOUR (should be 3600000)
}
void UpdateAI(const uint32 diff)
{
if (donetimer <= diff)
{
char msg[150];
sprintf(msg,"Watermelon");
sWorld->SendGlobalText(msg, NULL); // This is just to test to see if it works
donetimer = 10000; // ONE_HOUR (should be 3600000)
}
else
donetimer -= diff;
}
};
GameObjectAI * GetAI(GameObject * gobject) const
{
return new go_watermelonAI(gobject);
}
};[/CODE]
You obviously have to add go_watermelonAI to the class list at the bottom of the file (supposing you are using an already-cmaked file) and you have to add as a scriptname “go_watermelon” to the gobj entry.
I implied that in the first post. /emoticons/default_wink.png
Take a look at go_scripts.cpp, you can only use OnGossipHello and OnGossipSelect bool. No UpdateAI or Reset, gameobject scripting just lacks practically 50% of what it needs.
Why didn’t someone else say this here yet?
EDIT.
And about where you put made your script reset, why not put the donetimer = 10000; down there?