gggmork
If you can make any sense of this post, congratulations

Posts: 2381
Registered: 06-07 |
Ok, I figured it out:
make a doom in hexen map. put 3 mapspots in, tagged 1-3 (if have more mapspots, have to change the
#define numberOfInitialMapspots 3
value.
Then this code should work I guess (works for me). Have to fiddle with values in the arrays to do what you want and stuff.
If you run this, does it print "(whichever monster) died" every time someone dies? For me it keeps printing "allmap died" but I think that's just cuz I re-edited an old wad with unintentional lingering cacodemon decorate, which shouldn't be a problem for your wad.
code:
#include "zcommon.acs"
//PUT HOW MANY INITIAL MAPSPOTS THERE ARE
//and give each initial mapspot a ++ numbered tid starting at 1
#define numberOfInitialMapspots 3
//a list of points, each with an [x,y]
int initialPoints[numberOfInitialMapspots][2];
int items[14] = {"Allmap","ArmorBonus","Berserk","BlueArmor","BlurSphere","GreenArmor","HealthBonus",
"Infrared","InvulnerabilitySphere","Medikit","Megasphere","RadSuit","Soulsphere","Stimpack"};
int monsters[18] = {"arachnotron", "archvile", "baronofhell", "hellknight", "cacodemon", "cyberdemon",
"demon", "spectre", "chaingunguy", "doomimp", "fatso", "lostsoul", "painelemental",
"revenant", "shotgunguy", "spidermastermind", "wolfensteinss", "zombieman"};
int SpawnedItemChances[18][14] = {{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
//see, the below array is the 14th index of spawnedItemChances (counting starts at 0)
//which is the shotgun guy (14th of monsters array)
//I set 2:berserk to 9 and 4:blursphere to 14.
//this means 9/23 chance for berserk and 14/23 chance for blursphere (23 is 14+9)
//(corresponding to position in the items[] array)
{0,0,9,0,14,0,0,0,0,0,0,0,0,0},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4},
{0,9,4,0,2,0,0,1,6,0,0,0,0,4}};
//below 5 arays correspond to 5 skills, like 6+4+3+2+9+9+9=42, so 6/42 chance of an arachnotron in skill 1 etc
int MonsterChancesPerSkill[5][18] = {{6,0,0,4,3,2,9,0,0,0,9,0,0,0,9,0,0,0},
{6,0,0,4,3,2,9,0,0,0,9,0,0,0,9,0,0,0},
{6,0,0,4,3,2,9,0,0,0,9,0,0,0,9,0,0,0},
{6,0,0,4,3,2,9,0,0,0,9,0,0,0,9,9,0,0},
{6,0,0,4,3,2,9,0,0,0,9,0,0,0,9,0,0,0}};
script 1 open
{
int i,j,tid;
int initialx,initialy,x,y;
int gridwidth = 5;
int gridheight = 3;
int numMapSpots = numberOfInitialMapspots * gridwidth * gridheight;
int total;
int r;
int spottid;
int monsterindex;
int tally;
//get the points of initial mapspots
for(i=1;i<=numberOfInitialMapspots;i++)
{
initialPoints[i-1][0] = getactorx(i);
initialPoints[i-1][1] = getactory(i);
}
//remove those initial mapspots because they were only needed to get initial x/y locations
for(i=1;i<=numberOfInitialMapspots;i++)
{
thing_remove(i);
}
//spawn mapspots (kinda pointless, why not just spawn monsters with no mapspots?)
tid=1;
for(i=0;i<numberOfInitialMapspots;i++)
{
for(y = initialPoints[i][1]; y>initialPoints[i][1]-(256.0*gridheight); y-=256.0)
{
for(x = initialPoints[i][0]; x<initialPoints[i][0]+(256.0*gridwidth); x+=256.0)
{
spawn("mapspot",x,y,0,tid,192);
tid++;
}
}
}
//spawn random monsters to mapspots depending on skill
for(spottid=1; spottid<=numMapSpots; spottid++)
{
total = 0;
for(i=0; i<18; i++)
{
total+=monsterChancesPerSkill[gameskill()][i];
}
if(total!=0)
{
r=random(0,total-1);
tally=0;
for(i=0; i<18; i++)
{
tally += monsterChancesPerSkill[gameskill()][i];
if(monsterChancesPerSkill[gameskill()][i] != 0 && r < tally)
{
monsterIndex = i;
break;
}
}
//each monster runs script 2, giving it its tid as a parameter
spawnspot(monsters[monsterIndex], spottid, tid, 192);
setthingspecial(tid, acs_executealways(2,0,tid));
tid++;
}
}
}
script 2(int tid)
{
int dead=0;
int i;
int total,tally,r,monsterIndex,thingIndex;
While(dead==0)
{
if(getactorproperty(tid,APROP_health) <= 0)
{
for(i=0;i<18;i++)
{
if(checkactorclass(tid,monsters[i]))
{
monsterIndex=i;
break;
}
}
print(s:monsters[monsterIndex], s:" died ", d:monsterIndex);
delay(100);
total = 0;
for(i=0; i<14; i++)
{
total+=spawnedItemChances[monsterIndex][i];
}
if(total!=0)
{
r=random(0,total-1);
tally=0;
for(i=0; i<14; i++)
{
tally += spawnedItemChances[monsterIndex][i];
if(spawnedItemChances[monsterIndex][i] != 0 && r < tally)
{
thingIndex = i;
break;
}
}
spawn(items[thingIndex],getactorx(tid),getactory(tid),0);
dead=1;
}
}
delay(1);
}
}
Last edited by gggmork on 01-16-13 at 23:19
|