Jump to content

Photo

Help with enemy script / leveling enemies


  • Please log in to reply
44 replies to this topic

#1 Flying Fish

Flying Fish

    King of the Fish

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

Posted 26 October 2015 - 10:45 AM

I am trying to figure out how to increase the base enemy stats over time, or based on the items you acquired (including triforce pieces and health upgrades, but not items like rupees, bombs ammo, hearts, and arrows ammo).

So as the stronger you get the enemies will also get stronger, kind of like Final Fantasy 8 enemy system where the enemies strength/lvl was based on your level.

Any help will be appreciated.



#2 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 26 October 2015 - 10:46 PM

You could use a global script that checks every enemy on screen every frame, and changes its stats if they haven't been initialized yet. You'd mark them by setting a value in npc->Misc, so they don't get the stat boost infinitely. The stats would be just what you see in the enemy editor. All the relevant ones can be changed via script. npc->HP, npc->Damage, npc->WeaponDamage, npc->Step, and npc->Homing are the ones you'd probably want to change. Maybe even npc->Weapon if you want to get really mean with it. The real question is deciding how much each game variable like hearts and Triforce pieces will affect those stats. You can check Link->MaxHP for hearts (remember that there are 16 HP per heart), and either attach a pickup script to increment a counter to the Triforce item or check Game->LItems[] directly.


  • coolgamer012345 likes this

#3 Flying Fish

Flying Fish

    King of the Fish

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

Posted 27 October 2015 - 05:17 AM

Thanks I'll have to try using a global script which I not really familiar with, but I was also thinking it was a an script you could attach to enemies themselves like an item script.



#4 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 27 October 2015 - 06:39 AM

Yeah, I'd do global variables all the way. The first thing that comes to mind is simple modifiers that you multiply with enemy stats to get the modified value (Like maybe it starts at 1 and increments by 0.1 for every 'level' the player is or something). Kind of like if you had a 'hard mode' script you could have a simple multiplier value for every stat you wanted to buff and could tweak them seperately. This may not be what you want, but I'm just mentioning it because it's by far the easiest way to do it if you're in 'trial and error' mode.

#5 Flying Fish

Flying Fish

    King of the Fish

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

Posted 27 October 2015 - 06:53 AM

I will try the global method seems a bit stable from both of your explanations I was going with all the enemies are going to start base 1 states and a percentage increase based on items picked up, but i also want some of enemies to be slightly stronger than the base enemies.  I think I can just change the base stats to achieve that goal.

 

I guess I got a lot of research on global scripting ahead of me


Edited by Flying Fish, 27 October 2015 - 06:54 AM.


#6 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 27 October 2015 - 03:53 PM

Writing a global script is not more complicated than writing a local one. You just have to keep in mind it'll be running all the time, so you have to mind possible interactions with other scripts if you have any.



#7 Flying Fish

Flying Fish

    King of the Fish

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

Posted 27 October 2015 - 04:40 PM

Yeah I agree about that and will require a lot of testing with the others scripts that will be added with it in the game.



#8 Flying Fish

Flying Fish

    King of the Fish

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

Posted 29 October 2015 - 01:24 PM

The problem i am running into is the items you can pick up multiple copies of like the heart containers, magic containers, and heart pieces. I might have to add a script to those items to reset a value in the global script to be able run that function again.

I figured out a way to do it for each individual item but it looks like it will be a very bulky and long drawn out script to do this with each item in the game. 

 

Is there a way to simplify this to work or do I have to do it for item in the game to increase the enemeis base stats?

 

For being pretty new to ZC scripting, it is hard not to write this in C++, C#, or java.


Edited by Flying Fish, 29 October 2015 - 01:26 PM.


#9 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 29 October 2015 - 08:05 PM

The number of heart containers, magic containers, and heart pieces you have can be inferred from Link->MaxHP, Link->MaxMP, and Game->Generic[GEN_HEARTPIECES], respectively, so you don't necessarily have to attach an item script to all of them. The way I was thinking of how to implement this would be fairly simple and short. Maybe you could post what you've got so far?



#10 Flying Fish

Flying Fish

    King of the Fish

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

Posted 29 October 2015 - 08:15 PM

Oh it is a mess right now I trying to figure out why I keep getting immortal enemies when I pick up my first item.

I can post it when I get past that problem.

 

for the hearts I did when by Link's max HP since that was easier to do.

For Mp I went by the magic 32 number since every jar is 32 I just did a check at every 32.

The Triforce I just added a counter inter to the pick up for it.



#11 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 30 October 2015 - 01:45 AM

If you can wait a while, I'll post a modified version of how I do this.



#12 Flying Fish

Flying Fish

    King of the Fish

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

Posted 30 October 2015 - 05:08 AM

When I get home I can post what I have so far for this script. I still have not gotten the triforce part to work yet and have really tried to get it to work since I was dealing with other minor problems.



#13 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 30 October 2015 - 06:51 AM

Oh it is a mess right now I trying to figure out why I keep getting immortal enemies when I pick up my first item.

 

Did you set up the npcs' Misc variable, to ensure the stats are only altered once?



#14 Flying Fish

Flying Fish

    King of the Fish

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

Posted 30 October 2015 - 07:24 AM

no not very familiar with how to use misc variables yet fairly new to this I just somewhat figured out pointers and how to use them, but i got it to modify the atk as i acquire more items/health but i need to figure that out for the health portion. I will look into more about the misc variables and so far i am having trouble is finding is available in ZC and looking at the txt files in the ZC directory is a little hard to read and make sense. My problems so far is the npc health and the misc variable thing might fix that and setting up the triforce to increase the stats. I only need to modify the health, power, weapon power for all enemies on the screen.

 

Here is what i figure out messing with it so far...

 

const int tfcounter = 0;


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


//inventory check
int z_has_bow = 0;
int z_has_arrow1 = 0;
int z_has_wand = 0;
int z_has_sword1 = 0;


//life check
int z_has_heart1 = 0;


//magic check
int z_has_magic1 = 0;
int z_has_magic2 = 0;
int z_has_magic3 = 0;
int z_has_magic4 = 0;
int z_has_magic5 = 0;
int z_has_magic6 = 0;
int z_has_magic7 = 0;
//Triforce check
int z_has_Trif1 = 0;


while (true)
{


if (Link->Item[15] && z_has_bow == 0)
{
  z_has_bow = 1;


enehealth = enehealth  * 2.1;
enepow = enepow * 2.1;
wenepow = wenepow * 2.1;


Waitframe();


}


else if (Link->Item[13] && z_has_arrow1 == 0)
{ 
z_has_arrow1 = 1;
enehealth = enehealth * 2.1;
enepow = enepow * 2.1;
wenepow = wenepow * 2.1;
Waitframe();


}


else if (Link->Item[5] && z_has_sword1 == 0)
{ 
z_has_sword1 = 1;
enehealth = enehealth * 2.1;
enepow = enepow * 2.1;
wenepow = wenepow * 2.1;
Waitframe();


}


else if (Link->MaxHP == 80 && z_has_heart1 == 0)
{ 
enehealth = enehealth * 1.1;
enepow = enepow * 1.1;
wenepow = wenepow * 1.1;
z_has_heart1 = 1;
Waitframe();
}


//triforce counter used for check to do stats counter will be increased by collecting a triforce piece as an addon to the //triforce item.


else if (tfcounter == 1 && z_has_Trif1 == 0)
{ 
enehealth = enehealth * 1.1;
enepow = enepow * 1.1;
wenepow = wenepow * 1.1;
z_has_Trif1 = 1;
Waitframe();
}


if(npccounter <= Screen->NumNPCs()){
for (npccounter = 1; npccounter <= Screen->NumNPCs(); npccounter ++)
{
eexp = Screen->LoadNPC(npccounter);
eexp->Damage = enepow; 
eexp->WeaponDamage = wenepow;


}
}
else 
{ 
npccounter = 0;
Waitframe();
}




Waitframe();


}
}}

 


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


#15 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 30 October 2015 - 08:42 AM

This forum has code tags, to make your stuff more readable. They're to the left of the quote button on the post editor, or just typing "code" in brackets.

 

Firstly, you only want one Waitframe in your global. You could also condense all of this to a function, to make it look cleaner and to make combining it with other things easier. What everybody means by "Misc" is an array that the NPC pointer has. You'd use it like this.

 

eexe->Misc[0] = 1;

 

Each enemy has their own copy of this array, so you could set it along with the stat changes, and then check it in your conditional so that any enemy that already had its Misc value set won't go through the stat change again. The way you've implemented the multipliers will also make every enemy have the same stats. You should do something like

eexe->Damage *= enepow;

instead of setting it directly equal to it.

 

Some other things: you don't need to declare variables as arguments to run() in a global script, that feature is only used in item and FFC scripts. You also don't need to manage the for loop's counter variable yourself, it can be reinitialized every time the code hits the loop by just declaring it inside the parentheses. zscript.txt, std.txt, and std_constants.zh have a lot of the stuff you'd need to know about ZScript. They're all found in the base ZC directory.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users