How to commit or test an added script?

Volgin
Posts: 32
Joined: Sun Oct 13, 2013 10:27 pm

How to commit or test an added script?

Post by Volgin » Sun Dec 08, 2013 1:49 pm

Pretty simple question, I probably just missed it somewhere...

So I created blade_bash.lua (this wasn't in the abilities folder). Trying to test it on my test server, but keeps says "Unable to use job ability."

I put it in </scripts/globals/abilities/>, then used TortoiseSVN to 'add' the file. Now it has a blue + in the bottom left corner of the file icon. Tried to commit, but it gives me an error. Did I miss something, or am I just completely stupid?

Thanks,

K.

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

Re: How to commit or test an added script?

Post by kjLotus » Sun Dec 08, 2013 2:18 pm

committing is adding it to the central repository so everyone else can get it - only the developers can do that

if the script is just in the right folder with the right name, it'll be read by the game server. my guess is there's an error in the script somewhere, you can check what the DSGameServer spits out when you try to use it

Volgin
Posts: 32
Joined: Sun Oct 13, 2013 10:27 pm

Re: How to commit or test an added script?

Post by Volgin » Sun Dec 08, 2013 4:48 pm

It's in the right folder, but still giving me this message...GameServer says PERFORMING ACTION 09.

I delete the file, and it says the same thing...but when I delete another ability, such as konzen-ittai.lua, is gives an error message saying it can't find the file.

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

Re: How to commit or test an added script?

Post by kjLotus » Sun Dec 08, 2013 8:31 pm

hmm.. do you have merit points in it?

Volgin
Posts: 32
Joined: Sun Oct 13, 2013 10:27 pm

Re: How to commit or test an added script?

Post by Volgin » Sun Dec 08, 2013 8:55 pm

kjLotus wrote:hmm.. do you have merit points in it?
Yes, one. Was trying to implement the plague duration based on level as well. I commented out the addStatusEffect, though, and it still doesnt work

Code: Select all

function OnAbilityCheck(player,target,ability)
	if (not player:isWeaponTwoHanded()) then
		return MSGBASIC_NEEDS_2H_WEAPON,0;
	else
		return 0,0;
	end
end;

function OnUseAbility(player, target, ability)
	-- Stun rate
	if(math.random()*100 < 99) then
		target:addStatusEffect(EFFECT_STUN,1,0,6);
	end
	
	-- Blade Bash does not deal damage. -- Source: http://wiki.bluegartr.com/bg/Blade_Bash
	local damage = 0;
	
	-- Applying Plague based on merit level.
	-- target:addStatusEffect(EFFECT_PLAGUE,1,0,30 + (20 * player:getMerit(MERIT_BLADE_BASH)));
	
	target:delHP(damage);
	target:updateEnmityFromDamage(player,damage);
	
	return damage;
end;
EDIT: Do I have to edit another file along with this, like ai_char_normal.cpp?

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

Re: How to commit or test an added script?

Post by kjLotus » Sun Dec 08, 2013 9:41 pm

Volgin wrote:Do I have to edit another file along with this, like ai_char_normal.cpp?
not supposed to have to... let me see what happens on mine

edit: ok.. it had the wrong validTargets listed in the db. if you update and rerun abilities.sql it should try to grab the script now. I didn't change the message (defaults to "x uses y. z takes # damage.") so you'll probably want to change that in the DB as well

Volgin
Posts: 32
Joined: Sun Oct 13, 2013 10:27 pm

Re: How to commit or test an added script?

Post by Volgin » Sun Dec 08, 2013 11:04 pm

kjLotus wrote:
Volgin wrote:Do I have to edit another file along with this, like ai_char_normal.cpp?
not supposed to have to... let me see what happens on mine

edit: ok.. it had the wrong validTargets listed in the db. if you update and rerun abilities.sql it should try to grab the script now. I didn't change the message (defaults to "x uses y. z takes # damage.") so you'll probably want to change that in the DB as well
That worked, thanks!

If I may ask one more question...

Code: Select all

player:getMerit(MERIT_BLADE_BASH)
seems to be incorrect syntax. I tried the actual ID of the merit, which is 2754, and that didn't work either. I'm still getting used to this <lua_State *L> parameter...never know what goes inside. Do you happen to know the correct syntax for getMerit?

I tried:

Code: Select all

player:getMerit(MERIT_BLADE_BASH,0)
player:getMerit(MERIT_BLADE_BASH,player)
player:getMerit(2754)

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

Re: How to commit or test an added script?

Post by kjLotus » Sun Dec 08, 2013 11:13 pm

lua_State is just the current state of the entire lua interpreter. When you call getMerit, anything you passed in gets pushed on to the stack. Then, in the c++ lua function, anything you passed in can get popped with lua_toxxx (in the case of getMerit, lua_tointeger) which takes the state and the position on the stack as the parameter. Then, when you're done, you push return values back on to the stack, and return the number of values you pushed on to return (so that the lua side knows how many there were). in the case of getMerit

Code: Select all

lua_pushinteger(L, PChar->PMeritPoints->GetMeritValue((MERIT_TYPE)lua_tointeger(L,1), PChar));
is taking the first parameter passed in, calling GetMeritValue with is, and then passing what that returns back to the lua function that requested it

long story short, it's just getMerit(MERIT_TYPE), and it returns "value" (from database, merit table) times the number of points put in.

when you say "it doesn't work", what is happening specifically?

Volgin
Posts: 32
Joined: Sun Oct 13, 2013 10:27 pm

Re: How to commit or test an added script?

Post by Volgin » Sun Dec 08, 2013 11:36 pm

When I just use the default duration at:

Code: Select all

target:addStatusEffect(EFFECT_PLAGUE,1,0,30);
It wears off in 30 seconds, like it should. However, when I add:

Code: Select all

target:addStatusEffect(EFFECT_PLAGUE,1,0,10 + (20 * player:getMerit(MERIT_BLADE_BASH) ));
Plague doesn't come off. Being impatient with it, I changed it to EFFECT_BIND, and it wore off in 150seconds...meaning it got the value 7 from getMerit(MERIT_BLADE_BASH), when I only have it at 1 merit....and I don't think that's correct lol. With the above, it should give an extra 20 seconds per merit level, starting at 30seconds.
kjLotus wrote: when you say "it doesn't work", what is happening specifically?

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

Re: How to commit or test an added script?

Post by kjLotus » Mon Dec 09, 2013 12:41 am

you can print it and it'll come to the console

Post Reply