|
stranger
|
OP
stranger
Joined: Oct 2017
|
I'm not sure if this the correct place to post.
However, I'm trying to make a skill that changes effect based on the race of the caster. How would I go about doing this? This skill is not a racial ability.
|
|
|
|
enthusiast
|
enthusiast
Joined: May 2017
|
So there's a few options for how to go about this: Firstly, if what you want to change is solely based in the SkillProperties section of the skill, then you can try and see if the following conditions would work: For checking races on the caster: SELF:IF(Tagged:ELF):ELF_STATUS,100,1; For checking races on the target: TARGET:IF(Tagged:ELF):ELF_STATUS,100,1; And so on for every race. Obviously, this isn't very extensible, especially if you'd like to support modded races, or you want to change the damage type / effects / animations and so on. ___________________________________ That leads us to a second option: scripting. Personally I would go for story scripting in this situation, since databases will make adding additional races mostly painless. Before I supply some code samples, bookmark this page in case you're not familiar with story scripting: https://docs.larian.game/Your_First_Story_Script___________________________________ So the main idea here is that players will cast a skill that we look for in our script, and then we cast the "real" spell after fetching their race and attaching a skill to it. We'll call this skill "Target_MyMod_RacePower" (the actual stat entry is called "MyMod_RacePower", and since it's a target type, we must put "Target_" before the name when using it in scripts). The "MyMod" part should be changed to match the shorthand name of your mod (prefixing things is a good way to prevent conflicts). After you set up an initial goal, we can get started: First, we can set up our "race => racial skill" database in the INIT section of our goal: INIT: DB_MyMod_RacePowerSkills("Default", "Target_MyMod_AncestorEchoes");
DB_MyMod_RacePowerSkills("Dwarf", "Target_MyMod_DwarvenMetal");
DB_MyMod_RacePowerSkills("Human", "Target_MyMod_HumanIngenuity");
DB_MyMod_RacePowerSkills("Elf", "Target_MyMod_ElvenLineage");
DB_MyMod_RacePowerSkills("Lizard", "Target_MyMod_LizardOppression");
DB_MyMod_RacePowerSkills("Undead_Dwarf", "Target_MyMod_DwarvenMetal");
DB_MyMod_RacePowerSkills("Undead_Human", "Target_MyMod_HumanIngenuity");
DB_MyMod_RacePowerSkills("Undead_Elf", "Target_MyMod_ElvenLineage");
DB_MyMod_RacePowerSkills("Undead_Lizard", "Target_MyMod_LizardOppression"); For the sake of brevity, I assigned the undead race varients to the same skill as their original race. Alternatively, you could assign them all the same undead skill, or specific ones to those races. Next, we'll set up some rules in our goal to actually cast the "real" skill when the base one is cast: IF
CharacterUsedSkillOnTarget(_Caster, _Target, "Target_MyMod_RacePower", _SkillType)
AND
CharacterGetRace(_Caster, 0, _Race)
AND
DB_MyMod_RacePowerSkills(_Race, _TrueSkill)
THEN
DB_MyMod_Temp_CastRacialSkill(_Caster, _Target, _TrueSkill);
//If no race matches were made, use "Default"
IF
CharacterUsedSkillOnTarget(_Caster, _Target, "Target_MyMod_RacePower", _SkillType)
AND
NOT DB_MyMod_Temp_CastRacialSkill(_Caster, _Target, _)
AND
DB_MyMod_RacePowerSkills("Default", _TrueSkill)
THEN
DB_MyMod_Temp_CastRacialSkill(_Caster, _Target, _TrueSkill);
IF
SkillCast(_Caster, "Target_MyMod_RacePower", _SkillElement)
AND
DB_MyMod_Temp_CastRacialSkill(_Caster, _Target, _TrueSkill)
THEN
NOT DB_MyMod_Temp_CastRacialSkill(_Caster, _Target, _TrueSkill);
CharacterUseSkill(_Caster, _TrueSkill, _Target, 1, 1, 1); That's all you need for a basic implementation. Essentially, when the base skill is first used, we store the caster, target, and true skill in a database temporarily. If no race matches are found, we use the entry labeled as "Default" (this second rule acts as an "ELSE" statement, if you're familiar with programming principles). Once the skill has actually been cast (CharacterUsedSkillOnTarget fires when the skill is first used, whereas SkillCast fires when it reaches the "cast" part of the animation), we cast our "true skill" and remove the entry from the database. More info on CharacterUseSkill here: https://docs.larian.game/Osiris/API/CharacterUseSkill___________________________________ Some things to consider: ■ Depending on when the skill is actually cast in the animation, you may have to delay the casting of the second skill with a timer, if you want a second set of animations to play. Alternatively, you could set the "true" skill to have no animations, so it casts instantly. ■ Getting this to work with cone skills, or skills that don't rely on an "object" target, may require some extra "finesse", as you'll have to store the position of where the player targeted the initial skill. ■ Adding support for modded races is as simple as adding another database entry. Other mods that want to provide integration with your mod would be able to do this as well.
|
|
|
|
stranger
|
OP
stranger
Joined: Oct 2017
|
Thank you LaughingLeader, this has been incredibly helpful! I have a few more questions concerning this method so I should be a bit more clear now.
The skill in question summons a different unit based on the character race and sex (I neglected to mention this in the original post). I assumed the 'Template' section of the skill changes what summoned unit appears. Using your example from earlier: SELF:IF(Tagged:ELF):ELF_STATUS,100,1;
Would I need to change 'ELF_STATUS' to be the summon template I wanted? Or should I go with your second example where there are technically more than 1 skill and the story script checks for that?
|
|
|
|
enthusiast
|
enthusiast
Joined: May 2017
|
Unfortunately SkillProperties are solely for applying statuses, so you can't assign a different summon template there. I'm not sure if SELF checks work properly for summon skills either, so I would still go with the scripting option, as you it would still be the easiest method in the long run. What you could do is still have the "base" skill be a target skill, but instead of CharacterUsedSkillOnTarget, use the position alternative like so: IF
CharacterUsedSkillAtPosition(_Caster, _X, _Y, _Z, "Target_MyMod_RacePower", _SkillType)
AND
CharacterGetRace(_Caster, 0, _Race)
AND
CharacterIsFemale(_Caster, _IsFemale)
AND
DB_MyMod_RacePowerSkills(_Race, _IsFemale, _SummonSkill)
THEN
DB_MyMod_Temp_CastRacialSkill(_Caster, _X, _Y, _Z, _SummonSkill);
//If no race matches were made, use "Default"
IF
CharacterUsedSkillAtPosition(_Caster, _X, _Y, _Z, "Target_MyMod_RacePower", _SkillType)
AND
NOT DB_MyMod_Temp_CastRacialSkill(_Caster, _X, _Y, _Z, _)
AND
CharacterIsFemale(_Caster, _IsFemale)
AND
DB_MyMod_RacePowerSkills("Default", _IsFemale, _SummonSkill)
THEN
DB_MyMod_Temp_CastRacialSkill(_Caster, _X, _Y, _Z, _SummonSkill);
IF
SkillCast(_Caster, "Target_MyMod_RacePower", _SkillElement)
AND
DB_MyMod_Temp_CastRacialSkill(_Caster, _X, _Y, _Z, _SummonSkill)
THEN
NOT DB_MyMod_Temp_CastRacialSkill(_Caster, _X, _Y, _Z, _SummonSkill);
CharacterUseSkillAtPosition(_Caster, _SummonSkill, _X, _Y, _Z, 1, 1); Your databases would then have to be updated to account for the new "_IsFemale" value: DB_MyMod_RacePowerSkills("Default", 0, "Summon_MyMod_MaleDefault");
DB_MyMod_RacePowerSkills("Default", 1, "Summon_MyMod_FemaleDefault");
DB_MyMod_RacePowerSkills("Dwarf", 0, "Summon_MyMod_DwarfMale");
DB_MyMod_RacePowerSkills("Dwarf", 1, "Summon_MyMod_DwarfFemale");
|
|
|
|
|