Attnam / ivan

Iter Vehemens ad Necem - a continuation of the graphical roguelike by members of http://attnam.com
GNU General Public License v2.0
301 stars 43 forks source link

new crafting bugs: extract poison and "fire sparks" #554

Closed AquariusPower closed 4 years ago

AquariusPower commented 5 years ago

are these happening for you too? if they aren't, it could be specific to my current char/savegame or the way I tried to use'm.

1) Something changed on crafting and now the anvil soft explosions are big and quickly destroy the very anvil.

2) Extracting poison stopped working, apparently the potion that would be spawned is considered as not craftable, may be an exception could be added to it? I got this ABORT()

Main/Source/cmdcraft.cpp-3094-  if(!craftcore::canBeCrafted(itSpawn)){
Main/Source/cmdcraft.cpp-3095-    ABORT(
Main/Source/cmdcraft.cpp:3096:      "Dear developer, for the sake of balance and challenge do not create recipes for:\n"

I had only empty bottles and used a small spider corpse, but I think that makes no diff.

jakwings commented 5 years ago

The only related change is #538 : containers are auto-emptied so bottles (not vials) can pass the first craftcore::canBeCrafted check.

re (1): What are you crafting? The related code for explosion power is in crafthandle::CheckIngredients.

re (2): Can the code be reorganized so a second craftcore::canBeCrafted check is unnecessary? This doesn't seem to be a too-messy-to-control condition as most operations are done in that single file.

AquariusPower commented 5 years ago

sparks explosion

crafting: a pickaxe; craftSkill: 11.2; using: stick of fungiwood with 400cm3 and a copper ingot 225cm3;

crafthandle::CheckFumble()

I monitored the debug log with this script: ivanDbgmsg.sh \<filter>

and the strongest xplosion was "4":

2019/03/23-20:42:49(224417) cmdcraft.cpp:3309:CheckFumble:{rpd.xplodStr}="4";{rpd.dbgInfo().CStr()}="rc.IsCanBeSuspended()=1; itToolID=88386; itTool2ID=0; itSpawnCfg=0; itSpawnMatMainCfg=4099; itSpawnMatMainVol=225; itSpawnMatSecCfg=4226; itSpawnMatSecVol=400; otSpawnCfg=0; otSpawnMatMainCfg=0; otSpawnMatMainVol=0; otSpawnMatSecCfg=0; otSpawnMatSecVol=0; fsItemSpawnSearchPrototype=pickaxe; fsCraftInfo=create an item, started at Underwater Tunnel II; v2AnvilLocation=140,6; v2ForgeLocation=143,8; v2WorkbenchLocation=0,0; v2PlaceAt=0,0; v2PlayerCraftingAt=141,7; ";

this means the explosion value is correct!

something else is turning it into a big one.

may be adding a debug log (or a break point using a debugger like nemiver or a better one) showing the stack DBGSTK for every explosion and it's strength at level::Explosion() could hint what could be happening more precisely (but my guess is something is making it big even with small values now), the explosion size (sparks) should not be bigger than one square (anvil's one)

PS.: catched also a glitch that we can craft being far away from the anvil making it quite a safe action (when shouldnt be). the anvil should be on a nearby square to allow crafting!

extract poison (possible insta fix see at the end)

from netbeans search:

  cmdcraft.cpp
    struct srpForgeItem : public recipe{
      virtual bool work(recipedata& rpd){DBGLN;
        2184:  if(craftcore::canBeCrafted(itSpawn)){
      item* crafthandle::SpawnItem(recipedata& rpd, festring& fsCreated)
        3094:  if(!craftcore::canBeCrafted(itSpawn)){
      void crafthandle::CheckIngredients(recipedata& rpd){
        3340:  if(!craftcore::canBeCrafted(it)){ //basically contains some kind of magic

canBeCrafted() 1st - a loop when the user is trying to create an item 2nd - the extra essential check after the item is created when not using the user loop (1st chk). Intended for direct recipes/functionalities like the poison extraction spawing a bottle/vial, but could be any other thing one day. 3rd - a simple check to increase explosion size

but, I think that moving this "if" if(it->GetCategory()==POTION) to before this one if(game::IsQuestItem(it) || at craftcore::canBeCrafted() could be enough, just needs testing/compile/etc to confirm that xD

but I think the best could be to move if(game::IsQuestItem(it) || to the very end, as last check, to grant it wont mess other simpler checks :)

AquariusPower commented 5 years ago

I got this stack:

#0  level::Explosion(this = 0x27ee460, Terrorist = 0x2dfcf80, DeathMsg = , Pos = , Strength = 17, HurtNeutrals = false, FireOnly = false) at Main/Source/level.cpp:1029
#1  craft::Handle(this = 0x2ab1050) at Main/Source/actions.cpp:351
#2  character::Be(this = 0x2dfcf80) at Main/Source/char.cpp:1064
#3  pool::Be() at Main/Source/pool.cpp:31
#4  game::Run() at Main/Source/game.cpp:1115
#5  main(argc = 1, argv = 0x7ffffffc2b98) at Main/Source/main.cpp:164

Strength = 17 (rpdBkp.xplodStr), so at craft::Handle is this: game::GetCurrentLevel()->Explosion(..., rpdBkp.v2XplodAt, rpdBkp.xplodStr, false, false);

void crafthandle::CheckFumble(recipedata& rpd,bool bChangeTurns)
{
  rpd.rc.integrityCheck();
//  if(!v2XplodAt.Is0()){DBGSV2(v2XplodAt);
  if(rpd.fDifficulty>1.0){
    int xplodXtra=0;
    for(int i=0;i<rpd.iStrongerXplod;i++)
      xplodXtra+=clock()%5;

it appears that xplodXtra may be becoming too big, based on rpd.iStrongerXplod loops, but I still dont understand what changes could lead to that? from ingredient enchantment makes no sense as it was not enchanted (the stick and the ingot)

I am also having trouble to debug with nemiver as I cant see most of the variables/fields values, or may be I just dont know how to use it well...

Obs.: to be only one square, the explosion strength would have to be <= 10, but if the ingredients are enchanted (wonder if that test case will ever happen) the explosion may be larger ( > 10 ) and that would be ok (if ever happens).

PS.: I would like to know if anyone else is having that problem, otherwise I upload my savegame as testcase.

AquariusPower commented 5 years ago

created a new game, and the problem happened again.
a workaround would be to limit the value of rpdBkp.xplodStr just before game::GetCurrentLevel()->Explosion(...) is called at craft::Handle until someone findout why it is getting so big. I suggest if it is >=10 make it =9 and I think the explosion will be limited to 1 square.

AquariusPower commented 5 years ago

ah.. finally got some time to look on it:

See latest changes on commit log (check also the changed code specific to this issue) at Apr 5, 2019. https://github.com/AquariusPower/ivan/commits/AutoPickupRegex

I wont be able to test any more than what I already did tho sorry :( feel free to create and maintain a PR of that code :)