Aller au contenu

Photo

Overriding events is a bad idea


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

#1
anakin5

anakin5
  • Members
  • 258 messages
Overriding an event prevent this event to be fired in custom campaign scripts. Custom campaign scripts are scripts like creature_core, player_core, area_core etc... but there are most of times link to only one specicampaign ressource.

While we don't have access to campaign ressources and while there is no way to know if an event is used in a custom campaign script, overriding an event may be the source of bugs that you will not see at a first sight but that players can met during their play in a particular area, or with a particular creature.

HandleEvent() doest not solve the problem cause you need the ressource scripts and you don't have it.

#2
AND04

AND04
  • Members
  • 154 messages
erm HandleEvent() without a resource (seeing as the pararmeter is optional) WILL call the default event-script for that object...

#3
anakin5

anakin5
  • Members
  • 258 messages
Do you have an example ? The test I made on creature said that HandleEvent call creature_core and not the campaign custom script.

#4
AND04

AND04
  • Members
  • 154 messages
erm, what exactly are you trying to do?



A creature related Event usually doesn't fire into a Module-Script - unless told otherwise.

#5
anakin5

anakin5
  • Members
  • 258 messages
if you override an event that fired in creature scripts, if you call HandleEvent in this script, it call creature_core and not the custom script of the creature if any.

if you override an event that fired in area script, if you call HandleEvent in this script, it call area_core and not the custom script of the area if any.

#6
anakin5

anakin5
  • Members
  • 258 messages
say for example the event EVENT_TYPE_SPAWN

I override it and call HandleEvent(). The HandleEvent call the default event script for that event which is player_core or creature_core. But it will not call the custom event script for creatures that have one.

If this creature doesn't do anything special with EVENT_TYPE_SPAWN, there is no problem. But if this creature required a special processing for this event, you lost it.

You said HandleEvent call the default event script for that object. Have you tested for object that are associated with a campaign script ?

Modifié par anakin5, 01 décembre 2009 - 07:49 .


#7
AND04

AND04
  • Members
  • 154 messages
yeah for every placeables at least it does just as i said - using it in my auto loot mod like that.

as for other stuff - no idea honestly - btw a dev told us that some of those script pararmeters are not even used in the main game btw (like the one on items)


though if you can in fact use a creature-specific script to handle those events and HandleEvents(ev); doesn't call it if it exists thats a problem idd - seeing as we got no way to determine if a script is attached to something (got told by a Dev - Craig i believe -  that he will request that function)

i can only speak by my experience with placeables so far though (where it works with the main-campain) and i assumed it does so for other object-types as well.

Modifié par AND04, 02 décembre 2009 - 11:06 .


#8
anakin5

anakin5
  • Members
  • 258 messages
ok, I was doing something similar to Auto Loot but that was concerning creatures and not placeable. My test creature is the Spider Queen (Thaig) and I totally broke the event by overriding one event which is handle by creature scripts. After adding the HandleEvent, the Spider Queen was acting like all spider in the game.

#9
anakin5

anakin5
  • Members
  • 258 messages
So, it works for placable and doesn't seem to work for creature.

#10
Challseus

Challseus
  • Members
  • 1 032 messages
I'm curious, could you post your scripts, if you don't mind? I've been overriding scripts for creatures, abilities, module, etc. with no issues.

#11
anakin5

anakin5
  • Members
  • 258 messages
No issue but you didn't test all creatures in the game. the things is that you don't see anything until you faced a creature with a custom script.

For example, when the Spider Queen die, something is activated that let you read Banka's journal. I don't know if it is handle in the event EVENT_TYPE_DYING, but if it is the case, the following script should broke it.



void main()

{

event ev = GetCurrentEvent();

int nEventType = GetEventType(ev);



switch(nEventType)

{

case EVENT_TYPE_DYING:

{

HandleEvent(ev);

break;

}

}

}



assume you override EVENT_TYPE_DYING with this script.

#12
Challseus

Challseus
  • Members
  • 1 032 messages
Okay, I think I understand what you are saying. Let's say there is a creature, called spider queen. Her script in the palette is currently creature_core.nss, but somewhere in the OC, EnablevEvent() is being called, with some custom script (i.e. spider_queen_core.nss).

Now, when you try to make your own script to override her script, when you call HandleEvent, since you don't know the name of the custom script, it just defaults to creature_core.nss, which may break stuff if anything special happens in the custom script (i.e. spider_queen_core.nss).

Fair enough, yeah, I guess in that situation, overriding may be a bad idea. I personally haven't run into it, because I am not modding the OC (assuming that is what you're doing), I am making my own custom module.

Modifié par Challseus, 03 décembre 2009 - 05:31 .