[RM2K3] PLUGIN: IF MONSTER PRESENT IS...

Posts

Pages: 1
Basically, I want to have a comment
@ifmonsterpresent 8, switch
and
@setmonsterpresent variable

In the former one, the comment is active if the number of monsters present is equal to the number in question (ideally you'd have a less and greater comment too so you could make a range.

In the latter one, it sets the current monsters present to a variable.

Can someone help with this? I'd make it myself if (1) I could get my hands on CodeBlocks, and (2) I knew what to use to do this. There's obviously something to this in the monster preconditions, but I don't know what to use. Or is this currently possible with the present DynRpg?
author=bulmabriefs144
(1) I could get my hands on CodeBlocks

http://www.codeblocks.org/ ???? Literally just googled code blocks. Also, I'm currently working on a DynRPG src code update that adds a ton of new classes (including some game-changing battle additions). There will be a boolean value you can use if you've won the battle (which is basically what you're asking). The code for that would be very simple
bool onComment ( const char* text,
const RPG::ParsedCommentData* parsedData,
RPG::EventScriptLine* nextScriptLine,
RPG::EventScriptData* scriptData,
int eventId,
int pageId,
int lineId,
int* nextLineId )
{
std::string cmd = parsedData->command;

if(!cmd.compare("are_monsters_present")) {
// battleData is a new class
RPG::switches[parsedData->parameters[2].number] = RPG::battleData->isVictory;
// delay pauses the battle for as long as you need to.
// It's not fully tested, but you could probably throw in some animations or code in there.
RPG::battleData->delay = true:
return false;
}
return true;
}

Stay tuned! It might be a few weeks for the update.
I bet there's different ways to do this, but:
#include <DynRPG/DynRPG.h>


int isMonPresent (int ID)
{
int MonGroupSize = ( *reinterpret_cast<int ****> (0x4CDE64) )[0][2][2];
if (ID > 0 && ID <= MonGroupSize)
{
return RPG::monsters[(ID)-1]->notHidden;
} else {
return -1; //error message = "invalid monster"
}
}

bool onComment ( const char* text,
const RPG::ParsedCommentData* parsedData,
RPG::EventScriptLine* nextScriptLine,
RPG::EventScriptData* scriptData,
int eventId,
int pageId,
int lineId,
int* nextLineId )
{
std::string cmd = parsedData->command;
if(!cmd.compare("is_mon_present") && parsedData->parametersCount == 2 && parsedData->parameters[0].type == RPG::PARAM_NUMBER
&& parsedData->parameters[1].type == RPG::PARAM_NUMBER)
{
//comment "@is_mon_present [0], [1]" substitute [x] with numbers or a Var_ID with a "V" in front
int a = parsedData->parameters[0].number; //get Enemy_ID (1, 2, 3, ...)
int b = parsedData->parameters[1].number; //Var_ID for output
RPG::variables[b] = isMonPresent(a);
}
return true;
}



boolean value you can use if you've won the battle

There's always a workaround for everything.

Defeat:
return ( *reinterpret_cast<char ***> (0x4CDD38) )[0][132];


Victory:
return ( *reinterpret_cast<char ***> (0x4CDD38) )[0][133];



...or:
return ( *reinterpret_cast<long ***> (0x4CDD38) )[0][31];

current BattlePhase (0|1|2|3 = Battle|Death|Victory|End)
You can already do this with PepsiOtaku's Store Item, Skill ID & Condition ID in Battle plugin. It lets you check if a monster is inflicted with Death condition (which when it is, it's not present any longer).
author=PepsiOtaku
author=bulmabriefs144
(1) I could get my hands on CodeBlocks
http://www.codeblocks.org/ ???? Literally just googled code blocks. Also, I'm currently working on a DynRPG src code update that adds a ton of new classes (including some game-changing battle additions). There will be a boolean value you can use if you've won the battle (which is basically what you're asking). The code for that would be very simple
bool onComment ( const char* text,

const RPG::ParsedCommentData* parsedData,
RPG::EventScriptLine* nextScriptLine,
RPG::EventScriptData* scriptData,
int eventId,
int pageId,
int lineId,
int* nextLineId )
{
std::string cmd = parsedData->command;

if(!cmd.compare("are_monsters_present")) {
// battleData is a new class
RPG::switches[parsedData->parameters[2].number] = RPG::battleData->isVictory;
// delay pauses the battle for as long as you need to.
// It's not fully tested, but you could probably throw in some animations or code in there.
RPG::battleData->delay = true:
return false;
}
return true;
}


Stay tuned! It might be a few weeks for the update.


Actually, I'm asking "how many monsters present." The term comes from the Monster page where you can set preconditions to attack. Along with Switch, Variable, HP, etc there is If Monsters Present 1 - 8, which if you just want 8, you do 8-8. Essentially, this runs attacks based on that, but there is no simple method (I mean, I could do some serious programming) to simply program the variable MonsterNumber to update when a monster dies.

But this is good too. I could use this to make end of battle conditions (think AP or rare items).

Essentially, bugmenot I don't care about the monster ID (though, come to think of it, that is also helpful, as it could be used to do the Monster Name thing talked about elsewhere), so much as the total number of monsters. I'm using it for (1) flee chance (which should get easier or harder depending on how many monsters are non-hidden and alive), (2)and for turn based control.



Millenin that does help, but it's a very roundabout way. To update Monster Number (my variable) I'd need to check for all monsters, and then switch for each to subtract from the original.
int getMonLiveCount()
{
int MonGroupSize = ( *reinterpret_cast<int ****> (0x4CDE64) )[0][2][2];
int monLiveCount = 0;
for (int i = 0; i < MonGroupSize; i = i++)
{
if (RPG::monsters[i]->notHidden == true && RPG::monsters[i]->hp != 0)
{ monLiveCount++; }
}
return monLiveCount;
}

Uhm, yeah notHidden isn't actually set to false when a monster dies, so testing if hp != 0 would be needed, too.
That's so unbelievably cool! You're awesome, bugmenot! I'll need to figure out the #includes and such, but I can definitely make use of that. I'll probably have to insert it in a DynRpg variable though.

It'll be awhile before I compile. The issue is not finding CodeBlocks itself, so much as:

(1) I tried to run a copy pasted version of CodeBlocks from my old computer, and it had some compile error that I didn't understand. My old computer was XP, my new is 8.1, so I dunno if it's compatibility or just not setting stuff up right.
(2) DynRpg says in its homepage that some older version of CodeBlocks is what you need.
(3) It also says that you need to add Mingw, and DynRpg into the engine, but it's been about half a year, so I kinda need a walkthru as to the process of what to put where.

It's kinda a matter of getting back on my feet, coding-wise. I've been having trouble with that lately.
copy pasted version of CodeBlocks

Try the proper route (worked on Win7, works on Win8.1, as far as I can tell, too):

[1]
download Codeblocks with GCC 4.7.1

[2]
run the downloaded codeblocks-13.12mingw-setup

[3]
Don't read the License agreement, here's what it says:

-totally free (except time and nerves)
-creators: Free Software Foundation, Inc.; Copyright (C) 2007 ; try to respect them
-copy & distribute allowed, but no passing it off as your own work
-don't be a dick
-GNU General Public License:
  • -freedom to distribute free software (but not if there's a price on it)
    -freedom (with free software) to ask for source code, to modify source code, to use pieces
    of source code in your own stuff; try to respect other people if they decide to help you
    -if new software results, you yourself are responsible for figuring out bugs in it
    -the same freedom applies to others (using your stuff) as well
    -if you make your work free under GNU GPL and provide documented source code, others might
    help you figuring out bugs, make the software more useful and/or better
    -don't be a dick

-GNU General Public License may apply to your resulting programs as well, or you can sell the results if you want
(people buy if it's good & worth it (& not available for free elsewhere); try not to be too much of a dick)

[4]
Agree
Next >
Browse where to put it
Install
Wait
Next >
Finish

[5]
download dyn0.20
dynrpg_patcher: patch your RPG_RT.exe if you haven't already (use clean RPG_RT.exe if possible)
extract the sdk folder

[6]
put contents of ../sdk/include into ../CodeBlocks/MinGW/include
put contents of ../sdk/lib into ../CodeBlocks/MinGW/lib

[7]
Start CodeBlocks
default compiler: GNU GCC Compiler
OK
"No, leave everything as is"
(later, when selecting a .cbp file (in a plugins source folder) set CodeBlocks as default program to open it up with)
OK

[8]
(up top) File > New > Project...
select Dynamic Link Library, press Go/Enter/whatever
Next >
Project title: name your plugin
Folder to create project in: select DynPlugins folder of your game
Next >
make sure Compiler = GNU GCC Compiler
uncheck "Create "Debug" configuration"
Output dir.: put " ..\ " (2x dot, 1x \)
click Finish

[9]
(up top) Project > Build options...
Linker settings > Link libraries > Add
enter DynRPG
OK
OK

[10]
(up top) Project > Set programs' arguments...
Host application > select RPG_RT.exe
OK

[11]
(left side of CodeBlocks)
Sources > main.cpp > double click > Ctrl+A > delete contents of main.cpp
delete contents of main.h (in Headers) as well

[12]
start creating / pasting code in main.cpp

[13]
In case of trying to figure C++ out


figure out the #includes

#include <DynRPG/DynRPG.h>
author=bulmabriefs144
(2) DynRpg says in its homepage that some older version of CodeBlocks is what you need.


The DynRPG homepage is, unfortunately, not up-to-date. I looked into some of the .h files for DynRPG and found they asked for a later version of GCC than what the website calls for. There was also a callback function (I forget which one) which had more arguments than the website documentation described. The takeaway is, don't have complete trust in the website, and if something doesn't work, take a peek in the .h files to make sure there isn't something that works differently than you thought.
Oh, by include and other stuff, I meant all the prebuild, the OnComment or OnStart, that kinda stuff. But now I see that code two looks like code one, so I figure I just alter the code appropriately.

Urgh!



Tried the sample program, got this error after going to new -> project -> Dynamic Link Library -> typing are_you_sure in as name -> Debug is unchecked, Release is ..\, Gnu GCC Compiler is set. Must've missed something, but I'm not sure what.
Must've missed something, but I'm not sure what
It's called the "windows administrator rights issue".

Either create a new folder in C:\ that is outside of programs or programs(x86) and transfer all rpg maker projects there. Or have all your own stuff outside of C:\ if possible.

Or right click the codeblocks.exe (or its shortcut) and select 'Run as administrator'.
Or search through the internet how to give an executable administrator rights in Win8.1 without having to right click every damn time.
Or ask on the other rmn forums. I reckon people had similar issues with RM VXP being in C:\programs(x86) leading to the same admin rights issues, so they might have some useful advice.
Oh, yay that. Why didn't they just tell me that?

Okay, I tried to build and got:

#warning AUTO_DLLMAIN is deprecated as automatically adding a DllMain function is the default behaviour now. Use #define CUSTOM_DLLMAIN to achieve the reverse.

(Removed AUTO_DLLMAIN, because it seems to do it by default now. Works like a charm)

It seems to have built it, but it added it in Release vs inside are_you_sure or to the DynPlugins folders. Is there a way to make it put the dll in the are_you_sure folder and save on extra folders?

(Nvm, I figured that out too. Mainly the only issue about the above code is that I'm pretty horrible with passing variables through functions. I'll get back to you on that. Basically, I want it to count the monster number, and send it to OnComment. That may take some work.) I've got a few projects I wanna try first, now that I can code again.
Pages: 1