Aller au contenu

Photo

[new problem arisen] Get a creature's team within a creature_core override?


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

#1
0x30A88

0x30A88
  • Members
  • 1 081 messages
So I want to make a versatile script that I can apply to more creatures. I want it to call upon its team-mates (demons) when combat starts. To be used in the master's event handler.

I have the core script ready, but I need the function to get the creature's team number.. I.can't find it.

EDIT: if GetTeamID(OBJECT_SELF) is the way to do it, it's solved.

Modifié par Gisle Aune, 04 décembre 2010 - 07:37 .


#2
Proleric

Proleric
  • Members
  • 2 350 messages
Correct.

#3
0x30A88

0x30A88
  • Members
  • 1 081 messages
One more problem, one of my scripts, (creature event handler) does not activate the other teammates when combat is initiated, can you see what's wrong here? I suspect the event is wrong, as a similiar code is called upon in use of some placeables (....demon trap :P)

#include "utility_h"
#include "wrappers_h"
#include "events_h"

void main()
{
// The standaard ones
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
int nEventHandled = FALSE;
// My variables
int nTeam = GetTeamId(OBJECT_SELF);

switch(nEventType)
{
case EVENT_TYPE_COMBAT_INITIATED:
{
UT_TeamAppears(nTeam, TRUE);
nEventHandled = TRUE; //set this if no further action is required for this event
break;
}
}
if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
}
}

Modifié par Gisle Aune, 04 décembre 2010 - 07:36 .


#4
Proleric

Proleric
  • Members
  • 2 350 messages
The team mates are in the area, but inactive?

You're doing something to make the leader initiate combat?

The way I do that (in conversation) is to set a plot flag, whose script calls UT_TeamAppears, then UT_TeamGoesHostile. The same functions work in a trigger script.

That way, there is no special code for the leader.

Having said that, I'm not sure why your code doesn't make the team appear. I try not to mess with combat events, as they're relatively sophisticated and can impact performance. Have you tried displaying some text in the script, to ensure that it's firing?

Incidentally, I'm not sure why you're setting nEventHandled - that will stop the regular combat event script, which probably isn't what you want.

Modifié par Proleric1, 05 décembre 2010 - 08:48 .


#5
0x30A88

0x30A88
  • Members
  • 1 081 messages
I have removed that after I posted the script here, so the event is no longer overridden.



I am not that good at all the scripting yet. And are there combat events that work in the same way?

#6
Proleric

Proleric
  • Members
  • 2 350 messages
I guess my question is, why are you trying to do this in a combat event?

You must have an earlier event that makes the leader hostile - a conversation or trigger, perhaps - so why not make the team appear and turn them hostile at that time?

#7
0x30A88

0x30A88
  • Members
  • 1 081 messages
No, it's just a greater shade standing in a room, calling to itself rage demons once combat is started....however, it does not work. The leader is the same team as it's minions, but active.



I have such a function to be triggered from conversation (no events) for the other use.

#8
Proleric

Proleric
  • Members
  • 2 350 messages
Ah, I understand.

Since we know these functions work in triggers, you could use a temporary trigger to verify that the team code is recognised in game. You may need to export the area to refresh the team code on all creature instances.

If that works, then the event is the problem.

You could try putting the code in EVENT_TYPE_PERCEPTION_APPEAR instead, so that the other creatures are activated on perception but before combat starts. I haven't tested that, though.

#9
TimelordDC

TimelordDC
  • Members
  • 923 messages
The EVENT_TYPE_COMBAT_INITIATED is fired only when an attack command is added to the creatures command queue. Is your shade hostile to the player and attacking him?

If not, I suggest using the following events instead - EVENT_TYPE_ATTACKED, EVENT_TYPE_DAMAGED, EVENT_TYPE_CAST_AT.



You could do it so you are handling all those events:



case EVENT_TYPE_COMBAT_INITIATED:

case EVENT_TYPE_ATTACKED:

case EVENT_TYPE_DAMAGED:

case EVENT_TYPE_CAST_AT:

{

UT_TeamAppears(nTeam, TRUE);

nEventHandled = TRUE; //set this if no further action is required for this event

break;

}

#10
0x30A88

0x30A88
  • Members
  • 1 081 messages
Thank you, will test it as soon as time will allow it - thursday afternoon.