Messing around with shields


(GOLIATH Mod) #1

Is the size of the displayed sphere of the shield defined in the model? The effects are changing size, but not the ball that you can see. I’ve only been messing with the Taiidan one so far.


(Taiidan Republic Mod) #2

I do have the answer to this, but I need to look it up. I might be able to do that tomorrow… Nudge me if I forget…


(GOLIATH Mod) #3

ok cool - thanks


(Nathanius) #4

Have a read of this :wink:


(Taiidan Republic Mod) #5

hmmm, I just did this:

    event14 =
    {
        { "anim", "On" },
        { "animtime", "-1" },
        { "marker", "root" },
        { "sound", "SP_ELEMENTS/HGN_DEFENSEFIELDFRIGATE_ON" },
		{ "fx", "defensefield_sphere_spray" },
		{ "fx_scale", "1200" },
    },

But are you saying that doesn’t actually work? It just changes the fx without making the shield physically bigger?


(GOLIATH Mod) #6

AH!

I didn’t see that. I was just altering the values in the .ship file. I’ll check it out. Thanks!

I’m also going to have to turn the shields on somehow… gonna have another look at the shields in Continum again. I still don’t really get it. I also found a list of the modifiable values here: http://hw2bsg.org/wiki.hw2.info/ModifiableValues.html


(Nathanius) #7

The defense field FX are defined in the *.event file and the actual physical size of the sphere is defined in the *.ship file. The two work together.

We tried playing with the defense field for Trek shields I recall, but the different shapes we needed, coupled with the fact that the shield doesn’t rotate with the ship at all, made it not helpful for our purposes


(GOLIATH Mod) #8

I would be totally fine with the bubbles.

Changing the FX size totally works.

Ah, I was just about to ask where the shield effects are set for the Hiigaran field, but I realized they’re in the weapon files. Then the magnetic fields are set in the ship file. OK.

Any ideas on how the shield could be activated by an upgrade in the research tree?

‘MaxShield’ is the list from above, but then the button would be there all the time.


(Nathanius) #9

Combine a research item with this:

http://hw2bsg.org/wiki.hw2.info/FunctionSobGroup_AbilityActivate.html


(GOLIATH Mod) #10

Thanks. I see those sobgroups all over the place in the lua’s but I’ve never messed with them.

I guess SOB doesn’t mean what I’ thinking it means, right? haha

I tried this in the ability_upgrades.lua but it made it so that nothing out of that file was read:

	{
		Name =					"DefenseFieldon",
		RequiredResearch =		"",
		RequiredSubSystems =		"Research | AdvancedResearch & FrigateProduction",
		Cost = 					10,
		Time = 					10,
		DisplayedName =			"turn shield on",
		DisplayPriority =		29,
		Description =			"lets see if it works, yo",
		UpgradeType =			Ability,
		TargetType =			Ship,
		TargetName =			"Hgn_DefenseFieldFrigate",
		UpgradeType =			Ability,
		UpgradeName =			"SobGroup_AbilityActivate("Player_Ships<iPlayer>", AB_DefenseField, 1)",
		Icon = 				Icon_Ability,
		ShortDisplayedName = 		"shield on",
	},

I turned the function of the shield off in the .ship file, which I guess is the first step to getting the shields to be switched on in the game at some point. (Once the non-functional research item above is fixed somehow) However a non-bullet-stopping-bubble can still be turned on with the activation button and the button is also still visible. Weird, right? Okay, the button being available before the ability is active is different from the other abilities, but maybe they set the shields up differently than the other abilities.

Another big problem as I see it is the bubble fx in the .events file. Can the SOBgroup commands turn that on and off? Because if not, then a subsystem is probably the way to go for us as well.

There’s also plan B: Just make a couple more levels of extravagantly expensive armor upgrades. haha But even with that it would be cool if the ships had an effect, like being more shiny or having little wavy lines coming off it. Which gets back to the issue of switching an effect in the events file on or off. (I think)

Any ideas?


(Taiidan Republic Mod) #11

I think you would need to use custom code:

Basically custom code is a special script that runs for a specific ship.

Don’t worry about the event fx - it is linked to the ability, so the fx will not appear of the ability is switched off.


(Taiidan Republic Mod) #12

To elaborate, I think what you would need is something like this in the custom code of your ship:

if Player_HasResearch(playerID, "PlasmaBombs")==1 then
    SobGroup_AbilityActivate(customGroup, AB_DefenseField, 1)
else
    SobGroup_AbilityActivate(customGroup, AB_DefenseField, 0)
end

…where “playerID” is an integer of the player id and “customGroup” is the group itself. These variables are already passed to custom code as arguments normally.


(GOLIATH Mod) #13

I think the sob groups need to be set somewhere as well. Where does that go, in the gbx.lua maybe?

Also, are the effects linked to the ability in the model? Because I actually want to add the shields to the ships that don’t have them, and the models can’t be changed.


(Taiidan Republic Mod) #14

Ok, here is a little tutorial on custom code to help you:

We are going to make Hiigaran Defense Field frigates shield ability dependant on plasma bomb research…

1) Custom code file

Create a file called hgn_defensefieldfrigate.lua in data/ship/hgn_defensefieldfrigate/

This is the content of the file:

function Update_DefFieldFrigate(CustomGroup, playerIndex, shipID)
    if Player_HasResearch(playerIndex, "PlasmaBombs")==1 then
        SobGroup_AbilityActivate(CustomGroup, AB_DefenseField, 1)
    else
        SobGroup_AbilityActivate(CustomGroup, AB_DefenseField, 0)
    end
end

Basically, it checks if the player (playerIndex) owning the ship (CustomGroup) has plasma bomb research. If yes, this ship’s ability AB_DefenseField is enabled. If no, it is disabled.

2) Ship file

In hgn_defensefieldfrigate.ship, add the following line somewhere before LoadModel(NewShipType,1):

addCustomCode(NewShipType,"data:Ship/hgn_defensefieldfrigate/hgn_defensefieldfrigate.lua","","","Update_DefFieldFrigate","","hgn_defensefieldfrigate",2)

The arguments of addCustomCode() are:

  • NewShipType
  • string, path to the script (the script we created above)
  • string, function called on loading the ship files (not needed in our case)
  • string, function called on ship creation (not needed in our case)
  • string, function called on ship update (we use this, the arguments automatically passed to the function are player ID, sobgroup, ship ID)
  • string, function called on ship death (not needed in our case)
  • string, name of the group(?), I have never used this…
  • float, update frequency

This line makes the link to our new script file and tells the game to call the update function for this ship every 2 seconds.


Try the above. If it works, you can adjust it for your application.


(GOLIATH Mod) #15

WOAH.

You guys are taking it to the next level, man.

Cool, thanks! I’ll try it out tonight.

How do you know all this stuff, do you do this for work?


(Taiidan Republic Mod) #16

ok, it doesn’t seem to be working… :frowning: There is special something about AB_DefenseField that does not behave like the standard abilities. I tried AB_DefenseFieldShield as well, but the frigate still has the ability…

With AB_Move, it successfully removes the ability to move the ship until the research is available.


(Taiidan Republic Mod) #17

ok, I got it!

  1. You need to comment out the following line in hgn_defensefieldfrigate.ship:
--AddShipAbility(NewShipType,"DefenseField",1,"ThisShipOnly",0);

The reasons for this are quite complicated, but basically that line is unnecessary.

  1. Use this as the content of hgn_defensefieldfrigate.lua:
function Update_DefFieldFrigate(CustomGroup, playerIndex, shipID)
	if (Player_HasResearch(playerIndex, "ScoutPingAbility")==1) then
		SobGroup_AbilityActivate(CustomGroup, AB_DefenseField, 1)
		SobGroup_AbilityActivate(CustomGroup, AB_DefenseFieldShield, 1)
	else
		SobGroup_AbilityActivate(CustomGroup, AB_DefenseField, 0)
		SobGroup_AbilityActivate(CustomGroup, AB_DefenseFieldShield, 0)
	end
end
  1. Add this line to hgn_defensefieldfrigate.ship before the LoadModel bit:
addCustomCode(NewShipType,"data:Ship/hgn_defensefieldfrigate/hgn_defensefieldfrigate.lua","","","Update_DefFieldFrigate","","hgn_defensefieldfrigate",2)

[TUTORIAL] Simple Custom Code
(Nathanius) #18

Thank you @Dom2 for elaborating on my far too brief earlier response :sweat_smile:


(GOLIATH Mod) #19

Thanks for the help you guys!

I tried entering everything in as you described, but the shields don’t get turned on by the research.

Is there something that you didn’t specifically state maybe, something that you think is so obvious, that you don’t need to put it in? haha (I seriously have no idea what I’m doing, for me modding is kind of like doing a giant jigsaw puzzle)

If you like, you guys can send me a friend request on steam, there’s a private Goliath tester mod where you can have a look at my files.

I have to say though, after I entered all this stuff in, the game pauses for a second at start up. Is anything like this in the game itself? I don’t want to add anything in that causes instability in multiplayer or problems with saving.


(Taiidan Republic Mod) #20

Did you get it working for the hiigaran defense field frigate or did that not work?