Jump to content

[LE] What is wrong with my script ? :) [3] - Arena !


Recommended Posts

Hey i have problem xD

 

cause now im writing my Script for Arena

 

Script should spawn 120 waves and store all possible Units in Game but i have problem

//Edit2:{

Store units given by FormLists :X lel

}

 

 

 

i have FormList named "QXSpawners" and Array "XSpawners"

and now... how can i put objects in Render Window into FormList ?

 

//Edit:{

Q: How i can put Object from RenderWindow into FormList

OR

Q: How i can put many Objects from RenderWindow to Script

}

 

 

 

everything in Script is working fine at this moment but if any1 want to look at my Script

and if any1 have something to say about my Script any help is wellcome :smile:

 

 

 

Scriptname QLG_Script_Tests extends ObjectReference  


;Scriptname QLG_Script_ArenaSpawnWave ObjectReference
{ This is *Fuma Empire* Arena Script V0.052

}
;===- Base Info. -===;
 ;Created: 2019-03-19
 ;Update: 2019-03-20
 ;Author: TobiPL
 ;Unit: M.PC<3>
;===- Var. setup -===================================================


;===- Var. Units -==============================================

	FormList property QUnits_Common auto
	{ List of Units used for normal waves 
		This script use max of 120 Units }
	
	FormList property QUnits_Special auto
	{ List of Special Units for Boss waves 
		This script use max of 60 Units }
	
	FormList property QUnits_Bosses auto
	{ Lits of possible Bosses to Spawn
		This script use max of 30 Units }
	
	ActorBase[] CommonUnits			; Common Units Array
	ActorBase[] SpecialUnits		; Special Units Array
	ActorBase[] BossUnits			; Boss Units array
	
	int CommonUnitsAMT				; Amount of Common Units
	int SpecialUnitsAMT				; Amount of Special Units
	int BossUnitsAMT				; Amount of Boss Units



;===- Var. XMarkers to Spawn ===================================

	FormList property QXSpawnersList auto
	{ List of XMarkers where NPC may be spawn 
		Support up to 48 Markers }
	
	ObjectReference[] XSpawners		; List of XMarkers where NPC may be spawn
	
	int MarkersAMT					; Amount of XMarkers 



;===- Var. Wave Rewards ========================================

	int property QWaveReward auto
	{ Reward in gold for each wave
		Set to :0: for random
		Set to :-1: for No drop 
	Wave end when all Enemy Units are dead }
	
	int property QRoundReward auto
	{ Reward in gold for each round
		Set to :0: for random
		Set to :-1: for No drop
	Round end when all waves were defeat }



;=== Var. Wave Special Drop ====================================

	FormList property QSpecialDrop auto
	{ Special drop that NPCs may drop on arena
		This script use max of 120 items }
	
	FormList property QSpecialXSpawners auto
	{ XMarkers where special may appear 
		This script use max of 120 items }
	
	ObjectReference[] SpecialDrop	; Special drop for player
	ObjectReference[] SpecialSpawn	; Special XMarkers to spawn drop




	
;===- Script -Main- -================================================
Event OnActivate( ObjectReference QQQAA )
	
	
	QL_LoadActors()
	QL_LoadMarkers()
	
	
	
; *== DEBUG ==* ;

	
	QL_SpawnSingleWave()
	
	
	
		
EndEvent






Function QL_LoadActors()
	
	Int Temp
	
	CommonUnits = new ActorBase[120]
	SpecialUnits = new ActorBase[60]
	BossUnits = new ActorBase[30]
	

;=== Load Common Units ===	
	Temp = QUnits_Common.GetSize()
		If ( Temp >= 120 )
			Temp = 120
		EndIf
	CommonUnitsAMT = Temp
	While ( Temp > 0 )
		
		Temp -= 1
		
		CommonUnits[Temp] = QUnits_Common.GetAt(Temp) as ActorBase
	
	EndWhile




;=== Load Special Units ===
	Temp = QUnits_Special.GetSize()
		If ( Temp > 60 )
			Temp = 60
		EndIF
	SpecialUnitsAMT = Temp
	While ( Temp >= 0 )
		
		Temp -= 1
		
		SpecialUnits[Temp] = QUnits_Special.GetAt(Temp) as ActorBase
	
	EndWhile




;=== Load Boss Units ===
	Temp = QUnits_Bosses.GetSize()
		if ( Temp >= 30 )
			Temp = 30
		EndIf
	BossUnitsAMT = Temp
	While ( Temp > 0 )
	
		Temp -= 1
		
		BossUnits[Temp] = QUnits_Bosses.GetAt(Temp) as ActorBase
		
	EndWhile



EndFunction



Function QL_LoadMarkers()
	
	int Temp
	
	XSpawners = new ObjectReference[64]
	
	Temp = QXSpawnersList.GetSize()
		If ( Temp > 48 )
			Temp = 48
		EndIF
	MarkersAMT = Temp
	While ( Temp >= 0 )
		
		Temp -= 1
		
		XSpawners[Temp] = QXSpawnersList.GetAt(Temp) as ObjectReference
		
	EndWhile


EndFunction





Function QL_SpawnSingleWave()


EndFunction









 

 

 

is anything wrong in my Script ? :smile:

 

 

Y i know its pretty long and i stop at QL_SpawnSingleWave() Function :c

 

 

 

Help xD !

Edited by TobiaszPL
Link to comment
Share on other sites

really fragmented your script.. You asked: "Is anything wrong in my script?"

 

I tried to make your code a bit easier to handle. But you'll have your own coding style.

 

QLG_Script_Tests

 

Scriptname QLG_Script_Tests extends ObjectReference  

; https://forums.nexusmods.com/index.php?/topic/7493506-what-is-wrong-with-my-script-3-arena/

;Scriptname QLG_Script_ArenaSpawnWave ObjectReference
{ This is *Fuma Empire* Arena Script V0.052 }

;===- Base Info. -===;
 ;Created: 2019-03-19
 ;Update: 2019-03-20
 ;Author: TobiPL
 ;Unit: M.PC<3>

;===- Units -==============================================

  FormList PROPERTY QUnits_Common auto
    { List of common units for normal waves, max of 120 units }
    
  FormList PROPERTY QUnits_Special auto
    { List of special units for boss waves,    max of 60 units }
    
  FormList PROPERTY QUnits_Bosses auto
    { Lits of boss units to spawn, max of 30 units }
    
  ActorBase[] aCU                ; array of Common  Units
  ActorBase[] aSU                ; array of Special Units
  ActorBase[] aBU                ; array of Boss    Units
    
  Int iMaxCommonUnits  = -1      ; amount of Common  Units
  Int iMaxSpecialUnits = -1      ; amount of Special Units
  Int iMaxBossUnits    = -1      ; amount of Boss    Units


;===- XMarkers ============================================

  FormList PROPERTY QXSpawnersList auto
    { List of XMarkers where NPC may be spawn, max of 48 markers allowed }
    
  ObjectReference[] aPoints      ; array of XMarkers where NPC may be spawn
  Int iMaxPoints = -1            ; amount of XMarkers


; -- EVENTs -- 3

EVENT OnCellLoad()
    RegisterForSingleUpdateGameTime(0.0)    ; open a second thread to run initialization parallel
    QL_InitCommonActors()
ENDEVENT


EVENT OnUpdateGameTime()
    QL_InitMarkers()
    iMaxSpecialUnits = QL_InitActors(QUnits_Special, 60, aSU)
    iMaxBossUnits    = QL_InitActors(QUnits_Bosses,  30, aBU)
ENDEVENT


EVENT OnActivate(ObjectReference akActionRef)
WHILE (iMaxPoints < 0) || (iMaxCommonUnits < 0) || (iMaxSpecialUnits < 0) || (iMaxBossUnits < 0)
    Utility.Wait(0.25)
ENDWHILE

    QL_SpawnSingleWave()        ; == DEBUGGING ==
ENDEVENT


; -- FUNCTIONs -- 4

;------------------------
FUNCTION QL_InitMarkers()
;------------------------
int n = QXSpawnersList.GetSize()
    IF (n > 48)
        n = 48
    ENDIF

    aPoints = new ObjectReference[48]        ; init array length
int i = 0
    WHILE (i < n)
        aPoints[i] = QXSpawnersList.GetAt(i) as ObjectReference
        i = i + 1
    ENDWHILE

    iMaxPoints = n
ENDFUNCTION


;-----------------------------
FUNCTION QL_InitCommonActors()
;-----------------------------
int n = QUnits_Common.GetSize()
    IF (n > 120)
        n = 120
    ENDIF

    aCU = new ActorBase[128]
int i = n
    WHILE (i < n)
        aCU[i] = QUnits_Common.GetAt(i) as ActorBase
        i = i + 1
    ENDWHILE

    iMaxCommonUnits = n
ENDFUNCTION


;----------------------------------------------------------------
Int FUNCTION QL_InitActors(FormList fml, Int iMax, ActorBase[] a)  ; for special units and bosses only
;----------------------------------------------------------------
int n = fml.GetSize()
    IF (n > iMax)
        n = iMax
    ENDIF

    a = new ActorBase[128]                  ; set array length to maximum
int i = 0
    WHILE (i < n)
        a[i] = fml.GetAt(i) as ActorBase    ; fill array a[0] .. a[n-1]
        i = i + 1
    ENDWHILE
    RETURN n    ; give integer back
ENDFUNCTION


;----------------------------
FUNCTION QL_SpawnSingleWave()
;----------------------------

ENDFUNCTION


;===- Rewards ========================================

    int property QWaveReward auto
    { Reward in gold for each wave
        Set to :0: for random
        Set to :-1: for No drop
    Wave end when all Enemy Units are dead }
    
    int property QRoundReward auto
    { Reward in gold for each round
        Set to :0: for random
        Set to :-1: for No drop
    Round end when all waves were defeat }

;=== Special Drop ====================================

  FormList property QSpecialDrop auto
    { Special drop that NPCs may drop on arena
        This script use max of 120 items }
    
  FormList property QSpecialXSpawners auto
    { XMarkers where special may appear
        This script use max of 120 items }
    
    ObjectReference[] SpecialDrop     ; Special drop for player
    ObjectReference[] SpecialSpawn    ; Special XMarkers to spawn drop

 

 

Link to comment
Share on other sites

Your coding style is also hard for me :tongue:

 

 

im gonna try with Sin and Cos

 

SpawnX = Sin( ( 15 * SpawnID ) * 0.01744 ) * SpawnDistance

SpawnY = Cos( ( 15 * SpawnID ) * 0.01744 ) * SpawnDistance

 

But im not sure CK is using Radians or normal deegres xD

y i know my english is perfect :D

 

 

also about my "Tags"

 

Q -> Mean Variable / Class / Structure etc.

QL -> Mean Function

QLG -> Mean Object / Class Object

 

QLG_NPC_Wolf

QLG_Weapon_EpicDagger

QLG_Quest_Main_ToBraverock_01

QLG_Script_DeleteDead

 

you don't have to use my Tags :tongue:

 

//Edit:

{

Classes Structures Functions or any other stuff can be find in CB VS or Eclipse with browser

 

you can just write Q and you see everything you code and can use

if you add L to this Q you can see only functions and if you add G you see only objects

if code is insane long then tags like those can help u a lot

 

also for example N++ have Functions and Objects etc. Tree and those Tags help much :smile:

 

 

and ofc. other ppl in team can use other tags for example you

Q

QR

QRD :smile:

 

Q as first letter is must have cause its very rare in normal words even more rare in Var. / names

 

i remember only 3 names with Q first

 

so if we would be in team and i want to see your functions i can just press CTRL + Space

write QR and i already see everything you made ^_^

}

 

 

tomorow im gonna try with Sin and Cos to spawn monsters around player

also this way is much better than XMarkers

 

and i can make any "shape" in any time i want

 

even better without XMarkers im not using any memory

but im not sure how Math is working with CK never use it b4 xD

 

 

 

 

btw. many ppl say that my Coding style is... amazing xD lol

why u dont like style i write my code ? :tongue:

 

 

//Edit2:

 

Remember my English is pretty potato :tongue:

 

but i want to know

 

1) why u move Global Var. to bottom of file?

2) you made my Vars very short

does it matter in CK ? cause short Var Name is OK - less b used to save file...

maybe some less memory in use but anyway CK Script is compiled anyway so names probably

gonna change to HEX names

 

but like i said "probably" so im not sure :x

 

Short names do anything good in code ?

 

cause for example if i found in code something like ACU ASU ABU...

i will have no fk*n* idea what it is and i will have to find it first to know what ACU ASU and ABU is

 

thats why Bethesda use long names :tongue:

RegisterForSingleUpdateGameTime() probably one of longest Functions

 

but once you read this Function you already know what this do or what it is

 

and "Fast Writing" - ok but in 2005 or less

now we have autofill :tongue:

 

 

 

3) this part of code...

 

int n = QUnits_Common.GetSize()
IF (n > 120)
n = 120
ENDIF

aCU
= new ActorBase[128]

 

The meow what ? :tongue:

N - max nr. of possible items to load

and you made Array 128 items long ?

 

i know u probably write fast cause who care to answer me xD lel

im asking cause i want fast answer and finish my work faster but i probably can do it all alone

 

if you can and if you change my code plz read it once :c

 

 

 

 

egh why its not C++ my fav. xD

i could finish my work long time ago if it was C++ :c

 

 

//Edit3 or 4:

as always i made book on Forum :smile:

 

ahh xD i write so much XDDD

but i just love to write :D !...

 

//Edit4 or 5:

all my text is probably enough for 100/200 books xD

all text writen by last 10 years :tongue:

 

//Edit5 or 6:

 

YEY no need any ugly array of many X Markers xD

Function QL_SpawnSingleWave()

	int TempX = XSpawner.GetPositionY() as int
	int TempY = XSpawner.GetPositionX() as int
	int TempZ = XSpawner.GetPositionZ() as int
	
	int PosX
	int POsY
	
	
	int I = 10
	While ( I > 0 )
	
		PosX = ( ( sin( 15 * Utility.RandomInt( 0, 24 ) ) * Q02_Markers_Distance ) + TempX ) as int
		PosY = ( ( cos( 15 * Utility.RandomInt( 0, 24 ) ) * Q02_Markers_Distance ) + TempY ) as int
	
		XSpawner.SetPosition( PosX, PosY, TempZ )
		
		XSpawner.PlaceAtMe( QUnits_Bosses.GetAt( 0 ) as ActorBase )
		
	EndWhile
	
EndFunction

for now working pretty ugly but still working xD lel

Edited by TobiaszPL
Link to comment
Share on other sites

You asked me: "but i want to know"

 

1) why u move Global Var. to bottom of file?

overview only, nothing special here, scripts of big lines should be divided in smaller parts

 

2) you made my Vars very short

this Vars are script internal only, no need to make them overbloated

 

your sample code is missing of counter decreasing

    int I = 10
    While ( I > 0 )
       I = I - 1
      ; ...
    EndWhile

I have changed to

  ObjectReference PROPERTY XSpawner auto

  FormList PROPERTY QUnits_Bosses auto
    { Lits of boss units to spawn, max of 30 units }

  Float PROPERTY Q02_Markers_Distance auto


; -- EVENT --

EVENT OnActivate(ObjectReference akActionRef)
    QL_SpawnSingleWave(QUnits_Bosses, Q02_Markers_Distance)
ENDEVENT


; -- FUNCTION --

;-----------------------------------------------------
FUNCTION QL_SpawnSingleWave(FormList fml, Float fDist)
;-----------------------------------------------------
    float fx = XSpawner.GetPositionX()
    float fy = XSpawner.GetPositionY()
    float fz = XSpawner.GetPositionZ()
    float aZ = XSpawner.GetAngleZ()

    int[] a = new Int[20]                        ; *20* create temp array of integer
int i = a.Length
    WHILE (i > 0)
        i = i - 1
        a[i] = Utility.RandomInt(0, 24) * 15    ; a[19] .. a[0]  prefilled random values
    ENDWHILE

    i = 0
    WHILE (i < 10)                                ; *10*
        float px = Math.SIN( a[i]   ) * fDist
        float py = Math.COS( a[i+10]) * fDist    ; *10*

        px = px + fx
        py = py + fy

        XSpawner.SetPosition(px, py, fz)
        XSpawner.SetAngle(0.0, 0.0, aZ)

        form fm = fml.GetAt(i)
        XSpawner.PlaceAtMe(fm)

        i = i + 1
    ENDWHILE
ENDFUNCTION
Edited by ReDragon2013
Link to comment
Share on other sites

It was only lets call it "Beta Version"

 

im not gonna use any Arrays any more for this script

im gonna delete all arrays and replace them with FormList only and use Math to find place where NPC can be spawned

 

Here is how its working at this moment:

https://www.youtube.com/watch?v=t-e6cplclgs&t=130s

BIG WOW that Skyrim can hold so many Enemies in same time

 

Skip video to 2:10 or 2:20 and silent your Sounds cause i let YT play anything he want :D

 

 

 

still don't know why delay for spawn is so long cause on Video i press Dwemer Lever and after 15 sec Mobs were spawn

they should spawn in same moment i press Lever but its working pretty fine for now

 

also i tested MOD Function you gave me in other Topic and Script for deleting NPCs is working good :smile:

 

so im happy cause one script is finally done now i have to make this script working and probably im gonna make few more scripts

but its too hard for me to explain what i want to do now

 

but my knowledge about FormList has increase so i have new possible things to do :D

 

 

 

Once i finish first final version ill be back to show what i made and you can tell what is wrong and what is good :smile:

 

 

 

 

but here is my one question

why Math,SIN ?

 

Is Math.Sin any better have something more "detailed" - sry for my english xD

 

for me just sin() was working fine... is there any difference between Math.Sin and Sin ?

 

int I = 10
While ( I > 0 )
I = I - 1
; ...
EndWhile

 

Thats why game were spawn infinite amount of Crabs xD

my Bad i write it fast :c

Edited by TobiaszPL
Link to comment
Share on other sites

I watched your arena video and notice that you have underscore in your cell's name.

If you intend to port your mod to SSE sometime in the future you need to remove the underscore.

Saves made in SSE with underscore in the cell's name can't be seen by SSE engine and can corrupt the save.

qlg_greatbraverockarena

to

qlggreatbraverockarena

Link to comment
Share on other sites

Not gonna move to SSE

 

SSE problems are not my problems

i never gonna move to SSE cause 90% of my mods are LE only and they are abandoned

 

many of mods that i have are not even possible to download any more

 

LL, GTX, RU or many others

y i luf LL mods and i have downloaded every single mod from LL :smile: for now im using only few ... only 30/50 mods from LL cause others crash my game xD

 

but DD or SD or SL Defeat are must have :D

also RP // DS // THW // CL // SS - i write in short names cause i dont want to be banned for "bad words" xD lel

 

 

 

ty 4 help Maxarturo but im not gonna move my mod to SSE

i see no reason to move my mod to SSE

 

 

 

if any1 want to move it for SSE you are free to do it

for now only Tivo and Shaurows have most updated version xD

 

 

//Edit:

by "my mods" i mean mods that i use :smile:

 

//Edit:

But i just want to know... you mean i should remove just "_" from Cells Name ?

 

only Exteriors or Interiors and Exteriors ?

 

cause lel... for 30 Exteriors cells i can change name and

 

from

QLG_KingCastle_Cell01

 

to

KingCaslte

KingCastleCell01

KingCastleCell02

 

but if you want me to change EVERY SINGLE NAME IN CK

 

no fki*g way.... there is more than 500 objects that require other name...

this mod already is 6MB size so im not gonna change all the names

 

if you want and if i have to change only Exterior Cells i can do it for you

Edited by TobiaszPL
Link to comment
Share on other sites

From what i know :

- For sure remove underscore from interior cells, they do affect saves made in those.

- For exterior i'm not completely sure but i think they also affects saves.

- But if you are not going to port to SSE, then you have nothing to worry about.

Link to comment
Share on other sites

You asked : "for me just sin() was working fine... is there any difference between Math.Sin and Sin ?"

 

variant A

FUNCTION TestA()
   float f = Math.Sin(1)
ENDFUNCTION

variant B

import Math

FUNCTION TestB()
   float f = Sin(1)
ENDFUNCTION

In case you made your own sinus function, it would look like this

FUNCTION TestC()
   float f = Sin(1)
ENDFUNCTION

Float FUNCTION SIN(Float f) ; this overrides the native math sin function
   ; your code
   ; return f
  RETURN Math.Sin(f)
ENDFUNCTION
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...