|
|
Re: Code Snippets[message #327918]
|
Mon, 11 November 2013 01:36
|
|
Deleted. |
|
Messages:2663
Registered:December 2012 Location: Russian Federation |
|
|
Some experimental adjustments to explosive things.
1) Every normal explosion (only outdoor, not underground) causes small smoke - cosmetic feature.
2) You can attach some explosives to your grenade or mine:
- Attach rubber band or duct tape.
- Attach as many explosives or grenades (usItemClass= 256 or 512) as you wish. Attached explosives should have ubVolatility>0. No nested recursive attachments, only first level of attachments is processed.
- Throw to the enemy as usual grenade or plant as usual mine or TNT.
- PROFIT.
3) You can attach some special items to your explosives to add some special effects:
- molotov's explosion
- bigger molotov's explosion
- some frags
New self-describing options for ja2_options.ini:
ADD_SMOKE_AFTER_EXPLOSION = FALSE
ALLOW_EXPLOSIVE_ATTACHMENTS = FALSE
ALLOW_SPECIAL_EXPLOSIVE_ATTACHMENTS = FALSE
How it works:
Smoke effect is added to InternalIgniteExplosion function.
Toggle Spoiler
if(!InARoom( sGridNo, &tmp ) && !gbWorldSectorZ && gGameExternalOptions.bAddSmokeAfterExplosion)
{
if( Explosive[ Item[ usItem ].ubClassIndex ].ubType == 0 )
{
NewSmokeEffect( sGridNo, SMALL_SMOKE, 0, NOBODY );
}
}
New function HandleAttachedExplosions is added after HandleBuddyExplosions and is mostly copypasted from it.
Toggle Spoiler
void HandleAttachedExplosions(UINT8 ubOwner, INT16 sX, INT16 sY, INT16 sZ, INT32 sGridNo, UINT16 usItem, BOOLEAN fLocate, INT8 bLevel, UINT8 ubDirection, OBJECTTYPE * pObj)
{
BOOLEAN binderFound = FALSE;
attachmentList::iterator iterend;
attachmentList::iterator iter;
UINT8 direction;
if(pObj==NULL)
return;
// check all attachments, search for ELASTIC or DUCT_TAPE;
iterend = (*pObj)[0]->attachments.end();
for (iter = (*pObj)[0]->attachments.begin(); iter != iterend; ++iter)
{
if ( iter->exists() && Item[iter->usItem].usItemClass == IC_MISC )
{
if(Item[iter->usItem].uiIndex == ELASTIC || Item[iter->usItem].uiIndex == DUCT_TAPE )
{
binderFound = TRUE;
break;
}
}
}
if( !binderFound )
return;
// search for attached explosives
iterend = (*pObj)[0]->attachments.end();
for (iter = (*pObj)[0]->attachments.begin(); iter != iterend; ++iter)
{
if ( iter->exists() && Item[iter->usItem].usItemClass & (IC_GRENADE|IC_BOMB) )
{
if(Item[iter->usItem].directional && ubDirection == DIRECTION_IRRELEVANT)
direction=Random(8);
else
direction=ubDirection;
if( Explosive[Item[iter->usItem].ubClassIndex].ubVolatility > 0 )
IgniteExplosion( ubOwner, sX, sY, sZ, sGridNo, Item[iter->usItem].uiIndex, bLevel, direction , NULL );
}
if ( gGameExternalOptions.bAllowSpecialExplosiveAttachments && iter->exists() && Item[iter->usItem].usItemClass & IC_MISC )
{
if(Item[iter->usItem].gascan)
IgniteExplosion( ubOwner, sX, sY, sZ, sGridNo, GAS_EXPLOSION, bLevel, direction , NULL );
if(Item[iter->usItem].alcohol)
IgniteExplosion( ubOwner, sX, sY, sZ, sGridNo, MOLOTOV_EXPLOSION, bLevel, direction , NULL );
if(Item[iter->usItem].marbles)
IgniteExplosion( ubOwner, sX, sY, sZ, sGridNo, FRAG_EXPLOSION, bLevel, direction , NULL );
}
}
}
Added new parameter OBJECTTYPE * pObj =NULL to functions void IgniteExplosion and void InternalIgniteExplosion.
Added OBJECTTYPE* parameters when calling IgniteExplosion nearly everywhere.
Added new items 1702(SMALL_SMOKE), 1703 (GAS_EXPLOSION) and 1704 (FRAG_EXPLOSION) and new explosives 96 (SMALL_SMOKE), 97 (GAS_EXPLOSION) and 98 (FRAG_EXPLOSION).
Tested with different types and combinations and it seems ok.
Yet still it touches explosive game mechanics so it should be considered experimental feature and it definitely needs some thorough testing.
I would also be very grateful for any critical review from more experienced coders.
Link to source diff, gamedir diff and compiled exe:
(this includes mine-avoiding code from previous post)
[Updated on: Sun, 01 December 2013 12:19] by Moderator Report message to a moderator
|
|
|
|
|
|
|
Re: Code Snippets[message #327940]
|
Mon, 11 November 2013 15:30
|
|
Deleted. |
|
Messages:2663
Registered:December 2012 Location: Russian Federation |
|
|
silversurfer, thanks for you great help!
What do you think about "attachments weight not calculated for thrown distance" bug?
I looked at function CalcMaxTossRange in Tactical\Weapons.cpp and changed line
iRange = 2 + ( iThrowingStrength / (3 + (Item[usItem].ubWeight) / 3 ));
to
if(pObject!= NULL)
iRange = 2 + ( iThrowingStrength / (3 + (CalculateObjectWeight(pObject)) / 3 ));
else
iRange = 2 + ( iThrowingStrength / (3 + (Item[usItem].ubWeight) / 3 ));
also i added OBJECTTYPE* pObject=NULL to function definition and added pObj parameter to function calls in Tactical/Weapons.cpp and TileEngine/physics.cpp.
Now the bug with incorrect range calculation has gone in my tests.
EDIT: red aim still doesn't work correctly with added weight from attachments, though actually throwing works fine now.
I thing it uses another function which i was unfortunately unable to find yet.
EDIT2: i think problem was in function HandleNonActivatedTossCursor
// Do we have a launcable?
pObj = &(pSoldier->inv[HANDPOS]);
for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != (*pObj)[0]->attachments.end(); ++iter) {
if ( Item[ iter->usItem ].usItemClass & IC_EXPLOSV && iter->exists())
{
pObject = &(*iter);
break;
}
}
so i added check
if(Item[pObj->usItem].usItemClass & IC_WEAPON )
to prevent wrong logic when we throw item with explosives or grenade attached
EDIT: added link to patch
also added small fix (tripwire items previously did not set MAPELEMENT_PLAYER_MINE_PRESENT flag)
patch file (based on r6575)
[Updated on: Mon, 11 November 2013 21:05] by Moderator Report message to a moderator
|
|
|
|
|
Re: Code Snippets[message #328040]
|
Tue, 12 November 2013 21:17
|
|
Deleted. |
|
Messages:2663
Registered:December 2012 Location: Russian Federation |
|
|
I have done some tests on throwing grenades and stuff, and results seem strange.
r6446, r6585, stock 1.13, default options
hired Igor, landed in Omerta.
mini grenade (300g) - 24 tiles
Mk2 grenade (600g) - 19 tiles
40mm HE grenade (200g) - 31 tiles (!?)
Gas Tank (2kg) - 5 tiles
Dusters (100g) - 15 tiles
code from r6446, Tactical\Weapons.cpp, CalcMaxTossRange:
else if ( Item[ usItem ].usItemClass == IC_GRENADE )
{
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"calcmaxtossrange: grenade");
// start with the range based on the soldier's strength and the item's weight
// Altered by Digicrab on 14 March, 2004
// Reversed a Ja2Gold change that made grenades of weight 3 or more have the same throw distance as those of weight 3.
INT32 iThrowingStrength = ( EffectiveStrength( pSoldier, FALSE ) * 2 + 100 ) / 3;
iRange = 2 + ( iThrowingStrength / (3 + (Item[usItem].ubWeight) / 3 ));
}
else
{ // not as aerodynamic!
// start with the range based on the soldier's strength and the item's weight
iRange = 2 + ( ( EffectiveStrength( pSoldier, FALSE ) / ( 5 + Item[usItem].ubWeight) ) );
}
If we assume effective strengh=80, then we have:
for mk2 grenade (weight=6)
iRange=2+86/(3+6/3)=19 tiles
for mini grenade (weight=3)
iRange=2+86/(3+3/3)=23 tiles
for 40mm HE grenade (weight=2)
iRange=2+86/(3+2/3)=30 tiles
for dusters (weight=1)
iRange=2+80/(5+1)=15 tiles
Why 200g item is thrown twice as far as 100g item?
Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Re: Code Snippets[message #328286]
|
Mon, 18 November 2013 01:25
|
|
Deleted. |
|
Messages:2663
Registered:December 2012 Location: Russian Federation |
|
|
The following ITEM's work fine in my tests:
Toggle Spoiler
1702
SMALL_SMOKE
SMALL_SMOKE
INTERNAL ITEM
SMALL_SMOKE
INTERNAL ITEM
512
96
1
1703
GAS_EXPLOSION
GAS_EXPLOSION
INTERNAL ITEM
GAS_EXPLOSION
INTERNAL ITEM
512
97
1
1704
FRAG_EXPLOSION
FRAG_EXPLOSION
INTERNAL ITEM
FRAG_EXPLOSION
INTERNAL ITEM
512
98
1
As they should not be actually created, i suppose they don't need other tags.
[Updated on: Mon, 18 November 2013 01:26] by Moderator Report message to a moderator
|
|
|
|
|
|
|
Re: Code Snippets[message #328470]
|
Sat, 23 November 2013 16:02
|
|
Deleted. |
|
Messages:2663
Registered:December 2012 Location: Russian Federation |
|
|
Small convenience feature - improved bomb planting.
With new option IMPROVED_BOMB_PLANTING = TRUE, if you hold SHIFT key while planting new mine, then another mine with same item id will be taken automatically from your merc's inventory. If no such item found, any mine will be taken. If you plant tripwire-triggered mine, then only tripwire-triggered items will be taken. This new feature work only in realtime.
If you are making tripwire network, then this feature can be used to plant another tripwire item with network and hierarchy settings taken from previously planted tripwire. You just plant tripwire as usual, selecting it's settings from dialogue, then if you plant another one while holding SHIFT key, those settings will be used for new tripwire, instead of showing you dialogue.
I hope this small improvement will save you some time for building large and complicated defensive minefields.
patch r6641
ja2_settings.ini patch gamedir 1878
Report message to a moderator
|
|
|
|
|
Re: Code Snippets[message #328668]
|
Thu, 28 November 2013 14:38
|
|
Deleted. |
|
Messages:2663
Registered:December 2012 Location: Russian Federation |
|
|
Some small fixes and improvements for explosive things:
- New mine disarm dialogue (only for realtime): Disarm, Inspect, Remove Blue Flag, Blow up.
- You can now attach tripwire-activated explosives to tripwire.
- attached explosives volatility is now used in chain explosion calculation: added new function CalcTotalVolatility.
- new function CheckForBuriedBombsAndRemoveFlags removes MAPELEMENT_XXX_MINE_PRESENT flags if there is no buried bomb at checked tile. This should fix problems with flag not removed correctly after chain explosions and such.
- trip klaxon no longer calls enemies if it's activated as attached explosive (instead it makes some noise).
- added check to MineSpottedDialogueCallBack. It should fix problem with game crash with tiles that have MAPELEMENT_PLAYER_MINE_PRESENT flag set but no buried mine
- disarmed item will keep it's attachments if ALLOW_ATTACHED_EXPLOSIVES is TRUE.
- IMPROVED_BOMB_PLANTING feature can be used to auto-take tripwire items from inventory.
patch r6661
New disarm dialog:
[Updated on: Sun, 01 December 2013 12:15] by Moderator Report message to a moderator
|
|
|
|
|
|
Re: Code Snippets[message #328803]
|
Wed, 04 December 2013 21:33
|
|
Deleted. |
|
Messages:2663
Registered:December 2012 Location: Russian Federation |
|
|
Another infinitesimal feature (only NAS):
1) New merge type USE_ITEM_NEW (13)
It creates new items with firstResultingItemIndex and secondResultingItemIndex (if defined) and deducts 1 point from firstItemIndex's status (for each new item).
When firstItemIndex's status reaches 0, the item is destroyed.
With this type of merge, you can use knife on tripwire roll, for example, to get 2 new tripwire items. So you can think of tripwire roll as container for 100 tripwires.
2) USE_ITEM merge creates secondResultingItemIndex item if defined.
With this secondResultingItemIndex defined, you can use knife on T-Shirt to get 2 rags.
patch r6679
[Updated on: Wed, 04 December 2013 21:34] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Code Snippets[message #328880]
|
Mon, 09 December 2013 22:28
|
|
Deleted. |
|
Messages:2663
Registered:December 2012 Location: Russian Federation |
|
|
Small visual changes:
1) ENEMY_HIT_COUNT in ja2_options.ini accepts 2 new parameters:
3 - show damage as white asterisks
4 - show damage as red asterisks
Number of asterisks is scaled (maximum 5): >0, >10, >30, >60, >100
2) Suppression tactical tooltip now shows suppression points from last attacks.
Previously it was always = 0 because ubSuppressionPoints value is cleared after each attack.
3) It is now possible to show suppression values above soldier, just as hit count.
There are new options in ja2_options.ini
Possible values:
0 - do not show
1 - show on moving hit counter
2 - show above soldier
The values are color coded:
Suppression is light gray
Shock is yellow
AP loss is blue
Morale hit is green
SHOW_SUPPRESSION_COUNT = 0
SHOW_SHOCK_COUNT = 0
SHOW_AP_COUNT = 0
SHOW_MORALE_COUNT = 0
This option defines if values are shown as numbers or asterisks (1..5, using scale)
SHOW_SUPPRESSION_USE_ASTERISK = FALSE
This option defines if only 1 asterisk is shown or several (1..5) to represent value
SHOW_SUPPRESSION_SCALE_ASTERISK = TRUE
Show suppression above soldier during enemy attack. All other values are shown after attack, when HandleSuppressionFire function is calculated.
SHOW_SUPPRESSION_COUNT_ALT = TRUE
patch r6688
patch gamedir1890
patched exe r6688 for testing
Recommended settings for playing:
Toggle SpoilerENEMY_HIT_COUNT = 4
SHOW_SUPPRESSION_COUNT = 2
SHOW_SHOCK_COUNT = 0
SHOW_AP_COUNT = 0
SHOW_MORALE_COUNT = 0
SHOW_SUPPRESSION_USE_ASTERISK = TRUE
SHOW_SUPPRESSION_SCALE_ASTERISK = TRUE
SHOW_SUPPRESSION_COUNT_ALT = TRUE
With these settings, you will see red hit indicator, and grey suppression indicator above soldier.
[Updated on: Tue, 10 December 2013 00:56] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|