OMFG I NEED THIS FOR MY MOD!!!!
Moderator: Moderators
-
- MC: Legacy & Spring 1944 Developer
- Posts: 1948
- Joined: 21 Sep 2004, 08:25
OMFG I NEED THIS FOR MY MOD!!!!
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.
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.
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:
This also needs added to exptype.h by modders who intend to use it
CCobInstance::GetUnitVal
------------------------
Add the following to the switch:
CCobInstance::SetUnitVal
------------------------
Add the following to the switch:
Unit.h
------
Add the following to the CUnit class:
Unit.ccp
--------
CUnit::CUnit
------------
Add:
CUnit::SlowUpdate()
-------------------
Change this:
to this:
Not a huge change, really. Set works 100% perfectly, and I don't see how I could have fucked the Get part up
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!
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
CCobInstance::GetUnitVal
------------------------
Add the following to the switch:
Code: Select all
case CLOAKED:
if(unit->isCloaked)
return 1;
else
return 0;
break;
------------------------
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;
------
Add the following to the CUnit class:
Code: Select all
bool shouldCloakTimeout;
--------
CUnit::CUnit
------------
Add:
Code: Select all
shouldCloakTimeout(1),
-------------------
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;
}
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;
}
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!
- Tim Blokdijk
- Posts: 1242
- Joined: 29 May 2005, 11:18
I don't have a Windows machine but I think you can read this to help you with that svn confusion.
-
- MC: Legacy & Spring 1944 Developer
- Posts: 1948
- Joined: 21 Sep 2004, 08:25
-
- MC: Legacy & Spring 1944 Developer
- Posts: 1948
- Joined: 21 Sep 2004, 08:25
- Guessmyname
- Posts: 3301
- Joined: 28 Apr 2005, 21:07
-
- Posts: 854
- Joined: 28 Jan 2005, 18:15
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.
I can think of a couple slightly complicated ways to circumvent that, but it would be more than a couple lines of code.
-
- MC: Legacy & Spring 1944 Developer
- Posts: 1948
- Joined: 21 Sep 2004, 08:25
- Guessmyname
- Posts: 3301
- Joined: 28 Apr 2005, 21:07
have the cloaking=1; tag only make the button appear in the gui, with whether or not the unit can cloak completely unrelated to itArchangel 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.