Jump to content

Photo

Help with enemy script / leveling enemies


  • Please log in to reply
44 replies to this topic

#16 Flying Fish

Flying Fish

    King of the Fish

  • Members
  • Real Name:Flying fish
  • Location:Under the sea

Posted 30 October 2015 - 08:59 AM

Ok i will try messing with the MISC more and seeing if i can set that up.

 

I forgot to remove that for loop since I was moving around code trying out different methods on getting it to somewhat work. 

 

I was going by those files in the ZC directory and the tutorials on the purezc forums as how to get to where I am now with the code.

 

I will be moving away from each enemy having the same stats i was starting simple and keep building upon that till I could have different base stats. 

 

So Misc pointer would work somewhat like this 

 

const int MEXPM = 0;

global script Mexp
{
void run (int enehealth, int enepow, int wenepow){
npc eexp;
enehealth = 1;
enepow = 1;
wenepow = 1;


while (true)
{
if (eexp->Misc[MEXPM] =! 0)
{
enehealth = enehealth  * 2.1;
enepow = enepow * 2.1;
wenepow = wenepow * 2.1;
eexp->Misc[MEXPM] = 0;
}
Waitframe();
}
}}

And after this have and item script to make MEXP set to not 0 to set off the script when you pick up that item. 


Edited by Flying Fish, 30 October 2015 - 09:29 AM.


#17 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 30 October 2015 - 09:55 AM

You'll still definitely need a for loop, I was just saying that you don't have to manually set the value of the counter variable. And every value of the Misc array will be 0 when a new enemy is created, so you'll want to check for that instead. Something like this.

for (int npccounter = 1; npccounter <= Screen->NumNPCs(); npccounter ++)
{
     eexp = Screen->LoadNPC(npccounter);
     if (eexp->Misc[0] == 0)
     {
          //stuff
          eexp->Misc[0] = 1;
     }
}


#18 Flying Fish

Flying Fish

    King of the Fish

  • Members
  • Real Name:Flying fish
  • Location:Under the sea

Posted 30 October 2015 - 10:02 AM

what about summoner's and creatures that appear after this runs? i kept running into a problem with the spawned enemies were not effected by the modification with the for loop in place.

I will keep the for loop and continue testing this


Edited by Flying Fish, 30 October 2015 - 10:08 AM.


#19 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 30 October 2015 - 10:19 AM

That's why it's in your global active script's while loop. It runs continuously, every frame. If it finds an enemy whose Misc[0] is 0, it does the stat change.



#20 Flying Fish

Flying Fish

    King of the Fish

  • Members
  • Real Name:Flying fish
  • Location:Under the sea

Posted 30 October 2015 - 10:27 AM

and every time I pick up an item that will implement the stat boost, i can set that Misc back to 0 to implement the stat change again to increase their stats again?

That is what I am seeing from this and examples that were given.



#21 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 30 October 2015 - 10:35 AM

The game doesn't really keep track of base stats, i.e. if an enemy's Damage stat started as 2 and gets increased to 4, the game won't remember that it was originally 2. You'd have to either store that information yourself or spawn a new instance of the enemy. I don't think most of these enemy stat values will retain anything after the decimal point, either (i.e. they're integers), so having an item pickup increase them very slightly probably won't work. It doesn't seem worthwhile anyway. Picking up an item and immediately seeing stat changes for any enemies currently on the screen is an edge case that doesn't seem worth the effort. Globally altering enemies based on Link's equipment when they appear is much easier.

 

And in case it wasn't clear, each and every enemy has their own Misc array. It's not a thing there's only one of. If you set Misc[0] = 1 on one enemy, Misc[0] will still be 0 on the enemy standing next to it.


Edited by Lejes, 30 October 2015 - 10:38 AM.


#22 Flying Fish

Flying Fish

    King of the Fish

  • Members
  • Real Name:Flying fish
  • Location:Under the sea

Posted 30 October 2015 - 10:53 AM

I was aiming to increase the base stats of the enemies through a increasing multiplier (enepow, enehealth) and that multiplier increases as you pick up items, instead of modifying the base stats (it would look like somewhere along the lines eexp->hp would equal its basic HP stat times the enehealth multiplier (it will have a default and increase by a percentage for each item aquired)). I do not know if ZC has can round integers?

 

The reason I am making a script like this is because the game i am working on the entire game is open to the player and all the places you can explore and dungeon can be done in any order. I would like the enemies to get stronger as you progress through the game to make the game be more challenging. and doing items is the only thing i can think of on how to approach this problem.



#23 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 30 October 2015 - 11:19 AM

You can set HP to 10.1 or whatever all you want. It'll get immediately truncated by ZC if it thinks that value should be an integer. The multipliers themselves aren't tied to what ZC thinks enemy stats can be, so those can be whatever you want out to 4 decimal places. What you're trying to do will work and isn't all that hard to do. I'm not sure you're understanding what the Misc array does, though, because this statement

 

 

i can set that Misc back to 0 to implement the stat change again to increase their stats again?

doesn't make any sense.

 

Every enemy's Misc array will automatically be initialized as zero in all 16 elements when it spawns. Setting one of those values to not-zero is how you mark the enemy as done with, so the stats aren't multiplied infinitely for every enemy.



#24 Flying Fish

Flying Fish

    King of the Fish

  • Members
  • Real Name:Flying fish
  • Location:Under the sea

Posted 30 October 2015 - 11:28 AM

so how would i go about increasing the multiplier as i acquire items?

 

As for that quote I was thinking i could use the misc array to set it back to zero for the increasing the multiplier part of the script and not the applying to the enemies part of the script.  I do apologize if i mislead you i should of clarified that more and I do appreciate the helping me understanding this. 



#25 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 30 October 2015 - 06:30 PM

The multiplier would be a variable that you define yourself. You could attach pickup scripts to everything that increase it, dynamically recalculate it every frame, or a mix of both. Your string of "else if" statements wouldn't really work for this, since ideally you'd want everything to compound instead of being mutually exclusive like that.

HP_multiplier = (Link->MaxHP * 0.125 * 0.5) + (Link->MaxMP * 0.0313 * 0.5) + (numTriforce * 1.2);

A line like this could be in your global, executed every frame. Link's max HP and MP would be game values, but "numTriforce" would be a global variable you defined yourself that the pickup script for the Triforce item increments. If you want specific items to have effects on the multiplier, you could use if statements after that to check if the player has them, and add more to HP_multiplier if so. No need for a complicated if else chain.

 

As for Misc, unless I'm really misunderstanding what you want to do, there should never be any need to set it back to zero, ever.



#26 Flying Fish

Flying Fish

    King of the Fish

  • Members
  • Real Name:Flying fish
  • Location:Under the sea

Posted 30 October 2015 - 11:44 PM

 

The multiplier would be a variable that you define yourself. You could attach pickup scripts to everything that increase it, dynamically recalculate it every frame, or a mix of both. Your string of "else if" statements wouldn't really work for this, since ideally you'd want everything to compound instead of being mutually exclusive like that.

HP_multiplier = (Link->MaxHP * 0.125 * 0.5) + (Link->MaxMP * 0.0313 * 0.5) + (numTriforce * 1.2);

A line like this could be in your global, executed every frame. Link's max HP and MP would be game values, but "numTriforce" would be a global variable you defined yourself that the pickup script for the Triforce item increments. If you want specific items to have effects on the multiplier, you could use if statements after that to check if the player has them, and add more to HP_multiplier if so. No need for a complicated if else chain.

cool i can give that a try setting that up for a multiplier, 

 

As for Misc, unless I'm really misunderstanding what you want to do, there should never be any need to set it back to zero, ever.

I scraped that ideal of trying to use Misc like that.


Edited by Flying Fish, 30 October 2015 - 11:48 PM.


#27 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 31 October 2015 - 12:05 AM

You're going to have to use Misc, though? I'm having trouble seeing how you'd do it otherwise. The reason you're using it is because it's necessary to mark each enemy as already having leveled up, because you don't want to do this more than once to any single enemy. And for reasons of convenience as well as dealing with the problem of new enemies that get summoned after entering a room, this script would be global and running non-stop, cycling through every enemy present, every frame.



#28 Flying Fish

Flying Fish

    King of the Fish

  • Members
  • Real Name:Flying fish
  • Location:Under the sea

Posted 31 October 2015 - 12:14 AM

I meant with the whole setting it to zero and so forth.



#29 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 31 October 2015 - 12:16 AM

I'd need to check, but I believe that Link->Misc[] is saved between sessions. If so, you can use that, to store your multiplier/modifier.

 

I use tables, stored as custom arrays for that, and I set enemy HP based on their initial value, multiplied by Rand( 1,10 ) or Rand( 1,8 ) for diversity. (Treated as hit dice.)

 

You can update Link->Misc[ENEMY_DIFFICULTY] -- you will need to define that as a constant, from 0 to 15 -- by +1 each time the player picks up a LI_TRIFORCE, or any desired item. That may make it simpler to automate this kind of difficulty bump.


Edited by ZoriaRPG, 31 October 2015 - 12:20 AM.


#30 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 31 October 2015 - 12:37 AM

Link->Misc isn't saved between sessions. F6 Continue and saving and quitting both reset it to zero. A simple global variable for miscellaneous items like the Triforce would have to do. Since I was bored I went ahead and made this script.

 

Enemy Level Up

 

I included a debug display that shows the stats of an enemy in the room (press Ex1 to change which enemy's stats are displayed). This is just a first pass. The multipliers as-is produce ludicrously high values, and you'd probably want to add exceptions for certain enemy types, more specific item rules, etc.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users