WSE - Lua edition [Beta], a new way of scripting

Users who are viewing this thread

Thanks K700 for the example, perfect answer for my question  :smile:

What comes down to calling scripts with parameters, i realized i can use registers to do the job.
Instead of using params, i can simply use game.reg[1] = 1 before calling the script and use reg1 in MS.
Actually this way i can use script in MS to assign global variables too. It's kind of a dirty workaround, but get's the job done
 
So there isn't any other way to set/get game global variables except the one suggested by Muzzle ? In the mod i use global variables are heavy used and i can't slit one script in 10 lua functions to set the global variables. I prefer to rewrite the entire script with lua.
However doing game.assign("$my_global_var", 10) returns always 127 on lua side.
 
Code:
game.const.triggers.ti_simulate_battle
game.const.ti_simulate_battle
Both Return -5. So it works perfect
Code:
game.const.triggers.key_t
game.const.key_t
Both Return 0. So not working for me.
Maybe because its a hex number? (0x14)
-----------------------------
luaGuide.html said:
local gold = game.player_get_gold(0, playerId)
What does the blue zero stand for?
 
Global variables are a bit of an issue because their names get dropped at the compile stage. Internally it's just a value with some flags. So best I can think of to get around is a "register_gvar_with_name(gvar, name)" ms operation that you'd have to call from the ms prior to lua usage. Or, if you're brave enough, use the gvar no directly, skipping the registration. Or a ms compiler modification which I wouldn't know how to do right now. Sort of a hacky job in any case.

@Muzzle C: I recall someone having trouble here with call_script, thought I had fixed that with an update.. Oh well.

Sinideas IV said:
Code:
game.const.triggers.ti_simulate_battle
game.const.ti_simulate_battle
Both Return -5. So it works perfect
Code:
game.const.triggers.key_t
game.const.key_t
Both Return 0. So not working for me.
Maybe because its a hex number? (0x14)
Do you get any warning message in rgl log?

Sinideas IV said:
luaGuide.html said:
local gold = game.player_get_gold(0, playerId)
What does the blue zero stand for?
It stands for rtfm, although some say you have to put it in there because I can't decide between an lhs operand being output only or input/output from lua. :grin:
 
AgentSmith said:
Do you get any warning message in rgl log?
No one
AgentSmith said:
It stands for rtfm
Sorry my english is weak.
I read "luaGuide.html" a bunch of times trying to figure it out.
luaGuide.html said:
While most Lhs operations don't require an actual value for lhs_arg (in those cases it's strictly a return variable, for example player_get_gold), some (for example val_add) do, so you have to specify it anyway.
I guess that line is the one who say it, but I didn't get it.
Thank you for the clarification.
 
AgentSmith said:
@Muzzle C: I recall someone having trouble here with call_script, thought I had fixed that with an update.. Oh well.

Was the update included in the official WSE build? Just asking since that's what i've been using.
 
Is it possible to add triggers for items via Lua? I'd like to add ti_on_init_missile on certain items, but obviously operation game.addTrigger is meant for mission_templates only..
I've got a special project which would be the best to be done with Lua, but since this feature is missing i'm kinda halted.
 
AgentSmith said:
Probably possible, I'll see what I can do. Out ouf curiosity, what project you got going?

It's an attempt to create a statistics based anti-aimbot. Not sure if it'll end up anywhere, but if it does it could be powerful. Stats don't lie  :grin:
And thanks for your effort AgentSmith, this tool is splendid
 
Muzzle C said:
AgentSmith said:
Probably possible, I'll see what I can do. Out ouf curiosity, what project you got going?

It's an attempt to create a statistics based anti-aimbot. Not sure if it'll end up anywhere, but if it does it could be powerful. Stats don't lie  :grin:
And thanks for your effort AgentSmith, this tool is splendid

lol what xD
 
Mercenary_Frank said:
lol what xD

Anti-cheat. You could basically detect aimbot from the success rate of shots on different circumstances if you'd had enough data to compare. I don't quite understand what's lol in it..
 
Muzzle C said:
Mercenary_Frank said:
lol what xD

Anti-cheat. You could basically detect aimbot from the success rate of shots on different circumstances if you'd had enough data to compare. I don't quite understand what's lol in it..

What different circumstances? Headshot percentage? Hit percentage? If you somehow got an accurate measurement of a cheater his profile the solution will be as simple as shooting 5 arrows in a wall. There are a whole bunch of anti cheats on the market now and apart from FairFight none of them use statistics to detect an aimbot server sided. Bare in mind I am not saying a server sided aimbot detector isn't possible only that the way you plan on doing it you will have a meme anti-cheat.
 
I asked for help, can we keep it at it? This thread is no place for arguments and so i'm not gonna continue this chat with you Mercenary_Frank.

All in all, adding triggers to items via Lua would be useful in many ways.
 
You won't disturb anyone by arguing here  :grin:
That sounds pretty interesting. I had an idea myself for adding blockbot detection, if you're open for suggestions. Basically you have a dark room with a bot in it. Best to make it so you can't exactly see what's going on. Suspicious player gets teleported there and the bot holds his weapon in attack position. You can measure the delay time until the player blocks, if he even does. If it's too low he gets banned, if not tp'd back. And you could do this on player join, periodically or only on suspicion. If you do this right after a fight he won't have a chance to press a panic button.

Anyway, I had a go with the item triggers. Doesn't work right now and I don't know why, but hopefully I can sort it out soon.
 
AgentSmith said:
You won't disturb anyone by arguing here  :grin:
That sounds pretty interesting. I had an idea myself for adding blockbot detection, if you're open for suggestions. Basically you have a dark room with a bot in it. Best to make it so you can't exactly see what's going on. Suspicious player gets teleported there and the bot holds his weapon in attack position. You can measure the delay time until the player blocks, if he even does. If it's too low he gets banned, if not tp'd back. And you could do this on player join, periodically or only on suspicion. If you do this right after a fight he won't have a chance to press a panic button.

Anyway, I had a go with the item triggers. Doesn't work right now and I don't know why, but hopefully I can sort it out soon.

Disable it based on location or just disable it when you are teleported to that room. Catching autoblockers is actually pretty easy. I can already spot an autoblocker whenever I am using unblockable. I have to say on NW siege at least 50% of the players I come against is using autoblock so I think native will probably have even more.

Muzzle C said:
I asked for help, can we keep it at it? This thread is no place for arguments and so i'm not gonna continue this chat with you Mercenary_Frank.

All in all, adding triggers to items via Lua would be useful in many ways.

If you don't know how to hook agent::shoot_missile you should probably stay away from building an anti-cheat.
 
Muzzle, I got it to work. At least in my testings.  https://bitbucket.org/Kumpuu/warband-script-enhancer/downloads/addItemTrigger.7z

Usage:
Code:
intTriggerNo = game.addItemTrigger(strItemID, fTriggerInterval, funcCallback)

Example:
game.addItemTrigger("itm_fighting_pick", game.const.ti_on_weapon_attack, function()
	print("agent no " .. game.store_trigger_param_1(0) .. " swinged a fighting pick")
end)
Let me know if you have any issues.

Frank, your input might be valuable since you are a cheat dev... But you're still a cheater. :???:
 
AgentSmith said:
Muzzle, I got it to work. At least in my testings.  https://bitbucket.org/Kumpuu/warband-script-enhancer/downloads/addItemTrigger.7z

Usage:
Code:
intTriggerNo = game.addItemTrigger(strItemID, fTriggerInterval, funcCallback)

Example:
game.addItemTrigger("itm_fighting_pick", game.const.ti_on_weapon_attack, function()
	print("agent no " .. game.store_trigger_param_1(0) .. " swinged a fighting pick")
end)
Let me know if you have any issues.

Frank, your input might be valuable since you are a cheat dev... But you're still a cheater. :???:

Useless, doesn't show you which attack you swung and what direction you blocked. You also need to add this trigger to every missile/melee item in the game. I am also not sure if this will trigger if you shoot a missile since the game handles it as an event.

The solution is as simple as hooking the shoot missile function, you'd be even able to stop nospread as well.
 
Mercenary_Frank said:
Useless, doesn't show you which attack you swung and what direction you blocked. You also need to add this trigger to every missile/melee item in the game. I am also not sure if this will trigger if you shoot a missile since the game handles it as an event.

The solution is as simple as hooking the shoot missile function, you'd be even able to stop nospread as well.
You seem a bit confused. This is just an example.
 
Back
Top Bottom