The fun .LUA commands thread

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

User avatar
skelltor
Sith
Sith
Posts: 1431
Joined: Fri Dec 11, 2009 6:24 pm
Projects :: BFSM
Games I'm Playing :: SWBFII
xbox live or psn: skelltor95
Location: minisnowta
Contact:

Re: The fun .LUA commands thread

Post by skelltor »

Oh but I don't want to have to edit the stock maps and I still want vehicles is there another way?
THEWULFMAN
Space Ranger
Posts: 5557
Joined: Tue Aug 17, 2010 3:30 pm
Projects :: Evolved 2
Location: Columbus, Ohio
Contact:

Re: The fun .LUA commands thread

Post by THEWULFMAN »

skelltor wrote:Oh but I don't want to have to edit the stock maps and I still want vehicles is there another way?

Have someone like me edit it gor you, :P :yes:
User avatar
skelltor
Sith
Sith
Posts: 1431
Joined: Fri Dec 11, 2009 6:24 pm
Projects :: BFSM
Games I'm Playing :: SWBFII
xbox live or psn: skelltor95
Location: minisnowta
Contact:

Re: The fun .LUA commands thread

Post by skelltor »

Ok thanks for the help guys :D (sorry about offtopic talk)
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: The fun .LUA commands thread

Post by DarthD.U.C.K. »

skelltor wrote:Oh but I don't want to have to edit the stock maps and I still want vehicles is there another way?
DarthD.U.C.K. wrote:otherwise you will have to set this property via lua.
CalvaryCptMike
Captain
Captain
Posts: 476
Joined: Sat Feb 19, 2011 3:10 pm
Projects :: Nothing--absolutely nothing
Location: Freed by alien robots, now living on Mars
Contact:

Re: The fun .LUA commands thread

Post by CalvaryCptMike »

How would you go about doing that? :?
I've been looking for something like that.
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: The fun .LUA commands thread

Post by DarthD.U.C.K. »

like that:

Code: Select all

SetProperty("com_item_vehicle_spawn22", "ClassRepDEF", "rep_hover_fightertank")	
edit: well im not completely sure if vehiclespawns support properties via lua....but if they do it works like this.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: The fun .LUA commands thread

Post by Maveritchell »

DarthD.U.C.K. wrote:like that:

Code: Select all

SetProperty("com_item_vehicle_spawn22", "ClassRepDEF", "rep_hover_fightertank")	
edit: well im not completely sure if vehiclespawns support properties via lua....but if they do it works like this.
I don't believe vehicle spawns support their instance properties via lua (note that these are different kinds of properties than standard .odf properties). They can support basic properties of the vehicles they spawn, though - if, for example, you wanted to change the health of a vehicle spawned from a vehicle spawn, you could use SetProperty on the "CurHealth" property to modify it.
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: The fun .LUA commands thread

Post by DarthD.U.C.K. »

im not sure whether instanceproperties arent different from other odfproperties since you can put any property under the instanceproperty-tag and it will become an instanceproperty.
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: The fun .LUA commands thread

Post by Fiodis »

DarthD.U.C.K. wrote:im not sure whether instanceproperties arent different from other odfproperties since you can put any property under the instanceproperty-tag and it will become an instanceproperty.
Really? I didn't know that, wow. Does that include sound-related properties?

Wait; if that were true, couldn't you use that for smoother weapon pickups?
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: The fun .LUA commands thread

Post by DarthD.U.C.K. »

i dont know about the details, i just found it out by accident once.
THEWULFMAN
Space Ranger
Posts: 5557
Joined: Tue Aug 17, 2010 3:30 pm
Projects :: Evolved 2
Location: Columbus, Ohio
Contact:

Re: The fun .LUA commands thread

Post by THEWULFMAN »

Fiodis wrote:
DarthD.U.C.K. wrote:Wait; if that were true, couldn't you use that for smoother weapon pickups?
:shock: Could it be :runaway:
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: The fun .LUA commands thread

Post by Fiodis »

The thing about current weapon pickup systems is that they affect entire classes of units. If WeaponName can be made into an instance property, then you could have custom weapon pickups per unit rather than per class. I'm a little skeptic about it, though; how did you go about it, Duck?
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: The fun .LUA commands thread

Post by DarthD.U.C.K. »

i didnt go about anything! o.o
i just saw that an odfproperty would become editablein ze if it was put under indtanceproperties. thats all, i swear!
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: The fun .LUA commands thread

Post by Fiodis »

Ah. I'll take an educated guess and say it won't work with every odf property. :P

Pity. Would've been fun. :(
User avatar
asleeponduty
Private First Class
Posts: 77
Joined: Tue Jul 22, 2008 3:05 pm
Games I'm Playing :: AaaaaAAaaaAAAaaAAAA
xbox live or psn: No gamertag set
Location: Illinois

Re: The fun .LUA commands thread

Post by asleeponduty »

Heres a fun command, courtesy of theITfactor:

What it does: spawns a timebomb on you when you destroy an object (this example uses 3 objects)

Code: Select all


local eventSpawn = OnObjectKill(
function(object, killer)
if not killer then return end --do nothing if no killer
if not IsCharacterHuman(killer) then return end --do nothing unless killer is a human

local name = GetEntityName(object)

if (name == "OBJECTNAMEONE") or
(name == "ANOTHEROBJECT") or
(name == "YETANOTHEROBJECT") then
--make sure the player hasn't died already
local unit = GetCharacterUnit( killer )
if not unit then return end

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

--drop a time bomb directly on the unit
CreateEntity("fun_weap_inf_timebomb_ord", point, "fun_weap_inf_timebomb_ord")
end
end
)
*Note to people of the world*
This requires you to make (or copy from assets...) your own timebomb ordnance and place it somewhere in the world so it will spawn when you execute this command.
Look in the REP assets and the COMMON assets to find the files
User avatar
Firefang
Major
Major
Posts: 518
Joined: Mon Nov 15, 2010 8:55 pm
Location: California

Re: The fun .LUA commands thread

Post by Firefang »

TK432 wrote:Beat this! :)
I challenge thee!

Here is the script to my unfinished disguise kit work around
video
Just change the variables according to you map and make sure that all the changes are loaded. Thats it. Keep in mind that this doesn't support skeleton changes, but won't crash if it isn't the proper skeleton and this isn't finished so yes the enemy will still shoot you.
Beta Disguise

Code: Select all

--beginning of variables
Disguise = "msh you will turn into"
Original = "original msh"
Unit = "unit with weapon"
Changeweapon = "change_ord"
Change = 1
Unchange = 0
Team = TEAMNAME (three letter team)
--end of variables
ChangeTimer = CreateTimer("ChangeTimer")
SetTimerValue(ChangeTimer, 2)

Changebody = OnCharacterDispenseControllable(
	function(player,controllable)
	if GetEntityClass(controllable) == GetEntityClassPtr(Changeweapon) and IsCharacterHuman(player) and Change == 1 then
	AllowAISpawn(Team, false)
	SetClassProperty( Unit, "GeometryName", Disguise)
	spot = GetEntityMatrix(GetCharacterUnit(player))
	KillObject( GetCharacterUnit(player) )     
	AddReinforcements(Team, 1 )
	SelectCharacterClass(player,Unit)
	SpawnCharacter(player, spot)
	SetClassProperty( Unit, "GeometryName", Original)
	AllowAISpawn(Team, true)
	print("Change Complete")
	Unchange = 1
	Change = 0
      end
     end
)
Unchangebody = OnCharacterDispenseControllable(
	function(player,controllable)
	if GetEntityClass(controllable) == GetEntityClassPtr(Changeweapon) and IsCharacterHuman(player) and Unchange == 1 then
	spot = GetEntityMatrix(GetCharacterUnit(player))
	KillObject( GetCharacterUnit(player) )     
	AddReinforcements(Team, 1 )
	SelectCharacterClass(player,Unit)
	SpawnCharacter(player, spot)
	print("Change Back Complete")
	Unchange = 0
	StartTimer(ChangeTimer)

      end
     end
)

    Timer = OnTimerElapse(
    	function(timer)
	Change = 1
DestroyTimer(ChangeTimer)
    	end,
    	ChangeTimer
    	)
And you will have to add this weapon to your unit:
Weapon
Hidden/Spoiler:
[WeaponClass]
ClassLabel = "remote"

[Properties]
//IconTexture = "HUD_com_probedroid_health_icon"

MuzzleFlash = "small_muzzle_flash"
Discharge = "small_smoke_effect"

RoundsPerClip = "0"
ReloadTime = "0.0"
LockOnRange = "80.0"
LockTime = "0.4"

HeatPerShot = "0.0"
HeatRecoverRate = "0.05"

ZoomMin = "0.0"
ZoomMax = "0.0"
ZoomRate = "0.0"

//AnimationBank = "grenade"
OffhandWeapon = 1

SwitchImmediately = "0"

FireAnim = "1"
InstantPlayFireAnim = "1"

ShotDelay = "2.0"
MinSpread = "0.0"
MaxSpread = "0.0"
AutoAimSize = "1.0"

SalvoCount = "1"
SalvoDelay = "0.0"
InitialSalvoDelay = "0.3"

FireSound = "com_weap_inf_remotedroid_fire"
FireEmptySound = "com_weap_inf_ammo_empty"

OrdnanceName = "change_ord"
Ord (be sure you name it change_ord or you will have to change it in the script and lua
Hidden/Spoiler:
[GameObjectClass]
ClassLabel = "droid"
GeometryName = "com_weap_probedroid.msh"

[Properties]
//ExplosionName = "all_weap_inf_remotedroid_exp1"
GeometryName = "com_weap_probedroid"
ImpactEffectWater = "com_sfx_watersplash_ord"

FLYERSECTION = "BODY"
VehicleType = "light"

PilotType = "remote"

MapTexture = "troop_icon"
HealthTexture = "HUD_com_probedroid_health_icon"
MapScale = 1.0

MapViewMin = 50
MapViewMax = 50
MapSpeedMin = 0
MapSpeedMax = 100

CollisionScale = 10.0

MaxHealth = 100.0
AddHealth = -1.0

EnergyAutoRestore = -99999.9

SetAltitude = 2000.0
GravityScale = 1.0//2
LiftSpring = 10.0 //10Lighter the veh the high the number
LiftDamp = 3.0

ScanningRange = 30.0
TransmitRange = 300.0

Acceleration = 25.0
Deceleration = 3.0
Traction = 22.0
ForwardSpeed = 3.5
ReverseSpeed = 3.5
StrafeSpeed = 0.25

SpinRate = 1.5
TurnRate = 1.5
TurnFilter = 5.0
PitchRate = 2.0
PitchFilter = 5.0
BankAngle = 0.0
BankFilter = 0

MoveTension = "30.0"//how much swim the craft has from the center of the screen


LevelSpring = 5.0
LevelDamp = 3.0

EyePointOffset = "0.0 0.5 0.0"
TrackOffset = "0.0 -0.25 1.8"
TiltValue = "5.0"

DestructTrackOffset = "0.0 0.0 18.0"
DestructTiltValue = "10.0"
DestructChargeEffect = "com_sfx_weap_remotedroidcharge2"

PitchLimits = "-50.0 50.0"
YawLimits = "-0.0 0.0"
AimerPitchLimits = "-90 90"
AimerYawLimits = "-90 90"

WEAPONSECTION = 1
WeaponName = "com_weap_null"
WeaponAmmo = 0
WeaponChannel = 0

AISizeType = "SOLDIER"

AmbientSound = "remotedroid_engine_lp"
Ambient2Sound = "remotedroid_radio"
HurtSound = ""
DeathSound = ""

\\\\\\\\\\\\ Collision \\\\\\\\\\\\\\

BuildingCollision = "p_buildingsphere"
VehicleCollision = "p_buildingsphere"
OrdnanceCollision = "p_sphere"
SoldierCollision = "p_sphere"
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: The fun .LUA commands thread

Post by DarthD.U.C.K. »

wow, that really cool!
i couldnt resist trying to elaborate/extend it a bit:
Hidden/Spoiler:
[code]
--Above ScriptPostLoad
DisguiseATT= 3
DisguiseDEF= 4

--In ScriptInit
SetTeamAsFriend(ATT,3)
SetTeamAsFriend(3,ATT)
SetTeamAsNeutral(DEF,3)
SetTeamAsEnemy(3,DEF)

SetTeamAsFriend(ATT,4)
SetTeamAsFriend(4,ATT)
SetTeamAsNeutral(DEF,4)
SetTeamAsEnemy(4,DEF)

--beginning of variables
Disguise = "msh you will turn into"
Original = "original msh"
Unit = "unit with weapon"
Changeweapon = "change_ord"
Disguised = false
Player = "Character that is using Disguisekit"
--Team = TEAMNAME (three letter team)

--Timer for Change
ChangeTimer = CreateTimer("ChangeTimer")
SetTimerValue(ChangeTimer, 20)
--When timer elapses the change is reset
OnTimerElapse(
function(timer)
if Disguised == true then
spot = GetEntityMatrix(GetCharacterUnit(Player))
Health = GetObjectHealth(GetEntityName(Player))
if GetCharacterTeam(player) == DisguiseATT then
SelectCharacterTeam(player, ATT);
SetTeamAsNeutral(DEF,3)
elseif GetCharacterTeam(player) == DisguiseDEF then
SelectCharacterTeam(player, DEF);
SetTeamAsNeutral(ATT,4)
end
SetProperty(GetEntityName(player), "IsVisible", "0")
KillObject(GetCharacterUnit(Player))
AddReinforcements(Team, 1 )
SelectCharacterClass(Player,Unit)
SpawnCharacter(player, spot)
SetProperty(GetEntityName(player), "IsVisible", "1")
SetProperty(GetEntityName(Player), "CurHealth", Health)
print("Change Back Complete")
Disguised = false
ShowTimer(nil)
DestroyTimer(ChangeTimer)
end
end,
ChangeTimer
)

Changebody = OnCharacterDispenseControllable(
function(player,controllable)
if GetEntityClass(controllable) == GetEntityClassPtr(Changeweapon) and IsCharacterHuman(player) and Disguised == false then
Player = player
AllowAISpawn(Team, false)
SetClassProperty(Unit, "GeometryName", Disguise)
spot = GetEntityMatrix(GetCharacterUnit(player))
Health = GetObjectHealth(GetEntityName(player))
AddReinforcements(GetCharacterTeam(player), 1 )
if GetCharacterTeam(player) == ATT then
SelectCharacterTeam(player, DisguiseATT);
elseif GetCharacterTeam(player) == DEF then
SelectCharacterTeam(player, DisguiseDEF);
end
SetProperty(GetEntityName(player), "IsVisible", "0") --this *should* make the character invisible so you dont see the dead body
KillObject(GetCharacterUnit(player))
SelectCharacterClass(player,Unit)
SpawnCharacter(player, spot)
SetProperty(GetEntityName(player), "IsVisible", "1")
SetProperty(GetEntityName(player), "CurHealth", Health)
SetClassProperty(Unit, "GeometryName", Original)
AllowAISpawn(Team, true)
print("Change Complete")
Disguised = true
StartTimer(ChangeTimer)
ShowTimer(ChangeTimer)
end
end
)

--Checks whether disguised character was killed and resets timer
OnCharacterDeath(
function (character, killer)
if GetCharacterTeam(character) == DisguiseATT and Disguised == true then
Disguised = false
SetTeamAsNeutral(DEF,3)
ShowTimer(nil)
DestroyTimer(ChangeTimer)
elseif GetCharacterTeam(character) == DisguiseDEF and Disguised == true then
Disguised = false
SetTeamAsNeutralATT,4)
ShowTimer(nil)
DestroyTimer(ChangeTimer)
elseif GetCharacterTeam(killer) == DisguiseATT and GetCharacterTeam(character) == DEF then
SetTeamAsEnemy(DEF,3)
elseif GetCharacterTeam(killer) == DisguiseDEF and GetCharacterTeam(character) == ATT then
SetTeamAsEnemy(ATT,4)
end
end
)
[/code]
it disguises the unit for the time of changetimer. its supposed to put the character in another team neutral to the enemyteam when used. when disguised it should also give him the health he had before disguising and the other way around.
edit: i changed it a bit so the enemyteam starts attacking you once you killed one of them.

i havent tested it however, its rather hypothetical. the things im not sure about is whether you use a characters name as input for setproperty, if the parameters for selectteam are correct and if the "player"-variableof the character changes during gameplay
Last edited by DarthD.U.C.K. on Sat Mar 26, 2011 10:28 am, edited 3 times in total.
THEWULFMAN
Space Ranger
Posts: 5557
Joined: Tue Aug 17, 2010 3:30 pm
Projects :: Evolved 2
Location: Columbus, Ohio
Contact:

Re: The fun .LUA commands thread

Post by THEWULFMAN »

I Have to test this :shock:

Ok guys, AQT couldnt figure out my code, and mine, well, doesnt work as functioned :cpu:

I tryed making a code(it so didnt work right, but did give me intersting unwanted results) for when a weapon ord hits you(or an AI enemy more like it)the player or ai switches teams. Since this is suppossed to be a mind trick weapon, it will prob not be used on a human player much. Unless you have AI heroes like I do.

My question is this, Is this even possible?

This isnt really offtopic is it? I figured we could try to come up with more fun lua commands as well.
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: The fun .LUA commands thread

Post by Fiodis »

THEWULFMAN wrote:I tryed making a code(it so didnt work right, but did give me intersting unwanted results) for when a weapon ord hits you(or an AI enemy more like it)the player or ai switches teams.

My question is this, Is this even possible?
Yep; let me see if I can drag up my old code....

EDIT - couldn't find it, so I'll just throw this together:

Code: Select all

OnObjectDamage(
function(object, damager)
if GetObjectLastHitWeaponClass(object) == "weapon_odf" then -- weapon_odf is the odf name of the weapon, not the ord
-- You can also add an aditional check (IsCharacterHuman) if you only want this to work/not work on humans.
SetObjectTeam(object, #) -- # is the number of the team to be set to
end
end
)
That's the basic form. You can experiment (add timer, check to see which team the object is on, whatever) if you like.

You know, about a year ago I started putting together a LUA asset pack; essentially a bunch of custom scripts to do various things. I'll try and salvage them from the wreckage of my USB and post here what I get from it.
THEWULFMAN
Space Ranger
Posts: 5557
Joined: Tue Aug 17, 2010 3:30 pm
Projects :: Evolved 2
Location: Columbus, Ohio
Contact:

Re: The fun .LUA commands thread

Post by THEWULFMAN »

:shock: Ok, sweet, I will combine that with my scripts timer and stuff


I think its time to prove the all mighty power of lua. :P :wink: And make it easy for people to use it.
Last edited by THEWULFMAN on Sat Mar 26, 2011 1:46 pm, edited 1 time in total.
Post Reply