Hello, I wanted to buff every monster in the game, if it has lower level than hero.
So I made a function:
Code:
func void BuffMonster (var C_NPC monster, var int value){
if (value == 0)
{ value = (hero.level * (100+monster.level))/100; };
if (Npc_GetDistToNpc(hero, monster) < 2500)
{
if (hero.level > monster.level) && (monster.attribute[ATR_HITPOINTS] > 0)
{
monster.level = hero.level;// + monster.level;
monster.attribute[ATR_STRENGTH] += value;
monster.attribute[ATR_DEXTERITY] += value;
if (monster.attribute[ATR_HITPOINTS_MAX] < (40 + (12*monster.level)) * (((100+monster.level))/100))
{
monster.attribute[ATR_HITPOINTS_MAX] = (40 + (12*monster.level)) * (((100+monster.level))/100);
monster.attribute[ATR_HITPOINTS] = (40 + (12*monster.level)) * (((100+monster.level))/100);
};
monster.attribute[ATR_HITPOINTS_MAX] += value*(hero.level/20);
monster.attribute[ATR_HITPOINTS] += value*(hero.level/20);
if (((monster.protection[PROT_BLUNT] + monster.protection[PROT_EDGE] + monster.protection[PROT_POINT]
+ monster.protection[PROT_FIRE] + monster.protection[PROT_MAGIC] + monster.protection[PROT_FLY]) / 6) < 150)
{
monster.protection [PROT_BLUNT] += monster.level;
monster.protection [PROT_EDGE] += monster.level;
monster.protection [PROT_POINT] += monster.level;
monster.protection [PROT_FIRE] += monster.level;
monster.protection [PROT_FLY] += monster.level;
monster.protection [PROT_MAGIC] += monster.level;
};
};
};
};
Everything's alright, but only when I spawn a new monster, if the monster were already in the world, this function ignores it.
Scavenger was my doll, that tested everything, I used the function this way:
Code:
func void FGH()
{BuffMonster (Scavenger, 0);};
and this is called every frame in startup:
Code:
FF_ApplyOnce (FGH);
but still works only on new-summoned monsters.
I tried also with LeGo, but I don't know if the function is good:
Code:
func void FGH(){
var zCListSort list; list = _^(MEM_World.voblist_npcs);
while (list.next);
list = _^(list.next);
if (list.data)
{
var C_Npc npc; npc = _^(list.data);
if (npc.guild > GIL_SEPERATOR_HUM)
{
BuffMonster(npc, 0);
Print (npc.name);
};
};
end;
};
While using this function, I don't know why it only shows me the name of Orc-Warrior and does not buff any other monster (this should look forward for every npc, but it does not).
Could you, guys, help me? I would like to avoid using targetting functions as
Code:
var oCNpc her; her = Hlp_GetNpc(hero); var c_npc oth; oth = MEM_PtrToInst(her.focus_vob);
if (Hlp_Is_oCNpc(her.focus_vob))
{
if (oth.guild > GIL_SEPERATOR_HUM)
&& (oth.guild < GIL_SEPERATOR_ORC)
{
BuffMonster(oth, 0);
};
};