Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Jan 2015
K
journeyman
OP Offline
journeyman
K
Joined: Jan 2015
Hi. In my mod i have a skill that the player can use to click on an NPC and then get information about how that character has moved, the code looks like this:

IF
CharacterUsedSkillOnTarget(CHARACTER_Player1,CHARACTER_Manduk, "Target_Tracking", "Target")
THEN
ItemTeleportToTrigger(ITEM_Manduk_Trace_To_Bury_1,TRIGGER_Manduk_To_Bury_1);
ItemTeleportToTrigger(ITEM_Manduk_Trace_To_Bury_2,TRIGGER_Manduk_To_Bury_2);
etc etc for each
In game:

[Linked Image]


So the white glowing things are traces of the movement from the NPC and they move to the trigges when the player uses the skill on an NPC, this works fine. I also have a skill that's supposed to remove the white trace things but it's not working:

IF
CharacterUsedSkill(CHARACTER_Player1, "Remove_Tracks", "Earth")
THEN
ItemTeleportToTrigger(ITEM_Manduk_Trace_To_Bury_1,TRIGGER_Trace_Collector);
ItemTeleportToTrigger(ITEM_Manduk_Trace_To_Bury_2,TRIGGER_Trace_Collector);
etc etc...


Now this code works in so far that if i use the function ItemMoveToTrigger instead of ItemTeleportToTrigger the white things move nicely in the direction of the Trace Collector trigger. I can't redo this however, so it only works once and after that they're stuck. ItemTeleportToTrigger doesn't work at all.

Last edited by karlgoran; 04/04/15 01:50 PM.
Joined: Sep 2014
Z
apprentice
Offline
apprentice
Z
Joined: Sep 2014
Something you can try is setting the items off stage or changing their visibility instead of trying to move them away (using item scripts). This could also make placing and using your tracks way easier. They wouldn't have to be global, you don't need a trigger/item pair with a unique name for each set, and you can show them and make them disappear with a single global event.

Joined: Jan 2015
K
journeyman
OP Offline
journeyman
K
Joined: Jan 2015
it sounds like a great idea but after looking a bit at item scripts and your thread on the subject i'm unsure on how to write the code. There would have to an action that can change an object from visible to invisible and there would have to be a link between CharacterUsedSkillOnTarget in story and the event in the item script. Something like:


INIT
ITEM:__Me

EVENTS

EVENT ChangeVisibility
ON
Event somehow triggered by CharacterUsedSkillOnTarget
ACTIONS
ChangeVisibility(_Me, 0)



Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
Originally Posted by karlgoran

EVENT ChangeVisibility
ON
Event somehow triggered by CharacterUsedSkillOnTarget
ACTIONS
ChangeVisibility(_Me, 0)


This seems doable.

I have a charscript which switches events based on a timer started in Osiris. The call is there for events as well.

So you could write the script in Osiris for Characterusedskillontarget, have that trip an event which the charscript will react to.

The charscript call for visibility is "SetVisible".

This is my script for making my characters walk away after the timer runs.
Code
EVENT Squattersleaving
ON
	OnTimer("Squattersleaving")
ACTIONS
	SetPriority("Squattersleaving",1500)
	SetPriority("Wandering2",0)
	SetPriority("Wandering1",0)


So yours would be something like
Story editor:
Code
IF
CharacterUsedSkill(CHARACTER_Player1, "Remove_Tracks", "Earth")
THEN
GlobalSetEvent("RemoveTracks")


ItemScript
Code
INIT
ITEM:__Me

EVENTS
EVENT Disappears
ON
       OnGlobalEventSet("RemoveTracks")
ACTIONS
       SetVisible(__ME,0)

EVENT Appears
ON
       OnGlobalEventSet("ShowTracks")
ACTIONS
       SetVisible(__ME,1)






Joined: Jan 2015
K
journeyman
OP Offline
journeyman
K
Joined: Jan 2015
Welp that worked, looks pretty cool as well. Thanks guys.

Joined: Sep 2014
Z
apprentice
Offline
apprentice
Z
Joined: Sep 2014
Another detail that might make your life easier is using an EXTERN variable.
Code
INIT
ITEM:__Me
EXTERN STRING:%trigger="ShowTracks"

EVENTS
EVENT Disappears
ON
       OnGlobalEventCleared(%trigger)
ACTIONS
       SetVisible(__ME,0)

EVENT Appears
ON
       OnGlobalEventSet(%trigger)
ACTIONS
       SetVisible(__ME,1)

Using Extern will allow you to change by which trigger it is affected by when giving the track its scripts. So each characters tracks can be activated independently.

Joined: Jan 2015
K
journeyman
OP Offline
journeyman
K
Joined: Jan 2015
that was actually exactly what i started thinking about when i implemented the item scripts. Not sure how the code you posted would work in practice. What would the story script look like?

Joined: Sep 2014
Z
apprentice
Offline
apprentice
Z
Joined: Sep 2014
Here is how I would do it:

Story Scripts
INIT
Code
TracksEvents("ShowMandukTracks");
TracksEvents("ShowBobTracks");
//all track events go into TracksEvents database


KB
Code
//other track events would follow the same form, just change target and the event set
IF
CharacterUsedSkillOnTarget(_,CHARACTER_Manduk, "Target_Tracking", _)
THEN
GlobalSetEvent("ShowMandukTracks");

IF
CharacterUsedSkillOnTarget(_,CHARACTER_Bob, "Target_Tracking", _)
THEN
GlobalSetEvent("ShowBobTracks");

//More... 1 for each tracks set

//Clears ALL track events. Its possible to only clear some if you want
IF
CharacterUsedSkill(_, "Shout_Remove_Tracks", _)
AND
TracksEvents(_eve)
THEN
GlobalClearEvent(_eve);


The tracks would have the same scripts from what I provided above.
However when placing the track change the extern variable (its the extra box on the right side when adding scripts) to what event you want the track to trigger on. In this case: ShowMandukTracks and ShowBobTracks.
Note: Do NOT change the script code, that's what the extern is for.

Joined: Jan 2015
K
journeyman
OP Offline
journeyman
K
Joined: Jan 2015
hmm i must say i'm a bit confused by the code.


INIT
ITEM:__Me
EXTERN STRING:%trigger="ShowTracks"

Here the %variable is set to "ShowTracks", which means that if the code below is run:


IF
CharacterUsedSkillOnTarget(_,CHARACTER_Bob, "Target_Tracking", _)
THEN
GlobalSetEvent("ShowTracks");

then all items with the item script you posted will be made visible. I'm not sure if this is what is intended though so i must be missing something.

Last edited by karlgoran; 07/04/15 08:44 AM.
Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
The tl;dr version is the "ShowTracks" simply populates the field %trigger with a string by default. In this case ShowTracks. You could just leave it blank as "". You need the two quotes to identify it as a string.

Your conditional statement shouldn't use "ShowTracks" anymore but "ShowYOURCHARACTERNAMETracks". For each character.

Long version:

I believe the intent was that you set in the sidebar each characters appropriate globalevent for showing tracks. So in the portion of the script that says EXTERN STRING:%trigger="ShowTracks". %trigger is the variable you set in the sidebar. Which should match the characters name.

ShowBobTracks is the one Zoltan picked.

So your story editor should have separate conditionals for each character. The globalevent "ShowTracks" wouldn't show all characters, it would show none. Since the script is looking for the specific string you put in the sidebar. Unless you keep the conditional for "ShowTracks". I'd probably get rid of it and just use them all individually.

When you use EXTERN STRING:%trigger="ShowTracks" you can replace "ShowTracks with "ShowBobTracks" the "ShowTracks" part is what the script will check for. If you keep it the same and don't remove your conditional for "ShowTracks" then it will always show all characters tracks.

Code
EVENT Appears
ON
       OnGlobalEventSet("ShowBobTracks")
ACTIONS
       SetVisible(__ME,1)


^That is what the script will be if you change it in the sidebar. You do it on the right side pane during the process of adding the script. Not afterward.

This is where:
[Linked Image]




Last edited by SniperHF; 07/04/15 07:33 PM.
Joined: Jan 2015
K
journeyman
OP Offline
journeyman
K
Joined: Jan 2015
ah ok i didn't get that you were supposed to give %trigger a string in the sidebar. Now it works, thanks.


Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5