Pass the map 2-Let's make a map together

Started by pawel345, February 04, 2014, 01:08:28 PM

Previous topic - Next topic

pawel345

Try working on it on the Pass the map, as I managed to make it work on a test map but it breaks once copied to here.

Clean0nion

#61
Quote from: pawel345 on February 08, 2014, 12:57:36 PM
Try working on it on the Pass the map, as I managed to make it work on a test map but it breaks once copied to here.
The map that it's being tested on won't matter. If it doesn't work, it doesn't work.

UPDATE: Found a part of the script that makes no sense in the :GetClosestUnit function.

UPDATE: FIIIIIIIIIIIIXXXEEEEDDD!!!!!! Uploading now!

UPDATE: Merging with most recent script version...

Grayzzur

If I bump the energy resource node near the damaged turret up from 50 to 150-200, then I have an easier time establishing a base and being able to save the forge. I recommend we make that change. You still have to go for it fairly quickly, or it's position gets overrun with creeper.

The turret factory seems to only be making small turrets.

I beat the map and didn't get a victory. Not sure if it's me, or if there's something hiding that counts for victory.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Clean0nion

#63
Script is here.
Spoiler

# net_turret.crpl
# Created by VirgilW
# Modified by Clean0nion
# ------------------------------------------

#THIS IS PTM

$name:"Gun1"
#$barrelOffset:60
#$barrelRecoil:60
$barrelRecoilRate:0.5
#$barrelRecoilTime:330
$maxRotationSpeed:0.05
$fireDelay:60
$range:15
$payload:30
$scale:1.5
$MIN_TERRAIN_HEIGHT:7
$MAX_TERRAIN_HEIGHT:7
$SPEED:0.5

once
   Self CONST_DESTROYONDAMAGE 0 SetUnitAttribute
   Self CONST_SNIPERTARGET 1 SetUnitAttribute
   Self CONST_NULLIFIERDAMAGEAMT 10000 SetUnitAttribute
   Self CONST_MAXHEALTH 10000 SetUnitAttribute
   Self CONST_HEALTH 10000 SetUnitAttribute
   Self CONST_HEALRATE 0 SetUnitAttribute
   Self CONST_SNIPERIGNORELOS 1 SetUnitAttribute
   Self CONST_DESTROYONDAMAGE 1 SetUnitAttribute
   Self CONST_SHOWHEALTHBAR 0 SetUnitAttribute
   Self CONST_CREATEPZ 0 SetUnitAttribute
      
   15 <-scale mul ->barrelOffset
   15 <-scale mul ->barrelRecoil
   Self "main" "Custom0" SetImage
   self "barrel" "Custom1" SetImage
   self "circleImg" "Custom0_256pp" SetImage
   Self "main" <-scale <-scale SetImageScale
   Self "barrel" <-scale <-scale SetImageScale
   0 ->targetX
   0 ->targetY
   -1 ->lastCellX
   -1 ->lastCellY
   
   self "barrel" 0 SetImageRotation
   self "barrel" 0 0 -0.01 SetImagePosition
   Self "circleImg" 0 0 0 256 SetImageColor
   Self "circleImg" <-range Mul(2.0) Add(1) Div(3) Dup SetImageScale
   
   <-barrelOffset ->currentBarrelOffset
   1 ->recovery
endonce

@CheckHealth
@ShowRangeFinder

GetTimer0 eq0 if
@GetClosestUnit ->closestUnit

<-closestUnit neq0 if
   <-closestUnit CONST_COORDX GetUnitAttribute ->targetX
   <-closestUnit CONST_COORDY GetUnitAttribute ->targetY
else
   -1 ->targetX -1 ->targetY
   GetQueuedMoveCount eq0 if
      @ChooseNewCell if
         <-chosenX <-chosenY <-SPEED QueueMove
         CurrentX ->lastCellX
         CurrentY ->lastCellY
      endif
   endif
endif

@ManageBarrel ->onTarget
@HandleRecoil

<-onTarget if
   GetTimer0 eq0 if
      PlaySound("Weapons20")
      @CreateBullet
      <-currentBarrelOffset <-barrelRecoil sub ->currentBarrelOffset
      <-currentBarrelOffset 0 lt if 0 ->currentBarrelOffset endif
      <-fireDelay SetTimer0
   endif
else

endif
endif

:CreateBullet
   "CRPLCore" CurrentX CurrentY CreateUnit ->unit
   <-unit "net_turret_bullet.crpl" AddScriptToUnit
   <-unit "net_turret_bullet.crpl" "targetX" <-targetX SetScriptVar
   <-unit "net_turret_bullet.crpl" "targetY" <-targetY SetScriptVar
   <-unit "net_turret_bullet.crpl" "payload" <-payload SetScriptVar
   <-unit "main" "Custom2" SetImage
   <-unit "main" <-scale <-scale SetImageScale
   <-unit "main" -0.01 SetImagePositionZ
   <-unit "main" self "barrel" GetImageRotation SetImageRotation

:GetClosestUnit
   99999999 ->closestDistance
   0 ->closestUnit
   GetUnitsInRange(CurrentCoords <-range) ->unitCount
   do (<-unitCount 0)
      ->unit
      CurrentCoords <-unit CONST_COORDX GetUnitAttribute <-unit CONST_COORDY GetUnitAttribute Distance ->d
      <-d <-closestDistance lt
      #CurrentCoords <-unit CONST_COORDX GetUnitAttribute <-unit CONST_COORDY GetUnitAttribute
      if
         GetUnitType(<-unit) ->ut
         <-ut "POWERZONE" eq <-ut "TECHARTIFACT" eq or <-ut "MESSAGEARTIFACT" eq or <-ut "SHIELDKEY" eq or <-ut "TOTEM" eq or <-ut "OREDEPOSIT" eq or <-ut "RESOURCEPACK" eq or <-ut "BERTHA" eq or not if
            <-d ->closestDistance
            <-unit ->closestUnit
         endif   
      endif
   loop
   <-closestUnit

:ManageBarrel
   <-targetX -1 eq <-onTarget 1 eq or if
      0
      return
   endif

   <-targetX CurrentX sub ->deltaX
   CurrentY <-targetY sub ->deltaY
   <-deltaY <-deltaX atan2 ->desiredAngle
   
   self "barrel" GetImageRotation <-desiredAngle ShortestAngle ->rot
   
   <-rot <-maxRotationSpeed gt if
      <-maxRotationSpeed ->rot
   else
      <-rot <-maxRotationSpeed -1 mul lt if
         <-maxRotationSpeed -1 mul ->rot
      endif
   endif
   
   <-rot abs 0.0001 lt if
      1 ->onTarget
   else
      0 ->onTarget
   endif
   
   self "barrel" GetImageRotation <-rot 0.2 mul add ->rot
   self "barrel" <-rot SetImageRotation
   self "main" <-rot SetImageRotation

   <-onTarget

:HandleRecoil
   <-currentBarrelOffset <-barrelOffset lt if
      <-currentBarrelOffset <-barrelRecoilRate add ->currentBarrelOffset
      <-currentBarrelOffset <-barrelOffset gt if <-barrelOffset ->currentBarrelOffset endif
   endif
   
   self "barrel" GetImageRotation ->rot
   
   <-rot cos <-currentBarrelOffset mul ->barrelX
   <-rot sin <-currentBarrelOffset mul ->barrelY
   
   self "barrel" <-barrelX <-barrelY -0.01 SetImagePosition
   
:CheckHealth
   Self "main" 255 Self CONST_HEALTH GetUnitAttribute 9940 sub 60 div 255 mul dup 255 SetImageColor
   Self CONST_HEALTH GetUnitAttribute 9940 lte if
      Self CONST_SNIPERTARGET 0 SetUnitAttribute
      1 SetPopupTextAlwaysVisible
      "Recovering... " SetPopupText
      <-recovery if
         300 SetTimer0
         0 ->recovery
      endif
      GetTimer0 eq0 if
         "" SetPopupText
         0 SetPopupTextAlwaysVisible
         Self CONST_HEALTH 10000 SetUnitAttribute
         1 ->recovery
      endif
   else
      Self CONST_SNIPERTARGET 1 SetUnitAttribute
      Self CONST_SNIPERIGNORELOS 1 SetUnitAttribute
   endif
   
:ChooseNewCell
   -1 ->chosenX
   -1 ->chosenY
   @GetPossibleCells
   0 <-count RandInt ->randCellNumber
   <-count 0 do
      ->y
      ->x
      I <-randCellNumber eq if
         <-x ->chosenX
         <-y ->chosenY
      endif
   loop
   <-chosenX -1 neq


:GetPossibleCells
   0 ->count
   CurrentX 1 add ->cx CurrentY ->cy @CheckCell      #Right
   CurrentX ->cx CurrentY 1 sub ->cy @CheckCell      #Up
   CurrentX 1 sub ->cx CurrentY ->cy @CheckCell      #Left
   CurrentX ->cx CurrentY 1 add ->cy @CheckCell      #Down
   <-count eq0 if
      <-lastCellX
      <-lastCellY
      1 ->count
   endif


:CheckCell
   <-cx <-lastCellX neq <-cy <-lastCellY neq or if
      <-cx <-cy GetTerrain ->terrainHeight
      <-terrainHeight <-MIN_TERRAIN_HEIGHT gte <-terrainHeight <-MAX_TERRAIN_HEIGHT lte and if
         <-cx
         <-cy
         <-count 1 add ->count
      endif
   endif
   
:ShowRangefinder
   if (Distance(GetMouseCell CurrentCoords) lte(3.5))
      SetImageColor(Self "circleImg" 0 0 0 85)
   else
      SetImageColor(Self "circleImg" 0 0 0 0)      
   endif
[close]
The only things that might need changing are the image names - I've already gone over all the variables.

@Grayzzur - MadMag's Death Star?
Also not sure what happens to the giant shield when you take down the generators, but if it doesn't destroy itself that could be it.

UPDATE: Just updated that spoiler.

pawel345

I modified the factory so that it makes small turrets.

Grayzzur

I checked MadMag's Death Star and galaxy spinnner, both don't count. The shield gets destroyed. There are two other image cores on the map that also don't count for victory. Maybe it wigged out because I was playing through the editor.

Ok, if small turrets were intentional, we're good. I thought it was going to be random.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Clean0nion

#66
No idea was causing to map to fail winning, but the turrets completely work in this save.
It was the Hellrider that was breaking it.
Suffice to say that shields no longer protect you from turrets. The Hellrider has not been modified.

Another thing: the opening text is messy, not serious enough, does not follow the chat theme of other game levels, and is full of grammatical errors, and also focuses far too heavily on the Guppy.

One more thing: there are two areas where it would be EASIER to begin than the starting zone, even after three or four minutes into the game. These are between the shield and the AC tank, and beneath the spawn next to the guppy.

Warpsing

A small adjustment i made, should help with the text, also put a message artifact not too far from the hellrider.

Grayzzur

#68
UNLOCKED

Ok.

* Re-un-commented spore from random location to guppy - this snuck back in, it's confusing. The guppy has an emitter anyway.
* Fixed the targeting issue with the turrets. They now properly target the closest player unit, regardless of how many units are in range.
* Increased energy node by damaged turret to 100.
* Hellrider Guppy (per chat discussion) moves at 0.5, heals at 0.2, has 250 health.
* Spelling/grammar adjustments to the new message artifact.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Clean0nion

If you'd care to say what the problem was, too, I'd be much obliged.

Grayzzur

Quote from: Clean0nion on February 08, 2014, 05:25:36 PM
If you'd care to say what the problem was, too, I'd be much obliged.

Recoil issue: I think I commented out a couple variables by accident when helping with one of the earlier bugs. Putting those back fixed this.

Targeting issue: It was in the :GetClosestUnit function. There were some extra commands causing an IF to evaluate incorrectly, and also left numbers on the stack to be picked up as the unit id on the next loop. This would basically cause it to "lock on" to an invalid unit id and hang.
Spoiler

:GetClosestUnit
   99999999 ->closestDistance
   0 ->closestUnit
   GetUnitsInRange(CurrentCoords <-range)  ->unitCount
   do (<-unitCount 0)
      ->unit
      CurrentCoords <-unit CONST_COORDX GetUnitAttribute <-unit CONST_COORDY GetUnitAttribute Distance ->d
      <-d <-closestDistance lt CurrentCoords <-unit CONST_COORDX GetUnitAttribute <-unit CONST_COORDY GetUnitAttribute if
         GetUnitType(<-unit) ->ut
         <-ut "POWERZONE" eq <-ut "TECHARTIFACT" eq or <-ut "MESSAGEARTIFACT" eq or <-ut "SHIELDKEY" eq or <-ut "TOTEM" eq or <-ut "OREDEPOSIT" eq or <-ut "RESOURCEPACK" eq or <-ut "BERTHA" eq or not if
            <-d ->closestDistance
            <-unit ->closestUnit
         endif   
      endif
   loop
   <-closestUnit
[close]
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

pawel345

Ok then the first person to clear it may upload it with the following description:

A map made together by several knucklekracker forum members. Clean0nion, JonneeG, Lost in Nowhere, pawel345, Mikoz, Grayzzur, MadMag and Warpsing. Hope you enjoy. The pass the map game can be found on the forums in custom map discussion, if you want to make a part of the next map you are welcome. #PassTheMap #noDigitalis #Spores #CRPL #noRunners #Void
   

Clean0nion

Quote from: Grayzzur on February 08, 2014, 06:07:41 PM
Quote from: Clean0nion on February 08, 2014, 05:25:36 PM
If you'd care to say what the problem was, too, I'd be much obliged.

Recoil issue: I think I commented out a couple variables by accident when helping with one of the earlier bugs. Putting those back fixed this.

Targeting issue: It was in the :GetClosestUnit function. There were some extra commands causing an IF to evaluate incorrectly, and also left numbers on the stack to be picked up as the unit id on the next loop. This would basically cause it to "lock on" to an invalid unit id and hang.
Spoiler

:GetClosestUnit
   99999999 ->closestDistance
   0 ->closestUnit
   GetUnitsInRange(CurrentCoords <-range)  ->unitCount
   do (<-unitCount 0)
      ->unit
      CurrentCoords <-unit CONST_COORDX GetUnitAttribute <-unit CONST_COORDY GetUnitAttribute Distance ->d
      <-d <-closestDistance lt CurrentCoords <-unit CONST_COORDX GetUnitAttribute <-unit CONST_COORDY GetUnitAttribute if
         GetUnitType(<-unit) ->ut
         <-ut "POWERZONE" eq <-ut "TECHARTIFACT" eq or <-ut "MESSAGEARTIFACT" eq or <-ut "SHIELDKEY" eq or <-ut "TOTEM" eq or <-ut "OREDEPOSIT" eq or <-ut "RESOURCEPACK" eq or <-ut "BERTHA" eq or not if
            <-d ->closestDistance
            <-unit ->closestUnit
         endif   
      endif
   loop
   <-closestUnit
[close]
That's the same bit I removed in my updated script - look upwards a couple of posts in this topic. As for the variables: what were they?

pawel345

Another version here I really hope it works now

Grayzzur

#74
Fixed the bent rail.

EDIT: This time with both attachments.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker