![]() |
СтратегиЙа
Задумался на досуге , и решил спросить у вас. =)
Есть ли какие нибуть примеры реализации выбора кубов как в стратежке. Ну к примеру есть тип кубов, клепаем сто шутк. кликая на одного из них его имя заноситься в переменную или хз , и потом мы двигаем в указанную точку тот абйект который выбран у нас в текущий момент. Мне никакие идеи в голову не пришли. Как это реализуеться хз... Может кто обьяснит или подкинет примерчик :-D |
Ответ: СтратегиЙа
CameraPick()
PickedX() PickedY() PickedZ() |
Re: СтратегиЙа
И еще один вопрос... =)
А реально ли направить бота из одного типа на бота из этогоже типа? Ведь все они получат одинаковый указатель... :rolleyes: |
Ответ: СтратегиЙа
реально.
for a.bot = each bot for b.bot = each bot if a\toent=b\ent then a\attack=1:a\enemyID = b\id:a\EnemyHandle = handle(b) next next |
Re: СтратегиЙа
А теперь моно немного подробнее ибо я в типах тупой истукан :-D
P.S. Воть код маего анриала =) Без функции загрузки .CHM Извиняюсь за кривость кода ^^ В нем у нас воюют два бота между собой и игроком , а надо чтобы была возможность задавать кол-во ботофф. отак от Graphics3D 1024,768 SeedRnd MilliSecs() Const TypeCube=9 Global cur_ammo=20 Global all_ammo=100 Global health=100 Global health1=100 Global health2=100 Global G#=0.001 aptechka=CreateCube() EntityColor aptechka,255,0,0 PositionEntity aptechka,100,7.7,189 map=LoadCSM("map1.csm","textures\") ScaleEntity map,.05,.05,.05 PositionEntity map,100,0,100 HidePointer() Const TERRT=15 Global pricel=LoadImage("pricel.bmp") MidHandle pricel MaskImage pricel,255,255,255 Global house=CreateCube() PositionEntity house,100,1,100 EntityType house,TypeCube house_tex=LoadTexture("Text1.jpg") EntityTexture house,house_tex ScaleEntity house,3,3,3 EntityRadius house,4 theme=LoadSound("theme.mp3") LoopSound theme PlaySound theme Global shot_sprite=LoadSprite("SPARK.PNG") HideEntity shot_sprite Global bot1_s=0 , player_s=0, bot2_s=0 Const TypeBot1=1,TypeBot2=2,TypePlayer=3 Global windwave# Global grasscount Const SHOTT=3;for shot Type shot Field entity End Type Type health Field entity End Type Type shot1 Field entity End Type Type shot2 Field entity End Type Global player=CreateSphere() PositionEntity player,0, 1, -5 cam=CreateCamera(player) light=CreateLight() EntityType player,TypePlayer PositionEntity cam,0,1,0 GUN = LoadMD2("w_rotation.md2") gun_tex = LoadTexture("w_rotation.pcx") EntityTexture GUN,gun_tex TurnEntity GUN,0,0,0 ScaleEntity GUN,0.08,0.1,0.08 EntityParent GUN,cam PositionEntity GUN,1.9,-2.0,0.7 Global bot1=CreateSphere() PositionEntity bot1,0,1,-30 ;ScaleEntity bot1,.03,.03,.03 EntityType bot1,TypeBot1 Global bot2=CreateSphere() ;PositionEntity bot2,0,1,-50 EntityType bot2,TypeBot2 Collisions TypeBot2,TypeBot1,1,2 Collisions TypeBot2,TypePlayer,1,2 Collisions TypeBot1,TypePlayer,1,2 Collisions TypeBot1,TERRT,2,3 Collisions TypeBot2,TERRT,2,3 Collisions TypePlayer,TERRT,2,3 Collisions TypeBot2,TypeCube,1,2 Collisions TypeBot1,TypeCube,1,2 Collisions TypePlayer,TypeCube,1,2 Global groundtex=LoadTexture("ground.jpg") Ground=CreatePlane() PositionEntity Ground,0,-1,0 EntityTexture Ground, groundtex ScaleTexture groundtex,15,15 EntityType Ground,TERRT ramp=CreateMesh() surf=CreateSurface( ramp ) segs=1 width#=2 For k=0 To segs x#=Float(k)*width/segs-width/2 u#=Float(k)/segs AddVertex surf,x,1,0,u,0 AddVertex surf,x,-1,0,u,1 Next For k=0 To segs-1 AddTriangle surf,k*2,k*2+2,k*2+3 AddTriangle surf,k*2,k*2+3,k*2+1 Next EntityFX ramp, 16 Or 1 grasstex=LoadBrush("grass.png",4) PaintMesh ramp, grasstex ; create_health(Rand(1,100),1,Rand(1,100)) Dim grass(1000) Dim grass_dir#(1000) grasscount=0 For j#=-10 To 10 Step 1 For i#=-10 To 10 Step 1 grass(grasscount)=CopyEntity(ramp) x#=(i+Rnd(1,50)) z#=(j+Rnd(5,50)) y#=0; PositionEntity grass(grasscount),x,y,z grass_dir(grasscount)=Rand(-45,45) grasscount=grasscount+1 Next Next HideEntity ramp While KeyDown(1) <> True u=Rand(1,10) zlo=Rand(1,50) If zlo>48.98 Then create_shot(EntityX(bot1),EntityY(bot1),EntityZ(bo t1),EntityPitch(bot2),EntityYaw(bot1),0) EndIf jump1=Rand(1,1000) If jump1>998.8 Then TranslateEntity bot1,0,1,0 EndIf zlo1=Rand(1,50) If zlo1>48.98 Then create_shot(EntityX(bot2),EntityY(bot2),EntityZ(bo t2),EntityPitch(bot2),EntityYaw(bot2),0) EndIf update_bot1() update_bot2() If EntityDistance(bot1,bot2)<5 Then If u>5 Then bot2_s=bot_2+1 Else bot1_s=bot_1s+1 EndIf EndIf If EntityDistance(bot1,player)<5 Then If u>5 Then player_s=player_s + 1 Else bot1_s=bot1_s+1 EndIf EndIf If EntityDistance(bot2,player)<5 Then If u>5 Then player_s=player_s + 1 Else bot2_s=bot_2_s+1 EndIf EndIf V#=0.3 If KeyHit(57) Then TranslateEntity player,0,3,0 TurnEntity aptechka,0,1,0 If KeyDown(17) MoveEntity player, 0, 0, V# If KeyDown(31) MoveEntity player, 0, 0, -V# If KeyDown(30) MoveEntity player, -V#, 0,0 If KeyDown(32) MoveEntity player, V#, 0,0 If MouseHit(1) And cur_ammo>0 Then create_shot(EntityX(player),EntityY(player),Entity Z(player),EntityPitch(cam),EntityYaw(player),0) cur_ammo=cur_ammo-1 EndIf If EntityDistance(player,aptechka)<4 And health<100 Then health=health+1 EndIf TranslateEntity player,0,-0.1,0 If MouseDown(2) And cur_ammo>0 Then create_shot(EntityX(player),EntityY(player),Entity Z(player),EntityPitch(cam),EntityYaw(player),0) cur_ammo=cur_ammo-1 EndIf If KeyHit(19) And all_ammo > 19 And cur_ammo=0 Then cur_ammo=cur_ammo+20 all_ammo=all_ammo-20 EndIf TurnEntity cam,MouseYSpeed(),0,0 TurnEntity player,0,-MouseXSpeed(),0 u#=70 MoveMouse GraphicsWidth()*0.5,GraphicsHeight()*0.5 If Abs(EntityPitch#(cam))>u# RotateEntity cam,u#*Sgn(EntityPitch#(cam)),0,0 update_shot() If health<0 Then PositionEntity player,Rand(1,150),0,Rand(1,150) Print " =========== You Respawn in 2 seconds ============" Delay 2000 health=100 all_ammo=all_ammo+20 EndIf If health2<0 Then ;PositionEntity bot2,Rand(1,100),0,Rand(1,100) PositionEntity bot2,Rand(1,100),0,Rand(1,100) health2=100 EndIf If health1<0 Then PositionEntity bot1,Rand(1,100),0,Rand(1,100) health1=100 EndIf wind(1) UpdateWorld RenderWorld DrawImage pricel,MouseX(),MouseY() Text 100,10,"Bot1: " + bot1_s Text 100,40,"Bot2: " + bot2_s Text 100,60,"Player: " + player_s Text 200,10,"Health: " + health Text 200,40,"Bot 1 Health: " + health1 Text 200,60,"Bot 2 Health " + health2 Text 300,10,"Ammo: " + cur_ammo + "/" + all_ammo Text 400,10,"x#: " + EntityX(player) Text 400,40,"y#: " + EntityY(player) Text 400,60,"z#: " + EntityZ(player) Flip Wend End Function update_bot1() ibm=EntityDistance(bot1,player) ibn=EntityDistance(bot1,bot2) If ibm<ibn Then PointEntity bot1,player MoveEntity bot1,0,0,.3 Else PointEntity bot1,bot2 MoveEntity bot1,0,0,.3 EndIf End Function Function update_bot2() ibk=EntityDistance(bot2,player) ibf=EntityDistance(bot2,bot1) If ibk<ibf Then PointEntity bot2,player MoveEntity bot2,0,0,.3 Else PointEntity bot2,bot1 MoveEntity bot2,0,0,.3 EndIf End Function ;-------------------- Function wind(speed#) For i=0 To grasscount-1 x#=EntityX(grass(i)) z#=EntityZ(grass(i)) RotateEntity grass(i),0,grass_dir(i),Cos(windwave+z)*0.5 Next windwave=(windwave+speed#) End Function Function create_Shot(x#,y#,z#,pitch#,yaw#,roll#) s.shot=New shot s\entity=CopyEntity(shot_sprite) PositionEntity s\entity,x#,y#,z#,1 RotateEntity s\entity,pitch#,yaw#,roll#,1 ;EntityType s\entity,SHOTT Return True End Function Function create_health(x#,y#,z#) s.health=New health s\entity=CopyEntity(aptechka) PositionEntity s\entity,x#,y#,z# ;RotateEntity s\entity,pitch#,yaw#,roll#,1 ;EntityType s\entity,SHOTT Return True End Function Function update_shot() vs#=1 For a.shot=Each shot MoveEntity a\entity,0,0,vs# If EntityDistance(a\entity,bot1)<1 health1=health1-Rand(1,5) ;PositionEntity bot1,Rand(1,100),0,Rand(1,100) EndIf If EntityDistance(a\entity,bot2)<1 ;PositionEntity bot2,Rand(1,100),0,Rand(1,100) health2=health2-Rand(1,4) EndIf If EntityDistance(a\entity,player)<1 health=health-Rand(1,4) EndIf Next End Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;; |
Ответ: СтратегиЙа
Я тебе один умный вещь скажу: есть такая штука, как массив типов, а еще есть теги кода, а еще голова должна кумекать, а еще... , но это тебе еще рано.
|
Re: СтратегиЙа
Ну йа по аватарке вижу ты мудрый =)
Мне как раз последнего и нехватает :4to: А хватало бы я бы к вам не обращался с помощью. А все ети масивы типов , теги... пустые слова пока не напишешь: Теги - такие штуки , используються так-то и так-то там-то и там-то Вот ьтода йа пойму :) |
Ответ: Re: СтратегиЙа
Цитата:
И заноси туда хендл врага И все равно из какого он типа. Два перебора внутри организутся элементарно с помощью функций например в одной общий апдейт типа а в вспомогательных: поиск врага (в том же типе) и возврат хендла по выходу в другой - поиск своей группы союзников, команда им (групповой ИИ) и так далее. а ваще, ИМХО у тебя слишком слабо прокачан скилл логики, чтобы делать стратегию тренируйся на тетрисах Стратегический ИИ - сложнейшая штука. намного сложней десятка шуттеров |
Ответ: СтратегиЙа
Цитата:
я тут придумал одну интересную идейку. надо будет реализовать, как время свободное появится. |
Ответ: СтратегиЙа
о! у меня кстати тоже тут кое-чего есть но, я пока вам не покажу!
|
Ответ: СтратегиЙа
impersonalis ))
разбивать на группы. группа для нападения (одна или несколько), группа для защиты (одна или несколько), группа для помощи товарищу (одна или несколько). самое интересное, что ето неплохо ложится в архитктуру вартича, но времени пока посмотреть чо из етого выйдет нет ((( |
Ответ: СтратегиЙа
кстати - бует для свохи вартичAPI? ;)
|
Ответ: СтратегиЙа
Цитата:
|
Ответ: СтратегиЙа
набор функций - готовых программных реализаций типовых алгоритмов и классов данных, применяемых в стратегии (ВарТич)
|
Ответ: СтратегиЙа
Цитата:
|
Часовой пояс GMT +4, время: 20:01. |
vBulletin® Version 3.6.5.
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Перевод: zCarot