LUA Weapon - Cage Mine

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

LUA Weapon - Cage Mine

Post by Fiodis »

So I want to make a weapon called a Cage Mine for BrutalFront and a few other projects. Basically, you place a mine-type thing. When stepped on, a cage appears around you and you can't get out. So people could shoot you or you could suicide. People ask, why not just have a normal mine? Answer: cause I like this better.

But anyway that's not what it's about. Here's the script I wrote up for it:
Hidden/Spoiler:
[code]OnObjectDamage (
function (object, damager)
trap == "the_cage_odf"
if damager == nil then return end
if GetObjectLastHitWeaponClass == "rep_weap_inf_mine_dispenser" then
local victim = GetEntityMatrix (object)
local trap = GetEntityMatrix (trap)
SetEntityMatrix(trap, object)
end
end
)[/code]
Now, I've got most of it figured out but what troubles me is the

Code: Select all

trap == "the_cage_odf"


That's hopefully taking any object with the odf name "the_cage_odf" and setting it as variable trap, then later I use trap when I get the object's matrix and teleport it to object's matrix (where object is the victim).

I'm pretty sure something's wrong with the way I set that up, but what is it? Should I use the odf name of the trap, or a unique ZE name? And did I set it as the variable trap correctly?
User avatar
swingking
Private Recruit
Posts: 22
Joined: Tue Mar 17, 2009 8:04 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: somewhere in the gum on your shoe
Contact:

Re: LUA Weapon - Cage Mine

Post by swingking »

your problem:
trap == "the_cage_odf"

the lua script registers that as an equality and doesn't process it. Try removing 1 of your " = "s.

'''''''''''''''''''''edit'''''''''''''''''''''''''''
an equality and doesn't process it.
my bad... i meant to say "a comment and doesn't process it" :oops:
Last edited by swingking on Thu Apr 02, 2009 7:16 pm, edited 3 times in total.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA Weapon - Cage Mine

Post by [RDH]Zerted »

Fiodis wrote:That's hopefully taking any object with the odf name "the_cage_odf" and setting it as variable trap, then later I use trap ...
Nope, thats just setting the trap variable to the string the_cage_odf (after you fix the == problem).
What you need to do is create and spawn a new trap object.
theITfactor
Chief Warrant Officer
Chief Warrant Officer
Posts: 327
Joined: Wed Jun 28, 2006 12:56 pm
Projects :: The Pwnfest and Games Complex
Games I'm Playing :: SWTOR
xbox live or psn: You and I Know
Location: The Old Republic
Contact:

Re: LUA Weapon - Cage Mine

Post by theITfactor »

I'm doing something similar, try modifying this:
Hidden/Spoiler:
trap_region = OnEnterRegion(

function(regIn,character)
local unit = GetCharacterUnit( character )
if not unit then return end

--get the unit's location
local point = GetEntityMatrix( unit )

--drop prop directly on the unit

CreateEntity("insert name here", point, "insert name here")

end,
"trap_region"
)
ActivateRegion("trap_region")
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: LUA Weapon - Cage Mine

Post by Fiodis »

Thanks for that, it looks like it would work.

Hold on, a thought just struck me: when I use GetObjectLastHitWeaponClass, what do I put? The weapon that the damager used was the mine dispenser, but it's the mine itself that's blowing up and hurting the victim. Does that mean the mine is the damager, or the mine is the weapon?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA Weapon - Cage Mine

Post by [RDH]Zerted »

Test it and find out.
Post Reply