Spawn summon monster

This forum is for discussions on how to edit what can not be edited through the txt files, needless to say this isn't about battle net hacking.

Moderators: Nefarius, Havvoric

Post Reply

1
100%
 
Total votes: 1

User avatar
misiek1294
Junior Member
Paladin
Posts: 168
Joined: Mon Dec 29, 2014 3:58 pm
Poland

Spawn summon monster

Post by misiek1294 » Wed Apr 22, 2015 5:35 pm

Hi, again now i got problem with spawn a monster "summon" i try make monster's hirable, function work , monster spawn but i think my problem is MonsterAI.
if i put in AI 1 monster try kill me if i put 2 all works but not attack other monsters


Code: Select all


	D2SummonStrc hConfig={};
	hConfig.dwFlags = 1   ;
	hConfig.nXpos=pUnit->pPath->xPos+3;
	hConfig.nYpos=pUnit->pPath->yPos+3;
	hConfig.pOwner = pUnit;   
	hConfig.nHcIdx=156;             
	hConfig.nSpecialAiState=atoi(Msg2);   ->  There i put messeage argument from command for testing 
	hConfig.nMonMode = 1;            
    hConfig.nPetType = 0;            
	hConfig.nPetMax =1;   

		D2GAME_CreateSummon(pUnit->pGame,&hConfig);
	

User avatar
kidpaddle94
Forum Legend
Principality
Posts: 2057
Joined: Thu Aug 13, 2009 2:54 pm
Location: localhost
Canada

Re: Spawn summon monster

Post by kidpaddle94 » Wed Apr 22, 2015 5:42 pm

Might be because you're passing no pet type? That or your monster isn't setup correctly.
That's how I setup my summoning skill function:

Code: Select all

int __fastcall SKILLSRVDOFUNC_SummonPet(D2GameStrc* pGame, D2UnitStrc* pUnit, int nSkill, int nSkillLevel)
{
	if (!pGame || !pUnit || pUnit->dwType != UNIT_PLAYER) return 0;

	D2SkillsTXT* pSkillRecord = TXT_GetSkillsRecord(nSkill);
	D2SkillsDataTXT* pSkillDataRecord = TXT_GetSkillsDataRecord(nSkill);
	if (!pSkillRecord || !pSkillDataRecord) return 0;

	pUnit->dwFlags |= UNITFLAG_SKSRVDOFUNC;

	int nMinions = pSkillRecord->dwParam[0];
	int nMaxMinions = D2COMMON_EvalSkillCalc(pUnit, pSkillRecord->dwPetMax, nSkill, nSkillLevel);
	int nDuration = D2COMMON_EvalSkillCalc(pUnit, pSkillRecord->dwAuraLenCalc, nSkill, nSkillLevel);

	D2SummonStrc Summon = {};

	Summon.pOwner = pUnit;
	Summon.nHcIdx = pSkillRecord->nSummon;
	Summon.nMonMode = pSkillRecord->nSummMode;
	Summon.nPetType = pSkillRecord->nPetType;
	Summon.nPetMax = nMaxMinions;

	if (nMinions > nMaxMinions) nMinions = nMaxMinions;

	for (int i = 0; i < nMinions; i++)
	{
		D2UnitStrc* pMinion = D2GAME_CreateSummon(pGame, &Summon);
		if (!pMinion) continue;

		D2StatListStrc* pStatList = SUMMONS_CreateStatList(pGame, pMinion, nSkill, nSkillLevel);
		if (!pStatList) continue;

		SUMMONS_AssignStats(pUnit, pMinion, pStatList);
		SUMMONS_AssignBaseStats(pUnit, pMinion, pStatList);
		SUMMONS_AssignSkills(pUnit, pMinion, pStatList);

		if (pSkillRecord->dwParam[1])
		{
			pMinion->pMonsterData->pAiControl->dwAiParam[0] = 1;
			pMinion->pMonsterData->pAiControl->dwAiParam[1] = 0;
			D2COMMON_AssignSkill(pMinion, pSkillRecord->nSummSkill[0], D2COMMON_EvalSkillCalc(pUnit, pSkillRecord->dwSummSkCalc[0], nSkill, nSkillLevel), 1, __FILE__, __LINE__);
		}

		if (nDuration > 0)
		{
			D2GAME_InitTimer(pGame, pMinion, UNITEVENTCALLBACK_QUESTCALLBACK, pGame->dwGameFrame + nDuration, 0, 0, 0);
			MONUMODS_AssignMod(pGame, pMinion, MONUMOD_TEMPSUMMON, 0);
		}

		if (pSkillRecord->nSummUMod) 
		{
			MONUMODS_AssignMod(pGame, pMinion, pSkillRecord->nSummUMod, 0);
		}

		D2GAME_UpdatePetAI(pGame, pMinion, pUnit->dwTargetGUID, 0);
	}

	return 1;
}

User avatar
misiek1294
Junior Member
Paladin
Posts: 168
Joined: Mon Dec 29, 2014 3:58 pm
Poland

Re: Spawn summon monster

Post by misiek1294 » Thu Apr 23, 2015 7:02 pm

I'm working on This and i can't find
AssignBaseStats(pUnit, pMinion, pStatList);
AssignMod(pGame, pMinion, pSkillRecord->nSummUMod, 0);
D2GAME_UpdatePetAI(pGame, pMinion, pUnit->dwTargetGUID, 0);
and struct
->pAiControl->dwAiParam[1] = 0;
Can u help ?:)

User avatar
kidpaddle94
Forum Legend
Principality
Posts: 2057
Joined: Thu Aug 13, 2009 2:54 pm
Location: localhost
Canada

Re: Spawn summon monster

Post by kidpaddle94 » Fri Apr 24, 2015 6:57 am

The first function you mentioned is a custom function of my own. Here goes the other two:

Code: Select all

/*
	Function:		MONUMODS_AssignMod
	Address:		D2Game.0x232B0
	Notes:
*/
void __fastcall MONUMODS_AssignMod(D2GameStrc* pGame, D2UnitStrc* pMonster, int nMonUMod, BOOL bNewBoss)
{
	if (!pGame || !pMonster || nMonUMod <= 0) return;
	if (pMonster->dwType != UNIT_MONSTER || !pMonster->pMonsterData) return;
	
	if (bNewBoss)
	{
		int nLevel = pMonster->pMonsterData->dwTxtLevelNo;
		if (nLevel <= 0 || nLevel > TXT_GetLevelsRecordCount()) return;
		
		D2MonsterRegionStrc* pMonsterRegion = pGame->pMonRegion[nLevel];
		if (!pMonsterRegion) return;
		
		if (!MONSTERS_CheckMontypeFlag(pMonster, MONTYPEFLAG_UNIQUE))
		{
			pMonsterRegion->dwUniqueCount += 1;
			pMonster->pMonsterData->nTypeFlag |= MONTYPEFLAG_UNIQUE;
		}
	}
	
	for (int i = 0; i < 9; i++)
	{
		if (!pMonster->pMonsterData->nMonUMod[i])
		{
			pMonster->pMonsterData->nMonUMod[i] = (BYTE)nMonUMod;
			if (gptMonUModsInitFunctions[nMonUMod] != NULL)
			{
				gptMonUModsInitFunctions[nMonUMod](pMonster, nMonUMod, bNewBoss);
			}

			return;
		}
	}
}

Code: Select all

__declspec (naked) void __fastcall D2GAME_UpdatePetAI(D2GameStrc* pGame, D2UnitStrc* pPet, DWORD dwOwnerNodeIndex, DWORD dwType)
{
	__asm
	{
		push ebx
		push edi
		push [esp+0x10]
		mov ebx, [esp+0x10]
		mov edi, edx
		call D2GAME_6FD0FE40
		pop edi
		pop ebx
		retn 0x08
	}
}
As for the struct, click here

Code: Select all

struct D2MonsterDataStrc
{
	D2MonstatsTXT* pMonstatsRecord;				//0x00
	BYTE nComponent[16];						//0x04
	WORD nNameSeed;								//0x14
	BYTE nTypeFlag;								//0x16
	BYTE nLastAnimMode;							//0x17
	DWORD dwDurielFlag;							//0x18
	BYTE nMonUMod[10];							//0x1C
	WORD nBossHcidx;							//0x26
	D2AiControlStrc* pAiControl;				//0x28
	union										//0x2C
	{
		D2AiParamStrc* pAiParam;	//Server pMonster
		wchar_t* wszMonName;		//Client pMonster
	};
	DWORD __030[4];								//0x30
	DWORD dwNecropetFlag;						//0x40
	DWORD __UNK044[4];							//0x44
	DWORD dwAiState;							//0x54
	DWORD dwTxtLevelNo;							//0x58
	BYTE bSummonerFlag;							//0x5C
};

struct D2AiControlStrc
{
	DWORD dwSpecialState;			//0x00
	D2AiParam_t pAiParamFn;			//0x04
	DWORD dwAiFlags;				//0x08
	DWORD dwOwnerGUID;				//0x0C
	DWORD dwOwnerType;				//0x10
	DWORD dwAiParam[3];				//0x14
	D2AiCmdStrc* pCurrentCmd;		//0x20
	D2AiCmdStrc* pLastCmd;			//0x24
	D2GameStrc* pGame;				//0x28
	DWORD dwOwnerIdEx;				//0x2C
	DWORD dwOwnerTypeEx;			//0x30
	D2MinionListStrc* pMinionList;	//0x34
	int nTrapType;					//0x38
};

mengxuecen
Posts: 31
Joined: Mon Mar 11, 2019 5:34 am

Re: Spawn summon monster

Post by mengxuecen » Mon Apr 05, 2021 3:53 am

Help...

gptMonUModsInitFunctions Code?

User avatar
thaison
Junior Member
Paladin
Posts: 105
Joined: Fri Apr 03, 2015 11:59 am
Location: Viet Nam
Vietnam

Re: Spawn summon monster

Post by thaison » Tue Apr 06, 2021 2:34 pm

mengxuecen wrote:
Mon Apr 05, 2021 3:53 am
gptMonUModsInitFunctions

Code: Select all

typedef void(__fastcall* D2MonUModInit_t)(UnitAny* pMonster, int nMonUMod, BOOL bNewBoss);
D2VAR(D2GAME, gptMonUModsInitFunctions, D2MonUModInit_t, 0x10E550)

mengxuecen
Posts: 31
Joined: Mon Mar 11, 2019 5:34 am

Re: Spawn summon monster

Post by mengxuecen » Thu Apr 08, 2021 5:37 pm

Thx!thaison

Post Reply

Return to “Code Editing”