I know switching weapons through a lua command is not possible when the player is still alive nor rechanging the unit at any command post.
I used this code after an Objective is done, but the weapons don't switch:
SetClassProperty("all_inf_survive1", "WeaponName2", all_weap_inf_rifle)
and
SetProperty("all_inf_survive1", "WeaponName2", all_weap_inf_rifle)
He first carries a pistol. Then after surviving two waves of enemies he should receive a rifle. Only if he respawns or spawing again at any CP.
But the weapon doesn't switch.
WeaponName is currently a fusion-cutter (named as Slot2).
I hope you can help me out with this.
Re: Switching Weapons through .lua
Posted: Thu Nov 26, 2015 11:55 pm
by Noobasaurus
Have you tried enclosing the weapon name in quotation marks, like so?
onfirstspawn = OnCharacterSpawn(
function(character)
if character == 0 then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
BeginObjectivesTimer()
ScriptCB_EnableCommandPostVO(0)
ScriptCB_PlayInGameMusic("imp_dea_immVict_01")
end
end)
--Objecive 1 - Survive First Wave of Enemies
--Kill a bunch of Stormtroopers
---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------
SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo
This fixed it. But I am going to use weapons "borrowed" by the empire.
[RDH]Zerted wrote:
If you're changing weapon properties the map won't work online. Keep that in mind. Don't add it to the MP mission selection list in your addme.lua.
I will look what can be done for online compatibilty.
Thanks for all the replies. I still have some questions about mission scripting.
1. Currently I am working on a wave mode and the other team (enemies) have to kill the player (That's me). I used the "Deathmatch" AI goal, but the bots are mostly running away (when they are far away). Their goal is to kill me (=They have to walk to my current location and must kill me).
But they now just stands and don't do anything. They don't even react when I shoot them.
I think it's because of "ATT". What's the name of all (Or only me) human players. So their goal is to kill all humans in Team ATT (ALLiance).
2. This is a question about limitaions. How many objectives can I put into one single campain. I plan to do a further project with a long storyline. And I was curious about the total amount of working objectives.
My theory: File size. Maybe there's a maximum of KB's. Like the 16mb limit for textures. But I might be wrong.
Thank you for helping me.
Re: Switching Weapons through .lua [Solved]
Posted: Fri Nov 27, 2015 8:46 pm
by [RDH]Zerted
The topic has been labeled solved so I assume you got #1 working. As for #2, I don't think there's a limit to the number of objectives. If the objectives are running one at a time then there shouldn't be a limit. If you're trying to run a bunch of objectives at the same time then you'll have the issue of there only being so many AI goals allowed. I don't know the limit off hand, but it's in the FAQ's SWBF2 limitations topic. You can delete AI goals when they're no longer needed, but you can't have more goals active than you're allowed.