Weapons for each team?
Sun, 2016-01-17 00:51
It is possible to do this in game, or need to be added/marked as a new feature for future updates, is need to be, to allow properly setup weapons in missions.
It is possible to do this in game, or need to be added/marked as a new feature for future updates, is need to be, to allow properly setup weapons in missions.
I guess it's possibly by adding ammo to a hedgehog of that team?
Similar like highlander and other scripts do - just with PerHogAmmo not being turned on of course.
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Wait, what? I don't understand what you want.
Per-team weapons are already the default in Hedgewars.
Just don't turn on per-hog ammo in the game scheme.
Hi, I am a Hedgewars developer.
I think he meant that not all teams start with the same weaponset.
But e.g. that one team plays defender and one the attacker, or something.
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Yes, i want to allow config this by default in the mission script, what should i do??
Hai
I don't really know what you want to do, but i think you want what i kinda did in continental supplies (and some of my other scripts). However as i see it, i guess you want to be more team specific.
Below im posting some code that may be to some use.
declare a global vector for each team,clan whatever:
local setFirstTurn = {}
In onNewTurn() add:
if(setFirstTurn[GetHogTeamName(CurrentHedgehog)]==nil and GetHogTeamName(CurrentHedgehog) == "whatever team name") -- you could use GetClanColor(), GetHogClan() if you want that instead
then
-- dont remember if these lines are needed, but I put them there anyways. They are used to refresh all weapons before adding the ones you want.
AddAmmo(CurrentHedgehog,weapon1,0)
AddAmmo(CurrentHedgehog,weapon2,0)
AddAmmo(CurrentHedgehog,weapon3,0)
... all weapons except skip turn ...
AddAmmo(CurrentHedgehog,weapon1,amount)
AddAmmo(CurrentHedgehog,weapon2,amount)
AddAmmo(CurrentHedgehog,weapon3,amount)
...
setFirstTurn[GetHogTeamName(CurrentHedgehog)] = true
end
This could of course be improved, for example by using the tracker and by using an array to declare all weapons you may want to use.
Vattenania, my beloved motherland, my beloved homeland! You are always with me in my thoughts and in my heart!
Wow, so impressive line of code, but there is not native function for doing that, SetAmmo should also considerer the HogTeam to which should be preset ammo values.
What is the tracker?
The tracker is pretty much an array that store gears of some kind.
In this case it could be used to make the impression of giving out the weapons from the start to all teams.
From what i meant in the previous post, it could be used like this:
in your script add:
Vattenania, my beloved motherland, my beloved homeland! You are always with me in my thoughts and in my heart!
Thanks for the code snippet, but i really dont want to use all that only to achieve it by doing missions, there should be a way in the lua functions to do this easy way, something like SetAmmo(Team,Ammo,value,delay)
Here a working example script of what I meant earlier.
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
That should work, but is not being really useful, because i need to predefine local for each hog, to allow have ammo for them, or maybe could i repeat same variable in each team?
Using a local for ONE hog per team is just the easiest way to do it if you know how which teams there will be, because the script defines them.
If you do not know all the teams in advance, you could probably detect them and add weapons as needed.
E.g. giving all AI teams specific weapons and all player teams different ones.
If that's useful to you, I'll see if I can come up with a script that does that.
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Yes, thats is a good example of what i want to achieve, i do not need extra script, but if you can post it will be cool for testing purposes..
Because OnNewAmmoStore is currently lacking supporting functions, I decided to just give hogs 0 amSkip and check if the current hog has no ammo yet when each turns begins.
If that's the case, then some code can be used to dynamically decide what ammo to give (here: Players get different weapons than AI).
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Interesting code snippet, GetHogLevel check if CurrentHedgehog is a bot? skip need to be assigned as infinite?
Yes @ GetHogLevel. It gives the level of the bot. 0 means human player. Look it up in the LuaAPI for more details.
I don't think skip has to be set to infinite, that was just an example chosen by me. Because usually you always want players to be able to skip.
PS: That was not just a "code snippet" by the way. It's a fully functional multiplayer gamestyle/script example. I tested/played it ;p
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Yes, no problem, the functional game style will not be the firts script you showed, that has locale defined?, the second one is not missing something??
The second one isn't missing anything to run as multi-player script, except for a .cfg file of the same name to set default scheme/weapons (see other .cfg files in /Data/Scripts/Multiplayer/ ).
My test.cfg was:
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Ok, no problem, code is working good, right now i can easy implement it into the Mission Editor, using AddAmmo function.