Grappling Hook Code research

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Grappling Hook Code research

Post by Fiodis »

We all know, I'm sure, about Mav's clever workaround to the no-grapple problem. He wrote up a code that, I think, went something like this: upon hitting a certain type of object with a certain weapon, teleport the player to the object's location.

After pinning down a few basics of LUA, I tried to compose a code that would duplicate this effect. After all, I'm sure we'd all love to use a grappling hook in our maps! :)

Here's the code (so far), where "grapple_target" is the name of the object's ODF. The object is, for now, a destructable prop placed in ZE. "rep_inf_grapple" is the ODF name of the grappling hook weapon. For the purpose of testing, I just copied the republic stock EMP launcher, toned down it's damage, and renamed it (odf, ord, and exp).
Hidden/Spoiler:
[code]
grapplefunction = OnObjectDamage (
function (object, damager)
if GetEntityClass (object) == "grapple_target" and IsCharacterHuman (damager) and GetObjectLastHitWeaponClass (object) == "rep_inf_grapple" then
GetEntityMatrix (object)
MoveEntityToMatrix (damager, object)
end
end
)
[/code]
This is under ScriptPostLoad. I'm rather sure some of it is incorrect (not sure how to get the matrix and cite it) but the thing is that it munged perfectly without any mungelog complaints.

Still, I get a CTD right after loading the map. The only Severity: 3, shown below, apparently has nothing to do with the LUA or the weapon.
Hidden/Spoiler:
[code]Message Severity: 3
.\Source\Weapon.cpp(1604)
Weapon base class "com_weap_inf_lightsaber" not found[/code]
This confuses me because I don't use lightsabers. Why would this happen?
YaNkFaN
Field Commander
Field Commander
Posts: 943
Joined: Sat Dec 13, 2008 8:17 am

Re: Grappling Hook Code research

Post by YaNkFaN »

did you copy the common folder when you made a custom side?
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Grappling Hook Code research

Post by Fiodis »

D'oh! :oops:

Makes another one for that "embarrasing modding mistakes" topic....

I'll fix that and report on the code's status.
YaNkFaN
Field Commander
Field Commander
Posts: 943
Joined: Sat Dec 13, 2008 8:17 am

Re: Grappling Hook Code research

Post by YaNkFaN »

yea i always get that error cause i forget to put in the common folder the game i believe checks to see if it can find all the weapons whether you've loaded them or not i believe or maybe if u have a hero then it checks but neway if you see that error or any error about a com_item_something check to see if you put your common folder where it belongs :thumbs:
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Grappling Hook Code research

Post by Maveritchell »

Of course you could have just asked what lua code I used and saved yourself the trouble. I don't mind sharing how I set it up, provided no one releases anything with it in it until I've released "The Big 'L'."
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Grappling Hook Code research

Post by Fiodis »

I thought you didn't take requests?

And off-topic, you're still working on the Big L? :D Been such a while since that topic was posted in I thought you gave it up for Battlefront Unleashed.

Well, if you're willing to give out the code, that'd be great, and thanks!

About my own attempt: didn't work. Nothing showed up in the error log about it, either.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Grappling Hook Code research

Post by Maveritchell »

Fiodis wrote:And off-topic, you're still working on the Big L? :D Been such a while since that topic was posted in I thought you gave it up for Battlefront Unleashed.
No, "Rebel Ops" is still in the works. Because I like it as a project more than Battlefront Unleashed, I wanted to get Unleashed out of the way first (but I only work on one thing at a time).

I'll PM you the code.
Post Reply