Bertilsson Posted August 11, 2013 Share Posted August 11, 2013 Yes, from my understanding it should accept any int as parameter and doesn't require the bool.Instead of bit packing... Couldn't we use the bool to inform the helper function if room is 1 or not? if (Loc == 1) { DEMOUltimateSoldier(SlotIdx, true) } else { DEMOUltimateSoldier(SlotIdx, false) } Link to comment Share on other sites More sharing options...
XMarksTheSpot Posted August 11, 2013 Share Posted August 11, 2013 Instead of bit packing... Couldn't we use the bool to inform the helper function if room is 1 or not?That'd work, yeah, good catch :smile:I'd shorten the function call toDEMOUltimateSoldier(SlotIdx, Loc == 1)(less fiddling with jump offsets is always appreciated :wink:) Link to comment Share on other sites More sharing options...
Bertilsson Posted August 11, 2013 Share Posted August 11, 2013 (edited) So will DEMOUltimateSoldier-function be able to access m_kPawn in the same way as AddToLocation would?I'm guessing yes, since it is not declared locally and is from what I can tell already declared somewhere else before AddToLocation is called since AddToLocation can use it... Edit: Wait... Don't we still need the Loc value for calling AddUnitToRoomSequence ? :( Edited August 11, 2013 by Bertilsson Link to comment Share on other sites More sharing options...
Bertilsson Posted August 11, 2013 Share Posted August 11, 2013 (edited) But... The more I think about it... I don't think we need to worry about bit packing or sending parameters at all... From my understanding we can just access them right away same way as AddToLocation would... After all isn't that exactly what we do when we borrow I, tmpIndex, etc, from other functions? I made extra sure to only steal things that were explicitly declared as I = 0; before used by the function I stole from... But in this case we actually want to keep the value and have no need to modify it :smile: Edited August 11, 2013 by Bertilsson Link to comment Share on other sites More sharing options...
XMarksTheSpot Posted August 11, 2013 Share Posted August 11, 2013 (edited) So will DEMOUltimateSoldier-function be able to access m_kPawn in the same way as AddToLocation would?I'm guessing yes, since it is not declared locally and is from what I can tell already declared somewhere else before AddToLocation is called since AddToLocation can use it...m_kPawn is an instance variable of the XGStrategySoldier class, so it should be accessible from anywhere inside that class. Edit: Wait... Don't we still need the Loc value for calling AddUnitToRoomSequence ? :sad:Whoops, you're right about that :sweat: Back to bit-packing then :smile: From my understanding we can just access them right away same way as AddToLocation would... After all isn't that exactly what we do when we borrow I, tmpIndex, etc, from other functions?As far as I know this does apply to local variables declared inside a function's body, I don't know whether this extends to function parameters. From looking at the byte code it appears function parameters are referenced in the same way as local variables, so it might just be possible :smile: Edited August 11, 2013 by XMarksTheSpot Link to comment Share on other sites More sharing options...
Bertilsson Posted August 11, 2013 Share Posted August 11, 2013 (edited) Or my theory while we cross typed is valid :tongue: I think it worth a shot testing. If you write the object code for AddToLocation and DEMOUltimateSoldier for me I can probably find some time to test implementing it tomorrow... Unless you are eager to do it yourself... :smile: Edit: Just realized a bigger problem...This is 53 bytes:if(!class'SeqEvent_HQUnits'.static.AddUnitToRoomSequence(HQLocToName(Loc), m_kPawn, SlotIdx % 6)) And DemoUltimateSolder only has ~125 usable bytes in total... Edited August 11, 2013 by Bertilsson Link to comment Share on other sites More sharing options...
Bertilsson Posted August 11, 2013 Share Posted August 11, 2013 (edited) Rewriting DemoUltimate Soldiers logic to this might help with that? if (!class'SeqEvent_HQUnits'.static.AddUnitToRoomSequence(HQLocToName(Loc), m_kPawn, (SlotIdx <=5 ) ? SlotIdx : SlotIdx % 6 ) Edit: But then we would basically be back at always using SlotIdx % 6... And might as well let AddToLocation do that call and only call DemoUltimateSolder to move soldiers and nothing else... Edit again: But we have only 8 spare bytes in AddToLocation... and calling DemoUltimateSoldier is minimum 11 bytes :( gah! Edited August 11, 2013 by Bertilsson Link to comment Share on other sites More sharing options...
XMarksTheSpot Posted August 11, 2013 Share Posted August 11, 2013 (edited) If you write the object code for AddToLocation and DEMOUltimateSoldier for me I can probably find some time to test implementing it tomorrow... Unless you are eager to do it yourself... :smile:Hmmm, let's see... first off, inside AddToLocation(): before: CreatePawn(SoldierState); RoomName = HQLocToName(Loc); // End:0x129 if(!class'SeqEvent_HQUnits'.static.AddUnitToRoomSequence(RoomName, m_kPawn, SlotIdx)) { DestroyPawn(); } after: CreatePawn(SoldierState); DEMOUltimateSoldier(0, (Loc == 1) && (SlotIdx >= 6)); Inside DEMOUltimateSoldier(): before: m_kSoldier.iRank = 7; if(bPsi) { m_kSoldier.iPsiRank = 4; m_kChar.bHasPsiGift = true; } SetClass(eClass); GiveTopTreePerks(true); GiveBottomTreePerks(true); if(bPsi) { GivePsiPerks(); } return; after: if (bPsi) { SlotIdx = SlotIdx % 6; } if (!class'SeqEvent_HQUnits'.static.AddUnitToRoomSequence(HQLocToName(Loc), m_kPawn, SlotIdx)) { DestroyPawn(); return; } if (bPsi) { m_kPawn.Move(vect(10.0, 10.0, 0.0)) } return; A few pointers:Move() uses the native function token 0x0Avect() uses a 'vector const token' 0x23 Edited August 11, 2013 by XMarksTheSpot Link to comment Share on other sites More sharing options...
Bertilsson Posted August 11, 2013 Share Posted August 11, 2013 That will probably fit in both functions :) So I'm just going to stop thinking about it and if it hasn't changed before tomorrow I will probably try implement it. Link to comment Share on other sites More sharing options...
Bertilsson Posted August 11, 2013 Share Posted August 11, 2013 A few pointers:Move() uses the native function token 0x0Avect() uses a 'vector const token' 0x23Vect() I am already familiar with...vect(float x,float y, float z) is written like this: 23xxxxyyyyzzzz (13 bytes) But where does the move token get into the picture? Like this?0A m_kPawn 23xxxxyyyyzzzz 16 Or like this?m_kPawn.Move(0Axxxxyyyyzzzz) I guess I could probably look at some existing code... Link to comment Share on other sites More sharing options...
Recommended Posts