jobjorgos
Member
Im wondering how I can edit the value of a global variable from a string name as you can see below.
SCRIPT: scr_do_damage_to_enemy:
Somehow it does not affect the value of global.enemyhp0, global.enemyhp1, global.enemyhp2 etc.
I have about 40 different enemies and 30 different weapons, that would requires 40x30=1200 cases in a script which would make it way too big and messy.
Thats why I made this script to automate this and save time.
SCRIPT: scr_do_damage_to_enemy:
Code:
///scr_do_damage_to_enemy(enemy_id_number);
a = argument0; //the id of the enemy. it is just a number of 0 between 29 for every unique enemy
b = 'global.enemyhp'+string(a);
enemy_id = real(b);
if global.weapon == 0{
enemy_id -=1; //should remove 1HP from the enemy (not working right now too bad)
}
if global.weapon == 1{
enemy_id -=2; //should remove 2HP from the enemy (not working right now too bad)
}
if global.weapon == 2{
enemy_id -=6; //should remove 6HP from the enemy (not working right now too bad)
}
if global.weapon == 3{
enemy_id -=15; //should remove 15HP from the enemy (not working right now too bad)
}
//etc.
I have about 40 different enemies and 30 different weapons, that would requires 40x30=1200 cases in a script which would make it way too big and messy.
Thats why I made this script to automate this and save time.
Last edited: