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.
Re: The fun .LUA commands thread
Posted: Thu Mar 24, 2011 2:35 pm
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.
Re: The fun .LUA commands thread
Posted: Thu Mar 24, 2011 3:11 pm
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?
Re: The fun .LUA commands thread
Posted: Thu Mar 24, 2011 3:22 pm
by DarthD.U.C.K.
i dont know about the details, i just found it out by accident once.
Re: The fun .LUA commands thread
Posted: Thu Mar 24, 2011 3:30 pm
by THEWULFMAN
Fiodis wrote:
DarthD.U.C.K. wrote:Wait; if that were true, couldn't you use that for smoother weapon pickups?
Could it be
Re: The fun .LUA commands thread
Posted: Thu Mar 24, 2011 5:29 pm
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?
Re: The fun .LUA commands thread
Posted: Thu Mar 24, 2011 6:11 pm
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!
Re: The fun .LUA commands thread
Posted: Thu Mar 24, 2011 8:43 pm
by Fiodis
Ah. I'll take an educated guess and say it won't work with every odf property.
Pity. Would've been fun.
Re: The fun .LUA commands thread
Posted: Thu Mar 24, 2011 9:22 pm
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)
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
Re: The fun .LUA commands thread
Posted: Fri Mar 25, 2011 11:22 pm
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
--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
Re: The fun .LUA commands thread
Posted: Sat Mar 26, 2011 9:17 am
by THEWULFMAN
I Have to test this
Ok guys, AQT couldnt figure out my code, and mine, well, doesnt work as functioned
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.
Re: The fun .LUA commands thread
Posted: Sat Mar 26, 2011 9:20 am
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:
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.
Re: The fun .LUA commands thread
Posted: Sat Mar 26, 2011 10:33 am
by THEWULFMAN
Ok, sweet, I will combine that with my scripts timer and stuff
I think its time to prove the all mighty power of lua. And make it easy for people to use it.