Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Mar 2016
Location: Belgium
T
addict
OP Offline
addict
T
Joined: Mar 2016
Location: Belgium
(EE editor)

Hi,

I would like to move an item created via ItemCreateAtTrigger around via ItemMoveToTrigger() (or equivalent). I can't find a way to do that though:

  • • There is no itemScript equivalent for the charScript's CharacterMoveTo call
  • • If I call ItemEvent(__Me,"someEventString") for such an item in its itemScript (I've verified that the itemScript gets run on creation), that does not seem to generate an Osiris event (ItemEvent(_item, _Event) does not get triggered in the story editor, and I couldn't see anything in osirislog.txt either)
  • • I can catch the ItemCreatedAtTrigger event, but that returns an ItemHandle rather than an Item, and there does not appear to be an inverse of ItemGetHandle, and the Osiris call ItemMoveToTrigger only works with an Item and not with an ItemHandle.

The only thing I can think of right now is to use ItemHandleToTransform (haven't tried it yet), but that seems to be a bit overkill (and it doesn't take a speed parameter, which I'd like to specify).

Any ideas?

Thanks.

Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
I think you aren't seeing an event in Osiris for that item event because it's not global. And since are creating it via template there is no way it will be global. I think you have the right idea about the Item Handle (and Template) being the only way to manipulate a non global item.

If ItemHandleToTransform doesn't work for you, maybe you can describe what you are trying to accomplish and there's something else you could do?

Joined: Mar 2016
Location: Belgium
T
addict
OP Offline
addict
T
Joined: Mar 2016
Location: Belgium
Oh, and I forgot to mention: if I call ItemHandleSetEvent() inside the ItemCreatedAtTrigger() event code, that does not appear to trigger an event either.

Joined: Mar 2016
Location: Belgium
T
addict
OP Offline
addict
T
Joined: Mar 2016
Location: Belgium
Originally Posted by SniperHF
I think you aren't seeing an event in Osiris for that item event because it's not global. And since are creating it via template there is no way it will be global. I think you have the right idea about the Item Handle (and Template) being the only way to manipulate a non global item.

Yes, I'm also afraid that's indeed what's happening.

Quote

If ItemHandleToTransform doesn't work for you, maybe you can describe what you are trying to accomplish and there's something else you could do?

Technically, I could just make a bunch of global items, since their number and initial position is fixed. It's just nicer to define their properties completely as facts in a script's init section. It works fine for characters, since there I can do everything via the CharScripts.

What I'm trying to do is create platforms that move across lava, on which the player can walk/jump (I still have to figure out a way to make the character move along with the object, because by default the object just slides from under you once you're on it, but I have some ideas for that which I still have to try). And I hope no one at Larian will revoke my game license for the sacrilege of trying to implement some kind of jumping action inside the Divinity Engine smile

Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
Yep, I'd give up and just global the platforms.

The jumping part? Well you certainly picked a challenging thing to try and accomplish hahaha . I'd think you'd run into all sorts of animation issues.

If you don't already know, one of the only reliable ways to make certain scripted player actions happen automatically is by freezing the character.

Joined: Sep 2014
journeyman
Offline
journeyman
Joined: Sep 2014
Tinkerer, I'm afraid the engine is quite limiting in this kind of gameplay. I'm not super competent in this question but these are the facts I know.
- There are no jumps in game mechanic.
- Movement of characters is affected by AI grid, which is rarely updated dynamically (it is though because you can move and destroy items).
- Whyle moving item to trigger is possible, characters can walk only on top of few items, which has specific physics and setup (WalkOn flag).
- You will not be able to make a moving platform with characters on top of them.

You though can try to put on/off stage items alike to 1m_Cellar_A_Platform_A_Item template inside the puddles of lava to emulate something similar to what you described. But I can't gurantee that AI grid will adjsut to the changes. Indeed better solution will be to create a predefined set of global items and switch thier positon and appearence on stage in osiris with timers or other logic.

Happy modding!




Joined: Aug 2014
old hand
Offline
old hand
Joined: Aug 2014
For jumping, I might tie a teleport function to an item on use, gets your position and direction facing, and teleports you 5-10m into that direction, or something like that. Not entirely sure how to script that, but I think it'd be possible. Also not sure what would happen if you used it to try and teleport into a non-AI grid area, but I think it would just send you to the edge of the non-walkable area.

Joined: Mar 2016
Location: Belgium
T
addict
OP Offline
addict
T
Joined: Mar 2016
Location: Belgium
Thanks to everyone for their suggestions!

As far as the jumping is concerned, having the platforms close enough to the border of the area and to each other is sufficient to trigger a "jump" from one platform to the other (although clicks on the platforms themselves are currently not registered as move commands, you have to click outside them and hold the mouse button to move onto them; a controller may be more convenient, although this may also be solvable in case the AI grid gets adjusted). I don't intend to try to bridge any actual gaps.

In terms of platform, I'm currently using a HUM_StoneBench_A with WalkOn=True that is submerged in the soil up to the point that only the top slab is visible.

The good news: even without any AI grid adjustments, the character gets on top of it while walking (even if the platforms is moving) and can "run along" with the platform's movement.

The bad news: any kind of lava (created via TriggerCreateSurface, or by changing the AI grid over which the object moves to "lava") "permeates" through the object's top (even if it floats quite a bit over the surface), and hence standing on top of the moving object doesn't protect you from the lava. I was hoping to be able to assume that if you were in a certain area trigger and alive/not burning, you'd be on top of one of my platforms, because everywhere else in that trigger there'd be lava.

Now, this lava issue may be related to the fact that there's indeed no AI grid associated with my moving objects. However, this fact is also noted by Osiris itself, and it seems to suggest I can do something about it: "Moving item LEP_Row1Slab_001 which has no AI bound. If you move items, give it an AI bound. Otherwise it will be static on the AiGrid!"

There are a few moving items in the main campaign that in theory should provide all I need, such as ITEM_CYS_Church_Altar (the altar in the old church that hides the entrance to the cave below). I can't figure out how to create this "AI bound" though, nor do I see any special settings or scripts for ITEM_CYS_Church_Altar. Anyone have any ideas about this?

As an aside, in case someone else ever wants to create moving objects that occasionally have to be warped to a different location: use ItemMoveToTrigger() and then catch the ItemMoved() event to determine when it has arrived for regular movements. If you want to warp/teleport it at some point, do not use ItemTeleportToTrigger(), nor ItemSetOnStage(0) followed by ItemMoveTo*() (and then again ItemSetOnStage(1)). The reason that in that case the subsequent ItemMoveTo*() call will be ignored and your object will get stuck. Instead, what I'm currently doing is move it at very high speed (1000.0) to the place where I want it to be, which also gives the impression of instantaneous movement (you can make it move via a bunch of underground triggers to be cleaner).

Joined: Aug 2014
old hand
Offline
old hand
Joined: Aug 2014
What about instead of platforms moving across lava, you just have lava triggers that turn on and off with certain timers and you have to figure out the pattern and be quick to stay in the non-lava area and whatnot, maybe while dodging projectiles or something to up the ante. I mean, it's not quite the cool factor of platforms floating through lava, but it'd be easier and much more inline with what the engine is capable of. Plus I still think a mini-teleport sort of item would be mega fun. To make it more readable and easier to use, maybe you make two items, one that creates a mini-pyramid or some other indicator where you will teleport, and the other item teleports you to that mini-pyramid, which is destroyed on teleporting. Or you could just make an item that throws one of the existing teleport pyramid forward a certain distance.

By the way, is this just a section of some larger map, or are you trying to do like, a complete trap dungeon crawl kind of thing? Or just a case study kind of thing?

Joined: Mar 2016
Location: Belgium
T
addict
OP Offline
addict
T
Joined: Mar 2016
Location: Belgium
I've found what the "AI bound" refers to: it's the very first property of an item template (you can only edit it for templates, not for already instantiated objects). If it's not set, you can assign one. Unfortunately, it appears that the engine never allows walking on top of dynamically generated AI grids (even if WalkOn is checked for the object), so that's a dead end too (it does seem to override the lava AI grid if the object is high enough above the lava, so on that count it was okay).

Regarding you question of what I'm trying to do, "case study" would be the closest. I was trying to recreate Frogger in the Divinity Engine, just to see whether I could smile The idea of using triggers to create/remove lava is something I had thought of too, but the platforms are closer to how the game worked and indeed seem cooler. I already got the road/vehicles part of the game working, and that was surprisingly simple in the end: attach a charScript to every "vehicle" (animal in this case) that simply has a reaction when a player is within 1.0 distance of an animal (CharacterGet, CharacterIsPlayer), and if so kill the player (which was a bunny, since there is no frog model), wait half a second, transport him to the spawn trigger and resurrect him.

Since the platforms seem to be a no-go, I maybe I could go for Pac-man instead: after all, the above charScript would work equally well for the ghosts. For the pills/bullets that Pac-man has to eat, you could attach a similar script to the items representing them (moving them in Pac-man's inventory when triggered, rather than killing Pac-man), and also trigger an Osiris event when they're picked up so you can decrease a counter in order to detect when they've all been eaten smile

The pyramid mechanic you mentioned immediately reminded me of Portal, maybe that too could be recreated in some way smile

Joined: Mar 2016
Location: Belgium
T
addict
OP Offline
addict
T
Joined: Mar 2016
Location: Belgium
In case anyone ever ends up here looking for a way to achieve what I asked for in my original question (although it won't solve the other issues I wanted to use this for as described in the later posts): you can cheat by creating a character with the properties of the item you want to use.

1) open the templates (the list of all items, characters, triggers, ... you can create)
2) click on the third button at the pane's top (with the "+" on it) to create a new template
3) the default type will be "character", so that's already fine
4a) click on the field next to "PhysicsResourceID", then on the "..." at the end
4b) click on the second icon in the "pop-up field" to open the resource manager
4c) select the physics resource of the item you originally wanted to use (you can right click on the item in the template list and select "edit" to see this resource's name; in the resource manager, choose the item with correct name and the green icon)
4d) after clicking in the resource manager, the pop-up field" from step b) will have disappeared. Therefore, repeat steps 4a) and 4b) after selecting the physics resource in the resource manager, and this time click the first icon in the "pop-up field" (the left arrow) to fill in your selection
5) do the same as in 4) for the VisualResourceID (bleu teapot icon)
6) Set the AI bounds (the first field of the dialog box). Unfortunately, it appears characters are limited to cylinder bounds
7) uncheck "CanFight", "CanOpenDoors", "CanSeeThrough", "InfluenceTreasureLevel", "SpotSneakers", possibly also "CanBeTeleported" depending on the kind of item
8) change BloodSurfaceType to "None"
9) You can set the "Stats" to that of a character whose properties match those of your object (or I'm sure there are posts on this forum explaining how to create new character stats files), possibly also increasing the level to increase hitpoints etc.
10) change the HitFX to something that's not blood (e.g. maybe FX_GP_Hit_Metal_A_Small)
11) under "4) Select lsb" in the dialog window, select an lsb (you can add a new one by entering a name in the field next to the pop-up)
12) enter a name under "5) Name" (it will have been filled in with the name of the item whose resources you selected, but you can't use that name since it's already in use)
13) click on the "Create" button

I have only tested basic functionality of the resulting "character" (a CharacterMoveToTrigger() in the story editor), but I assume it can do anything a regular character can do as far as the Osiris and the charScripts are concerned (of course, lack of animations means you won't have any walking/running/being angry etc).

The main downside I've found until now is that due to its character nature, you'll always get a health bar when mousing over it (even if it's supposed to be an indestructible object like a bench).

Last edited by Tinkerer; 02/04/16 11:08 AM. Reason: minor correction to 4c), mention icon of visual resource ID in 5)
Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
Well you certainly fit your forum user name, much respect for attempting the impossible wave


I'm much more of a mucker than a tinkerer hahaha


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