Data Realms Fan Forums
http://45.55.195.193/

Easy inter-MO communication, Create() interception.
http://45.55.195.193/viewtopic.php?f=73&t=15692
Page 1 of 1

Author:  mail2345 [ Fri Jul 03, 2009 2:45 am ]
Post subject:  Easy inter-MO communication, Create() interception.

As the title says, you can intercept the creation of any scripted object simply by finding the conversion function(ToAHuman, ToACrab, ect) and copying somewhere, and replacing it with your own function.

This is due to the game copying scripted MOs from a list in MovableMan, conveting them andd copying them into lists named after the ClassName that hold the functions and the variables of scripted MOs.

For an example, if I wanted to kill all scripted AHumans, I would do this:
Code:
function DestroyHumans(actor)
actor:GibThis()
return OldToAHuman(actor)
end

And where I have a code injected:
Code:
if not(injected) then
OldToAHuman = ToAHuman
injected = true
ToAHuman = DestroyHumans
end



Now, by looking at the lists named after the plural of the classname, like AHumans, you can change variables without the hackish ID indexed lists.
The lists have two things in them, lists containing the preset functions, and the pointers to an object reference that allows you to edit variables.
And set new variables.
Example(resets the fly up timer on destroyer cannon things):
Code:
for k,v in pairs(AEmitters) do
if v.PresetName == "Destroyer Cannon Shot" then
v.testTimer:Reset()
end
end


Both of these do not work on attachables, attachables are covered with this:
viewtopic.php?f=73&t=15359

Author:  CrazyMLC [ Fri Jul 03, 2009 2:56 am ]
Post subject:  Re: Intercepting creation of scripted objects.

Cure for zombie infection, basically?
Or lua death bomb?

Author:  mail2345 [ Fri Jul 03, 2009 3:00 am ]
Post subject:  Re: Intercepting creation of scripted objects.

Also fire proofing. But if one of my zombies on the field, the controller MO is already made, so no for that.
But Darlos9D's flamethrower uses the fire to control the health damage, so you could check if the particle is near, and neutralize.

Lua death bomb depends on how.

This can also be used to neutralize heat seaking missiles.

Author:  CrazyMLC [ Fri Jul 03, 2009 3:04 am ]
Post subject:  Re: Intercepting creation of scripted objects.

Oh, yeah, that makes sense!
Heat-seeking rocket jammer here we come!
MUAHAHA!

Author:  Areku [ Fri Jul 03, 2009 3:08 am ]
Post subject:  Re: Intercepting creation of scripted objects.

Wait, wait, wait. Does that mean that we can have Lua scripts running on different objects, but that can influence each other? If so, it surely does expand scripting possibilities quite a lot.

Author:  Grif [ Fri Jul 03, 2009 3:09 am ]
Post subject:  Re: Intercepting creation of scripted objects.

We could always do that. 's called a global variable.

Author:  Areku [ Fri Jul 03, 2009 3:15 am ]
Post subject:  Re: Intercepting creation of scripted objects.

Uh. :oops:
If so, then what exactly is this script for?

Author:  mail2345 [ Fri Jul 03, 2009 3:19 am ]
Post subject:  Re: Intercepting creation of scripted objects.

Global variables are non-private, and are target towards all scripts.
You can index by ID, but that runs the risk of bugs.

Anyway, both MOs have to be willing.
Oh, I found another method. Will add to the OP.

Author:  Geti [ Wed Jul 29, 2009 11:42 am ]
Post subject:  Re: Easy inter-MO communication, Create() interception.

why didnt i see this topic before?
helpful, mail.

Author:  Kyred [ Sun Aug 09, 2009 8:44 pm ]
Post subject:  Re: Easy inter-MO communication, Create() interception.

So does this only work on objects that have a script attached to them?

Author:  mail2345 [ Sun Aug 09, 2009 11:16 pm ]
Post subject:  Re: Easy inter-MO communication, Create() interception.

Yes. Apparently the in game engine uses these lists, so becareful.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/