Talk:CheckActorClass
Hello,
I transcribed the script example of this element, but it does not work. I made that action happens when the player kills a monster (Monster death event). This is used to give an amount of experience point depending of the type of monster.
This is my script:
World Int 0:Lvl; // Actual Level Number World Int 1:Exp; World Int 2:ExpNeeded; #Define MaxNumber_Classes 17 Str mExpArray[MaxNumber_Classes][2] /*mExpArray[Monster][Exp Value]*/ = { {"LostSoul", 1}, /*0-LostSoul (110)*/ {"ZombieMan", 2}, /*1-Zombie (4)*/ {"ShotgunGuy", 4}, /*2-Shotguy (1)*/ {"Doomimp", 5}, /*3-Imp (5)*/ {"Demon", 5}, /*4-Demon (8)*/ {"Spectre", 5}, /*5-Spectre (9)*/ {"ChaingunGuy", 6}, /*6-Chainguy (2)*/ {"Cacodemon", 7}, /*7-Cacodemon (19)*/ {"HellKnight", 8}, /*8-HellKnight (113)*/ {"BaronOfHell", 10}, /*9-Baron (3)*/ {"Arachnotron", 12}, /*10-Arachnotron (6)*/ {"PainElemental", 14}, /*11-Painelemental (115)*/ {"Revenant", 16}, /*12-Revenant (20)*/ {"Fatso", 18}, /*13-Mancubus (112)*/ {"Archvile", 20}, /*14-Vile (111)*/ {"Spidermastermind", 75}, /*15-SpiderMasterMind (7)*/ {"Cyberdemon", 100} /*16-CyberDemon (114)*/ }; Script 255 (Int TID) { Int Class_Index; For(Int a = 0; a < MaxNumber_Classes; a++) { If(CheckActorClass(TID, "Demon")) { Class_Index = a; } } Exp += mExpArray[Class_Index][1]; } Script 999 Enter { ExpNeeded = 50+25*Lvl; SetFont("BigFont"); HudMessageBold(s:"Lvl "; HUDMSG_PLAIN, 0, CR_GOLD, 0.88, 0.9, 0); HudMessageBold(d:Lvl; HUDMSG_PLAIN, 6, CR_WHITE, 0.9, 0.9, 0); SetFont("SmallFont"); HudMessageBold(s:"Exp: ", d:Exp, c:'/', d:ExpNeeded; HUDMSG_PLAIN, 7, CR_BLACK, 0.9, 0.95, 0); If(Exp >= ExpNeeded) { Lvl++; SetFont("BigFont"); HudMessageBold(s:"LEVEL UP!"; HUDMSG_TYPEON | HUDMSG_LOG, 8, CR_UNTRANSLATED, 0.5, 0.3, 0); } Delay(3); Restart; }
As you see, I've replaced the variable by "Demon", because I tested it on a Demon. Can someone help me plz? It's been 2 days I'm looking for the solution. My doom builder 2's version is 2.1.2.1553.
English is my second language, I'm sorry for my errors.
thanks for your comprehension —Preceding unsigned comment added by Xanadu (talk • contribs) 00:27, 10 March 2013
- "As you see, I've replaced the variable by "Demon", because I tested it on a Demon." And that is precisely the source of your problem.
For(Int a = 0; a < MaxNumber_Classes; a++) { If(CheckActorClass(TID, "Demon")) { Class_Index = a; } }
- You are going to check if the monster is a demon each time. Since your monster is a demon, it'll be true every time. And every time, Class_Index will be set to the new value of a. This means that once the for loop is finished, Class_Index will be 16 (MaxNumber_Classes - 1). Inversely, if your monster isn't a demon, then the check will never be true, and Class_Index will never be given a value (so it'll stay at the default initialization value of 0).
- In short, if your monster is a demon, you'll get cyberdemon XP, and if it isn't a demon, you'll get lost soul XP. To solve this problem, go back to what the example showed:
For(Int a = 0; a < MaxNumber_Classes; a++) { If(CheckActorClass(TID, mExpArray[a][0])) { Class_Index = a; } }
- That should work. (At least, as long as you don't use monsters from a different class than all of those.) --Gez (talk) 04:19, 10 March 2013 (CDT)
I found my problem.
When I kill a monster, the killer is not the activator of the script, but the monster.
I found another way to do it:
Str mExpArray[MaxNumber_Classes][2] = { {"LOSTSOUL", 1}, /*0-LostSoul (110)*/ {"ZOMBIEMAN", 2}, /*1-Zombie (4)*/ {"SHOTGUNGUY", 4}, /*2-Shotguy (1)*/ {"DOOMIMP", 5}, /*3-Imp (5)*/ {"Demon", 5}, /*4-Demon (8)*/ {"SPECTRE", 5}, /*5-Spectre (9)*/ {"CHAINGUNGUY", 6}, /*6-Chainguy (2)*/ {"CACODEMON", 7}, /*7-Cacodemon (19)*/ {"HELLKNIGHT", 8}, /*8-HellKnight (113)*/ {"BARONOFHELL", 10}, /*9-Baron (3)*/ {"ARACHNOTRON", 12}, /*10-Arachnotron (6)*/ {"PAINELEMENTAL", 14}, /*11-Painelemental (115)*/ {"REVENANT", 16}, /*12-Revenant (20)*/ {"FATSO", 18}, /*13-Mancubus (112)*/ {"ARCHVILE", 20}, /*14-Vile (111)*/ {"SPIDERMASTERMIND", 75}, /*15-SpiderMasterMind (7)*/ {"CYBERDEMON", 100} /*16-CyberDemon (114)*/ }; Script 254 (Int mTID) { Int mType; For(Int m = 0; m < MaxNumber_Classes; m++) { If(mExpArray[m][0] == mExpArray[mTID][0]) { mType = m; } } Exp += mExpArray[mType][1]; }
I'll have to write the monster type in the first argument(mTID) of each monsters.