scripting mob 2hour use

Post Reply
horizon
Posts: 29
Joined: Wed Sep 24, 2014 10:28 pm

scripting mob 2hour use

Post by horizon » Wed Aug 31, 2016 10:17 am

I've been doing a lot of mob scripting lately, and while I've gotten just about everything working as I have intended in regards to normal mob abilities, I'm at a loss as how to make 2hour abilities work.

Using Kirin as an example, for any mob that I would like to have use a 2hour ability, I've gone into mob_spawn_mods and added MOBMOD_SCRIPTED_2HOUR to 1 for that mob.

From there I've added the 2hour ability ID to that mob's skill list. (though I don't even think this is necessary in this case, since it is to be called from script) However, when trying to activate the ability via scripting, nothing ever happens. In one case with Carrabosse, I was able to get her to use benediction, however it would be random, and never as dictated by scripting.

I've had zero issues scripting any other mob ability, including ones I've implemented myself, so I feel like I have a good feel in general for ability scripting. What then, am I missing under the hood that is particular to 2hour abilities?

On the MOBMOD subject, I notice several related to 2hours, and I'm curious what they do, specifically:

-MOBMOD_MAIN_2HOUR ( I assume this simply enables the mobs 2hour based on their main job? I've added this as well but it hasn't helped.)

-MOBMOD_SUB_2HOUR (enables 2hour of sub-job? To what end?)
-MODMOD_2HOUR_MULTI (i assume this unlocks all 2hours ala absolute virtue? Or does it just allow multiple uses?)
-MOBMOD_2HOUR_PROC (allows 2hour to be used at a specific core-chosen hp%?)
-MOBMOD_SCRIPTED_2HOUR (its mentioned in the 2hour ability scripts and is checked before activation so I think I have a good understanding of this one at least?)

thanks in advance for any insight or advice!

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: scripting mob 2hour use

Post by kjLotus » Wed Aug 31, 2016 7:45 pm

grep them if you want to read how they are used - sub lets it use the subjobs 2hour, multi lets it use it more than once (when not scripted), don't know what proc is, and scripted is pretty much deprecated at this point.

if you're scripting the 2hour manually, you should be fine with not using any mobmods at all and just using mob:useMobAbility(2hour id), and you don't need to add it to any list or anything

siuhamlop
Posts: 21
Joined: Thu Aug 04, 2016 3:50 am

Re: scripting mob 2hour use

Post by siuhamlop » Thu Sep 01, 2016 3:56 am

After reading this post I tried to add 2hour ability to Dynamis Bastok mob but no luck, can someone help me check the code, does it need to put something to onMobEngaged?

Code: Select all

-----------------------------------
-- Area: Dynamis Bastok
--  MOB: Vanguard_Hatamoto
-----------------------------------

require("scripts/globals/dynamis");
require("scripts/globals/ability");
require("scripts/globals/status");
require("scripts/globals/mobskills/Meikyo_Shisui");

-----------------------------------
-- onMobSpawn Action
-----------------------------------

function onMobSpawn(mob)
end;

-----------------------------------
-- onMobEngaged
-----------------------------------

function onMobEngaged(mob,target)
end;

-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)

    local battletime = mob:getBattleTime();

    if (battletime > 20) then
        mob:useMobAbility(730);
    end

end;

-----------------------------------
-- onMobDeath
-----------------------------------

function onMobDeath(mob, player, isKiller)
end;

horizon
Posts: 29
Joined: Wed Sep 24, 2014 10:28 pm

Re: scripting mob 2hour use

Post by horizon » Thu Sep 01, 2016 8:53 am

thanks for the reply kjlotus!

simply scripting them via mob:useMobAbility() is what I originally tried, but it doesn't seem to work for 2hour abilities, and only them.
I first figured it was due to this pre-ws check in the mobskill scripts:

Code: Select all

function onMobSkillCheck(target,mob,skill)
    if (mob:getMobMod(MOBMOD_SCRIPTED_2HOUR) == 1) then
        return 0;
    elseif (mob:getHPP() <= mob:getMobMod(MOBMOD_2HOUR_PROC)) then
        return 0;
    end
    return 1;
end;
wait a sec... After posting a big reply, I just looked at this script while previewing the post and I see the problem. The pre-check just returns 1 regardless of the if conditions above because there is no else before the return 1. /facepalm.

let me go test...

horizon
Posts: 29
Joined: Wed Sep 24, 2014 10:28 pm

Re: scripting mob 2hour use

Post by horizon » Thu Sep 01, 2016 9:37 am

I changed the pre-check scripting to just return 0, and then tried to use Mighty Strikes on a few different normal mobs with no results. From there I've changed MOBMOD_SCRIPTED_2HOUR to 1 for a war type NM, and used:

Code: Select all

    if (mob:hasStatusEffect(EFFECT_BIO) == true) then
	    mob:useMobAbility(1008);
	    mob:delStatusEffect(EFFECT_BIO);
    end
to test. Bio will land, and then wear immediately, showing that the script is running, but the ability isn't being used.

Adding MOBMOD_MAIN_2HOUR, 1, of course doesn't help. I'll dig around a bit more.

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: scripting mob 2hour use

Post by TeoTwawki » Mon Sep 05, 2016 8:45 am

wait a sec... After posting a big reply, I just looked at this script while previewing the post and I see the problem. The pre-check just returns 1 regardless of the if conditions above because there is no else before the return 1. /facepalm.
Wrong. Anytime you hit a return the script is done right there. so if the other conditions aren't hit, it will land at that line. No "else" required.

I have dozens of custom NMs with working scripted 2hrs, I know what I am talking about.: No mobmod, or change at all to skill check, or any skill list edit. mob:useMobAbility(skill_id_here) works without any of that. The other junk exists because legacy code and people who don't even understand what they are doing. If that command isn't getting you a skill going off you've messed up somewhere or are working on a mob that's already borked from something else. If a mob has a non scripted 2hr (everything in dynamis) that's likely going to interfere.
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

horizon
Posts: 29
Joined: Wed Sep 24, 2014 10:28 pm

Re: scripting mob 2hour use

Post by horizon » Tue Sep 06, 2016 11:47 am

Hold on TeoTwawki, I'm most certainly not trying to start fights or suggest anyone doesn't know what they're doing aside from myself. If something I said made you think that, then my sincere apologies - it definitely wasn't intentional. I'm here to ask for your guys' help in understanding, not to piss anyone off. I thought I had found one of those simple fixes that I had overlooked, and obviously that wasn't it. Let me start over.

I've started back from step 1, and used the following script on several mobs to try and see if I could make one of the 2hour abilities activate on command:

Code: Select all

if (mob:hasStatusEffect(EFFECT_BLINDNESS) == true) then
    mob:useMobAbility(skillid for whatever ability to test);
    mob:delStatusEffect(EFFECT_BLINDNESS);    
end
for the first test, I tried a flamingo in Ru'aun gardens.
Whatever ability I put in there, whether it be 622(helldive), or 376(Foul Breath), if I cast blind on it, the mob would use said ability and then blind would wear as intended. Just as you guys have said, it doesn't matter if the ability is in their skill list or not, it will be used. So that all works as intended.

If I put any of the 2hour ability id's in there however, nothing happens. No errors, no messages. Blind will land, and then blind will wear and that's it. For Mighty Strikes, that could be 688 or 1008 (688 is flagged in mob_skills as a 2hour, 1008 is not) , or for Benediction that could be 689,1010,1486. Nothing happens. Use of 2hours on any player character works normally.

I originally saw the precheck scripting in the mobskill script, and figured the reason they were not firing was that the script was returning 1 since a flamingo doesn't have the associated mobmods it checks for. That is what prompted the notes I made about adding said mobmods to a mob in hopes of getting things working, and why i did the "Return 0" part to the mobskill precheck. I hoped one would solve things, but neither has.

I've tried flamingo, the pots in sky, carabosse and ruminator in abyssea, even a few random mobs like rabbits and geiers in abyssea la theine. No dice with any.

You mentioned the mobs in dynamis and this has me thinking. I don't recall ever seeing a dyna mob use its 2hour on my server. I just did a maat fight on drk the other night and didn't see him use Blood weapon either. To investigate further, I added "THROUGH_THE_QUICKSAND_CAVES" to my active missions and entered the chamber of oracles BCNM. I recall these mobs all using 2hours in retail, and perhaps they could work as a control since they've been implemented in game for a while, and nothing about their scripting has been changed. No 2hours were used here either.

Something weird is going on specifically with my server maybe? I have an older version from about a year back on one of my laptops, so I will fire it up when I have a few minutes and see if the same issues happen there.

xipies
Posts: 119
Joined: Thu Aug 02, 2012 11:29 pm

Re: scripting mob 2hour use

Post by xipies » Tue Sep 06, 2016 11:58 am

horizon wrote:You mentioned the mobs in dynamis and this has me thinking. I don't recall ever seeing a dyna mob use its 2hour on my server.
NIN certainly go boom in dynamis, at least on classic (oldschool) server.

We've wiped on SMN avatars astral flow in dynamis, too.

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: scripting mob 2hour use

Post by TeoTwawki » Wed Sep 07, 2016 5:22 am

Hold on TeoTwawki, I'm most certainly not trying to start fights or suggest anyone doesn't know what they're doing aside from myself. If something I said made you think that, then my sincere apologies - it definitely wasn't intentional
I apologize I came off sounding like I was offended I guess. I'm often unaware when I am having giving my text a "tone". I don't mean to sound that way. I was trying to provide you with some credibility that "this does work, I'm using it this way" not accuse you of anything.

You mentioned the mobs in dynamis and this has me thinking. I don't recall ever seeing a dyna mob use its 2hour on my server.
I've seen quite a few diff servers say that. I dunno whats wrong as those mobs 2hr for me. And all my scripted custom ones are working on latest revision using that command. Some I shared with the legion server (they have my crab that does DRG and RUN 2hrs, among other things) and theirs are working to though that server isn't quite up to date yet.

An important thing to remember is that if something in a script is invalid syntax often it'll stop the entire thing from executing. There should be console log errors when that happens, but sometimes its hard to spot. I'm not saying that's your issue (sounds like you have something more globally busted on your server) its just good info to have here for the next person who's searching the forum in the future.
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: scripting mob 2hour use

Post by TeoTwawki » Sun Sep 11, 2016 2:02 am

Got reminded by talking about it in IRC chat tonight, so figured I should come back and mention there's an open PR about this now so if it is indeed busted in trunk (in which case, I dunno how its working for some of us and not all of us), its already being worked on: https://github.com/DarkstarProject/darkstar/pull/3359
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

Post Reply