Mod Question Repository... Questions come in, answers go out - Page 25

Mod Question Repository... Questions come in, answers go out

Resources to get you going on your new project, or to help you over some emergent problems during your development cycle.

Moderator: Moderators

Locked
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Mod Question Repository... Questions come in, answers go out

Post by KDR_11k »

I mean, is it an empty piece, a single vertex, two vertices or more? The piece might contain vertices that describe a zero vector.
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: Mod Question Repository... Questions come in, answers go out

Post by Evil4Zerggin »

Ah, that must be it then. After moving the fire point to a different piece it seemed to work as desired (except for firing from a different place that I wanted to, but that's to be expected). Thanks!

Now I have to figure out how to add fire pieces that do work... unfortunately I don't know anything about modeling.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

okay looking for away other than on/off (since on off is toggling the unit from movable to deployed) to choose between 2 weapons, only one or the other, besides fancy lua, got any idea?
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: Mod Question Repository... Questions come in, answers go out

Post by Pressure Line »

manual toggle? or an automatic system? ie tank has only a light laser gun while moving, when stopped it allows its big cannon to fire. that is doable in cob
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

no it will be stopped when 'on' is engaged because that deploys it to attack, versus non attackable via moving. so the switch can not use the on/off or moving true to differentiate between the 2 weapon types..
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Mod Question Repository... Questions come in, answers go out

Post by KDR_11k »

Within a gadget:

Code: Select all

CMD_WEAPON = 33319
desc = {
	name="Change Weapon", --button label
	type=CMDTYPE.ICON, --a button that activates when clicked on
	id=CMD_WEAPON,
	action="changeweapon"
}

--For new units
function gadget:UnitCreated(u,ud,defs)
	if UnitDefs[ud].customParams.canchangeweapon == "1" then
		Spring.InsertCmdDesc(u, desc) --add the command to the unit's list
	end
end

--Blocks commands that are invalid
function gadget:AllowCommand(u,ud,team,cmd,param,opt)
	if cmd == CMD_WEAPON then
		return UnitDefs[ud].customParams.canchangeweapon == "1" --makes sure CMD_WEAPPON can only be given to units that can change their weapon
	end
	return true
end

--Handles custom commands
function gadget:CommandFallback(u,ud,team,cmd,param,opt)
	if cmd == CMD_WEAPON then
		Spring.CallCOBScript(u, "ChangeWeapon", 0) --calls this COB function
		return true, true
	end
	return false
end
This creates a button that calls the COB function "ChangeWeapon()" when clicked. I'm sure it's possible to make this use a toggle button instead of a simple click button but I have no experience with those.

The button only appears for units with

Code: Select all

[customParams] {
    canChangeWeapon=1;
}
in the fbi.
User avatar
Abokasee
Posts: 222
Joined: 03 Nov 2006, 21:51

Re: Mod Question Repository... Questions come in, answers go out

Post by Abokasee »

Is there a way... to make a beam that fires constantly (like the beamer turret) to keep firing when sweep to another target?
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Re: Mod Question Repository... Questions come in, answers go out

Post by [Krogoth86] »

Try sweepfire=1 ... :wink:
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Mod Question Repository... Questions come in, answers go out

Post by Argh »

The last time I tested, Sweepfire had some issues. Mainly, it seems to change targets without calling AimWeapon() again, so the beam goes in wonky directions. May have been fixed since I last messed with it, though, give it a try.
User avatar
Abokasee
Posts: 222
Joined: 03 Nov 2006, 21:51

Re: Mod Question Repository... Questions come in, answers go out

Post by Abokasee »

Yeah when they try to target something behind another unit, they go a bit mad, but other wise fine (targeterror was turned off)
Ba-
Posts: 16
Joined: 09 Jan 2008, 23:16

Re: Mod Question Repository... Questions come in, answers go out

Post by Ba- »

Wondering about shields... Apparantly some binary or something or other allows shields to block certain weapons.. anyway, I was wondering, a. is it possible to have more than one 'shield' per unit. b. Is it possible to forcibly turn shields on or off via script (and have there be no on/off option in gui - onoffable=0?) c. are shields technically weapons?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Mod Question Repository... Questions come in, answers go out

Post by Argh »

A. Yes, so far as I know, there are no limits on the number of Shields a Unit may have. Keep in mind they're fairly CPU-intensive, though.

B. Yes. See the Changelog for details. You could either use Activate() or a separate LUA button via the UI to control it.

C. Only in the broadest sense of the word. They don't call aiming conditions, etc.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Mod Question Repository... Questions come in, answers go out

Post by KDR_11k »

A shield runs AimWeaponX and if that returns true the shield is active. I'm making extensive use of shields in CvC, that might be worth a look.
Ba-
Posts: 16
Joined: 09 Jan 2008, 23:16

Re: Mod Question Repository... Questions come in, answers go out

Post by Ba- »

So i'm guessing shields on pretty much every unit that would be turning on and off would be too CPU-intensive? I know spring can have more than 3 weapons per unit... what is the max amount of weapons per unit tho? I heard somewhere that shields can actually deflect weapons, rather than just absorb them, can they do either? Shields, I'm assuming, are just the effect of blocking/deflecting a weapon, so you'd have to make a part of the model that 'looks' like a shield as well, correct?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Mod Question Repository... Questions come in, answers go out

Post by KDR_11k »

Shields can have a visible part if you set them to, you can make deflecting shields and destroying shields (i.e. projectiles hit them and explode). I don't think the on/off part will do much to the CPU, having the shields visible could eat FPS in large numbers due to the rendering tho.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

kdr, what does the bos look like using that widget?
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Re: Mod Question Repository... Questions come in, answers go out

Post by [Krogoth86] »

Ba- wrote:what is the max amount of weapons per unit tho?
It's 16 if I'm still right...
Ba- wrote:I heard somewhere that shields can actually deflect weapons, rather than just absorb them, can they do either? Shields, I'm assuming, are just the effect of blocking/deflecting a weapon, so you'd have to make a part of the model that 'looks' like a shield as well, correct?
At the end of this Wiki article you should find everything you want to know:
http://spring.clan-sy.com/wiki/Weapon_V ... scriptions

With that said - yes, you can either do a repulsor shield which reflects projectiles or you make some sort of "hard shield" where everything explodes when touching the shield surface. You also can set it to work like an umbrella (i.e. the shield doesn't affect anything that is inside the shield range or make it affect the whole spherical area it consumes. Well you'll find all the options in that Wiki article...
bobthedinosaur wrote:kdr, what does the bos look like using that widget?
Well you for example could put a variable in the active() function which gets set to 1 and so triggers a while loop you've put in the aiming function which returns a TRUE to activate the shield. The deactivate function then switches the variable to 0 and this way you deactivate your shield...
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Mod Question Repository... Questions come in, answers go out

Post by KDR_11k »

bobthedinosaur wrote:kdr, what does the bos look like using that widget?
You have a ChangeWeapon() function that changes the active weapon.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

sorry i have not yet used the change weapon command, where would it go in the bos in order to receive widget triggers?
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Re: Mod Question Repository... Questions come in, answers go out

Post by Archangel of Death »

You'll just be adding a new function. You can place it in any position (well, not inside another function's block). Spring figures the rest out for you.
Locked

Return to “Game Development Tutorials & Resources”