Larian Banner
Previous Thread
Next Thread
Print Thread
Having trouble understanding.... #647852
09/08/18 01:29 AM
09/08/18 01:29 AM
Joined: Aug 2018
Posts: 37
Z
Zeth fox Offline OP
apprentice
Zeth fox  Offline OP
apprentice
Z

Joined: Aug 2018
Posts: 37
so Ive been messing with the engine, learning the basics of creating levels and such.
created quite a few new skills using existing abilities.
But while the basics of story scripting are very much covered in YT vid tuts, scripting abilities/skills/new status types/talents is completely in the dark.

there are no tuts on how to create a custom ability/skill that uses custom scripting anywhere.

also there is just about 250 scripts total in the scripts editor, some of which are empty like shared->statuses just saids "events" at top with no actual code in it.
am I not set up properly?
I thought a game like this would be very heavy on scripts, is there just many scripts we dont even get to see for whatever reason?

which now leads me to the main reason I reg'ed to the forum...

Ive coded c++ for about 9 years, and have a generally good ability to break down and understand coding languages but this engines code has me completely stumped.
How does an object ingame know that a script for it exist other than assigning it in the root.
If I wanted to add a stat->projectile with a custom status "choked"(example)...how do I go about connecting that ability and/or status to the code I write for handling it in the script editor.

I'll ask a more complex one next if that was simple, lets say I want the ability to spawn 3 ai controlled dogs If the target with choked dies within the debuff timer.
how do you link the scripts needed to handle that back to the ability/status its created for?

do all scripts simply just run at all times?(i would think that would be a nightmare for performance)

how are functions created and called?
using

CALLFUNCTION("whatever")
which i assume is what creates the "whatever" function
just throws errors saying "CALLFUNCTION" is unidentified.

Maybe I'm over thinking this, would be great if the studio made a long series for this topic like they did with the apples quest they created.

anyways thanks inadvance.



Re: Having trouble understanding.... [Re: Zeth fox] #647853
09/08/18 01:50 AM
09/08/18 01:50 AM
Joined: Sep 2017
Posts: 874
The Composer Offline

Moderator
The Composer  Offline

Moderator

Joined: Sep 2017
Posts: 874
As I like to say to new people: Prior coding experience often seems to be a negative thing almost, as (like you said) are probably overthinking it. There is a useful wiki, though.

Osiris Overview

There are typically two different "scripting languages" in DOS. Osiris (Story Editor) and behavior/game scripts (script editor). They both have their own unique quirks, and some things can often be achieved in both.

I personally tend to lean more on Osiris and use behavior to handle idle npc actions / life. I don't do much skill-related work compared to others, so gamescripts have been of little concern for me thus far.

An extremely dumbed down TL;DR would be something like...

Osiris is at its simplest an "IF this THEN that" deal. You also have databases to store / get prior information, procs to proc into different chains of events, and queries to run checks if something is true/false or to produce something on the fly, and the calls (THEN) will only run if the query(ies) and eventual conditions (AND) passes.

Behaviour scripts are split into three (charscripts: attached to characters, itemscripts: attached to items, and gamescripts: overall listening to game events etc)

I'd recommend start with the wiki, and hang out with us on the discord channel.

Last edited by The Composer; 09/08/18 01:51 AM.
Re: Having trouble understanding.... [Re: Zeth fox] #647856
09/08/18 06:06 AM
09/08/18 06:06 AM
Joined: Nov 2017
Posts: 129
L
LarIlya Offline
member
LarIlya  Offline
member
L

Joined: Nov 2017
Posts: 129
Originally Posted by Zeth fox
there are no tuts on how to create a custom ability/skill that uses custom scripting anywhere.

also there is just about 250 scripts total in the scripts editor, some of which are empty like shared->statuses just saids "events" at top with no actual code in it.
am I not set up properly?
I thought a game like this would be very heavy on scripts, is there just many scripts we dont even get to see for whatever reason?


The game doesn't use scripting to define how its abilities/skills work (with one exception - a gamescript governs how statuses interact).
Skills are defined in the stats editor, whereas things like talents, the effects of base attributes, etc. are defined mostly in code, with a few variables set in data.

A word of warning about trying to script your way around the combat engine: you can do that, and other here have, but because the AI doesn't parse scripts when trying to decide what to do, it will be unaware of any scripting you use to intercept normal combat flow, and will act as if it isn't there.

Re: Having trouble understanding.... [Re: Zeth fox] #647861
09/08/18 10:50 AM
09/08/18 10:50 AM
Joined: Aug 2018
Posts: 37
Z
Zeth fox Offline OP
apprentice
Zeth fox  Offline OP
apprentice
Z

Joined: Aug 2018
Posts: 37
When you say in code or data, do you mean some spot in the engine that we dont have access to? Or is there a place in the editor somewhere?

Re: Having trouble understanding.... [Re: Zeth fox] #647863
09/08/18 11:48 AM
09/08/18 11:48 AM
Joined: Aug 2018
Posts: 37
Z
Zeth fox Offline OP
apprentice
Zeth fox  Offline OP
apprentice
Z

Joined: Aug 2018
Posts: 37
I should clarify, like with the example above where I wanted it to create the three dogs if you killed the Enemy Within the debuff limit.
I do have understanding of how the stats data works to some extent at this point, I ended up creating a Target skill that applies a custom status in the stats status with a Dieability that does a projectile stat that spawnabilitys a resource Group of dogs.

Essentially it seems so complicated, I was looking at the script thinking it would be incredibly easy to have a script that checks the status and summons these dogs when the enemy dies. But I just don't understand how the scripts tie in with the abilities. WhiIe was very much able to create an ability that does what I wanted, it really feels like the way I accomplished it was very hackish.

Re: Having trouble understanding.... [Re: Zeth fox] #647866
09/08/18 02:12 PM
09/08/18 02:12 PM
Joined: May 2017
Posts: 349
LaughingLeader Offline
enthusiast
LaughingLeader  Offline
enthusiast

Joined: May 2017
Posts: 349
Originally Posted by Zeth fox
Essentially it seems so complicated, I was looking at the script thinking it would be incredibly easy to have a script that checks the status and summons these dogs when the enemy dies. But I just don't understand how the scripts tie in with the abilities. WhiIe was very much able to create an ability that does what I wanted, it really feels like the way I accomplished it was very hackish.

The basic usage of scripts, both behavior and story, are reaction-based. Meaning, they listens for an event, and then does something. So in this case, you could simply listen for an enemy dying, check if they have the status you applied, and then spawn the dogs at their position.

Story scripts and gameScripts work in a similar way - they're always actively running (though if the story script has a parent script, that script needs to be completed (GoalCompleted;) before it will become active). Additionally, since charScripts and itemScripts are attached to objects, those objects need to be active in the world before their scripts will run.

Here's an example of what the script could look like for what you want done (this would be in a gameScript):
Code
EVENT MyMod_OnDying_SpawnDogs
VARS
	CHARACTER:_Target
	CHARACTER:_Caster
	CHARACTER:_Dog1
	CHARACTER:_Dog2
	CHARACTER:_Dog3
	FLOAT3:_Pos
	FLOAT:_LevelF
	INT:_Level
	FIXEDSTRING:_Faction
ON
	OnCharacterStatusApplied(_Target, DYING)
ACTIONS
IF "c1&c2&c3&c4&c5"
	CharacterHasStatus(_Target, MYMOD_CUSTOM_STATUS)
	CharacterGetStatusSourceCharacter(_Target, MYMOD_CUSTOM_STATUS, _Caster)
	GetPosition(_Target, _Pos)
	CharacterGetStat(_LevelF, _Caster, Level)
	GetFaction(_Faction, _Caster)
THEN
	//FLOAT to INT
	Cast(_Level, _LevelF)
	SpawnCharacter(_Dog1, Animals_Dog_B_Black_ad8f1f47-3bb9-4d51-aadf-aed3b264530c, _Pos, 1, 0, _Caster, _Level)
	SpawnCharacter(_Dog2, Animals_Dog_A_Black_e0467912-f900-48ab-b677-28d14a515846, _Pos, 1, 0, _Caster, _Level)
	SpawnCharacter(_Dog3, Animals_Dog_B_RedFaction_A_41d02eb7-01aa-436e-af61-86cf2ce671f6, _Pos, 1, 0, _Caster, _Level)
	SetFaction(_Dog1, _Faction)
	SetFaction(_Dog2, _Faction)
	SetFaction(_Dog3, _Faction)
ENDIF

I tested this by using HASTED as my status to check.
The result:
[Linked Image]

A few things to note:

The parameters for SpawnCharacter:
Code
SpawnCharacter(OUT CHARACTER:result, CHARACTERTEMPLATE:rootTemplate, GAMEOBJECT|FLOAT3:position, INT:playSpawn, [INT:isSummon=0, CHARACTER:summonOwner=null, INT:overrideLevel=-1])

IsSummon will tie into the summon system, and use the character's max summon stat. When set to 1, I only had 1 dog spawn.

The SetFaction calls are optional of course, as is getting the source of the status, for making the dog spawn at status source character's level. The dogs will default to the level in their stats if you don't provide a level override, or if they're not a summon.

You could spruce up the dog-spawning part by playing some effects at the dog's positions, using CharacterPlayEffect, or PlayEffectAt:
Code
//playSpawn is set to 0 here, since we're using smoke effects to hide them "popping" in.
	SpawnCharacter(_Dog1, Animals_Dog_B_Black_ad8f1f47-3bb9-4d51-aadf-aed3b264530c, _Pos, 0, 0, _Caster, _Level)
	SpawnCharacter(_Dog2, Animals_Dog_A_Black_e0467912-f900-48ab-b677-28d14a515846, _Pos, 0, 0, _Caster, _Level)
	SpawnCharacter(_Dog3, Animals_Dog_B_RedFaction_A_41d02eb7-01aa-436e-af61-86cf2ce671f6, _Pos, 0, 0, _Caster, _Level)
	SetFaction(_Dog1, _Faction)
	SetFaction(_Dog2, _Faction)
	SetFaction(_Dog3, _Faction)
	SetTag(_Dog1, "MyMod_DogStatusSummon")
	SetTag(_Dog2, "MyMod_DogStatusSummon")
	SetTag(_Dog3, "MyMod_DogStatusSummon")
	CharacterApplyStatus(_Dog1, NULL, 0)
	CharacterApplyStatus(_Dog2, NULL, 0)
	CharacterApplyStatus(_Dog3, NULL, 0)
ENDIF

EVENT MyMod_PlayDogSpawnEffect
VARS
	CHARACTER:_Dog
ON
	OnCharacterStatusRemoved(_Dog, NULL)
ACTIONS
IF "c1"
	IsTagged(_Dog, "MyMod_DogStatusSummon")
THEN
	PlayEffectAt(_Dog, "RS3_FX_GP_ScriptedEvent_Ambushers_Smoke_01")
ENDIF

Here I'm applying a status called "NULL" for 0 turns, purely to delay the effects long enough for the position to be where they eventually end up, since the dogs spawn around _Pos if that position is blocked (which it will be).

If I don't delay the effects, they end up playing at position x0 y0 z0, since that's where the dogs initially spawn in until the engine moves them to the desired position.

Here's the result:
[Linked Image]

Re: Having trouble understanding.... [Re: Zeth fox] #647868
09/08/18 05:04 PM
09/08/18 05:04 PM
Joined: Nov 2017
Posts: 129
L
LarIlya Offline
member
LarIlya  Offline
member
L

Joined: Nov 2017
Posts: 129
Originally Posted by Zeth fox
When you say in code or data, do you mean some spot in the engine that we dont have access to? Or is there a place in the editor somewhere?


When I said 'data' I meant the entries you can adjust in the stats editor. These you can access, but only within the limits of the variables defined there.

When I say "code" I meant that these things are part of the programming of the engine itself. To change these (or at least, to change them in the same way they work in the game), you'd have to build an entirely new binary.

That said, if you're not too concerned about systems like the AI knowing what it is your changes do, you can indeed use script to work around the existing systems like LaughingLeader suggests.
But it should explain why you don't see scripts defining how skills and abilities work - that's not normally governed by script.

More relevantly to your problem: Statuses have an OnDie action, which can trigger a projectile skill (as if a projectile impacted at the location of death), which in turn can summon a character.
Those are limited by the maximum amount of summons the character has however.

Last edited by LarIlya; 09/08/18 05:20 PM.
Re: Having trouble understanding.... [Re: Zeth fox] #647869
09/08/18 05:32 PM
09/08/18 05:32 PM
Joined: Aug 2018
Posts: 37
Z
Zeth fox Offline OP
apprentice
Zeth fox  Offline OP
apprentice
Z

Joined: Aug 2018
Posts: 37
Thank you both for replying, laughingleader nailed it for me.
The effects i wish to create would mostly be reactions/after effects to skills like that post death summon skill.

So when writing a game script just assume it's always listening...i guess thats what really confused me, i thought i had to link it to the skill somehow and was missing a very obvious step.

The actual story scripting doesn't interest me as there's a million and a half examples for that i can reference plus about 8 hours of YouTube tuts i can follow.


Moderated by  Larian_Koala 

Powered by UBB.threads™ PHP Forum Software 7.6.2