Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: PR0T05T33L on April 05, 2017, 10:08:21 PM

Title: How do I get a transmission to start after enough time has passed?
Post by: PR0T05T33L on April 05, 2017, 10:08:21 PM
I've put something in a map I'm making that takes a while to become active, but once it does, I want to draw the player's attention to it with a brief discussion between Skars and Lia.

How do I make a transmission start after, for example, 10 minutes and 30 seconds if and only if a specific unit exists?
Title: Re: How do I get a transmission to start after enough time has passed?
Post by: GoodMorning on April 05, 2017, 10:15:07 PM
This may help:


#DelayedConversation
$Wait:18900 #10m30s
$Unit:-1 #Your target UID here

once
<-Wait Delay
ClearConversation
0 "Lia, something odd is going on..." AddConversationMessage
1 "I'm scanning it, Skars." AddConversationMessage
ShowConversation
PauseGame
endonce
Title: Re: How do I get a transmission to start after enough time has passed?
Post by: PR0T05T33L on April 05, 2017, 10:23:47 PM
How do I find the UID of a unit? And does the UID relate to the specific unit or every unit of that type?
Title: Re: How do I get a transmission to start after enough time has passed?
Post by: GoodMorning on April 05, 2017, 11:10:56 PM
A UID is unique to the specific unit.

CurrentCoords 10 GetAllUnitsInRange 0 do #Fairly close units
->UID
#Something to distinguish the correct unit from others
#Example:
<-UID GetUnitType "PULSECANNON" eq if
<-UID ->Unit
break
endif
loop
Title: Re: How do I get a transmission to start after enough time has passed?
Post by: PR0T05T33L on April 05, 2017, 11:24:16 PM
I have no idea how to use that. Am I supposed to put the unit's coordinates in there somewhere?
Title: Re: How do I get a transmission to start after enough time has passed?
Post by: GoodMorning on April 06, 2017, 12:00:07 AM
Forget the previous code:

#DelayedConversation
$Wait:18900 #10m30s
$UnitX:-1 #Set these to the cooordinates of the unit you want to check on.
$UnitY:-1
once
Self "main" "NONE" SetImage #Invisible
Self CONST_COUNTSFORVICTORY 0 SetUnitAttribute #Don't have to destroy this to win
Self CONST_TAKEMAPSPACE 0 SetUnitAttribute #Don't obstruct placement
Self CONST_NULLIFIERDAMAGES 0 SetUnitAttribute #Don't be accidentally killed
<-Wait Delay
<-UnitX <-UnitY GetUnitAt -1 neq if
ClearConversation
0 "Lia, something odd is going on..." AddConversationMessage
1 "I'm scanning it, Skars." AddConversationMessage
ShowConversation
PauseGame
endif
endonce


This checks if there is a unit at the specified coordinates, and if so, shows the conversation. Attach it to a new Core, set the input vars, and wait.
Title: Re: How do I get a transmission to start after enough time has passed?
Post by: PR0T05T33L on April 06, 2017, 01:22:41 AM
Okay, I figured out how to put in the coordinates. Now, how do I set it so it'll only show the message if a spore tower is there?
Title: Re: How do I get a transmission to start after enough time has passed?
Post by: GoodMorning on April 06, 2017, 02:47:47 AM
The form you see checks if there is a unit there. If the player has destroyed the Spore Tower, it will have dropped a PZ, so this script will find that.

A version which checks the unit type:

#DelayedConversation
$Wait:18900 #10m30s
$UnitX:-1 #Set these to the cooordinates of the unit you want to check on.
$UnitY:-1
$Type:"SPORETOWER"
once
Self "main" "NONE" SetImage #Invisible
Self CONST_COUNTSFORVICTORY 0 SetUnitAttribute #Don't have to destroy this to win
Self CONST_TAKEMAPSPACE 0 SetUnitAttribute #Don't obstruct placement
Self CONST_NULLIFIERDAMAGES 0 SetUnitAttribute #Don't be accidentally killed
<-Wait Delay
<-UnitX <-UnitY GetUnitAt GetUnitType <-Type eq if
ClearConversation
0 "Lia, something odd is going on..." AddConversationMessage
1 "I'm scanning it, Skars." AddConversationMessage
ShowConversation
PauseGame
endif
endonce


This may not be the correct unit type, but the wiki has more information.
http://knucklecracker.com/wiki/doku.php?id=crpl:crplreference