OMFG I NEED THIS FOR MY MOD!!!!

OMFG I NEED THIS FOR MY MOD!!!!

Requests for features in the spring code.

Moderator: Moderators

Post Reply
SpikedHelmet
MC: Legacy & Spring 1944 Developer
Posts: 1945
Joined: 21 Sep 2004, 08:25

OMFG I NEED THIS FOR MY MOD!!!!

Post by SpikedHelmet » 07 Jul 2006, 06:31

I will bug you FOREVER until you impliment:

Turning cloak on/off via script.

Since ATM cloaking is turned on/off via GUI buttons, and you've shown your ability to control that stuff via unit script, it shouldnt' be too hard, right?

SO DO IT!



...please. It is absolutely integral to Spring: 1944.
0 x

Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre » 07 Jul 2006, 07:06

Probably actually wouldn't be that hard... I think there's a simple variable switch in the engine that controls the cloak state, and I'm pretty sure the set/get handlers are insanely easy to poke...

Hmm, now I have to open it and look, you bastard!
0 x

Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre » 07 Jul 2006, 08:19

Double post, suck it.

I'm working with an older version of the source because honestly... SVN confuses the hell out of me. Make more packages :( In any case, that's why I didn't bother making patch files, it probably wouldn't be all that useful.

Anyway, here's how it's done:

CobInstance.cpp
---------------
Add the following to the #define list:

Code: Select all

#define CLOAKED					75
This also needs added to exptype.h by modders who intend to use it

CCobInstance::GetUnitVal
------------------------
Add the following to the switch:

Code: Select all

case CLOAKED:
		if(unit->isCloaked)
			return 1;
		else
			return 0;
		break;
CCobInstance::SetUnitVal
------------------------
Add the following to the switch:

Code: Select all

case CLOAKED:
		if (param == 1) {
			unit->isCloaked = true;
			unit->shouldCloakTimeout = 0; 
		} else {
			unit->isCloaked = false;
			unit->shouldCloakTimeout = 1;
		}
		break;
Unit.h
------
Add the following to the CUnit class:

Code: Select all

bool shouldCloakTimeout;
Unit.ccp
--------
CUnit::CUnit
------------
Add:

Code: Select all

shouldCloakTimeout(1),
CUnit::SlowUpdate()
-------------------
Change this:

Code: Select all

if(wantCloak){
		if(helper->GetClosestEnemyUnit(pos,unitDef->decloakDistance,allyteam)){
			curCloakTimeout=gs->frameNum+cloakTimeout;
			isCloaked=false;
		}
		if(isCloaked || gs->frameNum>=curCloakTimeout){
			float cloakCost=unitDef->cloakCost;
			if(speed.SqLength()>0.2)
				cloakCost=unitDef->cloakCostMoving;
			if(UseEnergy(cloakCost)){
				isCloaked=true;
			} else {
				isCloaked=false;
			}
		} else {
			isCloaked=false;
		}
	} 
	else {
		isCloaked=false;
	}
to this:

Code: Select all

[b]if(!shouldCloakTimeout)
		isCloaked=true;
	else[/b] if(wantCloak){
		if(helper->GetClosestEnemyUnit(pos,unitDef->decloakDistance,allyteam)){
			curCloakTimeout=gs->frameNum+cloakTimeout;
			isCloaked=false;
		}
		if(isCloaked || gs->frameNum>=curCloakTimeout){
			float cloakCost=unitDef->cloakCost;
			if(speed.SqLength()>0.2)
				cloakCost=unitDef->cloakCostMoving;
			if(UseEnergy(cloakCost)){
				isCloaked=true;
			} else {
				isCloaked=false;
			}
		} else {
			isCloaked=false;
		}
	} 
	else {
		isCloaked=false;
	}
Not a huge change, really. Set works 100% perfectly, and I don't see how I could have fucked the Get part up :P

Oh, and uh, I didn't test it with a unit that has cancloak, just a peewee. So uhh, yeah, I guess I'll do that now...

[edit] Yeah, that part definitely is beyond me... I have no idea how to fix it. I say fuck it, if you want it toggleable then you should use the fbi junk in the first place, jeez!
0 x

User avatar
Tim Blokdijk
Posts: 1239
Joined: 29 May 2005, 11:18

Post by Tim Blokdijk » 07 Jul 2006, 12:22

I don't have a Windows machine but I think you can read this to help you with that svn confusion.
0 x

SpikedHelmet
MC: Legacy & Spring 1944 Developer
Posts: 1945
Joined: 21 Sep 2004, 08:25

Post by SpikedHelmet » 09 Jul 2006, 01:08

The point is, I want it toggle-able, but also want it to toggle OFF whenever a unit moves.
0 x

SpikedHelmet
MC: Legacy & Spring 1944 Developer
Posts: 1945
Joined: 21 Sep 2004, 08:25

Post by SpikedHelmet » 09 Jul 2006, 01:13

Gnome, wtf is that shit?!?!?
0 x

User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname » 09 Jul 2006, 11:18

It's the bits of code necessary for Spring to allow cloaking to be toggleable via script.
0 x

Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death » 09 Jul 2006, 22:04

Hmm, where is the gui hook for the cloak on/off? (In the gui code of course!). Might at least be worth looking into to see how hard it would be to go through that instead, because it might allow for script and gui control to be synchronized. Maybe. With a tad of luck. Actually, that might not be as good as it sounds, because then the user could fight the script to try to keep their cloak on/off (whichever), thus forcing the scriptor to put in some function that keeps making sure it is set to the right state and at a higher frequency that the gui updates the cloak's state, which still wouldn't always prevent the user from changing the state between those updates.

I can think of a couple slightly complicated ways to circumvent that, but it would be more than a couple lines of code.
0 x

User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen » 09 Jul 2006, 22:10

Otherwise nice work, but you should really make it a normal patch instead of this manual stuff. Installing a svn client is a 5 min job...
0 x

SpikedHelmet
MC: Legacy & Spring 1944 Developer
Posts: 1945
Joined: 21 Sep 2004, 08:25

Post by SpikedHelmet » 09 Jul 2006, 23:20

Quick, I don't know how to impliment that, someone do it for me!
0 x

User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname » 09 Jul 2006, 23:49

Archangel of Death wrote:Hmm, where is the gui hook for the cloak on/off? (In the gui code of course!). Might at least be worth looking into to see how hard it would be to go through that instead, because it might allow for script and gui control to be synchronized. Maybe. With a tad of luck. Actually, that might not be as good as it sounds, because then the user could fight the script to try to keep their cloak on/off (whichever), thus forcing the scriptor to put in some function that keeps making sure it is set to the right state and at a higher frequency that the gui updates the cloak's state, which still wouldn't always prevent the user from changing the state between those updates.

I can think of a couple slightly complicated ways to circumvent that, but it would be more than a couple lines of code.
have the cloaking=1; tag only make the button appear in the gui, with whether or not the unit can cloak completely unrelated to it
0 x

Post Reply

Return to “Feature Requests”