void addItem(char *type, int yPos, int xPos){ if(!strcmp(type,"Pistol")){ struct Item pistolItem = {.type="Pistol", .symbol='p', .isAlive=1, .curXpos=xPos, .curYpos=yPos}; int i; for (i=0;i<MAX_ITEMS;i++){ if(!allItems[i].isAlive){ allItems[i]=pistolItem; break; } } } if(!strcmp(type,"Shotgun")){ struct Item shotgunItem = {.type="Shotgun", .symbol='s', .isAlive=1, .curXpos=xPos, .curYpos=yPos}; int i; for (i=0;i<MAX_ITEMS;i++){ if(!allItems[i].isAlive){ allItems[i]=shotgunItem; break; } } } } void tryRandomEvent(){ int eventTrigger = (rand()%100)+1; if (eventTrigger < 1+zombieModifier){ struct OpenPos openPos = getOpenPos(); addZombie(openPos.y, openPos.x); } if (eventTrigger < 5+itemModifier){ int i; int x=0; for (i=0;i<MAX_ITEMS;i++){ if(allItems[i].isAlive && !strcmp(allItems[i].type,"Shotgun")){ x++; } } if(x==0){ struct OpenPos openPos = getOpenPos(); addItem("Shotgun", openPos.y, openPos.x); } } if (eventTrigger < 10+itemModifier){ int i; int x=0; for (i=0;i<MAX_ITEMS;i++){ if(allItems[i].type && !strcmp(allItems[i].type,"Pistol")){ x++; } } if(x<3){ struct OpenPos openPos = getOpenPos(); addItem("Pistol", openPos.y, openPos.x); } } }
void AllZombies::sendZombies() { counter++; int row =(qrand() % (ROW_NUMBER)) + 0; // int row = 3; // qDebug()<<qrand(); // int type=1; int type = (qrand() % 3)+1; addZombie(row,type); // addZombie(ROW_NUMBER-1,type); }