if GetEntityClass(powerup) == GetEntityClassPtr(CommandRes) then
ClearAIGoals(ATT)
elseif GetEntityClass(powerup) == GetEntityClassPtr(CommandDef) then
AddAIGoal(ATT, "Defend", 500)
elseif GetEntityClass(powerup) == GetEntityClassPtr(CommandDes) then
AddAIGoal(ATT, "Destroy", 500)
elseif GetEntityClass(powerup) == GetEntityClassPtr(CommandDM) then
AddAIGoal(ATT, "Deathmatch", 500)
elseif GetEntityClass(powerup) == GetEntityClassPtr(CommandCon) then
AddAIGoal(ATT, "Conquest", 500)
elseif GetEntityClass(powerup) == GetEntityClassPtr(Toggle) then
if command == 0 then
SetProperty("rep_inf_ep3_commander", "WeaponName4", "Command_Deathmatch")
command = 1;
elseif command == 1 then
SetProperty("rep_inf_ep3_commander", "WeaponName4", "Command_Defend")
command = 2;
elseif command == 2 then
SetProperty("rep_inf_ep3_commander", "WeaponName4", "Command_Destroy")
command = 3;
elseif command == 3 then
SetProperty("rep_inf_ep3_commander", "WeaponName4", "Command_Reset")
command = 4;
else
SetProperty("rep_inf_ep3_commander", "WeaponName4", "Command_Conquest")
command = 0;
end
end
end
)
This is snip-bits of code i found else where on gt edited and added to try to get what im going for (im no LUA master )
I have a toggle weapon that will toggle commands so i can have more then 4, but this isnt what im concerned with.
The problem is when i use the powerup item that's suppose to trigger the aigoal, the game crashes (it does with the toggle weapon too).
Re: Help w/ LUA aigoal seting weapon
Posted: Mon Jul 07, 2008 10:47 pm
by RepSharpshooter
I'm no lua master either, but I thought zerted told me that SetProperty is for a specific instance of a unit whereas SetClassProperty affects the entire class such as rep_inf_ep3_commander
Re: Help w/ LUA aigoal seting weapon
Posted: Mon Jul 07, 2008 11:54 pm
by MasterSaitek009
Yeah your right Rep'. SetProperty is for instance properties like health. SetClassProperty will work for anything that carries over across classes, like weapons and anim sets.
Re: Help w/ LUA aigoal seting weapon
Posted: Tue Jul 08, 2008 12:37 am
by [RDH]Zerted
Yes you should be using SetClassProperty(), which also means that anyone using that class+weapon will change it for every other unit of that class. In addition to that, messing with weapon properties and weapon 'layouts' normally cause crashing when used online. You should test your idea with multiple players before releasing the map its in. One more thing, I think the max amount of AI goals is 7 (maybe 9, I forget...). Once you go over that, the game crashes.
Your weapon could work, but unless its for SP only, you need to rethink your toggle idea.
It should be crashing with something in the error log. Whats in it?
Re: Help w/ LUA aigoal seting weapon
Posted: Tue Jul 08, 2008 7:54 pm
by Syth
Again the toggle idea was just kinda added on a whim and i know about the its current draw backs.
So there is a limit on AI goals? e.g. you could only add the goal "conquest" added so many times?
I could just make it each time a goal is issued any other goals are cleared. While on the subject of aigoals, what does the number following the goal mean?
EDIT2: Okay i doofed. Apparently i made some change in the dispenser's odf that caused a crash. Whatever.. it works now at least.
Re: Help w/ LUA aigoal seting weapon
Posted: Tue Jul 08, 2008 11:43 pm
by [RDH]Zerted
Yes, there is an AI goal limit. One thing you can do is store and delete the last AI goal the weapon set. AddAIGoal() returns the added goal then you can use RemoveAIGoal() on it. Something like:
if storedGunGoal then
RemoveAIGoal( storedGunGoal )
end
storedGunGoal = AddAIGoal()
would would keep the AI goal count down. The number is the percentage of AI that should follow the goal. Its based off the max value, so a value of 500 doesn't mean 500%. If you do AddAIGoal( XXX, 500 ) and AddAIGoal( xxx, 1000 ), then 500 means 1/3 of the total AI bots (500 is one third of 1500).