the SERVER scripting thread

Moderator: EUO Moderators

Post Reply
User avatar
eggmceye
hello
Posts: 10577
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia
Contact:

Re: the SERVER scripting thread

Post by eggmceye »

important detail about instances: if multilevel map, eg minotaur halls, need to add a line into sdat/mapsets, to tell the server all these levels are part of same instance. the line specifically for mino halls is "54,55,56,57,58,59,60,61"

sdat/mapsets.txt

Code: Select all

54,55,56,57,58,59,60,61
175,176,177,178,179,180
67,68,69,70
230,231,232,233,234,235,236
63,64,65,66
182,183,184,185,186
136,137
120,121,122,123,124,125,126,127,128
198,199,200
260,261,262
User avatar
LordMortiferus
MACRO > me
Posts: 872
Joined: Tue Dec 01, 2009 10:23 pm

Re: the SERVER scripting thread

Post by LordMortiferus »

Is there a way to prevent visible weapons on mobs from dropping?

I tried to add m.weapon=Item(0x0) in the the death_function but that doesn't seem to work. Furthermore, I added to script to the death_func to look for a specific item when the mob dies and delete this, but this only works when the item drops at the same coords as the mob. I could expand the area to search for the specific item but this does not seem to be efficient imho.
User avatar
LordMortiferus
MACRO > me
Posts: 872
Joined: Tue Dec 01, 2009 10:23 pm

Re: the SERVER scripting thread

Post by LordMortiferus »

And another question about boss names. I am pretty sure the following code worked when I finished ToLS:
[code] if m.boss == true then
m:set_name("Drek'more")
m.hide_boss_name = true
end[/code]
Working on Carnival Carnage I noticed that I cannot overwrite the boss names any more. The boss name will either be a combination of "Elder" and species name or something else specified in boss_name.lua. Is my memory failing me or did something change?
Last edited by LordMortiferus on Sat Feb 02, 2019 2:26 am, edited 1 time in total.
User avatar
LordMortiferus
MACRO > me
Posts: 872
Joined: Tue Dec 01, 2009 10:23 pm

Re: the SERVER scripting thread

Post by LordMortiferus »

A suggestion for the API:
1) a function that allows visible weapons on all monsters regardless of their sprites (dragons, shadow warrior, etc.)
2) a function preventing the drop of any visible weapon a monster has, e.g. fancy flaming claymore.
User avatar
LordMortiferus
MACRO > me
Posts: 872
Joined: Tue Dec 01, 2009 10:23 pm

Re: the SERVER scripting thread

Post by LordMortiferus »

Here is a prove of concept for a diablo 1 flamewave in EUO using the new flame particle effects:
flamewave2.gif
I think some frames were lost during recording and converting to gif.
You do not have the required permissions to view the files attached to this post.
User avatar
LordMortiferus
MACRO > me
Posts: 872
Joined: Tue Dec 01, 2009 10:23 pm

Re: the SERVER scripting thread

Post by LordMortiferus »

Here is the nova spell from diablo:
nova.gif
If anyone wants these rudimentary scripts to work on and maybe finish these spells, just let me know.
You do not have the required permissions to view the files attached to this post.
dirtyking
I once posted in TFIOOC!
Posts: 100
Joined: Thu Aug 27, 2015 1:16 pm

Re: the SERVER scripting thread

Post by dirtyking »

Awesome , be cool for a boss on the map I’m working on
User avatar
Keighn
Stop posting already --;
Posts: 5509
Joined: Sat Jun 26, 2004 10:13 am
Location: Hey.... pssttt Back in Orgeon

Re: the SERVER scripting thread

Post by Keighn »

Can you make lightning in any color?
What about the other spell effects?
ZUPS!!!!
User avatar
LordMortiferus
MACRO > me
Posts: 872
Joined: Tue Dec 01, 2009 10:23 pm

Re: the SERVER scripting thread

Post by LordMortiferus »

I assume egg could make it any color. For now e have redish blood bolt, blueisch OG and some blackish OG, if I remember it correctly.

Edit: There is a certain problem with spell though. E.g., you will not see the lightning when its starting point is more than ~5 squares away from you. When you move away from the nova caster above you will only see half of a circle even though your line of sight is larger.
User avatar
Kynt
LAUGHING OUT LOUD LIKE A MORON
Posts: 61
Joined: Wed Feb 18, 2015 9:04 am

Re: the SERVER scripting thread

Post by Kynt »

I wonder if defining lua functions such as mob_hits, mob_loot, mob_select_spell, etc, override important definitions? In theory you couldn't have mob_hits defined in multiple scripts, since the one to load last is the one that stays.

I've been testing around and you can technically preserve the previous function using a variable then calling it within the new function:

Code: Select all

local prev_func = mob_hits
function mob_hits(id, target_id)
	prev_func(id, target_id)
	writelog2("GOT HIT")
end

local prev_func2 = mob_hits
function mob_hits(id, target_id)
	prev_func2(id, target_id)
	writelog2("GOT HIT 2")
end

local prev_func3 = mob_hits
function mob_hits(id, target_id)
	prev_func3(id, target_id)
	writelog2("GOT HIT 3")
end
With this code, every time I got hit, it would output "GOT HIT", "GOT HIT 2" and "GOT HIT 3" in order.
In the case of mob_dies you can use a monster's death_func variable to assign a callback, assuming no monster has an assigned function by default. However, I couldn't find callback variables to other functions such as a mob hitting a player (mob_hits), having to use the global definition instead and checking id and such.

I'm sure a more global solution could exist to avoid having to override functions. Maybe have a table with all callbacks associated to mob_hits, and have the mob_hits function call every function in this table?
Then every time you want a function to run when a mob hits a player, you'd use a global function that receives the callback function and adds it to the mob_hits table.
User avatar
eggmceye
hello
Posts: 10577
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia
Contact:

Re: the SERVER scripting thread

Post by eggmceye »

I sorta get all that but what is the actual outcome you want to achieve?
User avatar
Kynt
LAUGHING OUT LOUD LIKE A MORON
Posts: 61
Joined: Wed Feb 18, 2015 9:04 am

Re: the SERVER scripting thread

Post by Kynt »

In my map, there are certain effects I want to apply when mobs hit you. Amongst these effects is dealing extra damage based on player max HP, applying status effects, and other effects that need a reference to the player being hit and the hitting monster.

From what I understand, I need to define the mob_hits function amongst my scripts and code these effects here, checking if the monster in question belongs to my map. However, only one instance of the mob_hits function can exist for all maps, and by defining my own I'd probably be overriding an original definition of the function.

Is defining a version of mob_hits for my map the proper way to do it? The solution I provided before (the one where you define a variable with the current definition of mob_hits, then call it within the new definition) seems to deal with the overriding problem, but it would need to be applied every time you want to define extra behaviour for mob_hits in a different script file.
User avatar
eggmceye
hello
Posts: 10577
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia
Contact:

Re: the SERVER scripting thread

Post by eggmceye »

I get it now, ok so the 'proper' way (which sucks) is to edit the original mob_hits func in monsters.lua and add in your code !

A much better way would be to somehow define callbacks that you want for your mobs and somehow mob_hits calls them all. So a way around that would be to call any func that you want called when a mob hits to be called mob_hits_xyz() then the original mob_hits just calls them all (I bet this could be done in lua because it has tables of func names which could be scanned for mob_hits_* ). One sticky thing to consider might be order of them being called or even exclusivity, though I just checked the origi mob_hits and its probably wouldn't care if there custom mob_hits called at the end (or maybe at the beginning with a return state that decides whether to call more?)
User avatar
Kynt
LAUGHING OUT LOUD LIKE A MORON
Posts: 61
Joined: Wed Feb 18, 2015 9:04 am

Re: the SERVER scripting thread

Post by Kynt »

dumb me just now checked the monsters.lua script and indeed the mob_hits function is there.
I tested around a bit and found that doing this works:

monsters.lua:

Code: Select all

-- Table for mob_hits callback functions
mob_hits_callbacks = {}

function mob_hits(mob_id, target_id)
	local m=get_monster_ptr(mob_id)
	local tgt=get_sent_ptr(target_id)
	if m==nil or tgt==nil then return end

	-- Call associated functions
	for func, v in pairs(mob_hits_callbacks) do
		func(mob_id, target_id)
	end

end

-- Associate a function to mob_hits (mob hitting you)
function addcallback_mob_hits(func)
	if mob_hits_callbacks[func] == nil then
		mob_hits_callbacks[func] = true
	end
end
I made a table that will hold all callbacks that need to be called from mob_hits. At the end of mob_hits, it will loop through this table, calling all functions added to it.
There's the addcallback_mob_hits function, which takes a function reference and adds it to the callback table if it's not already there (avoiding duplicates).
This function should be defined in a script inside the scripts folder, to ensure it's defined before scripts.maps loads, thus letting maps safely use it.

Example usage:
Somewhere in a map script:

Code: Select all

function test1(id, tgt_id)
	writelog2("This works.")
end
addcallback_mob_hits(test1)
Different map script:

Code: Select all

function test2(id, tgt_id)
	writelog2("This also works.")
end
addcallback_mob_hits(test2)
I tried it this way, and every time I got hit by a mob, both functions would run, outputting "This also works." and "This works.". Possible downside is the difficulty in keeping track of which functions are running whenever mob_hits gets called, in case there's a bug in one of the callbacks (ideally, these should check for mob type or map id and such to narrow down the search).
Just an idea, wanted to test lua a bit here (functions as references/table keys is interesting), but I can stick to editing monsters.lua if need be.
User avatar
eggmceye
hello
Posts: 10577
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia
Contact:

Re: the SERVER scripting thread

Post by eggmceye »

yeh, so have a table you manually update (which is maintenance but readable) or have it just figure it out automatically

just note that thesedays there is only one scripts folder: scripts - the scripts.maps is gone (merged into scripts). weekly server gets a 2nd scripts folder called scripts.weekly .

also note that it almost nearly never matters what order scripts are loaded! there is an exception to this, but you prob don't need it. stuff that needs to be called/declared first can go in a _.lua file but currently it only has this in it

Code: Select all

package.path = package.path .. ';scripts/?.lua'
package.path = package.path .. ';scripts.weekly/?.lua'
which ensures the a-star class stuff works (I don't fully know why) - my longwinded point being you probably don't need to worry about order of funcs
User avatar
Kynt
LAUGHING OUT LOUD LIKE A MORON
Posts: 61
Joined: Wed Feb 18, 2015 9:04 am

Re: the SERVER scripting thread

Post by Kynt »

I see, that's good to know. I haven't actually ran into any order-related problems, but I was minding it just in case (better safe than sorry etc).
Post Reply