Aller au contenu

Photo

Solved: Setting rubber home location after spawning?


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

#1
thebigMuh

thebigMuh
  • Members
  • 98 messages
Howdy!

I have a tiny problem with the rubber banding system (that's what makes a creature return to it's home location after it has been pulled away by combat, for example).

I'm spawning creatures and trying to set their home location, somewhat like that:

object oCreature = CreateObject(OBJECT_TYPE_CREATURE, );
SetTeamId(oCreature, nTeam);
AddCommand(oCreature, CommandMoveToLocation(), true);
Rubber_SetHome(oCreature, GetObjectByTag("home_beacon"));

All of this happens in the area script in a heartbeat event.

The problem now seems to be that the creature gets spawned after all of this above is run, and in creature_core in the EVENT_TYPE_SPAWN handler the rubber home location gets reset by Rubber_SetHome(OBJECT_SELF);

Now - how do I elegantly set the rubber home location for my little beasties? Is there some event I can catch (preferrably in the area script) that fires after the creature was spawned?

Right now I'm looping over all the creatures in my teams and setting the home location every few seconds, but that's not very nice.

Ciao, muh!

Modifié par thebigMuh, 13 janvier 2010 - 11:22 .


#2
Craig Graff

Craig Graff
  • Members
  • 608 messages
In your creature script put this for your EVENT_TYPE_SPAWN:
[dascript]
case EVENT_TYPE_SPAWN:
{
     HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
     Rubber_SetHome(OBJECT_SELF, UT_GetNearestObjectByTag(OBJECT_SELF, "home_beacon"));
     nEventHandled = TRUE;
     break;
}
[/dascript]

This will let the core scripts handle the spawn and then let you override the home location.

Modifié par Craig Graff, 13 janvier 2010 - 08:11 .


#3
thebigMuh

thebigMuh
  • Members
  • 98 messages
Damn you're fast :)



Just implemented that, works like a charm.



Ciao, muh!