Divinity Banner
Previous Thread
Next Thread
Print Thread
What does _Event at the end of functions do? #556005
28/09/14 08:45 PM
28/09/14 08:45 PM
Joined: Aug 2014
Posts: 54
M
Mag Offline OP
journeyman
Mag  Offline OP
journeyman
M

Joined: Aug 2014
Posts: 54
Some of the functions end with (STRING)_Event). For instance:

CharacterMoveToItem(_CHARACTER,_ITEM,1,_EVENT);

I assumed it could be used to start an event. After using the function above I tried using

IF
GlobalEventSet("EVENT")
THEN
...

But the THEN part didn't fire.

Re: What does _Event at the end of functions do? [Re: Mag] #556006
28/09/14 09:23 PM
28/09/14 09:23 PM
Joined: Jul 2014
Posts: 459
R
Rhidian Offline
addict
Rhidian  Offline
addict
R

Joined: Jul 2014
Posts: 459
Like everything else that starts with an underscore, _Event is a local variable (type String in your case). In actuality, the name could be anything.

The problem is that you either need to know what the variable is supposed to be, or use the variable itself within the function. I think you could do something like this:

IF
//First function
THEN
CharacterMoveToItem(_Character, _Item, _Event);
GlobalSetEvent("Custom event");

IF
GlobalEventSet("Custom event")
THEN
//stuff

Re: What does _Event at the end of functions do? [Re: Mag] #556041
29/09/14 01:33 PM
29/09/14 01:33 PM
Joined: Aug 2014
Posts: 54
M
Mag Offline OP
journeyman
Mag  Offline OP
journeyman
M

Joined: Aug 2014
Posts: 54
I should have been more specific. I did fill the event section with a literal but the if statement failed. I don't think it's setting a global event.

I plan on searching the Main game code for the function and then searching the event to see which function recognizes the event.

Re: What does _Event at the end of functions do? [Re: Mag] #556048
29/09/14 02:48 PM
29/09/14 02:48 PM
Joined: Oct 2005
Posts: 67
T
Thoro Offline
journeyman
Thoro  Offline
journeyman
T

Joined: Oct 2005
Posts: 67
Edit: Nevermind... Read first, then post.

Last edited by Thoro; 29/09/14 02:50 PM.
Re: What does _Event at the end of functions do? [Re: Mag] #556060
29/09/14 08:22 PM
29/09/14 08:22 PM
Joined: Jul 2014
Posts: 459
R
Rhidian Offline
addict
Rhidian  Offline
addict
R

Joined: Jul 2014
Posts: 459
Well, if the IF statement isn't triggering then that means one of two things
1. The event isn't being called/triggered
2. The event that is triggering is different than the one you're wanting to respond to

In the example you gave in the first post, it seems as if the event being thrown is under the variable _EVENT, while your IF statement is wanting to respond to "EVENT". This will almost never trigger the IF statement, since it is most likely for something else to be stored on the _EVENT variable.

Consider this example:
Code:
IF
CharacterLeveledUp(_Char)
THEN
DB_First("LeveledUp");

IF
DB_First( (STRING)_Event )
THEN
PartyAddExperience(50);
DB_Second(_Event);

IF
DB_Second("Event")
THEN
PartyAddExperience(100);

In the above code, whenever a character levels up the party will receive one dose of 50 experience. The third If statement that depends on "Event" being passed to it will never trigger, since the actual String that is being passed is always "LeveledUp".

Edit:
It's also important to note that GlobalSetEvent and GlobalEventSet are two distinctly different functions. GlobalSetEvent basically broadcasts to the other parts of the code that some sort of Event is happening. GlobalEventSet is what actually responds to an event.

Last edited by Rhidian; 29/09/14 08:26 PM.
Re: What does _Event at the end of functions do? [Re: Rhidian] #556116
30/09/14 01:40 PM
30/09/14 01:40 PM
Joined: Aug 2014
Posts: 54
M
Mag Offline OP
journeyman
Mag  Offline OP
journeyman
M

Joined: Aug 2014
Posts: 54
My first post was sloppy. My real question is what type of event is being set by functions that have a secondary purpose of setting an event. I started researching via the main campaign but it isn't straight forward as setting a literal event and capturing with an if statement.

Re: What does _Event at the end of functions do? [Re: Mag] #556127
30/09/14 07:38 PM
30/09/14 07:38 PM
Joined: Jul 2014
Posts: 459
R
Rhidian Offline
addict
Rhidian  Offline
addict
R

Joined: Jul 2014
Posts: 459
Well, let's take a look at a Story script that makes use of an Event as part of an action.

Click to reveal..

From the DAF_HiddenFamily script
Code:
PROC
PROC_DAF_HiddenFamilyLeaves()
AND
DB_DAF_HiddenFamily(_FamilyMember)
THEN
CharacterSetHasDialog(_FamilyMember,0);
ProcCharacterMoveToTrigger(_FamilyMember,TRIGGER_DAF_DruidPortal_OUT,1,"DB_DAF_HiddenFamilyEscape_ReachedPortal");

IF
CharacterEvent(_FamilyMember,"DB_DAF_HiddenFamilyEscape_ReachedPortal")
THEN
CharacterTeleportToTrigger(_FamilyMember,TRIGGER_DAF_DruidPortal_IN,"DB_DAF_HiddenFamilyEscape_ReachedHouse");

IF
CharacterEvent(_FamilyMember,"DB_DAF_HiddenFamilyEscape_ReachedHouse")
THEN
ProcCharacterMoveToTrigger(_FamilyMember,TRIGGER_DAF_DruidHouse_1stFloorOUT,1,"DB_DAF_HiddenFamilyEscape_ReachedStairs");

IF
CharacterEvent(_FamilyMember,"DB_DAF_HiddenFamilyEscape_ReachedStairs")
THEN
CharacterTeleportToTrigger(_FamilyMember,TRIGGER_DAF_DruidHouse_1stFloorIN,"DB_DAF_HiddenFamilyEscape_ReachedTop");

IF
CharacterEvent(_FamilyMember,"DB_DAF_HiddenFamilyEscape_ReachedTop")
THEN
ProcCharacterMoveToTrigger(_FamilyMember,TRIGGER_WAYP_DarkForest_DruidHouse_Pos,1,"DB_DAF_HiddenFamilyEscape_ReachedWaypoint");

IF
CharacterEvent(_FamilyMember,"DB_DAF_HiddenFamilyEscape_ReachedWaypoint")
THEN
Poof(_FamilyMember);



Looking at those functions, it appears as if the Event is thrown *after* the action completes. To respond to it, you need to use something like

IF
CharacterEvent( _Char, "MyEvent")
THEN
//Stuff

Re: What does _Event at the end of functions do? [Re: Mag] #556128
30/09/14 07:40 PM
30/09/14 07:40 PM
Joined: Aug 2014
Posts: 54
M
Mag Offline OP
journeyman
Mag  Offline OP
journeyman
M

Joined: Aug 2014
Posts: 54
Gotcha, so it's setting a character event. Thanks, I'll give it a try.

Re: What does _Event at the end of functions do? [Re: Mag] #556129
30/09/14 07:45 PM
30/09/14 07:45 PM
Joined: Jul 2014
Posts: 459
R
Rhidian Offline
addict
Rhidian  Offline
addict
R

Joined: Jul 2014
Posts: 459
Be aware that you might need to use

CharacterEvent(_Char, _Event)
ItemEvent(_Item, _Event)
CharacterItemEvent(_Char, _Item, _Event)

Depending on what's throwing the event.


Powered by UBB.threads™ PHP Forum Software 7.6.2