From: Côme BERNIGAUD Date: Fri, 13 May 2011 15:00:35 +0000 (+0200) Subject: Weapon clean up. X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=8a1a91c0a10a37799dc95d423f9db8dc5ff7b965;p=lugaru.git Weapon clean up. --- diff --git a/Source/Awards.cpp b/Source/Awards.cpp index cbfe381..726eaec 100644 --- a/Source/Awards.cpp +++ b/Source/Awards.cpp @@ -104,7 +104,7 @@ int award_awards(int *awards) awards[numawards]=awardknifefighter; numawards++; } - if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){ + if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.size()>0){ awards[numawards]=awardkungfu; numawards++; } diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index 2a9a405..10ead71 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -943,42 +943,42 @@ void Game::LoadStuff() LOG("Loading weapon data..."); - LoadTexture(":Data:Textures:knife.png",&weapons.knifetextureptr,0,1); - LoadTexture(":Data:Textures:bloodknife.png",&weapons.bloodknifetextureptr,0,1); - LoadTexture(":Data:Textures:lightbloodknife.png",&weapons.lightbloodknifetextureptr,0,1); - LoadTexture(":Data:Textures:sword.jpg",&weapons.swordtextureptr,1,0); - LoadTexture(":Data:Textures:Swordblood.jpg",&weapons.bloodswordtextureptr,1,0); - LoadTexture(":Data:Textures:Swordbloodlight.jpg",&weapons.lightbloodswordtextureptr,1,0); - LoadTexture(":Data:Textures:Staff.jpg",&weapons.stafftextureptr,1,0); - - weapons.throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1); - weapons.throwingknifemodel.Scale(.001,.001,.001); - //weapons.throwingknifemodel.Rotate(0,0,-90); - weapons.throwingknifemodel.Rotate(90,0,0); - weapons.throwingknifemodel.Rotate(0,90,0); - weapons.throwingknifemodel.flat=0; - weapons.throwingknifemodel.CalculateNormals(1); - //weapons.throwingknifemodel.ScaleNormals(-1,-1,-1); - - weapons.swordmodel.load((char *)":Data:Models:sword.solid",1); - weapons.swordmodel.Scale(.001,.001,.001); - //weapons.swordmodel.Rotate(0,0,-90); - weapons.swordmodel.Rotate(90,0,0); - weapons.swordmodel.Rotate(0,90,0); - weapons.swordmodel.Rotate(0,0,90); - weapons.swordmodel.flat=1; - weapons.swordmodel.CalculateNormals(1); - //weapons.swordmodel.ScaleNormals(-1,-1,-1); - - weapons.staffmodel.load((char *)":Data:Models:staff.solid",1); - weapons.staffmodel.Scale(.005,.005,.005); - //weapons.staffmodel.Rotate(0,0,-90); - weapons.staffmodel.Rotate(90,0,0); - weapons.staffmodel.Rotate(0,90,0); - weapons.staffmodel.Rotate(0,0,90); - weapons.staffmodel.flat=1; - weapons.staffmodel.CalculateNormals(1); - //weapons.staffmodel.ScaleNormals(-1,-1,-1); + LoadTexture(":Data:Textures:knife.png",&Weapon::knifetextureptr,0,1); + LoadTexture(":Data:Textures:bloodknife.png",&Weapon::bloodknifetextureptr,0,1); + LoadTexture(":Data:Textures:lightbloodknife.png",&Weapon::lightbloodknifetextureptr,0,1); + LoadTexture(":Data:Textures:sword.jpg",&Weapon::swordtextureptr,1,0); + LoadTexture(":Data:Textures:Swordblood.jpg",&Weapon::bloodswordtextureptr,1,0); + LoadTexture(":Data:Textures:Swordbloodlight.jpg",&Weapon::lightbloodswordtextureptr,1,0); + LoadTexture(":Data:Textures:Staff.jpg",&Weapon::stafftextureptr,1,0); + + Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1); + Weapon::throwingknifemodel.Scale(.001,.001,.001); + //Weapon::throwingknifemodel.Rotate(0,0,-90); + Weapon::throwingknifemodel.Rotate(90,0,0); + Weapon::throwingknifemodel.Rotate(0,90,0); + Weapon::throwingknifemodel.flat=0; + Weapon::throwingknifemodel.CalculateNormals(1); + //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1); + + Weapon::swordmodel.load((char *)":Data:Models:sword.solid",1); + Weapon::swordmodel.Scale(.001,.001,.001); + //Weapon::swordmodel.Rotate(0,0,-90); + Weapon::swordmodel.Rotate(90,0,0); + Weapon::swordmodel.Rotate(0,90,0); + Weapon::swordmodel.Rotate(0,0,90); + Weapon::swordmodel.flat=1; + Weapon::swordmodel.CalculateNormals(1); + //Weapon::swordmodel.ScaleNormals(-1,-1,-1); + + Weapon::staffmodel.load((char *)":Data:Models:staff.solid",1); + Weapon::staffmodel.Scale(.005,.005,.005); + //Weapon::staffmodel.Rotate(0,0,-90); + Weapon::staffmodel.Rotate(90,0,0); + Weapon::staffmodel.Rotate(0,90,0); + Weapon::staffmodel.Rotate(0,0,90); + Weapon::staffmodel.flat=1; + Weapon::staffmodel.CalculateNormals(1); + //Weapon::staffmodel.ScaleNormals(-1,-1,-1); //temptexdetail=texdetail; //if(texdetail>4)texdetail=4; diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index b1f3ecc..ce260d6 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -303,7 +303,7 @@ static void ch_save(Game *game, const char *args){ player[0].rotation, player[0].targetrotation, player[0].num_weapons); if(player[0].num_weapons>0&&player[0].num_weapons<5) for(int j=0;j=15) @@ -1592,10 +1592,10 @@ void Game::Loadlevel(const char *name){ player[0].originalcoords=player[0].coords; if(player[0].num_weapons>0&&player[0].num_weapons<5) for(int j=0;j0&&player[i-howmanyremoved].num_weapons<5){ for(int j=0;j0){ - if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff; - else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife; - else weapons.type[player[0].weaponids[0]]=sword; - if(weapons.type[player[0].weaponids[0]]==sword){ - weapons.mass[player[0].weaponids[0]]=1.5; - weapons.tipmass[player[0].weaponids[0]]=1; - weapons.length[player[0].weaponids[0]]=.8; - } - if(weapons.type[player[0].weaponids[0]]==staff){ - weapons.mass[player[0].weaponids[0]]=2; - weapons.tipmass[player[0].weaponids[0]]=1; - weapons.length[player[0].weaponids[0]]=1.5; - } - - if(weapons.type[player[0].weaponids[0]]==knife){ - weapons.mass[player[0].weaponids[0]]=1; - weapons.tipmass[player[0].weaponids[0]]=1.2; - weapons.length[player[0].weaponids[0]]=.25; - } + if(weapons[player[0].weaponids[0]].getType()==sword) + weapons[player[0].weaponids[0]].setType(staff); + else if(weapons[player[0].weaponids[0]].getType()==staff) + weapons[player[0].weaponids[0]].setType(knife); + else + weapons[player[0].weaponids[0]].setType(sword); } } @@ -2570,44 +2517,19 @@ void Game::doDebugKeys(){ } if(closest!=-1){ if(player[closest].num_weapons){ - if(weapons.type[player[closest].weaponids[0]]==sword) - weapons.type[player[closest].weaponids[0]]=staff; - else if(weapons.type[player[closest].weaponids[0]]==staff) - weapons.type[player[closest].weaponids[0]]=knife; - else weapons.type[player[closest].weaponids[0]]=sword; - if(weapons.type[player[closest].weaponids[0]]==sword){ - weapons.mass[player[closest].weaponids[0]]=1.5; - weapons.tipmass[player[closest].weaponids[0]]=1; - weapons.length[player[closest].weaponids[0]]=.8; - } - if(weapons.type[player[0].weaponids[0]]==staff){ - weapons.mass[player[0].weaponids[0]]=2; - weapons.tipmass[player[0].weaponids[0]]=1; - weapons.length[player[0].weaponids[0]]=1.5; - } - if(weapons.type[player[closest].weaponids[0]]==knife){ - weapons.mass[player[closest].weaponids[0]]=1; - weapons.tipmass[player[closest].weaponids[0]]=1.2; - weapons.length[player[closest].weaponids[0]]=.25; - } + if(weapons[player[closest].weaponids[0]].getType()==sword) + weapons[player[closest].weaponids[0]].setType(staff); + else if(weapons[player[closest].weaponids[0]].getType()==staff) + weapons[player[closest].weaponids[0]].setType(knife); + else + weapons[player[closest].weaponids[0]].setType(sword); } if(!player[closest].num_weapons){ - player[closest].weaponids[0]=weapons.numweapons; - weapons.owner[weapons.numweapons]=closest; - weapons.type[weapons.numweapons]=knife; - weapons.damage[weapons.numweapons]=0; - weapons.numweapons++; + player[closest].weaponids[0]=weapons.size(); + + weapons.push_back(Weapon(knife,closest)); + player[closest].num_weapons=1; - if(weapons.type[player[closest].weaponids[0]]==sword){ - weapons.mass[player[closest].weaponids[0]]=1.5; - weapons.tipmass[player[closest].weaponids[0]]=1; - weapons.length[player[closest].weaponids[0]]=.8; - } - if(weapons.type[player[closest].weaponids[0]]==knife){ - weapons.mass[player[closest].weaponids[0]]=1; - weapons.tipmass[player[closest].weaponids[0]]=1.2; - weapons.length[player[closest].weaponids[0]]=.25; - } } } } @@ -3860,7 +3782,7 @@ void Game::doAttacks(){ player[k].targetanimation==walkanim|| player[k].targetanimation==sneakanim|| player[k].isCrouch())){ - const int attackweapon=player[k].weaponactive==-1?0:weapons.type[player[k].weaponids[player[k].weaponactive]]; + const int attackweapon=player[k].weaponactive==-1?0:weapons[player[k].weaponids[player[k].weaponactive]].getType(); //normal attacks (?) player[k].hasvictim=0; if(numplayers>1) @@ -4794,10 +4716,10 @@ void Game::doAI(int i){ if(j==0||(player[j].dead&&player[j].bloodloss>0)){ float smelldistance=50; if(j==0&&player[j].num_weapons>0){ - if(weapons.bloody[player[j].weaponids[0]]) + if(weapons[player[j].weaponids[0]].bloody) smelldistance=100; if(player[j].num_weapons==2) - if(weapons.bloody[player[j].weaponids[1]]) + if(weapons[player[j].weaponids[1]].bloody) smelldistance=100; } if(j!=0) @@ -5100,9 +5022,9 @@ void Game::doAI(int i){ if(player[i].ally<0){ int closest=-1; float closestdist=-1; - for(int k=0;k=0){ - if(weapons.owner[player[i].ally]!=-1|| - findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){ + if(weapons[player[i].ally].owner!=-1|| + findDistancefast(&player[i].coords,&weapons[player[i].ally].position)>16){ player[i].aitype=attacktypecutoff; player[i].lastseentime=1; } //TODO: factor these out as moveToward() - player[i].targetrotation=roughDirectionTo(player[i].coords,weapons.position[player[i].ally]); + player[i].targetrotation=roughDirectionTo(player[i].coords,weapons[player[i].ally].position); player[i].lookrotation=player[i].targetrotation; player[i].aiupdatedelay=.05; player[i].forwardkeydown=1; @@ -5185,7 +5107,7 @@ void Game::doAI(int i){ if(player[i].isIdle()) player[i].crouchkeydown=1; if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){ - if(weapons.type[player[0].weaponids[0]]==knife){ + if(weapons[player[0].weaponids[0]].getType()==knife){ if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){ if(abs(Random()%2==0)) setAnimation(i,backhandspringanim); @@ -5212,14 +5134,14 @@ void Game::doAI(int i){ } //go for weapon on the ground if(player[i].wentforweapon<3) - for(int k=0;kid) - if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1) - if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){ - if(weapons.type[j]!=staff) + weapons[j].owner==player[i].victim->id) + if(findDistancefastflat(&player[i].coords,&weapons[j].position)<2&&player[i].weaponactive==-1) + if(findDistancefast(&player[i].coords,&weapons[j].position)<1||player[i].victim){ + if(weapons[j].getType()!=staff) emit_sound_at(knifedrawsound, player[i].coords, 128.); player[i].weaponactive=0; - weapons.owner[j]=player[i].id; + weapons[j].owner=player[i].id; if(player[i].num_weapons>0) player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0]; player[i].num_weapons++; @@ -6748,31 +6670,31 @@ void Game::Tick(){ }else if((player[i].isIdle()|| player[i].isFlip()|| player[i].aitype!=playercontrolled)&& - findDistancefast(&player[i].coords,&weapons.position[j])<5&& - player[i].coords.yid) - if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&& + weapons[k].owner==player[i].victim->id) + if(findDistancefastflat(&player[i].coords,&weapons[k].position)<3&& player[i].weaponactive==-1){ - if(weapons.type[k]!=staff) + if(weapons[k].getType()!=staff) emit_sound_at(knifedrawsound, player[i].coords, 128.); player[i].weaponactive=0; - weapons.owner[k]=player[i].id; + weapons[k].owner=player[i].id; if(player[i].num_weapons>0) player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0]; player[i].num_weapons++; @@ -6822,14 +6744,14 @@ void Game::Tick(){ } } if(!fleshstuck){ - if(weapons.type[k]!=staff) + if(weapons[k].getType()!=staff) emit_sound_at(knifedrawsound, player[i].coords, 128.); } if(fleshstuck) emit_sound_at(fleshstabremovesound, player[i].coords, 128.); player[i].weaponactive=0; - if(weapons.owner[k]!=-1){ + if(weapons[k].owner!=-1){ if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0; else player[i].victim->num_weapons=1; @@ -6848,12 +6770,12 @@ void Game::Tick(){ Normalise(&relative); XYZ footvel,footpoint; footvel=0; - footpoint=weapons.position[k]; + footpoint=weapons[k].position; if(player[i].victim->weaponstuck!=-1){ if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3); - weapons.bloody[k]=2; - weapons.blooddrip[k]=5; + weapons[k].bloody=2; + weapons[k].blooddrip=5; player[i].victim->weaponstuck=-1; player[i].victim->bloodloss+=2000; player[i].victim->DoDamage(2000); @@ -6872,7 +6794,7 @@ void Game::Tick(){ playerJoint(player[i].victim,rightshoulder).velocity+=relative*6; playerJoint(player[i].victim,leftshoulder).velocity+=relative*6; } - weapons.owner[k]=i; + weapons[k].owner=i; if(player[i].num_weapons>0){ player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0]; } @@ -6885,7 +6807,7 @@ void Game::Tick(){ } } if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){ - if(weapons.type[player[i].weaponids[0]]==knife){ + if(weapons[player[i].weaponids[0]].getType()==knife){ if(player[i].isIdle()|| player[i].isRun()|| player[i].isCrouch()|| @@ -6913,18 +6835,18 @@ void Game::Tick(){ player[i].throwtogglekeydown=1; player[i].victim=&player[j]; XYZ aim; - weapons.owner[player[i].weaponids[0]]=-1; + weapons[player[i].weaponids[0]].owner=-1; aim=player[i].victim->coords+DoRotation(playerJoint(player[i].victim,abdomen).position,0,player[i].victim->rotation,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(playerJoint(i,righthand).position,0,player[i].rotation,0)*player[i].scale); Normalise(&aim); aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0); - weapons.velocity[player[i].weaponids[0]]=aim*50; - weapons.tipvelocity[player[i].weaponids[0]]=aim*50; - weapons.missed[player[i].weaponids[0]]=0; - weapons.freetime[player[i].weaponids[0]]=0; - weapons.firstfree[player[i].weaponids[0]]=1; - weapons.physics[player[i].weaponids[0]]=0; + weapons[player[i].weaponids[0]].velocity=aim*50; + weapons[player[i].weaponids[0]].tipvelocity=aim*50; + weapons[player[i].weaponids[0]].missed=0; + weapons[player[i].weaponids[0]].freetime=0; + weapons[player[i].weaponids[0]].firstfree=1; + weapons[player[i].weaponids[0]].physics=0; player[i].num_weapons--; if(player[i].num_weapons){ player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons]; @@ -6939,14 +6861,14 @@ void Game::Tick(){ if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){ if(player[i].isCrouch()||player[i].targetanimation==sneakanim){ player[i].throwtogglekeydown=1; - weapons.owner[player[i].weaponids[0]]=-1; - weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2; - if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1; - weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]]; - weapons.missed[player[i].weaponids[0]]=1; - weapons.freetime[player[i].weaponids[0]]=0; - weapons.firstfree[player[i].weaponids[0]]=1; - weapons.physics[player[i].weaponids[0]]=1; + weapons[player[i].weaponids[0]].owner=-1; + weapons[player[i].weaponids[0]].velocity=player[i].velocity*.2; + if(weapons[player[i].weaponids[0]].velocity.x==0)weapons[player[i].weaponids[0]].velocity.x=.1; + weapons[player[i].weaponids[0]].tipvelocity=weapons[player[i].weaponids[0]].velocity; + weapons[player[i].weaponids[0]].missed=1; + weapons[player[i].weaponids[0]].freetime=0; + weapons[player[i].weaponids[0]].firstfree=1; + weapons[player[i].weaponids[0]].physics=1; player[i].num_weapons--; if(player[i].num_weapons){ player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons]; @@ -6973,10 +6895,10 @@ void Game::Tick(){ i!=0){ bool isgood=1; if(player[i].weaponactive!=-1) - if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff) + if(weapons[player[i].weaponids[player[i].weaponactive]].getType()==staff) isgood=0; if(isgood&&player[i].creature!=wolftype){ - if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){ + if(player[i].isIdle()&&player[i].num_weapons&&weapons[player[i].weaponids[0]].getType()==knife){ setAnimation(i,drawrightanim); player[i].drawtogglekeydown=1; } @@ -6985,11 +6907,11 @@ void Game::Tick(){ player[0].weaponactive!=-1&& player[i].isRun()))&& player[i].num_weapons&& - weapons.type[player[i].weaponids[0]]==sword){ + weapons[player[i].weaponids[0]].getType()==sword){ setAnimation(i,drawleftanim); player[i].drawtogglekeydown=1; } - if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){ + if(player[i].isCrouch()&&player[i].num_weapons&&weapons[player[i].weaponids[0]].getType()==knife){ setAnimation(i,crouchdrawrightanim); player[i].drawtogglekeydown=1; } @@ -6997,22 +6919,18 @@ void Game::Tick(){ } //clean weapon if(player[i].isCrouch()&& - weapons.bloody[player[i].weaponids[player[i].weaponactive]]&& + weapons[player[i].weaponids[player[i].weaponactive]].bloody&& bloodtoggle&& player[i].onterrain&& player[i].num_weapons&& player[i].weaponactive!=-1&& - player[i].attackkeydown){ - if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&& - player[i].onterrain&& - bloodtoggle&&musictype!=stream_fighttheme){ - if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife) + player[i].attackkeydown&& + bloodtoggle&&musictype!=stream_fighttheme) { + if(weapons[player[i].weaponids[player[i].weaponactive]].getType()==knife) setAnimation(i,crouchstabanim); - if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword) + if(weapons[player[i].weaponids[player[i].weaponactive]].getType()==sword) setAnimation(i,swordgroundstabanim); player[i].hasvictim=0; - //player[i].attacktogglekeydown=1; - } } if(!player[i].drawkeydown) diff --git a/Source/Person.cpp b/Source/Person.cpp index 47212bd..a74b2df 100644 --- a/Source/Person.cpp +++ b/Source/Person.cpp @@ -177,10 +177,14 @@ int Person::getIdle(){ if(creature==wolftype)return wolfidle; } if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){ - if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim; - if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim; - if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim; - if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim; + if(weapons[weaponids[weaponactive]].getType()==knife) + return knifefightidleanim; + if(weapons[weaponids[weaponactive]].getType()==sword&&victim->weaponactive!=-1) + return swordfightidlebothanim; + if(weapons[weaponids[weaponactive]].getType()==sword) + return swordfightidleanim; + if(weapons[weaponids[weaponactive]].getType()==staff) + return swordfightidleanim; } if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep; } @@ -777,14 +781,14 @@ void Person::Reverse() if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){ if(victim->weaponactive!=-1){ victim->throwtogglekeydown=1; - weapons.owner[victim->weaponids[0]]=-1; - weapons.velocity[victim->weaponids[0]]=victim->velocity*.2; - if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1; - weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]]; - weapons.missed[victim->weaponids[0]]=1; - weapons.freetime[victim->weaponids[0]]=0; - weapons.firstfree[victim->weaponids[0]]=1; - weapons.physics[victim->weaponids[0]]=1; + weapons[victim->weaponids[0]].owner=-1; + weapons[victim->weaponids[0]].velocity=victim->velocity*.2; + if(weapons[victim->weaponids[0]].velocity.x==0)weapons[victim->weaponids[0]].velocity.x=.1; + weapons[victim->weaponids[0]].tipvelocity=weapons[victim->weaponids[0]].velocity; + weapons[victim->weaponids[0]].missed=1; + weapons[victim->weaponids[0]].freetime=0; + weapons[victim->weaponids[0]].firstfree=1; + weapons[victim->weaponids[0]].physics=1; victim->num_weapons--; if(victim->num_weapons){ victim->weaponids[0]=victim->weaponids[victim->num_weapons]; @@ -805,14 +809,14 @@ void Person::Reverse() if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){ if(victim->weaponactive!=-1){ victim->throwtogglekeydown=1; - weapons.owner[victim->weaponids[0]]=-1; - weapons.velocity[victim->weaponids[0]]=victim->velocity*.2; - if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1; - weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]]; - weapons.missed[victim->weaponids[0]]=1; - weapons.freetime[victim->weaponids[0]]=0; - weapons.firstfree[victim->weaponids[0]]=1; - weapons.physics[victim->weaponids[0]]=1; + weapons[victim->weaponids[0]].owner=-1; + weapons[victim->weaponids[0]].velocity=victim->velocity*.2; + if(weapons[victim->weaponids[0]].velocity.x==0)weapons[victim->weaponids[0]].velocity.x=.1; + weapons[victim->weaponids[0]].tipvelocity=weapons[victim->weaponids[0]].velocity; + weapons[victim->weaponids[0]].missed=1; + weapons[victim->weaponids[0]].freetime=0; + weapons[victim->weaponids[0]].firstfree=1; + weapons[victim->weaponids[0]].physics=1; victim->num_weapons--; if(victim->num_weapons){ victim->weaponids[0]=victim->weaponids[victim->num_weapons]; @@ -832,14 +836,14 @@ void Person::Reverse() if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){ if(victim->weaponactive!=-1){ victim->throwtogglekeydown=1; - weapons.owner[victim->weaponids[0]]=-1; - weapons.velocity[victim->weaponids[0]]=victim->velocity*.2; - if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1; - weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]]; - weapons.missed[victim->weaponids[0]]=1; - weapons.freetime[victim->weaponids[0]]=0; - weapons.firstfree[victim->weaponids[0]]=1; - weapons.physics[victim->weaponids[0]]=1; + weapons[victim->weaponids[0]].owner=-1; + weapons[victim->weaponids[0]].velocity=victim->velocity*.2; + if(weapons[victim->weaponids[0]].velocity.x==0)weapons[victim->weaponids[0]].velocity.x=.1; + weapons[victim->weaponids[0]].tipvelocity=weapons[victim->weaponids[0]].velocity; + weapons[victim->weaponids[0]].missed=1; + weapons[victim->weaponids[0]].freetime=0; + weapons[victim->weaponids[0]].firstfree=1; + weapons[victim->weaponids[0]].physics=1; victim->num_weapons--; if(victim->num_weapons){ victim->weaponids[0]=victim->weaponids[victim->num_weapons]; @@ -859,14 +863,14 @@ void Person::Reverse() if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){ if(victim->weaponactive!=-1){ victim->throwtogglekeydown=1; - weapons.owner[victim->weaponids[0]]=-1; - weapons.velocity[victim->weaponids[0]]=victim->velocity*.2; - if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1; - weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]]; - weapons.missed[victim->weaponids[0]]=1; - weapons.freetime[victim->weaponids[0]]=0; - weapons.firstfree[victim->weaponids[0]]=1; - weapons.physics[victim->weaponids[0]]=1; + weapons[victim->weaponids[0]].owner=-1; + weapons[victim->weaponids[0]].velocity=victim->velocity*.2; + if(weapons[victim->weaponids[0]].velocity.x==0)weapons[victim->weaponids[0]].velocity.x=.1; + weapons[victim->weaponids[0]].tipvelocity=weapons[victim->weaponids[0]].velocity; + weapons[victim->weaponids[0]].missed=1; + weapons[victim->weaponids[0]].freetime=0; + weapons[victim->weaponids[0]].firstfree=1; + weapons[victim->weaponids[0]].physics=1; victim->num_weapons--; if(victim->num_weapons){ victim->weaponids[0]=victim->weaponids[victim->num_weapons]; @@ -921,16 +925,18 @@ void Person::Reverse() victim->victim=this; victim->targetrotation=targetrotation+180; - if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){ + if(abs(Random()%20)==0||weapons[victim->weaponids[victim->weaponactive]].getType()==knife){ if(victim->weaponactive!=-1){ - if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){ - if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250; - if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250; - emit_sound_at(swordstaffsound, victim->coords); - } - else{ - emit_sound_at(metalhitsound, victim->coords); - } + if(weapons[victim->weaponids[0]].getType()==staff||weapons[weaponids[0]].getType()==staff) { + if(weapons[victim->weaponids[0]].getType()==staff) + weapons[victim->weaponids[0]].damage+=.2+float(abs(Random()%100)-50)/250; + if(weapons[weaponids[0]].getType()==staff) + weapons[weaponids[0]].damage+=.2+float(abs(Random()%100)-50)/250; + emit_sound_at(swordstaffsound, victim->coords); + } + else{ + emit_sound_at(metalhitsound, victim->coords); + } } XYZ aim; victim->Puff(righthand); @@ -939,16 +945,16 @@ void Person::Reverse() victim->targetanimation=staggerbackhighanim; victim->targetrotation=targetrotation+180; victim->target=0; - weapons.owner[victim->weaponids[0]]=-1; + weapons[victim->weaponids[0]].owner=-1; aim=DoRotation(facing,0,90,0)*21; aim.y+=7; - weapons.velocity[victim->weaponids[0]]=aim*-.2; - weapons.tipvelocity[victim->weaponids[0]]=aim; - weapons.missed[victim->weaponids[0]]=1; - weapons.hitsomething[victim->weaponids[0]]=0; - weapons.freetime[victim->weaponids[0]]=0; - weapons.firstfree[victim->weaponids[0]]=1; - weapons.physics[victim->weaponids[0]]=1; + weapons[victim->weaponids[0]].velocity=aim*-.2; + weapons[victim->weaponids[0]].tipvelocity=aim; + weapons[victim->weaponids[0]].missed=1; + weapons[victim->weaponids[0]].hitsomething=0; + weapons[victim->weaponids[0]].freetime=0; + weapons[victim->weaponids[0]].firstfree=1; + weapons[victim->weaponids[0]].physics=1; victim->num_weapons--; if(victim->num_weapons){ victim->weaponids[0]=victim->weaponids[num_weapons]; @@ -962,9 +968,9 @@ void Person::Reverse() if(abs(Random()%20)==0){ if(weaponactive!=-1){ - if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){ - if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250; - if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250; + if(weapons[victim->weaponids[0]].getType()==staff||weapons[weaponids[0]].getType()==staff){ + if(weapons[victim->weaponids[0]].getType()==staff)weapons[victim->weaponids[0]].damage+=.2+float(abs(Random()%100)-50)/250; + if(weapons[weaponids[0]].getType()==staff)weapons[weaponids[0]].damage+=.2+float(abs(Random()%100)-50)/250; emit_sound_at(swordstaffsound, coords); } @@ -980,16 +986,16 @@ void Person::Reverse() targetanimation=staggerbackhighanim; targetrotation=targetrotation+180; target=0; - weapons.owner[weaponids[0]]=-1; + weapons[weaponids[0]].owner=-1; aim=DoRotation(facing,0,90,0)*21; aim.y+=7; - weapons.velocity[weaponids[0]]=aim*-.2; - weapons.tipvelocity[weaponids[0]]=aim; - weapons.hitsomething[weaponids[0]]=0; - weapons.missed[weaponids[0]]=1; - weapons.freetime[weaponids[0]]=0; - weapons.firstfree[weaponids[0]]=1; - weapons.physics[weaponids[0]]=1; + weapons[weaponids[0]].velocity=aim*-.2; + weapons[weaponids[0]].tipvelocity=aim; + weapons[weaponids[0]].hitsomething=0; + weapons[weaponids[0]].missed=1; + weapons[weaponids[0]].freetime=0; + weapons[weaponids[0]].firstfree=1; + weapons[weaponids[0]].physics=1; num_weapons--; if(num_weapons){ weaponids[0]=weaponids[num_weapons]; @@ -1348,15 +1354,15 @@ void Person::RagDoll(bool checkcollision){ if(Random()%2==0){ if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){ - weapons.owner[weaponids[0]]=-1; - weapons.hitsomething[weaponids[0]]=0; - weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3; - weapons.velocity[weaponids[0]].x+=.01; - weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale; - weapons.missed[weaponids[0]]=1; - weapons.freetime[weaponids[0]]=0; - weapons.firstfree[weaponids[0]]=1; - weapons.physics[weaponids[0]]=1; + weapons[weaponids[0]].owner=-1; + weapons[weaponids[0]].hitsomething=0; + weapons[weaponids[0]].velocity=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3; + weapons[weaponids[0]].velocity.x+=.01; + weapons[weaponids[0]].tipvelocity=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale; + weapons[weaponids[0]].missed=1; + weapons[weaponids[0]].freetime=0; + weapons[weaponids[0]].firstfree=1; + weapons[weaponids[0]].physics=1; num_weapons--; if(num_weapons){ weaponids[0]=weaponids[num_weapons]; @@ -1530,7 +1536,7 @@ void Person::DoAnimations(){ } if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){ - if(weapons.type[weaponids[0]]==knife){ + if(weapons[weaponids[0]].getType()==knife){ if(weaponactive==-1)weaponactive=0; else if(weaponactive==0)weaponactive=-1; @@ -1644,16 +1650,16 @@ void Person::DoAnimations(){ targetframe++; if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){ - for(i=0;i=1){ - if(weapons.type[i]!=staff){ + for(i=0;i=1){ + if(weapons[i].getType()!=staff){ emit_sound_at(knifedrawsound, coords, 128.); } weaponactive=0; - weapons.owner[i]=id; + weapons[i].owner=id; if(num_weapons>0){ weaponids[num_weapons]=weaponids[0]; } @@ -1666,24 +1672,24 @@ void Person::DoAnimations(){ static bool willwork; if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){ - for(i=0;i1)willwork=0; - if((/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)||(hasvictim&&weapons.owner[i]==victim->id&&victim->skeleton.free)) - if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){ - if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){ + if(weapons[i].owner!=-1) + if(player[weapons[i].owner].weaponstuck!=-1) + if(player[weapons[i].owner].weaponids[player[weapons[i].owner].weaponstuck]==i) + if(player[weapons[i].owner].num_weapons>1)willwork=0; + if((weapons[i].owner==-1)||(hasvictim&&weapons[i].owner==victim->id&&victim->skeleton.free)) + if(willwork&&findDistancefastflat(&coords,&weapons[i].position)<3&&weaponactive==-1){ + if(findDistancefast(&coords,&weapons[i].position)<1||hasvictim){ bool fleshstuck=0; - if(weapons.owner[i]!=-1) + if(weapons[i].owner!=-1) if(victim->weaponstuck!=-1){ if(victim->weaponids[victim->weaponstuck]==i){ fleshstuck=1; } } if(!fleshstuck){ - if(weapons.type[i]!=staff){ + if(weapons[i].getType()!=staff){ emit_sound_at(knifedrawsound, coords, 128.); } } @@ -1691,9 +1697,9 @@ void Person::DoAnimations(){ emit_sound_at(fleshstabremovesound, coords, 128.); } weaponactive=0; - if(weapons.owner[i]!=-1){ + if(weapons[i].owner!=-1){ - victim=&player[weapons.owner[i]]; + victim=&player[weapons[i].owner]; if(victim->num_weapons==1)victim->num_weapons=0; else victim->num_weapons=1; @@ -1713,12 +1719,12 @@ void Person::DoAnimations(){ Normalise(&relative); XYZ footvel,footpoint; footvel=0; - footpoint=weapons.position[i]; + footpoint=weapons[i].position; if(victim->weaponstuck!=-1){ if(victim->weaponids[victim->weaponstuck]==i){ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3); - weapons.bloody[i]=2; - weapons.blooddrip[i]=5; + weapons[i].bloody=2; + weapons[i].blooddrip=5; victim->weaponstuck=-1; } } @@ -1733,7 +1739,7 @@ void Person::DoAnimations(){ victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6; victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6; } - weapons.owner[i]=id; + weapons[i].owner=id; if(num_weapons>0){ weaponids[num_weapons]=weaponids[0]; } @@ -2095,7 +2101,7 @@ void Person::DoAnimations(){ if(!victim->skeleton.free)hasvictim=0; if(!hasvictim){ - terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360); + terrain.MakeDecal(blooddecalfast,(weapons[weaponids[weaponactive]].tippoint*.8+weapons[weaponids[weaponactive]].position*.2),.08,.6,Random()%360); emit_sound_at(knifesheathesound, coords, 128.); } @@ -2105,8 +2111,8 @@ void Person::DoAnimations(){ XYZ where,startpoint,endpoint,movepoint,colpoint; float rotationpoint; int whichtri; - if(weapons.type[weaponids[weaponactive]]==knife){ - where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4); + if(weapons[weaponids[weaponactive]].getType()==knife){ + where=(weapons[weaponids[weaponactive]].tippoint*.6+weapons[weaponids[weaponactive]].position*.4); where-=victim->coords; if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0); //where=scale; @@ -2115,22 +2121,22 @@ void Person::DoAnimations(){ endpoint=where; endpoint.y-=100; } - if(weapons.type[weaponids[weaponactive]]==sword){ - where=weapons.position[weaponids[weaponactive]]; + if(weapons[weaponids[weaponactive]].getType()==sword){ + where=weapons[weaponids[weaponactive]].position; where-=victim->coords; if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0); startpoint=where; - where=weapons.tippoint[weaponids[weaponactive]]; + where=weapons[weaponids[weaponactive]].tippoint; where-=victim->coords; if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0); endpoint=where; } - if(weapons.type[weaponids[weaponactive]]==staff){ - where=weapons.position[weaponids[weaponactive]]; + if(weapons[weaponids[weaponactive]].getType()==staff){ + where=weapons[weaponids[weaponactive]].position; where-=victim->coords; if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0); startpoint=where; - where=weapons.tippoint[weaponids[weaponactive]]; + where=weapons[weaponids[weaponactive]].tippoint; where-=victim->coords; if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0); endpoint=where; @@ -2145,7 +2151,7 @@ void Person::DoAnimations(){ if (!victim->dead) award_bonus(id, FinishedBonus); } - if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2; + if(bloodtoggle)weapons[weaponids[weaponactive]].bloody=2; victim->skeleton.longdead=0; victim->skeleton.free=1; @@ -2159,9 +2165,9 @@ void Person::DoAnimations(){ emit_sound_at(fleshstabsound, coords, 128); } - if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){ - weapons.blooddrip[weaponids[weaponactive]]+=5; - weapons.blooddripdelay[weaponids[weaponactive]]=0; + if(whichtri!=-1||weapons[weaponids[weaponactive]].bloody){ + weapons[weaponids[weaponactive]].blooddrip+=5; + weapons[weaponids[weaponactive]].blooddripdelay=0; } if(whichtri==-1){ hasvictim=0; @@ -2182,18 +2188,18 @@ void Person::DoAnimations(){ emit_sound_at(fleshstabremovesound, coords, 128.); footvel=0; - footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2); + footpoint=(weapons[weaponids[weaponactive]].tippoint*.8+weapons[weaponids[weaponactive]].position*.2); - if(weapons.type[weaponids[weaponactive]]==sword){ + if(weapons[weaponids[weaponactive]].getType()==sword){ XYZ where,startpoint,endpoint,movepoint; float rotationpoint; int whichtri; - where=weapons.position[weaponids[weaponactive]]; + where=weapons[weaponids[weaponactive]].position; where-=victim->coords; if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0); startpoint=where; - where=weapons.tippoint[weaponids[weaponactive]]; + where=weapons[weaponids[weaponactive]].tippoint; where-=victim->coords; if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0); endpoint=where; @@ -2204,19 +2210,19 @@ void Person::DoAnimations(){ footpoint+=victim->coords; if(whichtri==-1){ - footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2); + footpoint=(weapons[weaponids[weaponactive]].tippoint*.8+weapons[weaponids[weaponactive]].position*.2); } } - if(weapons.type[weaponids[weaponactive]]==staff){ + if(weapons[weaponids[weaponactive]].getType()==staff){ XYZ where,startpoint,endpoint,movepoint; float rotationpoint; int whichtri; - where=weapons.position[weaponids[weaponactive]]; + where=weapons[weaponids[weaponactive]].position; where-=victim->coords; if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0); startpoint=where; - where=weapons.tippoint[weaponids[weaponactive]]; + where=weapons[weaponids[weaponactive]].tippoint; where-=victim->coords; if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0); endpoint=where; @@ -2227,7 +2233,7 @@ void Person::DoAnimations(){ footpoint+=victim->coords; if(whichtri==-1){ - footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2); + footpoint=(weapons[weaponids[weaponactive]].tippoint*.8+weapons[weaponids[weaponactive]].position*.2); } } hasvictim=victim->DoBloodBigWhere(2,220,footpoint); @@ -2260,8 +2266,8 @@ void Person::DoAnimations(){ } } if(!hasvictim&&onterrain){ - weapons.bloody[weaponids[weaponactive]]=0; - weapons.blooddrip[weaponids[weaponactive]]=0; + weapons[weaponids[weaponactive]].bloody=0; + weapons[weaponids[weaponactive]].blooddrip=0; } } @@ -2362,9 +2368,9 @@ void Person::DoAnimations(){ if(victim->id==0)camerashake+=.4; if(weaponactive!=-1){ - if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){ - if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250; - if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250; + if(weapons[victim->weaponids[0]].getType()==staff||weapons[weaponids[0]].getType()==staff){ + if(weapons[victim->weaponids[0]].getType()==staff)weapons[victim->weaponids[0]].damage+=.2+float(abs(Random()%100)-50)/250; + if(weapons[weaponids[0]].getType()==staff)weapons[weaponids[0]].damage+=.2+float(abs(Random()%100)-50)/250; emit_sound_at(swordstaffsound, victim->coords); } @@ -2381,19 +2387,19 @@ void Person::DoAnimations(){ if(weaponactive!=-1){ escapednum=0; XYZ aim; - weapons.owner[weaponids[0]]=-1; + weapons[weaponids[0]].owner=-1; aim=victim->coords+DoRotation(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position,0,victim->rotation,0)*victim->scale+victim->velocity*findDistance(&victim->coords,&coords)/50-(coords+DoRotation(skeleton.joints[skeleton.jointlabels[righthand]].position,0,rotation,0)*scale); Normalise(&aim); /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){ aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0); }*/ - weapons.velocity[weaponids[0]]=aim*50; - weapons.tipvelocity[weaponids[0]]=aim*50; - weapons.missed[weaponids[0]]=0; - weapons.hitsomething[weaponids[0]]=0; - weapons.freetime[weaponids[0]]=0; - weapons.firstfree[weaponids[0]]=1; - weapons.physics[weaponids[0]]=0; + weapons[weaponids[0]].velocity=aim*50; + weapons[weaponids[0]].tipvelocity=aim*50; + weapons[weaponids[0]].missed=0; + weapons[weaponids[0]].hitsomething=0; + weapons[weaponids[0]].freetime=0; + weapons[weaponids[0]].firstfree=1; + weapons[weaponids[0]].physics=0; num_weapons--; if(num_weapons){ weaponids[0]=weaponids[num_weapons]; @@ -2425,8 +2431,8 @@ void Person::DoAnimations(){ victim->highreversaldelay=0; if(aitype!=playercontrolled)weaponmissdelay=.6; - if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1; - if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3; + if(tutoriallevel!=1)if(bloodtoggle&&!weapons[weaponids[weaponactive]].bloody)weapons[weaponids[weaponactive]].bloody=1; + if(tutoriallevel!=1)weapons[weaponids[weaponactive]].blooddrip+=3; XYZ footvel,footpoint; footvel=0; @@ -2471,8 +2477,8 @@ void Person::DoAnimations(){ } if(tutoriallevel!=1){ - if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1; - weapons.blooddrip[weaponids[weaponactive]]+=3; + if(bloodtoggle&&!weapons[weaponids[weaponactive]].bloody)weapons[weaponids[weaponactive]].bloody=1; + weapons[weaponids[weaponactive]].blooddrip+=3; float bloodlossamount; bloodlossamount=200+abs((float)(Random()%40))-20; @@ -2499,9 +2505,9 @@ void Person::DoAnimations(){ } else { if(victim->weaponactive!=-1){ - if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){ - if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250; - if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250; + if(weapons[victim->weaponids[0]].getType()==staff||weapons[weaponids[0]].getType()==staff){ + if(weapons[victim->weaponids[0]].getType()==staff)weapons[victim->weaponids[0]].damage+=.2+float(abs(Random()%100)-50)/250; + if(weapons[weaponids[0]].getType()==staff)weapons[weaponids[0]].damage+=.2+float(abs(Random()%100)-50)/250; emit_sound_at(swordstaffsound, victim->coords); } @@ -2518,16 +2524,16 @@ void Person::DoAnimations(){ victim->targetanimation=staggerbackhighanim; victim->targetrotation=targetrotation+180; victim->target=0; - weapons.owner[victim->weaponids[0]]=-1; + weapons[victim->weaponids[0]].owner=-1; aim=DoRotation(facing,0,90,0)*21; aim.y+=7; - weapons.velocity[victim->weaponids[0]]=aim*-.2; - weapons.tipvelocity[victim->weaponids[0]]=aim; - weapons.missed[victim->weaponids[0]]=1; - weapons.hitsomething[weaponids[0]]=0; - weapons.freetime[victim->weaponids[0]]=0; - weapons.firstfree[victim->weaponids[0]]=1; - weapons.physics[victim->weaponids[0]]=1; + weapons[victim->weaponids[0]].velocity=aim*-.2; + weapons[victim->weaponids[0]].tipvelocity=aim; + weapons[victim->weaponids[0]].missed=1; + weapons[weaponids[0]].hitsomething=0; + weapons[victim->weaponids[0]].freetime=0; + weapons[victim->weaponids[0]].firstfree=1; + weapons[victim->weaponids[0]].physics=1; victim->num_weapons--; if(victim->num_weapons){ victim->weaponids[0]=victim->weaponids[num_weapons]; @@ -2545,7 +2551,7 @@ void Person::DoAnimations(){ if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){ if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){ if(tutoriallevel!=1){ - weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250; + weapons[weaponids[0]].damage+=.4+float(abs(Random()%100)-50)/250; escapednum=0; if(id==0)camerashake+=.4; if(Random()%2||creature==wolftype){ @@ -2579,7 +2585,7 @@ void Person::DoAnimations(){ if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){ if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){ if(tutoriallevel!=1){ - weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250; + weapons[weaponids[0]].damage+=.6+float(abs(Random()%100)-50)/250; escapednum=0; if(id==0)camerashake+=.4; if(Random()%2||creature==wolftype){ @@ -2611,7 +2617,7 @@ void Person::DoAnimations(){ if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){ escapednum=0; if(tutoriallevel!=1){ - if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500; + if(!victim->dead)weapons[weaponids[0]].damage+=.4+float(abs(Random()%100)-50)/500; if(id==0)camerashake+=.4; if(Random()%2||creature==wolftype){ victim->spurt=1; @@ -2809,8 +2815,8 @@ void Person::DoAnimations(){ if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){ if(victim->weaponactive!=-1&&victim->num_weapons>0){ - if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){ - weapons.owner[victim->weaponids[victim->weaponactive]]=id; + if(weapons[victim->weaponids[victim->weaponactive]].owner==victim->id){ + weapons[victim->weaponids[victim->weaponactive]].owner=id; weaponactive=0; if(num_weapons>0){ weaponids[num_weapons]=weaponids[victim->weaponactive]; @@ -2909,13 +2915,13 @@ void Person::DoAnimations(){ bool doslice; doslice=0; if(weaponactive!=-1||creature==wolftype)doslice=1; - if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0; + if(creature==rabbittype&&weaponactive!=-1)if(weapons[weaponids[0]].getType()==staff)doslice=0; if(doslice){ if(weaponactive!=-1){ victim->DoBloodBig(2/victim->armorhigh,225); emit_sound_at(knifeslicesound, victim->coords); - if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1; - weapons.blooddrip[weaponids[weaponactive]]+=3; + if(bloodtoggle&&!weapons[weaponids[weaponactive]].bloody)weapons[weaponids[weaponactive]].bloody=1; + weapons[weaponids[weaponactive]].blooddrip+=3; } if(weaponactive==-1&&creature==wolftype){; emit_sound_at(clawslicesound, victim->coords, 128.); @@ -2996,13 +3002,13 @@ void Person::DoAnimations(){ bool doslice; doslice=0; if(weaponactive!=-1||creature==wolftype)doslice=1; - if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0; + if(creature==rabbittype&&weaponactive!=-1)if(weapons[weaponids[0]].getType()==staff)doslice=0; if(doslice){ if(weaponactive!=-1){ victim->DoBloodBig(200,225); emit_sound_at(knifeslicesound, victim->coords); - if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2; - weapons.blooddrip[weaponids[weaponactive]]+=5; + if(bloodtoggle)weapons[weaponids[weaponactive]].bloody=2; + weapons[weaponids[weaponactive]].blooddrip+=5; } if(creature==wolftype&&weaponactive==-1){ @@ -3029,9 +3035,9 @@ void Person::DoAnimations(){ */ XYZ footvel,footpoint; footvel=0; - footpoint=weapons.tippoint[weaponids[0]]; + footpoint=weapons[weaponids[0]].tippoint; if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3); - footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]); + footvel=(weapons[weaponids[0]].tippoint-weapons[weaponids[0]].position); Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1); @@ -3043,9 +3049,9 @@ void Person::DoAnimations(){ award_bonus(id, Stabbonus); XYZ footvel,footpoint; footvel=0; - footpoint=weapons.tippoint[weaponids[0]]; + footpoint=weapons[weaponids[0]].tippoint; if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3); - footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1; + footvel=(weapons[weaponids[0]].tippoint-weapons[weaponids[0]].position)*-1; Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1); @@ -3055,8 +3061,8 @@ void Person::DoAnimations(){ victim->bloodloss+=10000; victim->velocity=0; emit_sound_at(fleshstabsound, victim->coords); - if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2; - weapons.blooddrip[weaponids[weaponactive]]+=5; + if(bloodtoggle)weapons[weaponids[weaponactive]].bloody=2; + weapons[weaponids[weaponactive]].blooddrip+=5; } } @@ -3074,14 +3080,14 @@ void Person::DoAnimations(){ } if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){ emit_sound_at(fleshstabremovesound, victim->coords); - if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2; - weapons.blooddrip[weaponids[weaponactive]]+=5; + if(bloodtoggle)weapons[weaponids[weaponactive]].bloody=2; + weapons[weaponids[weaponactive]].blooddrip+=5; XYZ footvel,footpoint; footvel=0; - footpoint=weapons.tippoint[weaponids[0]]; + footpoint=weapons[weaponids[0]].tippoint; if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3); - footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1; + footvel=(weapons[weaponids[0]].tippoint-weapons[weaponids[0]].position)*-1; Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1); @@ -3097,9 +3103,9 @@ void Person::DoAnimations(){ XYZ footvel,footpoint; footvel=0; - footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2; + footpoint=(weapons[weaponids[0]].tippoint+weapons[weaponids[0]].position)/2; if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3); - footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]); + footvel=(weapons[weaponids[0]].tippoint-weapons[weaponids[0]].position); Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1); @@ -3109,8 +3115,8 @@ void Person::DoAnimations(){ victim->bloodloss+=10000; victim->velocity=0; emit_sound_at(fleshstabsound, victim->coords); - if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2; - weapons.blooddrip[weaponids[weaponactive]]+=5; + if(bloodtoggle)weapons[weaponids[weaponactive]].bloody=2; + weapons[weaponids[weaponactive]].blooddrip+=5; } } @@ -3122,14 +3128,14 @@ void Person::DoAnimations(){ } if(weaponactive!=-1){ emit_sound_at(fleshstabremovesound, victim->coords); - if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2; - weapons.blooddrip[weaponids[weaponactive]]+=5; + if(bloodtoggle)weapons[weaponids[weaponactive]].bloody=2; + weapons[weaponids[weaponactive]].blooddrip+=5; XYZ footvel,footpoint; footvel=0; - footpoint=weapons.tippoint[weaponids[0]]; + footpoint=weapons[weaponids[0]].tippoint; if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3); - footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1; + footvel=(weapons[weaponids[0]].tippoint-weapons[weaponids[0]].position)*-1; Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9); Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1); @@ -3152,13 +3158,13 @@ void Person::DoAnimations(){ bool doslice; doslice=0; if(weaponactive!=-1||creature==wolftype)doslice=1; - if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0; + if(creature==rabbittype&&weaponactive!=-1)if(weapons[weaponids[0]].getType()==staff)doslice=0; if(doslice){ if(weaponactive!=-1){ victim->DoBloodBig(2/victim->armorhead,225); emit_sound_at(knifeslicesound, victim->coords); - if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1; - weapons.blooddrip[weaponids[weaponactive]]+=3; + if(bloodtoggle&&!weapons[weaponids[weaponactive]].bloody)weapons[weaponids[weaponactive]].bloody=1; + weapons[weaponids[weaponactive]].blooddrip+=3; } if(weaponactive==-1&&creature==wolftype){ emit_sound_at(clawslicesound, victim->coords, 128.); @@ -3536,7 +3542,7 @@ void Person::DoAnimations(){ targetrotation=rotation; bool hasstaff; hasstaff=0; - if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1; + if(num_weapons>0)if(weapons[0].getType()==staff)hasstaff=1; if(!hasstaff)DoDamage(35); RagDoll(0); lastfeint=0; @@ -3799,7 +3805,7 @@ void Person::DoStuff(){ } } if(weaponactive==-1&&num_weapons>0){ - if(weapons.type[weaponids[0]]==staff){ + if(weapons[weaponids[0]].getType()==staff){ weaponactive=0; } } @@ -3901,15 +3907,15 @@ void Person::DoStuff(){ if(deathbleeding<0)deathbleeding=0; if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){ if(weaponactive!=-1){ - weapons.owner[weaponids[0]]=-1; - weapons.velocity[weaponids[0]]=velocity*scale*-.3; - weapons.velocity[weaponids[0]].x+=.01; - weapons.tipvelocity[weaponids[0]]=velocity*scale; - weapons.missed[weaponids[0]]=1; - weapons.hitsomething[weaponids[0]]=0; - weapons.freetime[weaponids[0]]=0; - weapons.firstfree[weaponids[0]]=1; - weapons.physics[weaponids[0]]=1; + weapons[weaponids[0]].owner=-1; + weapons[weaponids[0]].velocity=velocity*scale*-.3; + weapons[weaponids[0]].velocity.x+=.01; + weapons[weaponids[0]].tipvelocity=velocity*scale; + weapons[weaponids[0]].missed=1; + weapons[weaponids[0]].hitsomething=0; + weapons[weaponids[0]].freetime=0; + weapons[weaponids[0]].firstfree=1; + weapons[weaponids[0]].physics=1; num_weapons--; if(num_weapons){ weaponids[0]=weaponids[num_weapons]; @@ -4311,15 +4317,15 @@ void Person::DoStuff(){ RagDoll(0); if(weaponactive!=-1){ - weapons.owner[weaponids[0]]=-1; - weapons.velocity[weaponids[0]]=velocity*scale*-.3; - weapons.velocity[weaponids[0]].x+=.01; - weapons.tipvelocity[weaponids[0]]=velocity*scale; - weapons.missed[weaponids[0]]=1; - weapons.hitsomething[weaponids[0]]=0; - weapons.freetime[weaponids[0]]=0; - weapons.firstfree[weaponids[0]]=1; - weapons.physics[weaponids[0]]=1; + weapons[weaponids[0]].owner=-1; + weapons[weaponids[0]].velocity=velocity*scale*-.3; + weapons[weaponids[0]].velocity.x+=.01; + weapons[weaponids[0]].tipvelocity=velocity*scale; + weapons[weaponids[0]].missed=1; + weapons[weaponids[0]].hitsomething=0; + weapons[weaponids[0]].freetime=0; + weapons[weaponids[0]].firstfree=1; + weapons[weaponids[0]].physics=1; num_weapons--; if(num_weapons){ weaponids[0]=weaponids[num_weapons]; @@ -4370,15 +4376,15 @@ void Person::DoStuff(){ DoBlood(1,255); if(weaponactive!=-1){ - weapons.owner[weaponids[0]]=-1; - weapons.velocity[weaponids[0]]=velocity*scale*-.3; - weapons.velocity[weaponids[0]].x+=.01; - weapons.tipvelocity[weaponids[0]]=velocity*scale; - weapons.missed[weaponids[0]]=1; - weapons.hitsomething[weaponids[0]]=0; - weapons.freetime[weaponids[0]]=0; - weapons.firstfree[weaponids[0]]=1; - weapons.physics[weaponids[0]]=1; + weapons[weaponids[0]].owner=-1; + weapons[weaponids[0]].velocity=velocity*scale*-.3; + weapons[weaponids[0]].velocity.x+=.01; + weapons[weaponids[0]].tipvelocity=velocity*scale; + weapons[weaponids[0]].missed=1; + weapons[weaponids[0]].hitsomething=0; + weapons[weaponids[0]].freetime=0; + weapons[weaponids[0]].firstfree=1; + weapons[weaponids[0]].physics=1; num_weapons--; if(num_weapons){ weaponids[0]=weaponids[num_weapons]; @@ -4678,7 +4684,7 @@ void Person::DoStuff(){ bool hasstaff; hasstaff=0; - if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1; + if(num_weapons>0)if(weapons[0].getType()==staff)hasstaff=1; if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){ if(velocity.y>-30){ XYZ tempvelocity; @@ -5005,13 +5011,7 @@ void Person::DoStuff(){ targetheadmorphness=1; } } - /* - if(speechdelay>.25){ - if(headmorphend!=2)headmorphness=0; - headmorphend=2; - targetheadmorphness=1; - } - */ + bool behind; behind=0; if(hasvictim){ @@ -5030,11 +5030,11 @@ void Person::DoStuff(){ } if(weaponactive!=-1){ - if(weapons.type[weaponids[weaponactive]]!=staff){ + if(weapons[weaponids[weaponactive]].getType()!=staff){ righthandmorphstart=1; righthandmorphend=1; } - if(weapons.type[weaponids[weaponactive]]==staff){ + if(weapons[weaponids[weaponactive]].getType()==staff){ righthandmorphstart=2; righthandmorphend=2; } @@ -5915,7 +5915,7 @@ int Person::DrawSkeleton(){ for(k=0;klabel==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){ weaponattachmuscle=j; @@ -5929,7 +5929,7 @@ int Person::DrawSkeleton(){ weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2; if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3); } - if(weapons.type[i]==staff){ + if(weapons[i].getType()==staff){ for(j=0;jlabel==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){ weaponattachmuscle=j; @@ -5952,9 +5952,9 @@ int Person::DrawSkeleton(){ } } if(weaponactive!=k&&weaponstuck!=k){ - if(weapons.type[i]==knife)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[righthip]].position-skeleton.joints[skeleton.jointlabels[lefthip]].position)*.1+(skeleton.joints[skeleton.jointlabels[rightshoulder]].position-skeleton.joints[skeleton.jointlabels[leftshoulder]].position)*.35; - if(weapons.type[i]==sword)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[lefthip]].position-skeleton.joints[skeleton.jointlabels[righthip]].position)*.09+(skeleton.joints[skeleton.jointlabels[leftshoulder]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position)*.33; - if(weapons.type[i]==staff)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[lefthip]].position-skeleton.joints[skeleton.jointlabels[righthip]].position)*.09+(skeleton.joints[skeleton.jointlabels[leftshoulder]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position)*.33; + if(weapons[i].getType()==knife)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[righthip]].position-skeleton.joints[skeleton.jointlabels[lefthip]].position)*.1+(skeleton.joints[skeleton.jointlabels[rightshoulder]].position-skeleton.joints[skeleton.jointlabels[leftshoulder]].position)*.35; + if(weapons[i].getType()==sword)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[lefthip]].position-skeleton.joints[skeleton.jointlabels[righthip]].position)*.09+(skeleton.joints[skeleton.jointlabels[leftshoulder]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position)*.33; + if(weapons[i].getType()==staff)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[lefthip]].position-skeleton.joints[skeleton.jointlabels[righthip]].position)*.09+(skeleton.joints[skeleton.jointlabels[leftshoulder]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position)*.33; for(j=0;jlabel==abdomen||skeleton.muscles[j].parent2->label==abdomen)&&(skeleton.muscles[j].parent1->label==neck||skeleton.muscles[j].parent2->label==neck)&&skeleton.muscles[j].numvertices>0){ weaponrotatemuscle=j; @@ -5970,30 +5970,29 @@ int Person::DrawSkeleton(){ } } } - if(!skeleton.free){ - weapons.position[i]=DoRotation(DoRotation(DoRotation(weaponpoint,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords+currentoffset*(1-target)*scale+targetoffset*target*scale; - weapons.bigrotation[i]=rotation; - weapons.bigtilt[i]=tilt; - weapons.bigtilt2[i]=tilt2; - } if(skeleton.free){ - weapons.position[i]=weaponpoint*scale+coords; - weapons.bigrotation[i]=0; - weapons.bigtilt[i]=0; - weapons.bigtilt2[i]=0; + weapons[i].position=weaponpoint*scale+coords; + weapons[i].bigrotation=0; + weapons[i].bigtilt=0; + weapons[i].bigtilt2=0; + } else { + weapons[i].position=DoRotation(DoRotation(DoRotation(weaponpoint,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords+currentoffset*(1-target)*scale+targetoffset*target*scale; + weapons[i].bigrotation=rotation; + weapons[i].bigtilt=tilt; + weapons[i].bigtilt2=tilt2; } - weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1; - weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2; - weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3; + weapons[i].rotation1=skeleton.muscles[weaponrotatemuscle].lastrotate1; + weapons[i].rotation2=skeleton.muscles[weaponrotatemuscle].lastrotate2; + weapons[i].rotation3=skeleton.muscles[weaponrotatemuscle].lastrotate3; if(weaponactive==k){ - if(weapons.type[i]==knife){ - weapons.smallrotation[i]=180; - weapons.smallrotation2[i]=0; + if(weapons[i].getType()==knife){ + weapons[i].smallrotation=180; + weapons[i].smallrotation2=0; if(isCrouch()||wasCrouch()){ - weapons.smallrotation2[i]=20; + weapons[i].smallrotation2=20; } if(targetanimation==hurtidleanim){ - weapons.smallrotation2[i]=50; + weapons[i].smallrotation2=50; } if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){ XYZ temppoint1,temppoint2,tempforward; @@ -6002,16 +6001,16 @@ int Person::DrawSkeleton(){ temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position; temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target); distance=findDistance(&temppoint1,&temppoint2); - weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance); - weapons.rotation2[i]*=360/6.28; + weapons[i].rotation2=asin((temppoint1.y-temppoint2.y)/distance); + weapons[i].rotation2*=360/6.28; temppoint1.y=0; temppoint2.y=0; - weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); - weapons.rotation1[i]*=360/6.28; - weapons.rotation3[i]=0; - weapons.smallrotation[i]=-90; - weapons.smallrotation2[i]=0; - if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i]; + weapons[i].rotation1=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); + weapons[i].rotation1*=360/6.28; + weapons[i].rotation3=0; + weapons[i].smallrotation=-90; + weapons[i].smallrotation2=0; + if(temppoint1.x>temppoint2.x)weapons[i].rotation1=360-weapons[i].rotation1; } if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){ XYZ temppoint1,temppoint2,tempforward; @@ -6020,41 +6019,41 @@ int Person::DrawSkeleton(){ temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position; temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target); distance=findDistance(&temppoint1,&temppoint2); - weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance); - weapons.rotation2[i]*=360/6.28; + weapons[i].rotation2=asin((temppoint1.y-temppoint2.y)/distance); + weapons[i].rotation2*=360/6.28; temppoint1.y=0; temppoint2.y=0; - weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); - weapons.rotation1[i]*=360/6.28; - weapons.rotation3[i]=0; - weapons.smallrotation[i]=90; - weapons.smallrotation2[i]=0; - if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i]; + weapons[i].rotation1=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); + weapons[i].rotation1*=360/6.28; + weapons[i].rotation3=0; + weapons[i].smallrotation=90; + weapons[i].smallrotation2=0; + if(temppoint1.x>temppoint2.x)weapons[i].rotation1=360-weapons[i].rotation1; } if(targetanimation==knifethrowanim){ - weapons.smallrotation[i]=90; - //weapons.smallrotation2[i]=-90; - weapons.smallrotation2[i]=0; - weapons.rotation1[i]=0; - weapons.rotation2[i]=0; - weapons.rotation3[i]=0; + weapons[i].smallrotation=90; + //weapons[i].smallrotation2=-90; + weapons[i].smallrotation2=0; + weapons[i].rotation1=0; + weapons[i].rotation2=0; + weapons[i].rotation3=0; } if(targetanimation==knifesneakattackanim&&targetframe<5){ - weapons.smallrotation[i]=-90; - weapons.rotation1[i]=0; - weapons.rotation2[i]=0; - weapons.rotation3[i]=0; + weapons[i].smallrotation=-90; + weapons[i].rotation1=0; + weapons[i].rotation2=0; + weapons[i].rotation3=0; } } - if(weapons.type[i]==sword){ - weapons.smallrotation[i]=0; - weapons.smallrotation2[i]=0; + if(weapons[i].getType()==sword){ + weapons[i].smallrotation=0; + weapons[i].smallrotation2=0; if(targetanimation==knifethrowanim){ - weapons.smallrotation[i]=-90; - weapons.smallrotation2[i]=0; - weapons.rotation1[i]=0; - weapons.rotation2[i]=0; - weapons.rotation3[i]=0; + weapons[i].smallrotation=-90; + weapons[i].smallrotation2=0; + weapons[i].rotation1=0; + weapons[i].rotation2=0; + weapons[i].rotation3=0; } if((targetanimation==swordgroundstabanim&¤tanimation==swordgroundstabanim)||(targetanimation==swordsneakattackanim&¤tanimation==swordsneakattackanim)||(targetanimation==swordslashparryanim&¤tanimation==swordslashparryanim)||(targetanimation==swordslashparriedanim&¤tanimation==swordslashparriedanim)||(targetanimation==swordslashreversalanim&¤tanimation==swordslashreversalanim)||(targetanimation==swordslashreversedanim&¤tanimation==swordslashreversedanim)||(targetanimation==knifeslashreversalanim&¤tanimation==knifeslashreversalanim)||(targetanimation==knifeslashreversedanim&¤tanimation==knifeslashreversedanim)||(targetanimation==swordslashanim&¤tanimation==swordslashanim)||(targetanimation==drawleftanim&¤tanimation==drawleftanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){ XYZ temppoint1,temppoint2,tempforward; @@ -6063,21 +6062,21 @@ int Person::DrawSkeleton(){ temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position; temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target); distance=findDistance(&temppoint1,&temppoint2); - weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance); - weapons.rotation2[i]*=360/6.28; + weapons[i].rotation2=asin((temppoint1.y-temppoint2.y)/distance); + weapons[i].rotation2*=360/6.28; temppoint1.y=0; temppoint2.y=0; - weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); - weapons.rotation1[i]*=360/6.28; - weapons.rotation3[i]=0; - weapons.smallrotation[i]=90; - weapons.smallrotation2[i]=0; - if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i]; + weapons[i].rotation1=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); + weapons[i].rotation1*=360/6.28; + weapons[i].rotation3=0; + weapons[i].smallrotation=90; + weapons[i].smallrotation2=0; + if(temppoint1.x>temppoint2.x)weapons[i].rotation1=360-weapons[i].rotation1; } } - if(weapons.type[i]==staff){ - weapons.smallrotation[i]=100; - weapons.smallrotation2[i]=0; + if(weapons[i].getType()==staff){ + weapons[i].smallrotation=100; + weapons[i].smallrotation2=0; if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){ XYZ temppoint1,temppoint2,tempforward; float distance; @@ -6085,37 +6084,39 @@ int Person::DrawSkeleton(){ temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position; temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target); distance=findDistance(&temppoint1,&temppoint2); - weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance); - weapons.rotation2[i]*=360/6.28; + weapons[i].rotation2=asin((temppoint1.y-temppoint2.y)/distance); + weapons[i].rotation2*=360/6.28; temppoint1.y=0; temppoint2.y=0; - weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); - weapons.rotation1[i]*=360/6.28; - weapons.rotation3[i]=0; - weapons.smallrotation[i]=90; - weapons.smallrotation2[i]=0; - if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i]; + weapons[i].rotation1=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); + weapons[i].rotation1*=360/6.28; + weapons[i].rotation3=0; + weapons[i].smallrotation=90; + weapons[i].smallrotation2=0; + if(temppoint1.x>temppoint2.x)weapons[i].rotation1=360-weapons[i].rotation1; } } } if(weaponactive!=k&&weaponstuck!=k){ - if(weapons.type[i]==knife){ - weapons.smallrotation[i]=-70; - weapons.smallrotation2[i]=10; + if(weapons[i].getType()==knife){ + weapons[i].smallrotation=-70; + weapons[i].smallrotation2=10; } - if(weapons.type[i]==sword){ - weapons.smallrotation[i]=-100; - weapons.smallrotation2[i]=-8; + if(weapons[i].getType()==sword){ + weapons[i].smallrotation=-100; + weapons[i].smallrotation2=-8; } - if(weapons.type[i]==staff){ - weapons.smallrotation[i]=-100; - weapons.smallrotation2[i]=-8; + if(weapons[i].getType()==staff){ + weapons[i].smallrotation=-100; + weapons[i].smallrotation2=-8; } } if(weaponstuck==k){ - if(weaponstuckwhere==0)weapons.smallrotation[i]=180; - else weapons.smallrotation[i]=0; - weapons.smallrotation2[i]=10; + if(weaponstuckwhere==0) + weapons[i].smallrotation=180; + else + weapons[i].smallrotation=0; + weapons[i].smallrotation2=10; } } } diff --git a/Source/Weapons.cpp b/Source/Weapons.cpp index d250f1e..df2c6cf 100644 --- a/Source/Weapons.cpp +++ b/Source/Weapons.cpp @@ -53,7 +53,51 @@ extern bool freeze; extern int tutoriallevel; extern int numthrowkill; -void Weapons::DoStuff(){ +Model Weapon::throwingknifemodel; +GLuint Weapon::knifetextureptr = 0; +GLuint Weapon::lightbloodknifetextureptr = 0; +GLuint Weapon::bloodknifetextureptr = 0; + +Model Weapon::swordmodel; +GLuint Weapon::swordtextureptr = 0; +GLuint Weapon::lightbloodswordtextureptr = 0; +GLuint Weapon::bloodswordtextureptr = 0; + +Model Weapon::staffmodel; +GLuint Weapon::stafftextureptr = 0; + +Weapon::Weapon(int t, int o) : owner(o) { + setType(t); + bloody=0; + blooddrip=0; + blooddripdelay=0; + onfire=0; + flamedelay=0; + damage=0; + position=-1000; + tippoint=-1000; +} + +void Weapon::setType(int t) { + type = t; + if(type==sword){ + mass=1.5; + tipmass=1; + length=.8; + } + if(type==staff){ + mass=2; + tipmass=1; + length=1.5; + } + if(type==knife){ + mass=1; + tipmass=1.2; + length=.25; + } +} + +void Weapon::DoStuff() { static int i,whichpatchx,whichpatchz,j,k,whichhit,m; static XYZ start,end,colpoint,normalrot,footvel,footpoint; static XYZ terrainnormal; @@ -74,939 +118,920 @@ void Weapons::DoStuff(){ static XYZ extramove; static float proportion; static float tempmult; - - //Move - - for(i=0;i=2&&type==staff&&owner!=-1){ + emit_sound_at(staffbreaksound, tippoint); + XYZ tempvel; + XYZ speed; + //speed=(tippoint-oldtippoint)/multiplier/6; + speed=0; + for(j=0;j<40;j++){ + tempvel.x=float(abs(Random()%100)-50)/20; + tempvel.y=float(abs(Random()%100)-50)/20; + tempvel.z=float(abs(Random()%100)-50)/20; + tempvel+=speed; + Sprite::MakeSprite(splintersprite, position+(tippoint-position)*((float)j-8)/32,tempvel*.5, 115/255,73/255,12/255, .1, 1); } - if(damage[i]>=2&&type[i]==staff&&owner[i]!=-1){ - emit_sound_at(staffbreaksound, tippoint[i]); - XYZ tempvel; - XYZ speed; - //speed=(tippoint[i]-oldtippoint[i])/multiplier/6; - speed=0; - for(j=0;j<40;j++){ - tempvel.x=float(abs(Random()%100)-50)/20; - tempvel.y=float(abs(Random()%100)-50)/20; - tempvel.z=float(abs(Random()%100)-50)/20; - tempvel+=speed; - Sprite::MakeSprite(splintersprite, position[i]+(tippoint[i]-position[i])*((float)j-8)/32,tempvel*.5, 115/255,73/255,12/255, .1, 1); - } - int tempowner; - tempowner=owner[i]; - owner[i]=-1; - hitsomething[i]=0; - missed[i]=1; - freetime[i]=0; - firstfree[i]=1; - position[i]=0; - physics[i]=0; - if(tempowner!=-1){ - player[tempowner].num_weapons--; - if(player[tempowner].num_weapons){ - player[tempowner].weaponids[0]=player[tempowner].weaponids[player[tempowner].num_weapons]; - if(player[tempowner].weaponstuck==player[tempowner].num_weapons)player[tempowner].weaponstuck=0; - } - player[tempowner].weaponactive=-1; + int tempowner; + tempowner=owner; + owner=-1; + hitsomething=0; + missed=1; + freetime=0; + firstfree=1; + position=0; + physics=0; + if(tempowner!=-1){ + player[tempowner].num_weapons--; + if(player[tempowner].num_weapons){ + player[tempowner].weaponids[0]=player[tempowner].weaponids[player[tempowner].num_weapons]; + if(player[tempowner].weaponstuck==player[tempowner].num_weapons)player[tempowner].weaponstuck=0; } + player[tempowner].weaponactive=-1; } - oldposition[i]=position[i]; - oldtippoint[i]=tippoint[i]; - if(owner[i]==-1&&(velocity[i].x||velocity[i].y||velocity[i].z)&&!physics[i]){ - position[i]+=velocity[i]*multiplier; - tippoint[i]+=velocity[i]*multiplier; - whichpatchx=position[i].x/(terrain.size/subdivision*terrain.scale); - whichpatchz=position[i].z/(terrain.size/subdivision*terrain.scale); - if(whichpatchx>0&&whichpatchz>0&&whichpatchxtemppoint2.x)rotation1[i]=360-rotation1[i]; - - rotation3[i]=0; - smallrotation[i]=90; - smallrotation2[i]=0; - bigtilt[i]=0; - bigtilt2[i]=0; - bigrotation[i]=0; - - emit_sound_at(knifesheathesound, position[i], 128.); - - bloody[i]=0; - - Sprite::MakeSprite(cloudimpactsprite, position[i],velocity[i], 1,1,1, .8, .3); - } - else { - physics[i]=1; - firstfree[i]=1; - position[i]-=velocity[i]*multiplier; - tippoint[i]-=velocity[i]*multiplier; - tipvelocity[i]=velocity[i]; - } + } + oldposition=position; + oldtippoint=tippoint; + if(owner==-1&&(velocity.x||velocity.y||velocity.z)&&!physics){ + position+=velocity*multiplier; + tippoint+=velocity*multiplier; + whichpatchx=position.x/(terrain.size/subdivision*terrain.scale); + whichpatchz=position.z/(terrain.size/subdivision*terrain.scale); + if(whichpatchx>0&&whichpatchz>0&&whichpatchxtemppoint2.x)rotation1=360-rotation1; + + rotation3=0; + smallrotation=90; + smallrotation2=0; + bigtilt=0; + bigtilt2=0; + bigrotation=0; + + emit_sound_at(knifesheathesound, position, 128.); + + bloody=0; + + Sprite::MakeSprite(cloudimpactsprite, position,velocity, 1,1,1, .8, .3); + } + else { + physics=1; + firstfree=1; + position-=velocity*multiplier; + tippoint-=velocity*multiplier; + tipvelocity=velocity; } } } - if(velocity[i].x||velocity[i].y||velocity[i].z) - for(j=0;j0){ - player[j].weaponids[player[j].num_weapons]=player[j].weaponids[0]; - } - player[j].num_weapons++; - player[j].weaponids[0]=i; + } + if(velocity.x||velocity.y||velocity.z) + for(j=0;j0){ + player[j].weaponids[player[j].num_weapons]=player[j].weaponids[0]; + } + player[j].num_weapons++; + player[j].weaponids[0]=i; - player[j].aitype=attacktypecutoff; + player[j].aitype=attacktypecutoff; + } + else { + if(j!=0)numthrowkill++; + player[j].num_weapons++; + player[j].weaponstuck=player[j].num_weapons-1; + if(normaldotproduct(player[j].facing,velocity)>0)player[j].weaponstuckwhere=1; + else player[j].weaponstuckwhere=0; + + player[j].weaponids[player[j].num_weapons-1]=i; + + player[j].RagDoll(0); + player[j].skeleton.joints[player[j].skeleton.jointlabels[abdomen]].velocity+=velocity*2; + player[j].skeleton.joints[player[j].skeleton.jointlabels[neck]].velocity+=velocity*2; + player[j].skeleton.joints[player[j].skeleton.jointlabels[rightshoulder]].velocity+=velocity*2; + player[j].skeleton.joints[player[j].skeleton.jointlabels[leftshoulder]].velocity+=velocity*2; + //player[j].Puff(abdomen); + if(bloodtoggle&&tutoriallevel!=1)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3); + if(tutoriallevel==1)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .8, .3); + footvel=tippoint-position; + Normalise(&footvel); + if(bloodtoggle&&tutoriallevel!=1)Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*-1, 1,0,0, .6, 1); + + if(tutoriallevel!=1){ + if(player[j].weaponstuckwhere==0)player[j].DoBloodBig(2,205); + if(player[j].weaponstuckwhere==1)player[j].DoBloodBig(2,200); + player[j].damage+=200/player[j].armorhigh; + player[j].deathbleeding=1; + player[j].bloodloss+=(200+abs((float)(Random()%40))-20)/player[j].armorhigh; + owner=j; + bloody=2; + blooddrip=5; } - else { - if(j!=0)numthrowkill++; - player[j].num_weapons++; - player[j].weaponstuck=player[j].num_weapons-1; - if(normaldotproduct(player[j].facing,velocity[i])>0)player[j].weaponstuckwhere=1; - else player[j].weaponstuckwhere=0; - - player[j].weaponids[player[j].num_weapons-1]=i; - - player[j].RagDoll(0); - player[j].skeleton.joints[player[j].skeleton.jointlabels[abdomen]].velocity+=velocity[i]*2; - player[j].skeleton.joints[player[j].skeleton.jointlabels[neck]].velocity+=velocity[i]*2; - player[j].skeleton.joints[player[j].skeleton.jointlabels[rightshoulder]].velocity+=velocity[i]*2; - player[j].skeleton.joints[player[j].skeleton.jointlabels[leftshoulder]].velocity+=velocity[i]*2; - //player[j].Puff(abdomen); - if(bloodtoggle&&tutoriallevel!=1)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3); - if(tutoriallevel==1)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .8, .3); - footvel=tippoint[i]-position[i]; - Normalise(&footvel); - if(bloodtoggle&&tutoriallevel!=1)Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*-1, 1,0,0, .6, 1); - - if(tutoriallevel!=1){ - if(player[j].weaponstuckwhere==0)player[j].DoBloodBig(2,205); - if(player[j].weaponstuckwhere==1)player[j].DoBloodBig(2,200); - player[j].damage+=200/player[j].armorhigh; - player[j].deathbleeding=1; - player[j].bloodloss+=(200+abs((float)(Random()%40))-20)/player[j].armorhigh; - owner[i]=j; - bloody[i]=2; - blooddrip[i]=5; - } - emit_sound_at(fleshstabsound, position[i], 128.); + emit_sound_at(fleshstabsound, position, 128.); - if(animation[player[0].targetanimation].height==highheight) - award_bonus(0, ninja); - else - award_bonus(0, Bullseyebonus); - } + if(animation[player[0].targetanimation].height==highheight) + award_bonus(0, ninja); + else + award_bonus(0, Bullseyebonus); } - else missed[i]=1; } + else missed=1; } - if(position[i].ytemppoint2.x)rotation1[i]=360-rotation1[i]; - } - } - //Sword physics - XYZ mid; - XYZ oldmid; - XYZ oldmid2; - - tempmult=multiplier; - multiplier/=10; - for(int l=0;l<10;l++){ - if(owner[i]==-1&&(velocity[i].x||velocity[i].y||velocity[i].z)&&physics[i]){ - //move - position[i]+=velocity[i]*multiplier; - tippoint[i]+=tipvelocity[i]*multiplier; - - //Length constrain - midp=(position[i]*mass[i]+tippoint[i]*tipmass[i])/(mass[i]+tipmass[i]); - vel=tippoint[i]-midp; - Normalise(&vel); - newpoint1=midp-vel*length[i]*(tipmass[i]/(mass[i]+tipmass[i])); - newpoint2=midp+vel*length[i]*(mass[i]/(mass[i]+tipmass[i])); - if(!freeze){ - if(freetime[i]>.04)velocity[i]=velocity[i]+(newpoint1-position[i])/multiplier; - if(freetime[i]>.04)tipvelocity[i]=tipvelocity[i]+(newpoint2-tippoint[i])/multiplier; + temppoint1=0; + temppoint2=velocity; + distance=findDistance(&temppoint1,&temppoint2); + rotation2=asin((temppoint1.y-temppoint2.y)/distance); + rotation2*=360/6.28; + temppoint1.y=0; + temppoint2.y=0; + rotation1=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); + rotation1*=360/6.28; + rotation3=0; + smallrotation=90; + smallrotation2=0; + bigtilt=0; + bigtilt2=0; + bigrotation=0; + if(temppoint1.x>temppoint2.x)rotation1=360-rotation1; } - position[i]=newpoint1; - tippoint[i]=newpoint2; - - - //Object collisions - whichpatchx=(position[i].x)/(terrain.size/subdivision*terrain.scale); - whichpatchz=(position[i].z)/(terrain.size/subdivision*terrain.scale); - if(whichpatchx>0&&whichpatchz>0&&whichpatchx.04)velocity=velocity+(newpoint1-position)/multiplier; + if(freetime>.04)tipvelocity=tipvelocity+(newpoint2-tippoint)/multiplier; + } + position=newpoint1; + tippoint=newpoint2; + + + //Object collisions + whichpatchx=(position.x)/(terrain.size/subdivision*terrain.scale); + whichpatchz=(position.z)/(terrain.size/subdivision*terrain.scale); + if(whichpatchx>0&&whichpatchz>0&&whichpatchx0)velocity[i]*=1-friction*frictionness; - else velocity[i]=0; - velocity[i]+=bounceness*elasticity; - - if(findLengthfast(&bounceness)>1){ - int whichsound; - if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); - emit_sound_at(whichsound, position[i], 128*findLengthfast(&bounceness)); - } + start=oldposition; + end=position; + whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]); + if(whichhit!=-1){ + hitsomething=1; + position=colpoint; + terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1; + ReflectVector(&velocity,&terrainnormal); + position+=terrainnormal*.002; + + bounceness=terrainnormal*findLength(&velocity)*(abs(normaldotproduct(velocity,terrainnormal))); + if(findLengthfast(&velocity)0)velocity*=1-friction*frictionness; + else velocity=0; + velocity+=bounceness*elasticity; + + if(findLengthfast(&bounceness)>1){ + int whichsound; + if(type==staff)whichsound=footstepsound3+abs(Random()%2); + if(type!=staff)whichsound=clank1sound+abs(Random()%4); + emit_sound_at(whichsound, position, 128*findLengthfast(&bounceness)); } - start=oldtippoint[i]; - end=tippoint[i]; - whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]); - if(whichhit!=-1){ - hitsomething[i]=1; - tippoint[i]=colpoint; - terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1; - ReflectVector(&tipvelocity[i],&terrainnormal); - tippoint[i]+=terrainnormal*.002; - - bounceness=terrainnormal*findLength(&tipvelocity[i])*(abs(normaldotproduct(tipvelocity[i],terrainnormal))); - if(findLengthfast(&tipvelocity[i])0)tipvelocity[i]*=1-friction*frictionness; - else tipvelocity[i]=0; - tipvelocity[i]+=bounceness*elasticity; - - if(findLengthfast(&bounceness)>1){ - int whichsound; - if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); - emit_sound_at(whichsound, position[i], 128*findLengthfast(&bounceness)); - } + } + start=oldtippoint; + end=tippoint; + whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]); + if(whichhit!=-1){ + hitsomething=1; + tippoint=colpoint; + terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1; + ReflectVector(&tipvelocity,&terrainnormal); + tippoint+=terrainnormal*.002; + + bounceness=terrainnormal*findLength(&tipvelocity)*(abs(normaldotproduct(tipvelocity,terrainnormal))); + if(findLengthfast(&tipvelocity)0)tipvelocity*=1-friction*frictionness; + else tipvelocity=0; + tipvelocity+=bounceness*elasticity; + + if(findLengthfast(&bounceness)>1){ + int whichsound; + if(type==staff)whichsound=footstepsound3+abs(Random()%2); + if(type!=staff)whichsound=clank1sound+abs(Random()%4); + emit_sound_at(whichsound, position, 128*findLengthfast(&bounceness)); } + } - if((objects.type[k]!=boxtype&&objects.type[k]!=platformtype&&objects.type[k]!=walltype&&objects.type[k]!=weirdtype)||objects.rotation2[k]!=0) - for(m=0;m<2;m++){ - mid=(position[i]*(21+(float)m*10)+tippoint[i]*(19-(float)m*10))/40; - oldmid2=mid; - oldmid=(oldposition[i]*(21+(float)m*10)+oldtippoint[i]*(19-(float)m*10))/40; - - start=oldmid; - end=mid; - whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]); - if(whichhit!=-1){ - hitsomething[i]=1; - mid=colpoint; - terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1; - ReflectVector(&velocity[i],&terrainnormal); - - bounceness=terrainnormal*findLength(&velocity[i])*(abs(normaldotproduct(velocity[i],terrainnormal))); - if(findLengthfast(&velocity[i])0)velocity[i]*=1-friction*frictionness; - else velocity[i]=0; - velocity[i]+=bounceness*elasticity; - - if(findLengthfast(&bounceness)>1){ - int whichsound; - if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); - emit_sound_at(whichsound, mid, 128*findLengthfast(&bounceness)); - } - position[i]+=(mid-oldmid2)*(20/(1+(float)m*10)); - } + if((objects.type[k]!=boxtype&&objects.type[k]!=platformtype&&objects.type[k]!=walltype&&objects.type[k]!=weirdtype)||objects.rotation2[k]!=0) + for(m=0;m<2;m++){ + mid=(position*(21+(float)m*10)+tippoint*(19-(float)m*10))/40; + oldmid2=mid; + oldmid=(oldposition*(21+(float)m*10)+oldtippoint*(19-(float)m*10))/40; - mid=(position[i]*(19-(float)m*10)+tippoint[i]*(21+(float)m*10))/40; - oldmid2=mid; - oldmid=(oldposition[i]*(19-(float)m*10)+oldtippoint[i]*(21+(float)m*10))/40; - - start=oldmid; - end=mid; - whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]); - if(whichhit!=-1){ - hitsomething[i]=1; - mid=colpoint; - terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1; - ReflectVector(&tipvelocity[i],&terrainnormal); - - bounceness=terrainnormal*findLength(&tipvelocity[i])*(abs(normaldotproduct(tipvelocity[i],terrainnormal))); - if(findLengthfast(&tipvelocity[i])0)tipvelocity[i]*=1-friction*frictionness; - else tipvelocity[i]=0; - tipvelocity[i]+=bounceness*elasticity; - - if(findLengthfast(&bounceness)>1){ - int whichsound; - if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); - emit_sound_at(whichsound, mid, 128*findLengthfast(&bounceness)); - } - tippoint[i]+=(mid-oldmid2)*(20/(1+(float)m*10)); + start=oldmid; + end=mid; + whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]); + if(whichhit!=-1){ + hitsomething=1; + mid=colpoint; + terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1; + ReflectVector(&velocity,&terrainnormal); + + bounceness=terrainnormal*findLength(&velocity)*(abs(normaldotproduct(velocity,terrainnormal))); + if(findLengthfast(&velocity)0)velocity*=1-friction*frictionness; + else velocity=0; + velocity+=bounceness*elasticity; + + if(findLengthfast(&bounceness)>1){ + int whichsound; + if(type==staff)whichsound=footstepsound3+abs(Random()%2); + if(type!=staff)whichsound=clank1sound+abs(Random()%4); + emit_sound_at(whichsound, mid, 128*findLengthfast(&bounceness)); } + position+=(mid-oldmid2)*(20/(1+(float)m*10)); } - else - { - start=position[i]; - end=tippoint[i]; + + mid=(position*(19-(float)m*10)+tippoint*(21+(float)m*10))/40; + oldmid2=mid; + oldmid=(oldposition*(19-(float)m*10)+oldtippoint*(21+(float)m*10))/40; + + start=oldmid; + end=mid; whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]); if(whichhit!=-1){ - hitsomething[i]=1; - closestdistance=-1; - closestswordpoint=colpoint;//(position[i]+tippoint[i])/2; - point[0]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[0]],0,objects.rotation[k],0)+objects.position[k]; - point[1]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[1]],0,objects.rotation[k],0)+objects.position[k]; - point[2]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[2]],0,objects.rotation[k],0)+objects.position[k]; - if(DistancePointLine(&closestswordpoint, &point[0], &point[1], &distance,&colpoint )) + hitsomething=1; + mid=colpoint; + terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1; + ReflectVector(&tipvelocity,&terrainnormal); + + bounceness=terrainnormal*findLength(&tipvelocity)*(abs(normaldotproduct(tipvelocity,terrainnormal))); + if(findLengthfast(&tipvelocity)0)tipvelocity*=1-friction*frictionness; + else tipvelocity=0; + tipvelocity+=bounceness*elasticity; + + if(findLengthfast(&bounceness)>1){ + int whichsound; + if(type==staff)whichsound=footstepsound3+abs(Random()%2); + if(type!=staff)whichsound=clank1sound+abs(Random()%4); + emit_sound_at(whichsound, mid, 128*findLengthfast(&bounceness)); + } + tippoint+=(mid-oldmid2)*(20/(1+(float)m*10)); + } + } + else + { + start=position; + end=tippoint; + whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]); + if(whichhit!=-1){ + hitsomething=1; + closestdistance=-1; + closestswordpoint=colpoint;//(position+tippoint)/2; + point[0]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[0]],0,objects.rotation[k],0)+objects.position[k]; + point[1]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[1]],0,objects.rotation[k],0)+objects.position[k]; + point[2]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[2]],0,objects.rotation[k],0)+objects.position[k]; + if(DistancePointLine(&closestswordpoint, &point[0], &point[1], &distance,&colpoint )) + if(distance0)velocity[i]*=1-friction*frictionness; - else velocity[i]=0; - if(terrain.getOpacity(position[i].x,position[i].z)<.2)velocity[i]+=bounceness*elasticity*.3; - else velocity[i]+=bounceness*elasticity; -//if (type[i]==knife) printf("velocity of knife %d now %f,%f,%f.\n", i, velocity[i].x, velocity[i].y, velocity[i].z); - if(findLengthfast(&bounceness)>1){ - int whichsound; - if(terrain.getOpacity(position[i].x,position[i].z)>.2){ - if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); + } + //Terrain collisions + whichhit=terrain.lineTerrain(oldposition,position,&colpoint); + if(whichhit!=-1||position.y0)velocity*=1-friction*frictionness; + else velocity=0; + if(terrain.getOpacity(position.x,position.z)<.2)velocity+=bounceness*elasticity*.3; + else velocity+=bounceness*elasticity; +//if (type==knife) printf("velocity of knife %d now %f,%f,%f.\n", i, velocity.x, velocity.y, velocity.z); + if(findLengthfast(&bounceness)>1){ + int whichsound; + if(terrain.getOpacity(position.x,position.z)>.2){ + if(type==staff)whichsound=footstepsound3+abs(Random()%2); + if(type!=staff)whichsound=clank1sound+abs(Random()%4); + } + else whichsound=footstepsound+abs(Random()%2); + emit_sound_at(whichsound, position, + findLengthfast(&bounceness) + * (terrain.getOpacity(position.x,position.z) > .2 + ? 128. + : 32.)); + + if(terrain.getOpacity(position.x,position.z)<.2){ + XYZ terrainlight; + terrainlight=terrain.getLighting(position.x,position.z); + if(environment==snowyenvironment){ + if(findDistancefast(&position,&viewer) .2 - ? 128. - : 32.)); - - if(terrain.getOpacity(position[i].x,position[i].z)<.2){ - XYZ terrainlight; - terrainlight=terrain.getLighting(position[i].x,position[i].z); - if(environment==snowyenvironment){ - if(findDistancefast(&position[i],&viewer)0)tipvelocity[i]*=1-friction*frictionness; - else tipvelocity[i]=0; - if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)<.2)tipvelocity[i]+=bounceness*elasticity*.3; - else tipvelocity[i]+=bounceness*elasticity; -//if (type[i]==knife) printf("tipvelocity of knife %d now %f,%f,%f.\n", i, tipvelocity[i].x, tipvelocity[i].y, tipvelocity[i].z); - - if(findLengthfast(&bounceness)>1){ - int whichsound; - if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2){ - if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); + } + whichhit=terrain.lineTerrain(oldtippoint,tippoint,&colpoint); + if(whichhit!=-1||tippoint.y0)tipvelocity*=1-friction*frictionness; + else tipvelocity=0; + if(terrain.getOpacity(tippoint.x,tippoint.z)<.2)tipvelocity+=bounceness*elasticity*.3; + else tipvelocity+=bounceness*elasticity; +//if (type==knife) printf("tipvelocity of knife %d now %f,%f,%f.\n", i, tipvelocity.x, tipvelocity.y, tipvelocity.z); + + if(findLengthfast(&bounceness)>1){ + int whichsound; + if(terrain.getOpacity(tippoint.x,tippoint.z)>.2){ + if(type==staff)whichsound=footstepsound3+abs(Random()%2); + if(type!=staff)whichsound=clank1sound+abs(Random()%4); + } + else whichsound=footstepsound+abs(Random()%2); + emit_sound_at(whichsound, tippoint, + findLengthfast(&bounceness) + * (terrain.getOpacity(tippoint.x,tippoint.z) > .2 + ? 128. + : 32.)); + + if(terrain.getOpacity(tippoint.x,tippoint.z)<.2){ + XYZ terrainlight; + terrainlight=terrain.getLighting(tippoint.x,tippoint.z); + if(environment==snowyenvironment){ + if(findDistancefast(&tippoint,&viewer) .2 - ? 128. - : 32.)); - - if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)<.2){ - XYZ terrainlight; - terrainlight=terrain.getLighting(tippoint[i].x,tippoint[i].z); - if(environment==snowyenvironment){ - if(findDistancefast(&tippoint[i],&viewer)0)velocity[i]*=1-friction*frictionness; - else velocity[i]=0; - if(terrain.getOpacity(mid.x,mid.z)<.2)velocity[i]+=bounceness*elasticity*.3; - else velocity[i]+=bounceness*elasticity; - - if(findLengthfast(&bounceness)>1){ - int whichsound; - if(terrain.getOpacity(mid.x,mid.z)>.2){ - if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); + else if(environment==desertenvironment){ + if(findDistancefast(&tippoint,&viewer) .2 - ? 128. - : 32.)); } - position[i]+=(mid-oldmid)*20; } + } - mid=position[i]+tippoint[i]; - mid/=2; - mid+=(tippoint[i]-mid)/20; - oldmid=mid; - if(mid.y0)tipvelocity[i]*=1-friction*frictionness; - else tipvelocity[i]=0; - if(terrain.getOpacity(mid.x,mid.z)<.2)tipvelocity[i]+=bounceness*elasticity*.3; - else tipvelocity[i]+=bounceness*elasticity; - - if(findLengthfast(&bounceness)>1){ - int whichsound; - if(terrain.getOpacity(mid.x,mid.z)>.2){ - if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); - } - else whichsound=footstepsound+abs(Random()%2); - emit_sound_at(whichsound, mid, - findLengthfast(&bounceness) - * (terrain.getOpacity(position[i].x,position[i].z) > .2 - ? 128. - : 32.)); + //Edges + mid=position+tippoint; + mid/=2; + mid+=(position-mid)/20; + oldmid=mid; + if(mid.y0)velocity*=1-friction*frictionness; + else velocity=0; + if(terrain.getOpacity(mid.x,mid.z)<.2)velocity+=bounceness*elasticity*.3; + else velocity+=bounceness*elasticity; + + if(findLengthfast(&bounceness)>1){ + int whichsound; + if(terrain.getOpacity(mid.x,mid.z)>.2){ + if(type==staff)whichsound=footstepsound3+abs(Random()%2); + if(type!=staff)whichsound=clank1sound+abs(Random()%4); } - tippoint[i]+=(mid-oldmid)*20; + else whichsound=footstepsound+abs(Random()%2); + emit_sound_at(whichsound, mid, + findLengthfast(&bounceness) + * (terrain.getOpacity(position.x,position.z) > .2 + ? 128. + : 32.)); } - //Gravity - velocity[i].y+=gravity*multiplier; - tipvelocity[i].y+=gravity*multiplier; - //position[i].y+=gravity*multiplier*multiplier; - //tippoint[i].y+=gravity*multiplier*multiplier; - - //Rotation - XYZ temppoint1,temppoint2,tempforward; - float distance; + position+=(mid-oldmid)*20; + } - temppoint1=position[i]; - temppoint2=tippoint[i]; - distance=findDistance(&temppoint1,&temppoint2); - rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance); - rotation2[i]*=360/6.28; - temppoint1.y=0; - temppoint2.y=0; - rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); - rotation1[i]*=360/6.28; - rotation3[i]=0; - smallrotation[i]=90; - smallrotation2[i]=0; - bigtilt[i]=0; - bigtilt2[i]=0; - bigrotation[i]=0; - if(temppoint1.x>temppoint2.x)rotation1[i]=360-rotation1[i]; - - //Stop moving - if(findLengthfast(&velocity[i])<.3&&findLengthfast(&tipvelocity[i])<.3&&hitsomething[i]){ - freetime[i]+=multiplier; + mid=position+tippoint; + mid/=2; + mid+=(tippoint-mid)/20; + oldmid=mid; + if(mid.y0)tipvelocity*=1-friction*frictionness; + else tipvelocity=0; + if(terrain.getOpacity(mid.x,mid.z)<.2)tipvelocity+=bounceness*elasticity*.3; + else tipvelocity+=bounceness*elasticity; + + if(findLengthfast(&bounceness)>1){ + int whichsound; + if(terrain.getOpacity(mid.x,mid.z)>.2){ + if(type==staff)whichsound=footstepsound3+abs(Random()%2); + if(type!=staff)whichsound=clank1sound+abs(Random()%4); + } + else whichsound=footstepsound+abs(Random()%2); + emit_sound_at(whichsound, mid, + findLengthfast(&bounceness) + * (terrain.getOpacity(position.x,position.z) > .2 + ? 128. + : 32.)); } + tippoint+=(mid-oldmid)*20; + } + //Gravity + velocity.y+=gravity*multiplier; + tipvelocity.y+=gravity*multiplier; + //position.y+=gravity*multiplier*multiplier; + //tippoint.y+=gravity*multiplier*multiplier; + + //Rotation + XYZ temppoint1,temppoint2,tempforward; + float distance; + + temppoint1=position; + temppoint2=tippoint; + distance=findDistance(&temppoint1,&temppoint2); + rotation2=asin((temppoint1.y-temppoint2.y)/distance); + rotation2*=360/6.28; + temppoint1.y=0; + temppoint2.y=0; + rotation1=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2)); + rotation1*=360/6.28; + rotation3=0; + smallrotation=90; + smallrotation2=0; + bigtilt=0; + bigtilt2=0; + bigrotation=0; + if(temppoint1.x>temppoint2.x)rotation1=360-rotation1; + + //Stop moving + if(findLengthfast(&velocity)<.3&&findLengthfast(&tipvelocity)<.3&&hitsomething){ + freetime+=multiplier; + } - //velocity[i]=(position[i]-oldposition[i])/multiplier; - //tipvelocity[i]==(tippoint[i-+oldtippoint[i])/multiplier; - if(freetime[i]>.4){ - velocity[i]=0; - tipvelocity[i]=0; - } - firstfree[i]=0; + //velocity=(position-oldposition)/multiplier; + //tipvelocity==(tippoint[i-+oldtippoint)/multiplier; + if(freetime>.4){ + velocity=0; + tipvelocity=0; + } + firstfree=0; + } + } + multiplier=tempmult; + if(blooddrip&&bloody){ + blooddripdelay-=blooddrip*multiplier/2; + blooddrip-=multiplier; + if(blooddrip<0)blooddrip=0; + if(blooddrip>5)blooddrip=5; + if(blooddripdelay<0&&bloodtoggle){ + blooddripdelay=1; + XYZ bloodvel; + XYZ bloodloc; + bloodloc=position+(tippoint-position)*.7; + bloodloc.y-=.05; + if(bloodtoggle){ + bloodvel=0; + Sprite::MakeSprite(bloodsprite, bloodloc,bloodvel, 1,1,1, .03, 1); } } - multiplier=tempmult; - if(blooddrip[i]&&bloody[i]){ - blooddripdelay[i]-=blooddrip[i]*multiplier/2; - blooddrip[i]-=multiplier; - if(blooddrip[i]<0)blooddrip[i]=0; - if(blooddrip[i]>5)blooddrip[i]=5; - if(blooddripdelay[i]<0&&bloodtoggle){ - blooddripdelay[i]=1; - XYZ bloodvel; - XYZ bloodloc; - bloodloc=position[i]+(tippoint[i]-position[i])*.7; - bloodloc.y-=.05; - if(bloodtoggle){ - bloodvel=0; - Sprite::MakeSprite(bloodsprite, bloodloc,bloodvel, 1,1,1, .03, 1); + } + if(onfire){ + flamedelay-=multiplier; + if(onfire&&flamedelay<=0){ + flamedelay=.020; + flamedelay-=multiplier; + normalrot=0; + if(owner!=-1){ + normalrot=player[owner].velocity; + } + normalrot.y+=1; + if(owner!=-1){ + if(player[owner].onterrain){ + normalrot.y=1; } } + Sprite::MakeSprite(weaponflamesprite, position+tippoint*(((float)abs(Random()%100))/600+.05),normalrot, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*1/3, 1); + Sprite::setLastSpriteSpeed(4); + Sprite::setLastSpriteAlivetime(.3); } - if(onfire[i]){ - flamedelay[i]-=multiplier; - if(onfire[i]&&flamedelay[i]<=0){ - flamedelay[i]=.020; - flamedelay[i]-=multiplier; - normalrot=0; - if(owner[i]!=-1){ - normalrot=player[owner[i]].velocity; - } - normalrot.y+=1; - if(owner[i]!=-1){ - if(player[owner[i]].onterrain){ - normalrot.y=1; - } - } - Sprite::MakeSprite(weaponflamesprite, position[i]+tippoint[i]*(((float)abs(Random()%100))/600+.05),normalrot, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*1/3, 1); + } + + if(!onfire&&owner==-1&&type!=staff){ + flamedelay-=multiplier; + if(flamedelay<=0){ + flamedelay=.020; + flamedelay-=multiplier; + normalrot=0; + if(Random()%50==0&&findDistancefast(&position,&viewer)>80){ + XYZ shinepoint; + shinepoint=position+(tippoint-position)*(((float)abs(Random()%100))/100); + Sprite::MakeSprite(weaponshinesprite, shinepoint,normalrot, 1,1,1, (.1+(float)abs(Random()%100)/200-.25)*1/3*fast_sqrt(findDistance(&shinepoint,&viewer)), 1); Sprite::setLastSpriteSpeed(4); Sprite::setLastSpriteAlivetime(.3); } } + } +} - if(!onfire[i]&&owner[i]==-1&&type[i]!=staff){ - flamedelay[i]-=multiplier; - if(flamedelay[i]<=0){ - flamedelay[i]=.020; - flamedelay[i]-=multiplier; - normalrot=0; - if(Random()%50==0&&findDistancefast(&position[i],&viewer)>80){ - XYZ shinepoint; - shinepoint=position[i]+(tippoint[i]-position[i])*(((float)abs(Random()%100))/100); - Sprite::MakeSprite(weaponshinesprite, shinepoint,normalrot, 1,1,1, (.1+(float)abs(Random()%100)/200-.25)*1/3*fast_sqrt(findDistance(&shinepoint,&viewer)), 1); - Sprite::setLastSpriteSpeed(4); - Sprite::setLastSpriteAlivetime(.3); - } - } - } +void Weapons::DoStuff() { + //Move + for(std::vector::iterator weapon = begin(); weapon != end(); ++weapon) { + weapon->DoStuff(); } } -int Weapons::Draw() -{ +void Weapon::Draw() { static int i,j; static XYZ terrainlight; static GLfloat M[16]; static bool draw; - glAlphaFunc(GL_GREATER, 0.9); - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - glEnable(GL_CULL_FACE); - glCullFace(GL_FRONT); - glDepthMask(1); - for(i=0;i1)||(player[owner].currentanimation==staffhitreversedanim&&player[owner].currentframe>1)||(player[owner].currentanimation==staffspinhitanim&&player[owner].currentframe>1)||(player[owner].currentanimation==staffspinhitreversedanim&&player[owner].currentframe>1)||(player[owner].currentanimation==staffgroundsmashanim&&player[owner].currentframe>1)||(player[owner].targetanimation==swordslashanim&&player[owner].targetframe<7)||player[owner].targetanimation==crouchstabanim||player[owner].targetanimation==swordslashreversalanim||player[owner].targetanimation==swordslashreversedanim||player[owner].targetanimation==knifefollowanim||player[owner].targetanimation==swordgroundstabanim||player[owner].targetanimation==knifethrowanim)&&player[owner].targetanimation==lastdrawnanim&&!player[owner].skeleton.free) { - draw=1; - if(velocity[i].x&&!physics[i])drawhowmany[i]=10; - else drawhowmany[i]=1; + drawhowmany=10; } - if(owner[i]!=-1) + else drawhowmany=1; + if(player[owner].targetanimation==swordgroundstabanim) { - if(player[owner[i]].occluded<25) - if((frustum.SphereInFrustum(player[owner[i]].coords.x,player[owner[i]].coords.y+player[owner[i]].scale*3,player[owner[i]].coords.z,player[owner[i]].scale*8)&&findDistancefast(&viewer,&player[owner[i]].coords)1)||(player[owner[i]].currentanimation==staffhitreversedanim&&player[owner[i]].currentframe>1)||(player[owner[i]].currentanimation==staffspinhitanim&&player[owner[i]].currentframe>1)||(player[owner[i]].currentanimation==staffspinhitreversedanim&&player[owner[i]].currentframe>1)||(player[owner[i]].currentanimation==staffgroundsmashanim&&player[owner[i]].currentframe>1)||(player[owner[i]].targetanimation==swordslashanim&&player[owner[i]].targetframe<7)||player[owner[i]].targetanimation==crouchstabanim||player[owner[i]].targetanimation==swordslashreversalanim||player[owner[i]].targetanimation==swordslashreversedanim||player[owner[i]].targetanimation==knifefollowanim||player[owner[i]].targetanimation==swordgroundstabanim||player[owner[i]].targetanimation==knifethrowanim)&&player[owner[i]].targetanimation==lastdrawnanim[i]&&!player[owner[i]].skeleton.free) - { - drawhowmany[i]=10; - } - else drawhowmany[i]=1; - if(player[owner[i]].targetanimation==swordgroundstabanim) - { - lastdrawnrotation1[i]=rotation1[i]; - lastdrawnrotation2[i]=rotation2[i]; - lastdrawnrotation3[i]=rotation3[i]; - lastdrawnbigrotation[i]=bigrotation[i]; - lastdrawnbigtilt[i]=bigtilt[i]; - lastdrawnbigtilt2[i]=bigtilt2[i]; - lastdrawnsmallrotation[i]=smallrotation[i]; - lastdrawnsmallrotation2[i]=smallrotation2[i]; - } + lastdrawnrotation1=rotation1; + lastdrawnrotation2=rotation2; + lastdrawnrotation3=rotation3; + lastdrawnbigrotation=bigrotation; + lastdrawnbigtilt=bigtilt; + lastdrawnbigtilt2=bigtilt2; + lastdrawnsmallrotation=smallrotation; + lastdrawnsmallrotation2=smallrotation2; } - if(draw) + } + if(draw) + { + terrainlight=terrain.getLighting(position.x,position.z); + if(drawhowmany>0) { - terrainlight=terrain.getLighting(position[i].x,position[i].z); - if(drawhowmany[i]>0) - { - glAlphaFunc(GL_GREATER, 0.01); - } - for(j=drawhowmany[i];j>0;j--) - { - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); - glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,j/drawhowmany[i]); - if(owner[i]!=-1)glTranslatef(position[i].x*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].x*(1-((float)(j))/drawhowmany[i]),position[i].y*(((float)(j))/drawhowmany[i])-.02+lastdrawnposition[i].y*(1-((float)(j))/drawhowmany[i]),position[i].z*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].z*(1-((float)(j))/drawhowmany[i])); - if(owner[i]==-1)glTranslatef(position[i].x*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].x*(1-((float)(j))/drawhowmany[i]),position[i].y*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].y*(1-((float)(j))/drawhowmany[i]),position[i].z*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].z*(1-((float)(j))/drawhowmany[i])); - //glTranslatef(position[i].x,position[i].y-.02,position[i].z); - glRotatef(bigrotation[i]*(((float)(j))/drawhowmany[i])+lastdrawnbigrotation[i]*(1-((float)(j))/drawhowmany[i]),0,1,0); - glRotatef(bigtilt2[i]*(((float)(j))/drawhowmany[i])+lastdrawnbigtilt2[i]*(1-((float)(j))/drawhowmany[i]),1,0,0); - glRotatef(bigtilt[i]*(((float)(j))/drawhowmany[i])+lastdrawnbigtilt[i]*(1-((float)(j))/drawhowmany[i]),0,0,1); - glRotatef(-rotation1[i]*(((float)(j))/drawhowmany[i])-lastdrawnrotation1[i]*(1-((float)(j))/drawhowmany[i])+90,0,1,0); - glRotatef(-rotation2[i]*(((float)(j))/drawhowmany[i])-lastdrawnrotation2[i]*(1-((float)(j))/drawhowmany[i])+90,0,0,1); - glRotatef(-rotation3[i]*(((float)(j))/drawhowmany[i])-lastdrawnrotation3[i]*(1-((float)(j))/drawhowmany[i]),0,1,0); - glRotatef(smallrotation[i]*(((float)(j))/drawhowmany[i])+lastdrawnsmallrotation[i]*(1-((float)(j))/drawhowmany[i]),1,0,0); - glRotatef(smallrotation2[i]*(((float)(j))/drawhowmany[i])+lastdrawnsmallrotation2[i]*(1-((float)(j))/drawhowmany[i]),0,1,0); - - if(owner[i]!=-1) + glAlphaFunc(GL_GREATER, 0.01); + } + for(j=drawhowmany;j>0;j--) + { + glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix + glPushMatrix(); + glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,j/drawhowmany); + if(owner!=-1)glTranslatef(position.x*(((float)(j))/drawhowmany)+lastdrawnposition.x*(1-((float)(j))/drawhowmany),position.y*(((float)(j))/drawhowmany)-.02+lastdrawnposition.y*(1-((float)(j))/drawhowmany),position.z*(((float)(j))/drawhowmany)+lastdrawnposition.z*(1-((float)(j))/drawhowmany)); + if(owner==-1)glTranslatef(position.x*(((float)(j))/drawhowmany)+lastdrawnposition.x*(1-((float)(j))/drawhowmany),position.y*(((float)(j))/drawhowmany)+lastdrawnposition.y*(1-((float)(j))/drawhowmany),position.z*(((float)(j))/drawhowmany)+lastdrawnposition.z*(1-((float)(j))/drawhowmany)); + //glTranslatef(position.x,position.y-.02,position.z); + glRotatef(bigrotation*(((float)(j))/drawhowmany)+lastdrawnbigrotation*(1-((float)(j))/drawhowmany),0,1,0); + glRotatef(bigtilt2*(((float)(j))/drawhowmany)+lastdrawnbigtilt2*(1-((float)(j))/drawhowmany),1,0,0); + glRotatef(bigtilt*(((float)(j))/drawhowmany)+lastdrawnbigtilt*(1-((float)(j))/drawhowmany),0,0,1); + glRotatef(-rotation1*(((float)(j))/drawhowmany)-lastdrawnrotation1*(1-((float)(j))/drawhowmany)+90,0,1,0); + glRotatef(-rotation2*(((float)(j))/drawhowmany)-lastdrawnrotation2*(1-((float)(j))/drawhowmany)+90,0,0,1); + glRotatef(-rotation3*(((float)(j))/drawhowmany)-lastdrawnrotation3*(1-((float)(j))/drawhowmany),0,1,0); + glRotatef(smallrotation*(((float)(j))/drawhowmany)+lastdrawnsmallrotation*(1-((float)(j))/drawhowmany),1,0,0); + glRotatef(smallrotation2*(((float)(j))/drawhowmany)+lastdrawnsmallrotation2*(1-((float)(j))/drawhowmany),0,1,0); + + if(owner!=-1) + { + if(player[owner].targetanimation==staffhitanim||player[owner].currentanimation==staffhitanim||player[owner].targetanimation==staffhitreversedanim||player[owner].currentanimation==staffhitreversedanim) { - if(player[owner[i]].targetanimation==staffhitanim||player[owner[i]].currentanimation==staffhitanim||player[owner[i]].targetanimation==staffhitreversedanim||player[owner[i]].currentanimation==staffhitreversedanim) - { - glTranslatef(0,0,-.3); - } - if(player[owner[i]].targetanimation==staffgroundsmashanim||player[owner[i]].currentanimation==staffgroundsmashanim||player[owner[i]].targetanimation==staffspinhitreversedanim||player[owner[i]].currentanimation==staffspinhitreversedanim||player[owner[i]].targetanimation==staffspinhitanim||player[owner[i]].currentanimation==staffspinhitanim) - { - glTranslatef(0,0,-.1); - } + glTranslatef(0,0,-.3); } - /*if(type[i]==knife){ - if(owner[i]==-1){ - if(!physics[i]&&findDistance(&position[i],&oldposition[i])*5>1)glScalef(1,1,findDistance(&position[i],&oldposition[i])*5); + if(player[owner].targetanimation==staffgroundsmashanim||player[owner].currentanimation==staffgroundsmashanim||player[owner].targetanimation==staffspinhitreversedanim||player[owner].currentanimation==staffspinhitreversedanim||player[owner].targetanimation==staffspinhitanim||player[owner].currentanimation==staffspinhitanim) + { + glTranslatef(0,0,-.1); } - }*/ + } - if(type[i]==knife) - { - glEnable(GL_LIGHTING); - if(!bloody[i]||!bloodtoggle)throwingknifemodel.drawdifftex(knifetextureptr); + glEnable(GL_LIGHTING); + switch(type) { + case knife: + if(!bloody||!bloodtoggle) + throwingknifemodel.drawdifftex(knifetextureptr); if(bloodtoggle) { - if(bloody[i]==1)throwingknifemodel.drawdifftex(lightbloodknifetextureptr); - if(bloody[i]==2)throwingknifemodel.drawdifftex(bloodknifetextureptr); + if(bloody==1) + throwingknifemodel.drawdifftex(lightbloodknifetextureptr); + if(bloody==2) + throwingknifemodel.drawdifftex(bloodknifetextureptr); } - } - if(type[i]==sword) - { - glEnable(GL_LIGHTING); - if(!bloody[i]||!bloodtoggle)swordmodel.drawdifftex(swordtextureptr); + break; + case sword: + if(!bloody||!bloodtoggle) + swordmodel.drawdifftex(swordtextureptr); if(bloodtoggle) { - if(bloody[i]==1)swordmodel.drawdifftex(lightbloodswordtextureptr); - if(bloody[i]==2)swordmodel.drawdifftex(bloodswordtextureptr); + if(bloody==1) + swordmodel.drawdifftex(lightbloodswordtextureptr); + if(bloody==2) + swordmodel.drawdifftex(bloodswordtextureptr); } - } - if(type[i]==staff) - { - glEnable(GL_LIGHTING); + break; + case staff: staffmodel.drawdifftex(stafftextureptr); - } - - glPopMatrix(); - } + break; + } - lastdrawnposition[i]=position[i]; - lastdrawntippoint[i]=tippoint[i]; - lastdrawnrotation1[i]=rotation1[i]; - lastdrawnrotation2[i]=rotation2[i]; - lastdrawnrotation3[i]=rotation3[i]; - lastdrawnbigrotation[i]=bigrotation[i]; - lastdrawnbigtilt[i]=bigtilt[i]; - lastdrawnbigtilt2[i]=bigtilt2[i]; - lastdrawnsmallrotation[i]=smallrotation[i]; - lastdrawnsmallrotation2[i]=smallrotation2[i]; - if(owner[i]!=-1)lastdrawnanim[i]=player[owner[i]].currentanimation; - } - if(owner[i]!=-1) - { - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); - glLoadIdentity(); - glTranslatef(position[i].x,position[i].y-.02,position[i].z); - glRotatef(bigrotation[i],0,1,0); - glRotatef(bigtilt2[i],1,0,0); - glRotatef(bigtilt[i],0,0,1); - glRotatef(-rotation1[i]+90,0,1,0); - glRotatef(-rotation2[i]+90,0,0,1); - glRotatef(-rotation3[i],0,1,0); - glRotatef(smallrotation[i],1,0,0); - glRotatef(smallrotation2[i],0,1,0); - glTranslatef(0,0,length[i]); - glGetFloatv(GL_MODELVIEW_MATRIX,M); - tippoint[i].x=M[12]; - tippoint[i].y=M[13]; - tippoint[i].z=M[14]; glPopMatrix(); } - /*XYZ shinepoint; - XYZ nothingpoint; - nothingpoint=0; - shinepoint=position[i]; - Sprite::MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1); - Sprite::speed[Sprite::numsprites-1]=4; - Sprite::alivetime[Sprite::numsprites-1]=.3; - shinepoint=tippoint[i]; - Sprite::MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1); - Sprite::speed[Sprite::numsprites-1]=4; - Sprite::alivetime[Sprite::numsprites-1]=.3;*/ + + lastdrawnposition=position; + lastdrawntippoint=tippoint; + lastdrawnrotation1=rotation1; + lastdrawnrotation2=rotation2; + lastdrawnrotation3=rotation3; + lastdrawnbigrotation=bigrotation; + lastdrawnbigtilt=bigtilt; + lastdrawnbigtilt2=bigtilt2; + lastdrawnsmallrotation=smallrotation; + lastdrawnsmallrotation2=smallrotation2; + if(owner!=-1)lastdrawnanim=player[owner].currentanimation; + } + if(owner!=-1) + { + glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix + glPushMatrix(); + glLoadIdentity(); + glTranslatef(position.x,position.y-.02,position.z); + glRotatef(bigrotation,0,1,0); + glRotatef(bigtilt2,1,0,0); + glRotatef(bigtilt,0,0,1); + glRotatef(-rotation1+90,0,1,0); + glRotatef(-rotation2+90,0,0,1); + glRotatef(-rotation3,0,1,0); + glRotatef(smallrotation,1,0,0); + glRotatef(smallrotation2,0,1,0); + glTranslatef(0,0,length); + glGetFloatv(GL_MODELVIEW_MATRIX,M); + tippoint.x=M[12]; + tippoint.y=M[13]; + tippoint.z=M[14]; + glPopMatrix(); } } +} + +int Weapons::Draw() +{ + glAlphaFunc(GL_GREATER, 0.9); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glEnable(GL_CULL_FACE); + glCullFace(GL_FRONT); + glDepthMask(1); + + for(std::vector::iterator weapon = begin(); weapon != end(); ++weapon) { + weapon->Draw(); + } return 0; } Weapons::Weapons() { - numweapons = 0; - - // Model throwingknifemodel; - knifetextureptr = 0; - lightbloodknifetextureptr = 0; - bloodknifetextureptr = 0; - - // Model swordmodel; - swordtextureptr = 0; - lightbloodswordtextureptr = 0; - bloodswordtextureptr = 0; - - // Model staffmodel; - stafftextureptr = 0; } Weapons::~Weapons() { - if (stafftextureptr) glDeleteTextures( 1, &stafftextureptr ); - if (knifetextureptr) glDeleteTextures( 1, &knifetextureptr ); - if (lightbloodknifetextureptr) glDeleteTextures( 1, &lightbloodknifetextureptr ); - if (bloodknifetextureptr) glDeleteTextures( 1, &bloodknifetextureptr ); - if (swordtextureptr) glDeleteTextures( 1, &swordtextureptr ); - if (lightbloodswordtextureptr) glDeleteTextures( 1, &lightbloodswordtextureptr ); - if (bloodswordtextureptr) glDeleteTextures( 1, &bloodswordtextureptr ); + if (Weapon::stafftextureptr) glDeleteTextures( 1, &Weapon::stafftextureptr ); + if (Weapon::knifetextureptr) glDeleteTextures( 1, &Weapon::knifetextureptr ); + if (Weapon::lightbloodknifetextureptr) glDeleteTextures( 1, &Weapon::lightbloodknifetextureptr ); + if (Weapon::bloodknifetextureptr) glDeleteTextures( 1, &Weapon::bloodknifetextureptr ); + if (Weapon::swordtextureptr) glDeleteTextures( 1, &Weapon::swordtextureptr ); + if (Weapon::lightbloodswordtextureptr) glDeleteTextures( 1, &Weapon::lightbloodswordtextureptr ); + if (Weapon::bloodswordtextureptr) glDeleteTextures( 1, &Weapon::bloodswordtextureptr ); } diff --git a/Source/Weapons.h b/Source/Weapons.h index c6f4560..35271f7 100644 --- a/Source/Weapons.h +++ b/Source/Weapons.h @@ -40,77 +40,88 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define sword 2 #define staff 3 -class Weapons +class Weapon { + public: + Weapon(int type, int owner); + + static Model throwingknifemodel; + static GLuint knifetextureptr; + static GLuint lightbloodknifetextureptr; + static GLuint bloodknifetextureptr; + + static Model swordmodel; + static GLuint swordtextureptr; + static GLuint lightbloodswordtextureptr; + static GLuint bloodswordtextureptr; + + static Model staffmodel; + static GLuint stafftextureptr; + + void Draw(); + void DoStuff(); + + int getType() { return type; } + void setType(int); + + int owner; + XYZ position; + XYZ tippoint; + XYZ velocity; + XYZ tipvelocity; + bool missed; + bool hitsomething; + float freetime; + bool firstfree; + bool physics; + + float damage; + int bloody; + float blooddrip; + float blooddripdelay; + + float rotation1; + float rotation2; + float rotation3; + float bigrotation; + float bigtilt; + float bigtilt2; + float smallrotation; + float smallrotation2; + private: + int type; + + XYZ oldtippoint; + float lastmult; + XYZ oldposition; + int oldowner; + bool onfire; + float flamedelay; + float mass; + float tipmass; + float length; + float drawhowmany; + + XYZ lastdrawnposition; + XYZ lastdrawntippoint; + float lastdrawnrotation1; + float lastdrawnrotation2; + float lastdrawnrotation3; + float lastdrawnbigrotation; + float lastdrawnbigtilt; + float lastdrawnbigtilt2; + float lastdrawnsmallrotation; + float lastdrawnsmallrotation2; + int lastdrawnanim; +}; + +class Weapons : public std::vector { public: - - float rotation1[max_weaponinstances]; - float rotation2[max_weaponinstances]; - float rotation3[max_weaponinstances]; - float bigrotation[max_weaponinstances]; - float bigtilt[max_weaponinstances]; - float bigtilt2[max_weaponinstances]; - float smallrotation[max_weaponinstances]; - float smallrotation2[max_weaponinstances]; - - int numweapons; - float damage[max_weaponinstances]; - XYZ tippoint[max_weaponinstances]; - XYZ oldtippoint[max_weaponinstances]; - XYZ position[max_weaponinstances]; - float lastmult[max_weaponinstances]; - XYZ oldposition[max_weaponinstances]; - XYZ velocity[max_weaponinstances]; - XYZ tipvelocity[max_weaponinstances]; - int type[max_weaponinstances]; - int oldowner[max_weaponinstances]; - int owner[max_weaponinstances]; - int bloody[max_weaponinstances]; - float blooddrip[max_weaponinstances]; - float blooddripdelay[max_weaponinstances]; - bool onfire[max_weaponinstances]; - float flamedelay[max_weaponinstances]; - bool missed[max_weaponinstances]; - float mass[max_weaponinstances]; - float tipmass[max_weaponinstances]; - float length[max_weaponinstances]; - float freetime[max_weaponinstances]; - bool firstfree[max_weaponinstances]; - bool physics[max_weaponinstances]; - float drawhowmany[max_weaponinstances]; - bool hitsomething[max_weaponinstances]; - - XYZ lastdrawnposition[max_weaponinstances]; - XYZ lastdrawntippoint[max_weaponinstances]; - float lastdrawnrotation1[max_weaponinstances]; - float lastdrawnrotation2[max_weaponinstances]; - float lastdrawnrotation3[max_weaponinstances]; - float lastdrawnbigrotation[max_weaponinstances]; - float lastdrawnbigtilt[max_weaponinstances]; - float lastdrawnbigtilt2[max_weaponinstances]; - float lastdrawnsmallrotation[max_weaponinstances]; - float lastdrawnsmallrotation2[max_weaponinstances]; - int lastdrawnanim[max_weaponinstances]; - - Model throwingknifemodel; - GLuint knifetextureptr; - GLuint lightbloodknifetextureptr; - GLuint bloodknifetextureptr; - - Model swordmodel; - GLuint swordtextureptr; - GLuint lightbloodswordtextureptr; - GLuint bloodswordtextureptr; - - Model staffmodel; - GLuint stafftextureptr; - - int Draw(); - void DoStuff(); - Weapons(); - ~Weapons(); + + int Draw(); + void DoStuff(); }; extern Weapons weapons;